|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
package com.openapi.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hfkj.common.exception.BaseException; |
|
|
|
|
import com.hfkj.common.exception.ErrorCode; |
|
|
|
|
import com.hfkj.common.exception.ErrorHelp; |
|
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
|
@ -19,10 +19,10 @@ import com.hfkj.service.agent.BsAgentApiParamService; |
|
|
|
|
import com.hfkj.service.agent.BsAgentDiscountService; |
|
|
|
|
import com.hfkj.service.discount.BsDiscountPkRelService; |
|
|
|
|
import com.hfkj.service.discount.BsDiscountPkService; |
|
|
|
|
import com.hfkj.service.discount.BsDiscountService; |
|
|
|
|
import com.hfkj.service.discount.BsDiscountUserService; |
|
|
|
|
import com.hfkj.sysenum.discount.DiscountPkStatusEnum; |
|
|
|
|
import com.hfkj.sysenum.discount.DiscountStockCodeObtainTypeEnum; |
|
|
|
|
import com.hfkj.sysenum.discount.DiscountUserStatusEnum; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
@ -123,11 +123,11 @@ public class BsDiscountController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/queryPkList",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value="/refund",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "查询优惠券包列表") |
|
|
|
|
public ResponseData queryPkList(@Validated @RequestBody RequestQueryPkDiscountListModel body) { |
|
|
|
|
log.info("========= Start 查询优惠券包列表 Start ==========="); |
|
|
|
|
@ApiOperation(value = "退回优惠券") |
|
|
|
|
public ResponseData refund(@Validated @RequestBody RequestRefundDiscountModel body) { |
|
|
|
|
log.info("========= Start 退回优惠券 Start ==========="); |
|
|
|
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
|
|
|
|
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs(); |
|
|
|
|
try { |
|
|
|
@ -142,22 +142,97 @@ public class BsDiscountController { |
|
|
|
|
} |
|
|
|
|
apiLog.setAppId(body.getAppId()); |
|
|
|
|
apiLog.setRequestId(body.getReqId()); |
|
|
|
|
apiLog.setRequestUrl("discount/queryPkList"); |
|
|
|
|
apiLog.setRequestUrl("discount/refund"); |
|
|
|
|
apiLog.setRequestParam(JSONObject.toJSONString(body)); |
|
|
|
|
|
|
|
|
|
ResponseQueryPkDiscountListModel response = new ResponseQueryPkDiscountListModel(); |
|
|
|
|
response.setAppId(body.getAppId()); |
|
|
|
|
response.setReqId(body.getReqId()); |
|
|
|
|
response.setDataList(new LinkedList<>()); |
|
|
|
|
// 查询日志
|
|
|
|
|
BsAgentApiLogWithBLOBs apiLogWithBLOBs = agentApiLogService.getDetail(body.getAppId(), body.getPushReqId()); |
|
|
|
|
if (apiLogWithBLOBs == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到推送请求"); |
|
|
|
|
} |
|
|
|
|
if (!apiLogWithBLOBs.getRequestUrl().equals("discount/push")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到推送请求"); |
|
|
|
|
} |
|
|
|
|
JSONObject data = JSONObject.parseObject(apiLogWithBLOBs.getResponseParam()); |
|
|
|
|
JSONArray codeList = data.getJSONArray("codeList"); |
|
|
|
|
for (Object obj : codeList) { |
|
|
|
|
JSONObject code = (JSONObject) obj; |
|
|
|
|
// 查询用户与优惠券信息
|
|
|
|
|
BsDiscountUser discountUser = discountUserService.getDetailByUserCodeId(code.getString("phone"), code.getLong("code")); |
|
|
|
|
if (discountUser != null && discountUser.getStatus().equals(DiscountUserStatusEnum.type1.getCode())) { |
|
|
|
|
discountUser.setStatus(DiscountUserStatusEnum.type4.getCode()); |
|
|
|
|
discountUserService.editData(discountUser); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
log.info("返回参数:ok"); |
|
|
|
|
apiLog.setResponseParam("ok"); |
|
|
|
|
return ResponseMsgUtil.success("ok"); |
|
|
|
|
|
|
|
|
|
// 券包中的优惠券列表
|
|
|
|
|
List<BsAgentDiscount> list = agentDiscountService.getList(apiParam.getAgentId()).stream().filter(o->o.getType().equals(2)).collect(Collectors.toList()); |
|
|
|
|
for (BsAgentDiscount discount : list) { |
|
|
|
|
JSONObject discountObj = new JSONObject(); |
|
|
|
|
discountObj.put("discountPkNo", discount.getObjectNo()); |
|
|
|
|
discountObj.put("discountPkName", discount.getObjectName()); |
|
|
|
|
response.getDataList().add(discountObj); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.info("出现异常:", e); |
|
|
|
|
// 异常内容
|
|
|
|
|
ResponseData exception = ResponseMsgUtil.exception(e); |
|
|
|
|
apiLog.setErrorContent(JSONObject.toJSONString(exception)); |
|
|
|
|
return exception; |
|
|
|
|
} finally { |
|
|
|
|
// 记录日志
|
|
|
|
|
if (apiLog.getAppId() != null) { |
|
|
|
|
agentApiLogService.edit(apiLog); |
|
|
|
|
} |
|
|
|
|
log.info("========= END 退回优惠券 END ==========="); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/pushPk",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "推送优惠券包") |
|
|
|
|
public ResponseData pushPk(@Validated @RequestBody RequestPushPkDiscountModel body) { |
|
|
|
|
log.info("========= Start 推送优惠券包 Start ==========="); |
|
|
|
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
|
|
|
|
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs(); |
|
|
|
|
try { |
|
|
|
|
// 验证签名
|
|
|
|
|
BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(body.getAppId()); |
|
|
|
|
if (!SignatureUtil.checkSign(body.getSign(), body, apiParam.getAppSecret())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
|
|
|
|
} |
|
|
|
|
// 验证请求id
|
|
|
|
|
if (agentApiLogService.isExist(body.getAppId(), body.getReqId())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_REQ_ID_ERR, ""); |
|
|
|
|
} |
|
|
|
|
apiLog.setAppId(body.getAppId()); |
|
|
|
|
apiLog.setRequestId(body.getReqId()); |
|
|
|
|
apiLog.setRequestUrl("discount/pushPk"); |
|
|
|
|
apiLog.setRequestParam(JSONObject.toJSONString(body)); |
|
|
|
|
|
|
|
|
|
// 查询代理商是否拥有优惠券包权限
|
|
|
|
|
if (agentDiscountService.getDetail(apiParam.getAgentId(),2,body.getDiscountPkNo()) == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "未配置优惠券包"); |
|
|
|
|
} |
|
|
|
|
// 领取优惠券
|
|
|
|
|
List<BsDiscountUser> codeDataList = discountUserService.receivePk( |
|
|
|
|
body.getDiscountPkNo(), |
|
|
|
|
body.getNumber(), |
|
|
|
|
DiscountStockCodeObtainTypeEnum.type4, body.getPhone(), |
|
|
|
|
body.getAppId() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> codeMapList = new ArrayList<>(); |
|
|
|
|
for (BsDiscountUser discountUser : codeDataList) { |
|
|
|
|
Map<String,Object> codeMap = new HashMap<>(); |
|
|
|
|
codeMap.put("discountNo", discountUser.getDiscountNo()); |
|
|
|
|
codeMap.put("phone", discountUser.getUserPhone()); |
|
|
|
|
codeMap.put("code", discountUser.getDiscountStockCode()); |
|
|
|
|
codeMap.put("status", discountUser.getStatus()); |
|
|
|
|
codeMap.put("createTime", DateUtil.date2String(discountUser.getCreateTime(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
codeMap.put("expirationDate", DateUtil.date2String(discountUser.getExpirationDate(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
codeMapList.add(codeMap); |
|
|
|
|
} |
|
|
|
|
ResponsePushDiscountPkModel response = new ResponsePushDiscountPkModel(); |
|
|
|
|
response.setReqId(body.getReqId()); |
|
|
|
|
response.setAppId(body.getAppId()); |
|
|
|
|
response.setDiscountPkNo(body.getDiscountPkNo()); |
|
|
|
|
response.setCodeList(codeMapList); |
|
|
|
|
response.setSign(SignatureUtil.createSign(response, agentApiParamService.getParamByAppId(body.getAppId()).getAppSecret())); |
|
|
|
|
log.info("返回参数:" + JSONObject.toJSONString(response)); |
|
|
|
|
apiLog.setResponseParam(JSONObject.toJSONString(response)); |
|
|
|
@ -175,7 +250,67 @@ public class BsDiscountController { |
|
|
|
|
if (apiLog.getAppId() != null) { |
|
|
|
|
agentApiLogService.edit(apiLog); |
|
|
|
|
} |
|
|
|
|
log.info("========= END 查询优惠券包列表 END ==========="); |
|
|
|
|
log.info("========= END 推送优惠券包 END ==========="); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/refundPk",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "退回优惠券包") |
|
|
|
|
public ResponseData refundPk(@Validated @RequestBody RequestRefundPkDiscountModel body) { |
|
|
|
|
log.info("========= Start 退款优惠券包 Start ==========="); |
|
|
|
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
|
|
|
|
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs(); |
|
|
|
|
try { |
|
|
|
|
// 验证签名
|
|
|
|
|
BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(body.getAppId()); |
|
|
|
|
if (!SignatureUtil.checkSign(body.getSign(), body, apiParam.getAppSecret())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
|
|
|
|
} |
|
|
|
|
// 验证请求id
|
|
|
|
|
if (agentApiLogService.isExist(body.getAppId(), body.getReqId())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_REQ_ID_ERR, ""); |
|
|
|
|
} |
|
|
|
|
apiLog.setAppId(body.getAppId()); |
|
|
|
|
apiLog.setRequestId(body.getReqId()); |
|
|
|
|
apiLog.setRequestUrl("discount/refundPk"); |
|
|
|
|
apiLog.setRequestParam(JSONObject.toJSONString(body)); |
|
|
|
|
|
|
|
|
|
// 查询日志
|
|
|
|
|
BsAgentApiLogWithBLOBs apiLogWithBLOBs = agentApiLogService.getDetail(body.getAppId(), body.getPushReqId()); |
|
|
|
|
if (apiLogWithBLOBs == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到推送请求"); |
|
|
|
|
} |
|
|
|
|
if (!apiLogWithBLOBs.getRequestUrl().equals("discount/pushPk")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到推送请求"); |
|
|
|
|
} |
|
|
|
|
JSONObject data = JSONObject.parseObject(apiLogWithBLOBs.getResponseParam()); |
|
|
|
|
JSONArray codeList = data.getJSONArray("codeList"); |
|
|
|
|
for (Object obj : codeList) { |
|
|
|
|
JSONObject code = (JSONObject) obj; |
|
|
|
|
// 查询用户与优惠券信息
|
|
|
|
|
BsDiscountUser discountUser = discountUserService.getDetailByUserCodeId(code.getString("phone"), code.getLong("code")); |
|
|
|
|
if (discountUser != null && discountUser.getStatus().equals(DiscountUserStatusEnum.type1.getCode())) { |
|
|
|
|
discountUser.setStatus(DiscountUserStatusEnum.type4.getCode()); |
|
|
|
|
discountUserService.editData(discountUser); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
log.info("返回参数:ok"); |
|
|
|
|
apiLog.setResponseParam("ok"); |
|
|
|
|
return ResponseMsgUtil.success("ok"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.info("出现异常:", e); |
|
|
|
|
// 异常内容
|
|
|
|
|
ResponseData exception = ResponseMsgUtil.exception(e); |
|
|
|
|
apiLog.setErrorContent(JSONObject.toJSONString(exception)); |
|
|
|
|
return exception; |
|
|
|
|
} finally { |
|
|
|
|
// 记录日志
|
|
|
|
|
if (apiLog.getAppId() != null) { |
|
|
|
|
agentApiLogService.edit(apiLog); |
|
|
|
|
} |
|
|
|
|
log.info("========= END 退款优惠券包 END ==========="); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -255,11 +390,11 @@ public class BsDiscountController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/pushPk",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value="/queryPkDetailByReqId",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "推送优惠券包") |
|
|
|
|
public ResponseData pushPk(@Validated @RequestBody RequestPushPkDiscountModel body) { |
|
|
|
|
log.info("========= Start 推送优惠券包 Start ==========="); |
|
|
|
|
@ApiOperation(value = "根据请求id查询优惠券包详情") |
|
|
|
|
public ResponseData queryPkDetailByReqId(@Validated @RequestBody RequestQueryPkDiscountByReqIdModel body) { |
|
|
|
|
log.info("========= Start 根据手机号查询优惠券包详情 Start ==========="); |
|
|
|
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
|
|
|
|
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs(); |
|
|
|
|
try { |
|
|
|
@ -274,37 +409,103 @@ public class BsDiscountController { |
|
|
|
|
} |
|
|
|
|
apiLog.setAppId(body.getAppId()); |
|
|
|
|
apiLog.setRequestId(body.getReqId()); |
|
|
|
|
apiLog.setRequestUrl("discount/pushPk"); |
|
|
|
|
apiLog.setRequestUrl("discount/queryPkDetailByPhone"); |
|
|
|
|
apiLog.setRequestParam(JSONObject.toJSONString(body)); |
|
|
|
|
|
|
|
|
|
// 查询代理商是否拥有优惠券包权限
|
|
|
|
|
if (agentDiscountService.getDetail(apiParam.getAgentId(),2,body.getDiscountPkNo()) == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "未配置优惠券包"); |
|
|
|
|
// 查询日志
|
|
|
|
|
BsAgentApiLogWithBLOBs apiLogWithBLOBs = agentApiLogService.getDetail(body.getAppId(), body.getPushReqId()); |
|
|
|
|
if (apiLogWithBLOBs == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到推送请求"); |
|
|
|
|
} |
|
|
|
|
// 领取优惠券
|
|
|
|
|
List<BsDiscountUser> codeDataList = discountUserService.receivePk( |
|
|
|
|
body.getDiscountPkNo(), |
|
|
|
|
body.getNumber(), |
|
|
|
|
DiscountStockCodeObtainTypeEnum.type4, body.getPhone(), |
|
|
|
|
body.getAppId() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> codeMapList = new ArrayList<>(); |
|
|
|
|
for (BsDiscountUser discountUser : codeDataList) { |
|
|
|
|
Map<String,Object> codeMap = new HashMap<>(); |
|
|
|
|
codeMap.put("discountNo", discountUser.getDiscountNo()); |
|
|
|
|
codeMap.put("phone", discountUser.getUserPhone()); |
|
|
|
|
codeMap.put("code", discountUser.getDiscountStockCode()); |
|
|
|
|
codeMap.put("status", discountUser.getStatus()); |
|
|
|
|
codeMap.put("createTime", DateUtil.date2String(discountUser.getCreateTime(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
codeMap.put("expirationDate", DateUtil.date2String(discountUser.getExpirationDate(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
codeMapList.add(codeMap); |
|
|
|
|
if (!apiLogWithBLOBs.getRequestUrl().equals("discount/pushPk")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到推送请求"); |
|
|
|
|
} |
|
|
|
|
ResponsePushDiscountPkModel response = new ResponsePushDiscountPkModel(); |
|
|
|
|
JSONObject data = JSONObject.parseObject(apiLogWithBLOBs.getResponseParam()); |
|
|
|
|
BsDiscountPk discountPk = discountPkService.getDetail(data.getString("discountPkNo")); |
|
|
|
|
if (discountPk == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "优惠券包已失效"); |
|
|
|
|
} |
|
|
|
|
ResponseQueryPkDiscountByReqIdModel response = new ResponseQueryPkDiscountByReqIdModel(); |
|
|
|
|
response.setAppId(body.getAppId()); |
|
|
|
|
response.setReqId(body.getReqId()); |
|
|
|
|
response.setDiscountPkNo(discountPk.getDiscountPkNo()); |
|
|
|
|
response.setPushReqId(body.getPushReqId()); |
|
|
|
|
response.setCodeList(new LinkedList<>()); |
|
|
|
|
|
|
|
|
|
JSONArray codeList = data.getJSONArray("codeList"); |
|
|
|
|
for (Object obj : codeList) { |
|
|
|
|
JSONObject code = (JSONObject) obj; |
|
|
|
|
// 查询用户与优惠券信息
|
|
|
|
|
BsDiscountUser discountUser = discountUserService.getDetailByUserCodeId(code.getString("phone"), code.getLong("code")); |
|
|
|
|
code.put("discountNo", discountUser.getDiscountNo()); |
|
|
|
|
code.put("discountType", discountUser.getDiscountType()); |
|
|
|
|
code.put("discountCondition", discountUser.getDiscountCondition()); |
|
|
|
|
code.put("discountPrice", discountUser.getDiscountPrice()); |
|
|
|
|
code.put("overlayDiscount", discountUser.getOverlayDiscount()); |
|
|
|
|
code.put("phone", discountUser.getUserPhone()); |
|
|
|
|
code.put("code", discountUser.getDiscountStockCode()); |
|
|
|
|
code.put("status", discountUser.getStatus()); |
|
|
|
|
code.put("createTime", DateUtil.date2String(discountUser.getCreateTime(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
code.put("expirationDate", DateUtil.date2String(discountUser.getExpirationDate(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
code.put("useDate", DateUtil.date2String(discountUser.getUseDate(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
response.getCodeList().add(code); |
|
|
|
|
} |
|
|
|
|
response.setSign(SignatureUtil.createSign(response, agentApiParamService.getParamByAppId(body.getAppId()).getAppSecret())); |
|
|
|
|
log.info("返回参数:" + JSONObject.toJSONString(response)); |
|
|
|
|
apiLog.setResponseParam(JSONObject.toJSONString(response)); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(response); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.info("出现异常:", e); |
|
|
|
|
// 异常内容
|
|
|
|
|
ResponseData exception = ResponseMsgUtil.exception(e); |
|
|
|
|
apiLog.setErrorContent(JSONObject.toJSONString(exception)); |
|
|
|
|
return exception; |
|
|
|
|
} finally { |
|
|
|
|
// 记录日志
|
|
|
|
|
if (apiLog.getAppId() != null) { |
|
|
|
|
agentApiLogService.edit(apiLog); |
|
|
|
|
} |
|
|
|
|
log.info("========= END 根据手机号查询优惠券包详情 END ==========="); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/queryPkList",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "查询优惠券包列表") |
|
|
|
|
public ResponseData queryPkList(@Validated @RequestBody RequestQueryPkDiscountListModel body) { |
|
|
|
|
log.info("========= Start 查询优惠券包列表 Start ==========="); |
|
|
|
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
|
|
|
|
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs(); |
|
|
|
|
try { |
|
|
|
|
// 验证签名
|
|
|
|
|
BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(body.getAppId()); |
|
|
|
|
if (!SignatureUtil.checkSign(body.getSign(), body, apiParam.getAppSecret())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
|
|
|
|
} |
|
|
|
|
// 验证请求id
|
|
|
|
|
if (agentApiLogService.isExist(body.getAppId(), body.getReqId())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_REQ_ID_ERR, ""); |
|
|
|
|
} |
|
|
|
|
apiLog.setAppId(body.getAppId()); |
|
|
|
|
apiLog.setRequestId(body.getReqId()); |
|
|
|
|
apiLog.setRequestUrl("discount/queryPkList"); |
|
|
|
|
apiLog.setRequestParam(JSONObject.toJSONString(body)); |
|
|
|
|
|
|
|
|
|
ResponseQueryPkDiscountListModel response = new ResponseQueryPkDiscountListModel(); |
|
|
|
|
response.setAppId(body.getAppId()); |
|
|
|
|
response.setDiscountPkNo(body.getDiscountPkNo()); |
|
|
|
|
response.setCodeList(codeMapList); |
|
|
|
|
response.setReqId(body.getReqId()); |
|
|
|
|
response.setDataList(new LinkedList<>()); |
|
|
|
|
|
|
|
|
|
// 券包中的优惠券列表
|
|
|
|
|
List<BsAgentDiscount> list = agentDiscountService.getList(apiParam.getAgentId()).stream().filter(o->o.getType().equals(2)).collect(Collectors.toList()); |
|
|
|
|
for (BsAgentDiscount discount : list) { |
|
|
|
|
JSONObject discountObj = new JSONObject(); |
|
|
|
|
discountObj.put("discountPkNo", discount.getObjectNo()); |
|
|
|
|
discountObj.put("discountPkName", discount.getObjectName()); |
|
|
|
|
response.getDataList().add(discountObj); |
|
|
|
|
} |
|
|
|
|
response.setSign(SignatureUtil.createSign(response, agentApiParamService.getParamByAppId(body.getAppId()).getAppSecret())); |
|
|
|
|
log.info("返回参数:" + JSONObject.toJSONString(response)); |
|
|
|
|
apiLog.setResponseParam(JSONObject.toJSONString(response)); |
|
|
|
@ -322,7 +523,7 @@ public class BsDiscountController { |
|
|
|
|
if (apiLog.getAppId() != null) { |
|
|
|
|
agentApiLogService.edit(apiLog); |
|
|
|
|
} |
|
|
|
|
log.info("========= END 推送优惠券包 END ==========="); |
|
|
|
|
log.info("========= END 查询优惠券包列表 END ==========="); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|