提交代码

pre
胡锐 2 weeks ago
parent 2c7b4c7bff
commit 0c8c864973
  1. 299
      openapi/src/main/java/com/openapi/controller/BsDiscountController.java
  2. 7
      service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java
  3. 39
      service/src/main/java/com/hfkj/openapi/model/request/RequestQueryPkDiscountByReqIdModel.java
  4. 39
      service/src/main/java/com/hfkj/openapi/model/request/RequestRefundDiscountModel.java
  5. 39
      service/src/main/java/com/hfkj/openapi/model/request/RequestRefundPkDiscountModel.java
  6. 46
      service/src/main/java/com/hfkj/openapi/model/response/ResponseQueryPkDiscountByReqIdModel.java
  7. 11
      service/src/main/java/com/hfkj/service/agent/BsAgentApiLogService.java
  8. 13
      service/src/main/java/com/hfkj/service/agent/impl/BsAgentApiLogServiceImpl.java
  9. 8
      service/src/main/java/com/hfkj/service/discount/BsDiscountUserService.java
  10. 14
      service/src/main/java/com/hfkj/service/discount/impl/BsDiscountUserServiceImpl.java
  11. 4
      service/src/main/java/com/hfkj/sysenum/discount/DiscountUserStatusEnum.java

@ -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 ===========");
}
}

@ -86,10 +86,11 @@ public class SignatureUtil {
public static void main(String[] args) throws Exception {
String paramStr = "{\n" +
" \"appId\": \"hffeab7fdb44d4f1\",\n" +
" \"orderNo\": \"test10001\"\n" +
" \"reqId\": \"cs0007\",\n" +
" \"appId\": \"hf7356c71fb97ab0\",\n" +
" \"pushReqId\": \"cs0005\"\n" +
"}";
String sign = createSign(JSONObject.parseObject(paramStr), "3a9b2772b9a2d319a9b18e55fa30246d");
String sign = createSign(JSONObject.parseObject(paramStr), "8aef995ff71485dc19b36e35f04c4016");
System.out.println(sign);
}

@ -0,0 +1,39 @@
package com.hfkj.openapi.model.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @className: RequestQueryDiscountListModel
* @author: HuRui
* @date: 2024/9/1
**/
@Data
public class RequestQueryPkDiscountByReqIdModel {
/**
* 请求id必填项
*/
@NotBlank(message = "请求id必填项")
private String reqId;
/**
* appId
*/
@NotBlank(message = "appId必填项")
private String appId;
/**
* 推送请求id
*/
@NotBlank(message = "推送请求id必填项")
private String pushReqId;
/**
* 签名参数
*/
@NotBlank(message = "签名必填项")
private String sign;
}

@ -0,0 +1,39 @@
package com.hfkj.openapi.model.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @className: RequestQueryDiscountListModel
* @author: HuRui
* @date: 2024/9/1
**/
@Data
public class RequestRefundDiscountModel {
/**
* 请求id必填项
*/
@NotBlank(message = "请求id必填项")
private String reqId;
/**
* appId
*/
@NotBlank(message = "appId必填项")
private String appId;
/**
* 推送请求id
*/
@NotBlank(message = "推送请求id必填项")
private String pushReqId;
/**
* 签名参数
*/
@NotBlank(message = "签名必填项")
private String sign;
}

@ -0,0 +1,39 @@
package com.hfkj.openapi.model.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @className: RequestQueryDiscountListModel
* @author: HuRui
* @date: 2024/9/1
**/
@Data
public class RequestRefundPkDiscountModel {
/**
* 请求id必填项
*/
@NotBlank(message = "请求id必填项")
private String reqId;
/**
* appId
*/
@NotBlank(message = "appId必填项")
private String appId;
/**
* 推送请求id
*/
@NotBlank(message = "推送请求id必填项")
private String pushReqId;
/**
* 签名参数
*/
@NotBlank(message = "签名必填项")
private String sign;
}

@ -0,0 +1,46 @@
package com.hfkj.openapi.model.response;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @className: RequestQueryDiscountListModel
* @author: HuRui
* @date: 2024/9/1
**/
@Data
public class ResponseQueryPkDiscountByReqIdModel {
/**
* appid
*/
private String reqId;
/**
* appid
*/
private String appId;
/**
* 推送请求id
*/
private String pushReqId;
/**
* 优惠券编号
*/
private String discountPkNo;
/**
* 优惠券code列表
*/
List<Object> codeList;
/**
* 签名参数
*/
private String sign;
}

@ -1,5 +1,6 @@
package com.hfkj.service.agent;
import com.hfkj.entity.BsAgentApiLog;
import com.hfkj.entity.BsAgentApiLogWithBLOBs;
/**
@ -16,11 +17,19 @@ public interface BsAgentApiLogService {
void edit(BsAgentApiLogWithBLOBs data);
/**
*
* 是否存在
* @param appId
* @param reqId
* @return
*/
boolean isExist(String appId, String reqId);
/**
* 查询详情
* @param appId
* @param reqId
* @return
*/
BsAgentApiLogWithBLOBs getDetail(String appId, String reqId);
}

@ -2,12 +2,14 @@ package com.hfkj.service.agent.impl;
import com.hfkj.dao.BsAgentApiLogMapper;
import com.hfkj.entity.BsAgentApiLog;
import com.hfkj.entity.BsAgentApiLogExample;
import com.hfkj.entity.BsAgentApiLogWithBLOBs;
import com.hfkj.service.agent.BsAgentApiLogService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* @className: BsAgentApiLogServiceImpl
@ -32,4 +34,15 @@ public class BsAgentApiLogServiceImpl implements BsAgentApiLogService {
public boolean isExist(String appId, String reqId) {
return agentApiLogMapper.isExist(appId, reqId) > 0;
}
@Override
public BsAgentApiLogWithBLOBs getDetail(String appId, String reqId) {
BsAgentApiLogExample example = new BsAgentApiLogExample();
example.createCriteria().andAppIdEqualTo(appId).andRequestIdEqualTo(reqId);
List<BsAgentApiLogWithBLOBs> list = agentApiLogMapper.selectByExampleWithBLOBs(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
}

@ -76,6 +76,14 @@ public interface BsDiscountUserService {
*/
BsDiscountUser getDetailByCodeId(Long stockCodeId);
/**
* 查询详情根据用户手机号和库存id
* @param phone
* @param stockCodeId
* @return
*/
BsDiscountUser getDetailByUserCodeId(String phone,Long stockCodeId);
/**
* 用户优惠券列表
* @param param

@ -364,6 +364,20 @@ public class BsDiscountUserServiceImpl implements BsDiscountUserService {
return null;
}
@Override
public BsDiscountUser getDetailByUserCodeId(String phone, Long stockCodeId) {
BsDiscountUserExample example = new BsDiscountUserExample();
example.createCriteria()
.andUserPhoneEqualTo(phone)
.andDiscountStockCodeEqualTo(stockCodeId)
.andStatusNotEqualTo(DiscountUserStatusEnum.type0.getCode());
List<BsDiscountUser> list = discountUserMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override
public List<DiscountUserModel> getUserDiscountList(Map<String, Object> param) {
return discountUserMapper.queryUserDiscountList(param);

@ -26,6 +26,10 @@ public enum DiscountUserStatusEnum {
* 已过期
*/
type3(3 , "已过期"),
/**
* 已作废
*/
type4(4 , "已作废"),
;
private Integer code;

Loading…
Cancel
Save