|
|
|
@ -1,12 +1,17 @@ |
|
|
|
|
package com.cweb.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hai.common.Base64Util; |
|
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
|
import com.hai.common.security.AESEncodeUtil; |
|
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hai.entity.HighDiscountAgentCode; |
|
|
|
|
import com.hai.entity.HighDiscountAgentRel; |
|
|
|
|
import com.hai.model.ResponseData; |
|
|
|
|
import com.hai.service.HighDiscountAgentCodeService; |
|
|
|
|
import com.hai.service.HighDiscountAgentRelService; |
|
|
|
|
import com.hai.service.HighDiscountCouponRelService; |
|
|
|
|
import com.hai.service.HighDiscountService; |
|
|
|
@ -18,6 +23,8 @@ import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Auther: 胡锐 |
|
|
|
@ -37,6 +44,9 @@ public class HighDiscountController { |
|
|
|
|
@Resource |
|
|
|
|
private HighDiscountCouponRelService highDiscountCouponRelService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighDiscountAgentCodeService highDiscountAgentCodeService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighDiscountService highDiscountService; |
|
|
|
|
|
|
|
|
@ -45,14 +55,26 @@ public class HighDiscountController { |
|
|
|
|
@ApiOperation(value = "根据二维码Code查询") |
|
|
|
|
public ResponseData getDiscountByQrCode(@RequestParam(name = "code", required = true) String code) { |
|
|
|
|
try { |
|
|
|
|
String relId; |
|
|
|
|
String jsonData; |
|
|
|
|
try { |
|
|
|
|
relId = AESEncodeUtil.aesDecrypt(Base64Util.decode(code)); |
|
|
|
|
jsonData = AESEncodeUtil.aesDecrypt(Base64Util.decode(code)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighDiscountController -> getDiscountByQrCode() error!","code解码错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "code解码错误"); |
|
|
|
|
} |
|
|
|
|
return ResponseMsgUtil.success(highDiscountAgentRelService.getRelById(Long.parseLong(relId))); |
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(jsonData); |
|
|
|
|
String type = jsonObject.getString("type"); |
|
|
|
|
Long id = jsonObject.getLong("id"); |
|
|
|
|
|
|
|
|
|
HighDiscountAgentCode discountAgentCode = highDiscountAgentCodeService.getCodeById(id); |
|
|
|
|
if (discountAgentCode != null) { |
|
|
|
|
HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(discountAgentCode.getDiscountAgentId()); |
|
|
|
|
if (rel == null) { |
|
|
|
|
rel.setHighDiscountAgentCode(discountAgentCode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return ResponseMsgUtil.success(null); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighDiscountController -> getDiscountByQrCode() error!",e); |
|
|
|
|