Compare commits

...

4 Commits

  1. 2
      bweb/src/main/java/com/bweb/controller/BsDiscountController.java
  2. 281
      openapi/src/main/java/com/openapi/controller/BsDiscountController.java
  3. 11
      service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java
  4. 1
      service/src/main/java/com/hfkj/dao/BsAgentMerMapperExt.java
  5. 41
      service/src/main/java/com/hfkj/dao/BsDiscountMapper.java
  6. 14
      service/src/main/java/com/hfkj/dao/BsDiscountSqlProvider.java
  7. 35
      service/src/main/java/com/hfkj/dao/BsDiscountUserMapper.java
  8. 14
      service/src/main/java/com/hfkj/dao/BsDiscountUserSqlProvider.java
  9. 16
      service/src/main/java/com/hfkj/entity/BsDiscount.java
  10. 60
      service/src/main/java/com/hfkj/entity/BsDiscountExample.java
  11. 16
      service/src/main/java/com/hfkj/entity/BsDiscountUser.java
  12. 60
      service/src/main/java/com/hfkj/entity/BsDiscountUserExample.java
  13. 5
      service/src/main/java/com/hfkj/model/GasPayPriceModel.java
  14. 35
      service/src/main/java/com/hfkj/model/ReceiveDiscountPkModel.java
  15. 39
      service/src/main/java/com/hfkj/openapi/model/request/RequestQueryPkDiscountByStockCodeModel.java
  16. 39
      service/src/main/java/com/hfkj/openapi/model/request/RequestRefundDiscountModel.java
  17. 40
      service/src/main/java/com/hfkj/openapi/model/request/RequestRefundPkDiscountModel.java
  18. 7
      service/src/main/java/com/hfkj/openapi/model/response/ResponsePushDiscountPkModel.java
  19. 46
      service/src/main/java/com/hfkj/openapi/model/response/ResponseQueryPkDiscountByReqIdModel.java
  20. 11
      service/src/main/java/com/hfkj/service/agent/BsAgentApiLogService.java
  21. 13
      service/src/main/java/com/hfkj/service/agent/impl/BsAgentApiLogServiceImpl.java
  22. 6
      service/src/main/java/com/hfkj/service/discount/BsDiscountPkStockBatchService.java
  23. 6
      service/src/main/java/com/hfkj/service/discount/BsDiscountPkStockCodeService.java
  24. 13
      service/src/main/java/com/hfkj/service/discount/BsDiscountStockCodeService.java
  25. 12
      service/src/main/java/com/hfkj/service/discount/BsDiscountUserService.java
  26. 34
      service/src/main/java/com/hfkj/service/discount/impl/BsDiscountPkStockBatchServiceImpl.java
  27. 9
      service/src/main/java/com/hfkj/service/discount/impl/BsDiscountPkStockCodeServiceImpl.java
  28. 45
      service/src/main/java/com/hfkj/service/discount/impl/BsDiscountStockCodeServiceImpl.java
  29. 37
      service/src/main/java/com/hfkj/service/discount/impl/BsDiscountUserServiceImpl.java
  30. 19
      service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderServiceImpl.java
  31. 50
      service/src/main/java/com/hfkj/service/gas/impl/BsGasServiceImpl.java
  32. 122
      service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java
  33. 7
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java
  34. 4
      service/src/main/java/com/hfkj/sysenum/discount/DiscountUserStatusEnum.java

@ -48,6 +48,7 @@ public class BsDiscountController {
if (StringUtils.isBlank(body.getString("discountName"))
|| body.getInteger("discountType") == null
|| body.getBigDecimal("discountPrice") == null
|| body.getBoolean("overlayDiscount") == null
|| StringUtils.isBlank(body.getString("useScope"))
|| body.getInteger("receiveExpirationDate") == null
|| body.getLong("endTime") == null
@ -76,6 +77,7 @@ public class BsDiscountController {
discount.setDiscountType(body.getInteger("discountType"));
discount.setDiscountName(body.getString("discountName"));
discount.setDiscountPrice(body.getBigDecimal("discountPrice"));
discount.setOverlayDiscount(body.getBoolean("overlayDiscount"));
discount.setDiscountCondition(body.getBigDecimal("discountCondition"));
discount.setUseScope(body.getString("useScope"));
discount.setReceiveExpirationDate(body.getInteger("receiveExpirationDate"));

@ -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;
@ -10,6 +10,7 @@ import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.*;
import com.hfkj.model.DiscountUserModel;
import com.hfkj.model.ReceiveDiscountPkModel;
import com.hfkj.model.ResponseData;
import com.hfkj.openapi.model.UserDiscountModel;
import com.hfkj.openapi.model.request.*;
@ -17,12 +18,11 @@ import com.hfkj.openapi.model.response.*;
import com.hfkj.service.agent.BsAgentApiLogService;
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.service.discount.*;
import com.hfkj.sysenum.discount.DiscountPkStatusEnum;
import com.hfkj.sysenum.discount.DiscountPkStockCodeStatusEnum;
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;
@ -47,6 +47,12 @@ public class BsDiscountController {
@Resource
private BsDiscountPkService discountPkService;
@Resource
private BsDiscountPkStockBatchService discountPkStockBatchService;
@Resource
private BsDiscountPkStockCodeService discountPkStockCodeService;
@Resource
private BsDiscountStockCodeService discountStockCodeService;
@Resource
private BsDiscountPkRelService discountPkRelService;
@Resource
private BsAgentApiLogService agentApiLogService;
@ -123,11 +129,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 +148,89 @@ public class BsDiscountController {
}
apiLog.setAppId(body.getAppId());
apiLog.setRequestId(body.getReqId());
apiLog.setRequestUrl("discount/queryPkList");
apiLog.setRequestUrl("discount/refund");
apiLog.setRequestParam(JSONObject.toJSONString(body));
// 退回优惠券
discountStockCodeService.recycle(body.getDiscountStockCode());
ResponseQueryPkDiscountListModel response = new ResponseQueryPkDiscountListModel();
response.setAppId(body.getAppId());
response.setReqId(body.getReqId());
response.setDataList(new LinkedList<>());
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<ReceiveDiscountPkModel> codeDataList = discountUserService.receivePk(
body.getDiscountPkNo(),
body.getNumber(),
DiscountStockCodeObtainTypeEnum.type4, body.getPhone(),
body.getAppId()
);
List<Map<String,Object>> codeMapList = new ArrayList<>();
for (ReceiveDiscountPkModel receiveDiscountPk : codeDataList) {
Map<String,Object> discountPkMap = new HashMap<>();
discountPkMap.put("phone", receiveDiscountPk.getPhone());
discountPkMap.put("discountPkNo", receiveDiscountPk.getDiscountPkNo());
discountPkMap.put("discountPkStockCode", receiveDiscountPk.getDiscountPkStockCode());
List<Map<String,Object>> codeList = new LinkedList<>();
for (BsDiscountUser discountUser : receiveDiscountPk.getDiscountUserList()) {
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));
codeList.add(codeMap);
}
discountPkMap.put("codeList", codeList);
codeMapList.add(discountPkMap);
}
ResponsePushDiscountPkModel response = new ResponsePushDiscountPkModel();
response.setReqId(body.getReqId());
response.setAppId(body.getAppId());
response.setList(codeMapList);
response.setSign(SignatureUtil.createSign(response, agentApiParamService.getParamByAppId(body.getAppId()).getAppSecret()));
log.info("返回参数:" + JSONObject.toJSONString(response));
apiLog.setResponseParam(JSONObject.toJSONString(response));
@ -175,7 +248,50 @@ 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));
discountPkStockBatchService.recycle(Long.parseLong(body.getDiscountPkStockCode()));
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 +371,11 @@ public class BsDiscountController {
}
}
@RequestMapping(value="/pushPk",method = RequestMethod.POST)
@RequestMapping(value="/queryPkDetailByStockCode",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "推送优惠券包")
public ResponseData pushPk(@Validated @RequestBody RequestPushPkDiscountModel body) {
log.info("========= Start 推送优惠券包 Start ===========");
@ApiOperation(value = "根据库存code查询优惠券包详情")
public ResponseData queryPkDetailByStockCode(@Validated @RequestBody RequestQueryPkDiscountByStockCodeModel body) {
log.info("========= Start 根据库存code查询优惠券包详情 Start ===========");
log.info("请求参数:" + JSONObject.toJSONString(body));
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs();
try {
@ -274,37 +390,98 @@ public class BsDiscountController {
}
apiLog.setAppId(body.getAppId());
apiLog.setRequestId(body.getReqId());
apiLog.setRequestUrl("discount/pushPk");
apiLog.setRequestUrl("discount/queryPkDetailByStockCode");
apiLog.setRequestParam(JSONObject.toJSONString(body));
// 查询代理商是否拥有优惠券包权限
if (agentDiscountService.getDetail(apiParam.getAgentId(),2,body.getDiscountPkNo()) == null) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "未配置优惠券包");
// 查询库存code
BsDiscountPkStockCode stockCode = discountPkStockCodeService.getDetail(Long.parseLong(body.getDiscountPkStockCode()));
if (stockCode == null) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到code");
}
// 领取优惠券
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 (stockCode.getStatus().equals(DiscountPkStockCodeStatusEnum.status1.getCode())) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到code");
}
ResponsePushDiscountPkModel response = new ResponsePushDiscountPkModel();
ResponseQueryPkDiscountByReqIdModel response = new ResponseQueryPkDiscountByReqIdModel();
response.setAppId(body.getAppId());
response.setReqId(body.getReqId());
response.setDiscountPkNo(stockCode.getDiscountPkNo());
response.setDiscountPkStockCode(stockCode.getId());
response.setCodeList(new LinkedList<>());
List<BsDiscountStockCode> codeList = discountStockCodeService.getCodeListByPkStockId(stockCode.getId());
for (BsDiscountStockCode obj : codeList) {
JSONObject code = new JSONObject();
// 查询用户与优惠券信息
BsDiscountUser discountUser = discountUserService.getDetailByUserCodeId(obj.getReceiveMerUserPhone(), obj.getId());
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 根据库存code查询优惠券包详情 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 +499,7 @@ public class BsDiscountController {
if (apiLog.getAppId() != null) {
agentApiLogService.edit(apiLog);
}
log.info("========= END 推送优惠券包 END ===========");
log.info("========= END 查询优惠券包列表 END ===========");
}
}

@ -85,11 +85,14 @@ public class SignatureUtil {
}
public static void main(String[] args) throws Exception {
String paramStr = "{\n" +
" \"appId\": \"hffeab7fdb44d4f1\",\n" +
" \"orderNo\": \"test10001\"\n" +
String paramStr = "{ \n" +
" \"reqId\": \"cs0008\",\n" +
" \"appId\": \"hf7356c71fb97ab0\",\n" +
" \"discountPkNo\": \"DPK10018\",\n" +
" \"number\": \"1\",\n" +
" \"phone\": \"17726395120\"\n" +
"}";
String sign = createSign(JSONObject.parseObject(paramStr), "3a9b2772b9a2d319a9b18e55fa30246d");
String sign = createSign(JSONObject.parseObject(paramStr), "8aef995ff71485dc19b36e35f04c4016");
System.out.println(sign);
}

@ -46,7 +46,6 @@ public interface BsAgentMerMapperExt {
" a.merName," +
" a.merAddress," +
" a.agentName," +
" a.`status`," +
" a.createTime," +
" GROUP_CONCAT(a.agentStaffName) agentStaff" +
" FROM " +

@ -41,24 +41,24 @@ public interface BsDiscountMapper extends BsDiscountMapperExt {
@Insert({
"insert into bs_discount (discount_no, discount_name, ",
"discount_type, discount_condition, ",
"discount_price, use_scope, ",
"receive_expiration_date, start_time, ",
"end_time, reality_end_time, ",
"`status`, create_time, ",
"create_user_type, create_user_id, ",
"create_user_name, create_user_mer_no, ",
"update_time, ext_1, ",
"ext_2, ext_3)",
"discount_price, overlay_discount, ",
"use_scope, receive_expiration_date, ",
"start_time, end_time, ",
"reality_end_time, `status`, ",
"create_time, create_user_type, ",
"create_user_id, create_user_name, ",
"create_user_mer_no, update_time, ",
"ext_1, ext_2, ext_3)",
"values (#{discountNo,jdbcType=VARCHAR}, #{discountName,jdbcType=VARCHAR}, ",
"#{discountType,jdbcType=INTEGER}, #{discountCondition,jdbcType=DECIMAL}, ",
"#{discountPrice,jdbcType=DECIMAL}, #{useScope,jdbcType=VARCHAR}, ",
"#{receiveExpirationDate,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, ",
"#{endTime,jdbcType=TIMESTAMP}, #{realityEndTime,jdbcType=TIMESTAMP}, ",
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{createUserType,jdbcType=INTEGER}, #{createUserId,jdbcType=BIGINT}, ",
"#{createUserName,jdbcType=VARCHAR}, #{createUserMerNo,jdbcType=VARCHAR}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
"#{discountPrice,jdbcType=DECIMAL}, #{overlayDiscount,jdbcType=BIT}, ",
"#{useScope,jdbcType=VARCHAR}, #{receiveExpirationDate,jdbcType=INTEGER}, ",
"#{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, ",
"#{realityEndTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{createUserType,jdbcType=INTEGER}, ",
"#{createUserId,jdbcType=BIGINT}, #{createUserName,jdbcType=VARCHAR}, ",
"#{createUserMerNo,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(BsDiscount record);
@ -75,6 +75,7 @@ public interface BsDiscountMapper extends BsDiscountMapperExt {
@Result(column="discount_type", property="discountType", jdbcType=JdbcType.INTEGER),
@Result(column="discount_condition", property="discountCondition", jdbcType=JdbcType.DECIMAL),
@Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="overlay_discount", property="overlayDiscount", jdbcType=JdbcType.BIT),
@Result(column="use_scope", property="useScope", jdbcType=JdbcType.VARCHAR),
@Result(column="receive_expiration_date", property="receiveExpirationDate", jdbcType=JdbcType.INTEGER),
@Result(column="start_time", property="startTime", jdbcType=JdbcType.TIMESTAMP),
@ -96,9 +97,9 @@ public interface BsDiscountMapper extends BsDiscountMapperExt {
@Select({
"select",
"id, discount_no, discount_name, discount_type, discount_condition, discount_price, ",
"use_scope, receive_expiration_date, start_time, end_time, reality_end_time, ",
"`status`, create_time, create_user_type, create_user_id, create_user_name, create_user_mer_no, ",
"update_time, ext_1, ext_2, ext_3",
"overlay_discount, use_scope, receive_expiration_date, start_time, end_time, ",
"reality_end_time, `status`, create_time, create_user_type, create_user_id, create_user_name, ",
"create_user_mer_no, update_time, ext_1, ext_2, ext_3",
"from bs_discount",
"where id = #{id,jdbcType=BIGINT}"
})
@ -109,6 +110,7 @@ public interface BsDiscountMapper extends BsDiscountMapperExt {
@Result(column="discount_type", property="discountType", jdbcType=JdbcType.INTEGER),
@Result(column="discount_condition", property="discountCondition", jdbcType=JdbcType.DECIMAL),
@Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="overlay_discount", property="overlayDiscount", jdbcType=JdbcType.BIT),
@Result(column="use_scope", property="useScope", jdbcType=JdbcType.VARCHAR),
@Result(column="receive_expiration_date", property="receiveExpirationDate", jdbcType=JdbcType.INTEGER),
@Result(column="start_time", property="startTime", jdbcType=JdbcType.TIMESTAMP),
@ -143,6 +145,7 @@ public interface BsDiscountMapper extends BsDiscountMapperExt {
"discount_type = #{discountType,jdbcType=INTEGER},",
"discount_condition = #{discountCondition,jdbcType=DECIMAL},",
"discount_price = #{discountPrice,jdbcType=DECIMAL},",
"overlay_discount = #{overlayDiscount,jdbcType=BIT},",
"use_scope = #{useScope,jdbcType=VARCHAR},",
"receive_expiration_date = #{receiveExpirationDate,jdbcType=INTEGER},",
"start_time = #{startTime,jdbcType=TIMESTAMP},",

@ -48,6 +48,10 @@ public class BsDiscountSqlProvider {
sql.VALUES("discount_price", "#{discountPrice,jdbcType=DECIMAL}");
}
if (record.getOverlayDiscount() != null) {
sql.VALUES("overlay_discount", "#{overlayDiscount,jdbcType=BIT}");
}
if (record.getUseScope() != null) {
sql.VALUES("use_scope", "#{useScope,jdbcType=VARCHAR}");
}
@ -123,6 +127,7 @@ public class BsDiscountSqlProvider {
sql.SELECT("discount_type");
sql.SELECT("discount_condition");
sql.SELECT("discount_price");
sql.SELECT("overlay_discount");
sql.SELECT("use_scope");
sql.SELECT("receive_expiration_date");
sql.SELECT("start_time");
@ -179,6 +184,10 @@ public class BsDiscountSqlProvider {
sql.SET("discount_price = #{record.discountPrice,jdbcType=DECIMAL}");
}
if (record.getOverlayDiscount() != null) {
sql.SET("overlay_discount = #{record.overlayDiscount,jdbcType=BIT}");
}
if (record.getUseScope() != null) {
sql.SET("use_scope = #{record.useScope,jdbcType=VARCHAR}");
}
@ -253,6 +262,7 @@ public class BsDiscountSqlProvider {
sql.SET("discount_type = #{record.discountType,jdbcType=INTEGER}");
sql.SET("discount_condition = #{record.discountCondition,jdbcType=DECIMAL}");
sql.SET("discount_price = #{record.discountPrice,jdbcType=DECIMAL}");
sql.SET("overlay_discount = #{record.overlayDiscount,jdbcType=BIT}");
sql.SET("use_scope = #{record.useScope,jdbcType=VARCHAR}");
sql.SET("receive_expiration_date = #{record.receiveExpirationDate,jdbcType=INTEGER}");
sql.SET("start_time = #{record.startTime,jdbcType=TIMESTAMP}");
@ -298,6 +308,10 @@ public class BsDiscountSqlProvider {
sql.SET("discount_price = #{discountPrice,jdbcType=DECIMAL}");
}
if (record.getOverlayDiscount() != null) {
sql.SET("overlay_discount = #{overlayDiscount,jdbcType=BIT}");
}
if (record.getUseScope() != null) {
sql.SET("use_scope = #{useScope,jdbcType=VARCHAR}");
}

@ -42,21 +42,23 @@ public interface BsDiscountUserMapper extends BsDiscountUserMapperExt {
"insert into bs_discount_user (user_id, user_phone, ",
"discount_id, discount_no, ",
"discount_name, discount_type, ",
"discount_condition, discount_price, ",
"discount_stock_code, use_scope, ",
"use_date, expiration_date, ",
"agent_appid, `status`, ",
"create_time, update_time, ",
"ext_1, ext_2, ext_3)",
"overlay_discount, discount_condition, ",
"discount_price, discount_stock_code, ",
"use_scope, use_date, ",
"expiration_date, agent_appid, ",
"`status`, create_time, ",
"update_time, ext_1, ",
"ext_2, ext_3)",
"values (#{userId,jdbcType=BIGINT}, #{userPhone,jdbcType=VARCHAR}, ",
"#{discountId,jdbcType=BIGINT}, #{discountNo,jdbcType=VARCHAR}, ",
"#{discountName,jdbcType=VARCHAR}, #{discountType,jdbcType=INTEGER}, ",
"#{discountCondition,jdbcType=DECIMAL}, #{discountPrice,jdbcType=DECIMAL}, ",
"#{discountStockCode,jdbcType=BIGINT}, #{useScope,jdbcType=VARCHAR}, ",
"#{useDate,jdbcType=TIMESTAMP}, #{expirationDate,jdbcType=TIMESTAMP}, ",
"#{agentAppid,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
"#{overlayDiscount,jdbcType=BIT}, #{discountCondition,jdbcType=DECIMAL}, ",
"#{discountPrice,jdbcType=DECIMAL}, #{discountStockCode,jdbcType=BIGINT}, ",
"#{useScope,jdbcType=VARCHAR}, #{useDate,jdbcType=TIMESTAMP}, ",
"#{expirationDate,jdbcType=TIMESTAMP}, #{agentAppid,jdbcType=VARCHAR}, ",
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(BsDiscountUser record);
@ -74,6 +76,7 @@ public interface BsDiscountUserMapper extends BsDiscountUserMapperExt {
@Result(column="discount_no", property="discountNo", jdbcType=JdbcType.VARCHAR),
@Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR),
@Result(column="discount_type", property="discountType", jdbcType=JdbcType.INTEGER),
@Result(column="overlay_discount", property="overlayDiscount", jdbcType=JdbcType.BIT),
@Result(column="discount_condition", property="discountCondition", jdbcType=JdbcType.DECIMAL),
@Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="discount_stock_code", property="discountStockCode", jdbcType=JdbcType.BIGINT),
@ -93,9 +96,9 @@ public interface BsDiscountUserMapper extends BsDiscountUserMapperExt {
@Select({
"select",
"id, user_id, user_phone, discount_id, discount_no, discount_name, discount_type, ",
"discount_condition, discount_price, discount_stock_code, use_scope, use_date, ",
"expiration_date, agent_appid, `status`, create_time, update_time, ext_1, ext_2, ",
"ext_3",
"overlay_discount, discount_condition, discount_price, discount_stock_code, use_scope, ",
"use_date, expiration_date, agent_appid, `status`, create_time, update_time, ",
"ext_1, ext_2, ext_3",
"from bs_discount_user",
"where id = #{id,jdbcType=BIGINT}"
})
@ -107,6 +110,7 @@ public interface BsDiscountUserMapper extends BsDiscountUserMapperExt {
@Result(column="discount_no", property="discountNo", jdbcType=JdbcType.VARCHAR),
@Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR),
@Result(column="discount_type", property="discountType", jdbcType=JdbcType.INTEGER),
@Result(column="overlay_discount", property="overlayDiscount", jdbcType=JdbcType.BIT),
@Result(column="discount_condition", property="discountCondition", jdbcType=JdbcType.DECIMAL),
@Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="discount_stock_code", property="discountStockCode", jdbcType=JdbcType.BIGINT),
@ -140,6 +144,7 @@ public interface BsDiscountUserMapper extends BsDiscountUserMapperExt {
"discount_no = #{discountNo,jdbcType=VARCHAR},",
"discount_name = #{discountName,jdbcType=VARCHAR},",
"discount_type = #{discountType,jdbcType=INTEGER},",
"overlay_discount = #{overlayDiscount,jdbcType=BIT},",
"discount_condition = #{discountCondition,jdbcType=DECIMAL},",
"discount_price = #{discountPrice,jdbcType=DECIMAL},",
"discount_stock_code = #{discountStockCode,jdbcType=BIGINT},",

@ -52,6 +52,10 @@ public class BsDiscountUserSqlProvider {
sql.VALUES("discount_type", "#{discountType,jdbcType=INTEGER}");
}
if (record.getOverlayDiscount() != null) {
sql.VALUES("overlay_discount", "#{overlayDiscount,jdbcType=BIT}");
}
if (record.getDiscountCondition() != null) {
sql.VALUES("discount_condition", "#{discountCondition,jdbcType=DECIMAL}");
}
@ -120,6 +124,7 @@ public class BsDiscountUserSqlProvider {
sql.SELECT("discount_no");
sql.SELECT("discount_name");
sql.SELECT("discount_type");
sql.SELECT("overlay_discount");
sql.SELECT("discount_condition");
sql.SELECT("discount_price");
sql.SELECT("discount_stock_code");
@ -178,6 +183,10 @@ public class BsDiscountUserSqlProvider {
sql.SET("discount_type = #{record.discountType,jdbcType=INTEGER}");
}
if (record.getOverlayDiscount() != null) {
sql.SET("overlay_discount = #{record.overlayDiscount,jdbcType=BIT}");
}
if (record.getDiscountCondition() != null) {
sql.SET("discount_condition = #{record.discountCondition,jdbcType=DECIMAL}");
}
@ -245,6 +254,7 @@ public class BsDiscountUserSqlProvider {
sql.SET("discount_no = #{record.discountNo,jdbcType=VARCHAR}");
sql.SET("discount_name = #{record.discountName,jdbcType=VARCHAR}");
sql.SET("discount_type = #{record.discountType,jdbcType=INTEGER}");
sql.SET("overlay_discount = #{record.overlayDiscount,jdbcType=BIT}");
sql.SET("discount_condition = #{record.discountCondition,jdbcType=DECIMAL}");
sql.SET("discount_price = #{record.discountPrice,jdbcType=DECIMAL}");
sql.SET("discount_stock_code = #{record.discountStockCode,jdbcType=BIGINT}");
@ -292,6 +302,10 @@ public class BsDiscountUserSqlProvider {
sql.SET("discount_type = #{discountType,jdbcType=INTEGER}");
}
if (record.getOverlayDiscount() != null) {
sql.SET("overlay_discount = #{overlayDiscount,jdbcType=BIT}");
}
if (record.getDiscountCondition() != null) {
sql.SET("discount_condition = #{discountCondition,jdbcType=DECIMAL}");
}

@ -44,6 +44,11 @@ public class BsDiscount implements Serializable {
*/
private BigDecimal discountPrice;
/**
* 叠加优惠
*/
private Boolean overlayDiscount;
/**
* 使用范围支持多选 1加油 2商城
*/
@ -160,6 +165,14 @@ public class BsDiscount implements Serializable {
this.discountPrice = discountPrice;
}
public Boolean getOverlayDiscount() {
return overlayDiscount;
}
public void setOverlayDiscount(Boolean overlayDiscount) {
this.overlayDiscount = overlayDiscount;
}
public String getUseScope() {
return useScope;
}
@ -298,6 +311,7 @@ public class BsDiscount implements Serializable {
&& (this.getDiscountType() == null ? other.getDiscountType() == null : this.getDiscountType().equals(other.getDiscountType()))
&& (this.getDiscountCondition() == null ? other.getDiscountCondition() == null : this.getDiscountCondition().equals(other.getDiscountCondition()))
&& (this.getDiscountPrice() == null ? other.getDiscountPrice() == null : this.getDiscountPrice().equals(other.getDiscountPrice()))
&& (this.getOverlayDiscount() == null ? other.getOverlayDiscount() == null : this.getOverlayDiscount().equals(other.getOverlayDiscount()))
&& (this.getUseScope() == null ? other.getUseScope() == null : this.getUseScope().equals(other.getUseScope()))
&& (this.getReceiveExpirationDate() == null ? other.getReceiveExpirationDate() == null : this.getReceiveExpirationDate().equals(other.getReceiveExpirationDate()))
&& (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime()))
@ -325,6 +339,7 @@ public class BsDiscount implements Serializable {
result = prime * result + ((getDiscountType() == null) ? 0 : getDiscountType().hashCode());
result = prime * result + ((getDiscountCondition() == null) ? 0 : getDiscountCondition().hashCode());
result = prime * result + ((getDiscountPrice() == null) ? 0 : getDiscountPrice().hashCode());
result = prime * result + ((getOverlayDiscount() == null) ? 0 : getOverlayDiscount().hashCode());
result = prime * result + ((getUseScope() == null) ? 0 : getUseScope().hashCode());
result = prime * result + ((getReceiveExpirationDate() == null) ? 0 : getReceiveExpirationDate().hashCode());
result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode());
@ -355,6 +370,7 @@ public class BsDiscount implements Serializable {
sb.append(", discountType=").append(discountType);
sb.append(", discountCondition=").append(discountCondition);
sb.append(", discountPrice=").append(discountPrice);
sb.append(", overlayDiscount=").append(overlayDiscount);
sb.append(", useScope=").append(useScope);
sb.append(", receiveExpirationDate=").append(receiveExpirationDate);
sb.append(", startTime=").append(startTime);

@ -506,6 +506,66 @@ public class BsDiscountExample {
return (Criteria) this;
}
public Criteria andOverlayDiscountIsNull() {
addCriterion("overlay_discount is null");
return (Criteria) this;
}
public Criteria andOverlayDiscountIsNotNull() {
addCriterion("overlay_discount is not null");
return (Criteria) this;
}
public Criteria andOverlayDiscountEqualTo(Boolean value) {
addCriterion("overlay_discount =", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountNotEqualTo(Boolean value) {
addCriterion("overlay_discount <>", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountGreaterThan(Boolean value) {
addCriterion("overlay_discount >", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountGreaterThanOrEqualTo(Boolean value) {
addCriterion("overlay_discount >=", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountLessThan(Boolean value) {
addCriterion("overlay_discount <", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountLessThanOrEqualTo(Boolean value) {
addCriterion("overlay_discount <=", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountIn(List<Boolean> values) {
addCriterion("overlay_discount in", values, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountNotIn(List<Boolean> values) {
addCriterion("overlay_discount not in", values, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountBetween(Boolean value1, Boolean value2) {
addCriterion("overlay_discount between", value1, value2, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountNotBetween(Boolean value1, Boolean value2) {
addCriterion("overlay_discount not between", value1, value2, "overlayDiscount");
return (Criteria) this;
}
public Criteria andUseScopeIsNull() {
addCriterion("use_scope is null");
return (Criteria) this;

@ -49,6 +49,11 @@ public class BsDiscountUser implements Serializable {
*/
private Integer discountType;
/**
* 叠加优惠
*/
private Boolean overlayDiscount;
/**
* 优惠券条件(满减价格)
*/
@ -163,6 +168,14 @@ public class BsDiscountUser implements Serializable {
this.discountType = discountType;
}
public Boolean getOverlayDiscount() {
return overlayDiscount;
}
public void setOverlayDiscount(Boolean overlayDiscount) {
this.overlayDiscount = overlayDiscount;
}
public BigDecimal getDiscountCondition() {
return discountCondition;
}
@ -286,6 +299,7 @@ public class BsDiscountUser implements Serializable {
&& (this.getDiscountNo() == null ? other.getDiscountNo() == null : this.getDiscountNo().equals(other.getDiscountNo()))
&& (this.getDiscountName() == null ? other.getDiscountName() == null : this.getDiscountName().equals(other.getDiscountName()))
&& (this.getDiscountType() == null ? other.getDiscountType() == null : this.getDiscountType().equals(other.getDiscountType()))
&& (this.getOverlayDiscount() == null ? other.getOverlayDiscount() == null : this.getOverlayDiscount().equals(other.getOverlayDiscount()))
&& (this.getDiscountCondition() == null ? other.getDiscountCondition() == null : this.getDiscountCondition().equals(other.getDiscountCondition()))
&& (this.getDiscountPrice() == null ? other.getDiscountPrice() == null : this.getDiscountPrice().equals(other.getDiscountPrice()))
&& (this.getDiscountStockCode() == null ? other.getDiscountStockCode() == null : this.getDiscountStockCode().equals(other.getDiscountStockCode()))
@ -312,6 +326,7 @@ public class BsDiscountUser implements Serializable {
result = prime * result + ((getDiscountNo() == null) ? 0 : getDiscountNo().hashCode());
result = prime * result + ((getDiscountName() == null) ? 0 : getDiscountName().hashCode());
result = prime * result + ((getDiscountType() == null) ? 0 : getDiscountType().hashCode());
result = prime * result + ((getOverlayDiscount() == null) ? 0 : getOverlayDiscount().hashCode());
result = prime * result + ((getDiscountCondition() == null) ? 0 : getDiscountCondition().hashCode());
result = prime * result + ((getDiscountPrice() == null) ? 0 : getDiscountPrice().hashCode());
result = prime * result + ((getDiscountStockCode() == null) ? 0 : getDiscountStockCode().hashCode());
@ -341,6 +356,7 @@ public class BsDiscountUser implements Serializable {
sb.append(", discountNo=").append(discountNo);
sb.append(", discountName=").append(discountName);
sb.append(", discountType=").append(discountType);
sb.append(", overlayDiscount=").append(overlayDiscount);
sb.append(", discountCondition=").append(discountCondition);
sb.append(", discountPrice=").append(discountPrice);
sb.append(", discountStockCode=").append(discountStockCode);

@ -576,6 +576,66 @@ public class BsDiscountUserExample {
return (Criteria) this;
}
public Criteria andOverlayDiscountIsNull() {
addCriterion("overlay_discount is null");
return (Criteria) this;
}
public Criteria andOverlayDiscountIsNotNull() {
addCriterion("overlay_discount is not null");
return (Criteria) this;
}
public Criteria andOverlayDiscountEqualTo(Boolean value) {
addCriterion("overlay_discount =", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountNotEqualTo(Boolean value) {
addCriterion("overlay_discount <>", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountGreaterThan(Boolean value) {
addCriterion("overlay_discount >", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountGreaterThanOrEqualTo(Boolean value) {
addCriterion("overlay_discount >=", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountLessThan(Boolean value) {
addCriterion("overlay_discount <", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountLessThanOrEqualTo(Boolean value) {
addCriterion("overlay_discount <=", value, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountIn(List<Boolean> values) {
addCriterion("overlay_discount in", values, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountNotIn(List<Boolean> values) {
addCriterion("overlay_discount not in", values, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountBetween(Boolean value1, Boolean value2) {
addCriterion("overlay_discount between", value1, value2, "overlayDiscount");
return (Criteria) this;
}
public Criteria andOverlayDiscountNotBetween(Boolean value1, Boolean value2) {
addCriterion("overlay_discount not between", value1, value2, "overlayDiscount");
return (Criteria) this;
}
public Criteria andDiscountConditionIsNull() {
addCriterion("discount_condition is null");
return (Criteria) this;

@ -63,6 +63,11 @@ public class GasPayPriceModel {
*/
private BigDecimal discount;
/**
* 是否叠加优惠
*/
private Boolean overlayDiscount;
/**
* 每升优惠
*/

@ -0,0 +1,35 @@
package com.hfkj.model;
import com.hfkj.entity.BsDiscountUser;
import lombok.Data;
import java.util.List;
/**
* 领取优惠券包返回参数
* @className: receiveDiscountPk
* @author: HuRui
* @date: 2025/1/13
**/
@Data
public class ReceiveDiscountPkModel {
/**
* 用户手机号
*/
private String phone;
/**
* 优惠券包编码
*/
private String discountPkNo;
/**
* 优惠券包库存id
*/
private Long discountPkStockCode;
/**
* 用户优惠券
*/
private List<BsDiscountUser> discountUserList;
}

@ -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 RequestQueryPkDiscountByStockCodeModel {
/**
* 请求id必填项
*/
@NotBlank(message = "请求id必填项")
private String reqId;
/**
* appId
*/
@NotBlank(message = "appId必填项")
private String appId;
/**
* 优惠券包库存代码
*/
@NotBlank(message = "优惠券包库存代码必填项")
private String discountPkStockCode;
/**
* 签名参数
*/
@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 = "优惠券库存代码必填项")
private Long discountStockCode;
/**
* 签名参数
*/
@NotBlank(message = "签名必填项")
private String sign;
}

@ -0,0 +1,40 @@
package com.hfkj.openapi.model.request;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
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;
/**
* 优惠券包库存代码
*/
@NotBlank(message = "优惠券包库存代码必填项")
private String discountPkStockCode;
/**
* 签名参数
*/
@NotBlank(message = "签名必填项")
private String sign;
}

@ -22,15 +22,10 @@ public class ResponsePushDiscountPkModel {
*/
private String appId;
/**
* 券包编号
*/
private String discountPkNo;
/**
* 优惠券编码列表
*/
private List<Map<String,Object>> codeList;
private List<Map<String,Object>> list;
/**
* 签名参数

@ -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;
/**
* 优惠券编号
*/
private String discountPkNo;
/**
* 优惠券包库存代码
*/
private Long discountPkStockCode;
/**
* 优惠券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;
}
}

@ -27,6 +27,12 @@ public interface BsDiscountPkStockBatchService {
*/
void addStock(String discountPkNo,Integer stockCount);
/**
* 回收优惠券包
* @param stockCodeId 库存id
*/
void recycle(Long stockCodeId);
/**
* 查询详情
* @param batchNo

@ -32,6 +32,12 @@ public interface BsDiscountPkStockCodeService {
*/
List<BsDiscountPkStockCode> getAssignCodeList(String discountPkNo, Integer number);
/**
* 查询详情
* @param stockId 库存id
* @return
*/
BsDiscountPkStockCode getDetail(Long stockId);
/**
* 查询列表
* @param param

@ -24,6 +24,12 @@ public interface BsDiscountStockCodeService {
*/
void update(BsDiscountStockCode data);
/**
* 回收优惠券
* @param stockCodeId
*/
void recycle(Long stockCodeId);
/**
* 查询详情
* @param id
@ -38,6 +44,13 @@ public interface BsDiscountStockCodeService {
*/
List<BsDiscountStockCode> getAssignCodeList(String discountNo, Integer number);
/**
* 查询优惠券库存id
* @param
* @return
*/
List<BsDiscountStockCode> getCodeListByPkStockId(Long discountPkStockId);
/**
* 查询列表
* @param param

@ -1,8 +1,8 @@
package com.hfkj.service.discount;
import com.hfkj.entity.BsDiscount;
import com.hfkj.entity.BsDiscountUser;
import com.hfkj.model.DiscountUserModel;
import com.hfkj.model.ReceiveDiscountPkModel;
import com.hfkj.sysenum.discount.DiscountStockCodeObtainTypeEnum;
import java.util.List;
@ -39,7 +39,7 @@ public interface BsDiscountUserService {
* @param agentAppid
* @return
*/
List<BsDiscountUser> receivePk(String discountPkNo, Integer number, DiscountStockCodeObtainTypeEnum obtainType, String userPhone, String agentAppid);
List<ReceiveDiscountPkModel> receivePk(String discountPkNo, Integer number, DiscountStockCodeObtainTypeEnum obtainType, String userPhone, String agentAppid);
/**
* 使用优惠券
@ -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

@ -6,11 +6,14 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.dao.BsDiscountPkStockBatchMapper;
import com.hfkj.entity.*;
import com.hfkj.service.discount.*;
import com.hfkj.sysenum.discount.DiscountPkStatusEnum;
import com.hfkj.sysenum.discount.DiscountPkStockCodeStatusEnum;
import com.hfkj.sysenum.discount.DiscountStockCodeStatusEnum;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
@ -31,6 +34,8 @@ public class BsDiscountPkStockBatchServiceImpl implements BsDiscountPkStockBatch
private BsDiscountPkService discountPkService;
@Resource
private BsDiscountPkStockCodeService discountPkStockCodeService;
@Resource
private BsDiscountStockCodeService discountStockCodeService;
@Override
public void editData(BsDiscountPkStockBatch data) {
@ -84,6 +89,35 @@ public class BsDiscountPkStockBatchServiceImpl implements BsDiscountPkStockBatch
editData(batch);
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW, rollbackFor= {RuntimeException.class})
public void recycle(Long stockCodeId) {
// 查询优惠券包库存编号
BsDiscountPkStockCode pkStockCode = discountPkStockCodeService.getDetail(stockCodeId);
if (pkStockCode == null) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "未找到优惠券包库存编码");
}
if (!pkStockCode.getStatus().equals(DiscountPkStockCodeStatusEnum.status2.getCode())) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "优惠券包状态错误");
}
pkStockCode.setObtainType(null);
pkStockCode.setObtainTime(null);
pkStockCode.setReceiveMerUserId(null);
pkStockCode.setReceiveMerUserPhone(null);
pkStockCode.setStatus(DiscountPkStockCodeStatusEnum.status1.getCode());
pkStockCode.setAgentAppid(null);
discountPkStockCodeService.update(pkStockCode);
// 查询优惠券包下的优惠券
List<BsDiscountStockCode> discountStockCodeList = discountStockCodeService.getCodeListByPkStockId(pkStockCode.getId());
for (BsDiscountStockCode discountStockCode : discountStockCodeList) {
if (discountStockCode.getStatus().equals(DiscountStockCodeStatusEnum.status2.getCode())) {
// 退回优惠券
discountStockCodeService.recycle(discountStockCode.getId());
}
}
}
@Override
public BsDiscountPkStockBatch getStockBatchDetail(String batchNo) {
BsDiscountPkStockBatchExample example = new BsDiscountPkStockBatchExample();

@ -40,7 +40,7 @@ public class BsDiscountPkStockCodeServiceImpl implements BsDiscountPkStockCodeSe
@Override
public void update(BsDiscountPkStockCode data) {
data.setUpdateTime(new Date());
discountPkStockCodeMapper.updateByPrimaryKeySelective(data);
discountPkStockCodeMapper.updateByPrimaryKey(data);
}
@Override
@ -54,11 +54,16 @@ public class BsDiscountPkStockCodeServiceImpl implements BsDiscountPkStockCodeSe
PageInfo<BsDiscountPkStockCode> pageInfo = new PageInfo<>(discountPkStockCodeMapper.selectByExample(example));
if (pageInfo.getList().size() != number) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券库存不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券库存不足");
}
return pageInfo.getList();
}
@Override
public BsDiscountPkStockCode getDetail(Long stockId) {
return discountPkStockCodeMapper.selectByPrimaryKey(stockId);
}
@Override
public List<BsDiscountPkStockCode> getCodeList(Map<String, Object> param) {
BsDiscountPkStockCodeExample example = new BsDiscountPkStockCodeExample();

@ -8,11 +8,16 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.dao.BsDiscountStockCodeMapper;
import com.hfkj.entity.BsDiscountStockCode;
import com.hfkj.entity.BsDiscountStockCodeExample;
import com.hfkj.entity.BsDiscountUser;
import com.hfkj.service.discount.BsDiscountStockCodeService;
import com.hfkj.service.discount.BsDiscountUserService;
import com.hfkj.sysenum.discount.DiscountStockCodeStatusEnum;
import com.hfkj.sysenum.discount.DiscountUserStatusEnum;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
@ -29,7 +34,8 @@ public class BsDiscountStockCodeServiceImpl implements BsDiscountStockCodeServic
@Resource
private BsDiscountStockCodeMapper discountStockCodeMapper;
@Resource
private BsDiscountUserService discountUserService;
@Override
public void insertList(List<BsDiscountStockCode> codeList) {
discountStockCodeMapper.insertList(codeList);
@ -41,6 +47,33 @@ public class BsDiscountStockCodeServiceImpl implements BsDiscountStockCodeServic
discountStockCodeMapper.updateByPrimaryKey(data);
}
@Override
@Transactional(propagation= Propagation.REQUIRED, rollbackFor= {RuntimeException.class})
public void recycle(Long stockCodeId) {
// 查询库存记录
BsDiscountStockCode stockCode = getDetail(stockCodeId);
if (stockCode == null) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "位置优惠券库存id");
}
if (stockCode.getStatus().equals(DiscountStockCodeStatusEnum.status2.getCode())) {
// 退回优惠券库存
stockCode.setObtainType(null);
stockCode.setObtainTime(null);
stockCode.setReceiveMerUserId(null);
stockCode.setReceiveMerUserPhone(null);
stockCode.setStatus(DiscountStockCodeStatusEnum.status1.getCode());
stockCode.setAgentAppid(null);
update(stockCode);
// 用户优惠券
BsDiscountUser discountUser = discountUserService.getDetailByCodeId(stockCodeId);
if (discountUser != null) {
discountUser.setStatus(DiscountUserStatusEnum.type4.getCode());
discountUserService.editData(discountUser);
}
}
}
@Override
public BsDiscountStockCode getDetail(Long id) {
return discountStockCodeMapper.selectByPrimaryKey(id);
@ -62,6 +95,16 @@ public class BsDiscountStockCodeServiceImpl implements BsDiscountStockCodeServic
return pageInfo.getList();
}
@Override
public List<BsDiscountStockCode> getCodeListByPkStockId(Long discountPkStockId) {
BsDiscountStockCodeExample example = new BsDiscountStockCodeExample();
example.createCriteria()
.andStatusNotEqualTo(DiscountStockCodeStatusEnum.status0.getCode())
.andDiscountPkStockCodeEqualTo(discountPkStockId);
example.setOrderByClause("id desc");
return discountStockCodeMapper.selectByExample(example);
}
@Override
public List<BsDiscountStockCode> getCodeList(Map<String, Object> param) {
BsDiscountStockCodeExample example = new BsDiscountStockCodeExample();

@ -7,6 +7,7 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.dao.BsDiscountUserMapper;
import com.hfkj.entity.*;
import com.hfkj.model.DiscountUserModel;
import com.hfkj.model.ReceiveDiscountPkModel;
import com.hfkj.service.discount.*;
import com.hfkj.service.user.BsUserService;
import com.hfkj.sysenum.discount.*;
@ -113,6 +114,7 @@ public class BsDiscountUserServiceImpl implements BsDiscountUserService {
discountUser.setDiscountNo(discount.getDiscountNo());
discountUser.setDiscountName(discount.getDiscountName());
discountUser.setDiscountType(discount.getDiscountType());
discountUser.setOverlayDiscount(discount.getOverlayDiscount());
discountUser.setDiscountCondition(discount.getDiscountCondition());
discountUser.setDiscountPrice(discount.getDiscountPrice());
discountUser.setDiscountStockCode(discountStockCode.getId());
@ -159,11 +161,13 @@ public class BsDiscountUserServiceImpl implements BsDiscountUserService {
@Override
@Transactional(propagation= Propagation.REQUIRED)
public List<BsDiscountUser> receivePk(String discountPkNo, Integer number, DiscountStockCodeObtainTypeEnum obtainType, String userPhone, String agentAppid) {
public List<ReceiveDiscountPkModel> receivePk(String discountPkNo, Integer number, DiscountStockCodeObtainTypeEnum obtainType, String userPhone, String agentAppid) {
// 锁编号
String lockKey = RECEIVE_DISCOUNT_PK_LOCK_KEY+"_"+discountPkNo;
// 获取锁
Boolean lock = redisTemplate.opsForValue().setIfAbsent(lockKey, "");
List<ReceiveDiscountPkModel> list = new LinkedList<>();
if (Boolean.TRUE.equals(lock)) {
try {
// 锁超时时间 10秒
@ -184,12 +188,12 @@ public class BsDiscountUserServiceImpl implements BsDiscountUserService {
other.put("agentAppid", agentAppid);
user = userService.register(userPhone, other);
}
List<BsDiscountUser> receiveList = new ArrayList<>();
// 优惠券包库存编码
List<BsDiscountPkStockCode> codeList = discountPkStockCodeService.getAssignCodeList(discountPkNo, number);
for (BsDiscountPkStockCode code : codeList) {
// 库存领取数据
List<BsDiscountUser> receiveList = new ArrayList<>();
code.setObtainType(obtainType.getCode());
code.setObtainTime(new Date());
code.setReceiveMerUserId(user.getId());
@ -207,7 +211,7 @@ public class BsDiscountUserServiceImpl implements BsDiscountUserService {
// 优惠券库存编码
BsDiscountStockCode discountStockCode = discountStockCodeService.getDetail(discountUser.getDiscountStockCode());
if (discountStockCode != null) {
discountStockCode.setDiscountPkStockCode(discountStockCode.getId());
discountStockCode.setDiscountPkStockCode(code.getId());
discountStockCode.setDiscountPkId(discountPk.getId());
discountStockCode.setDiscountPkNo(discountPk.getDiscountPkNo());
discountStockCode.setDiscountPkName(discountPk.getDiscountPkName());
@ -216,8 +220,15 @@ public class BsDiscountUserServiceImpl implements BsDiscountUserService {
}
receiveList.addAll(discountUsers);
}
ReceiveDiscountPkModel receiveDiscountPkModel = new ReceiveDiscountPkModel();
receiveDiscountPkModel.setDiscountPkNo(discountPkNo);
receiveDiscountPkModel.setDiscountPkStockCode(code.getId());
receiveDiscountPkModel.setPhone(userPhone);
receiveDiscountPkModel.setDiscountUserList(receiveList);
list.add(receiveDiscountPkModel);
}
return receiveList;
return list;
} catch (BaseException e) {
// 释放锁
redisTemplate.delete(lockKey);
@ -364,6 +375,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);

@ -10,6 +10,7 @@ import com.hfkj.entity.BsGasOrderExample;
import com.hfkj.service.gas.BsGasOrderService;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.OrderPaySuccessService;
import com.hfkj.sysenum.order.OrderPayTypeEnum;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -71,9 +72,21 @@ public class BsGasOrderServiceImpl implements BsGasOrderService {
@Override
public BsGasOrder repairOrder(String orderNo) throws Exception {
BsGasOrder result = paySuccessService.oilHandle(orderService.getDetail(orderNo));
if (result.getAbnormal().equals(true)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "补单失败!原因:" + result.getAbnormalContent());
// 加油订单
BsGasOrder gasOrder = getDetailByOrderNo(orderNo);
BsGasOrder result = null;
if (!gasOrder.getPayType().equals(OrderPayTypeEnum.type4.getCode())) {
// 补推
result = paySuccessService.oilHandle(orderService.getDetail(orderNo));
if (result.getAbnormal().equals(true)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "补单失败!原因:" + result.getAbnormalContent());
}
} else {
// 补推
result = paySuccessService.oilApiHandle(gasOrder);
if (result.getAbnormal().equals(true)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "补单失败!原因:" + result.getAbnormalContent());
}
}
return result;
}

@ -70,7 +70,7 @@ public class BsGasServiceImpl implements BsGasService {
if (merchant == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站");
}
BsDiscountUser discountUser = null;
GasPayPriceModel payPriceModel = new GasPayPriceModel();
payPriceModel.setDeductionCouponPrice(new BigDecimal("0"));
@ -78,29 +78,32 @@ public class BsGasServiceImpl implements BsGasService {
BigDecimal discount = new BigDecimal("100");
BigDecimal serviceFeeRate = new BigDecimal("0");
// 没有使用优惠券,可以享受油价优惠
if (userDiscountId == null) {
if (agentMerId != null) {
// 查询代理价格
BsAgentPrice agentPrice = agentPriceService.getDetail(agentMerId, oilNo);
if (agentPrice != null) {
discount = agentPrice.getPriceRate();
serviceFeeRate = agentPrice.getServiceFeeRate();
}
} else {
// 查询平台价格
BsAgentPrice agentPrice = agentPriceService.getDetail(AgentPriceTypeEnum.type1, merNo, oilNo);
if (agentPrice != null) {
discount = agentPrice.getPriceRate();
serviceFeeRate = agentPrice.getServiceFeeRate();
}
if (agentMerId != null) {
// 查询代理价格
BsAgentPrice agentPrice = agentPriceService.getDetail(agentMerId, oilNo);
if (agentPrice != null) {
discount = agentPrice.getPriceRate();
serviceFeeRate = agentPrice.getServiceFeeRate();
}
} else {
// 查询平台价格
BsAgentPrice agentPrice = agentPriceService.getDetail(AgentPriceTypeEnum.type1, merNo, oilNo);
if (agentPrice != null) {
discount = agentPrice.getPriceRate();
serviceFeeRate = agentPrice.getServiceFeeRate();
}
}
if (userDiscountId != null) {
// 查询用户优惠券
BsDiscountUser discountUser = discountUserService.getDetail(userDiscountId);
discountUser = discountUserService.getDetail(userDiscountId);
if (discountUser == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户优惠券");
}
if (discountUser.getOverlayDiscount().equals(false)) {
// 优惠券与油价不叠加
discount = new BigDecimal("100");
}
// 查询平台服务费
BsAgentPrice agentPrice = agentPriceService.getDetail(AgentPriceTypeEnum.type1, merNo, oilNo);
if (agentPrice != null) {
@ -112,6 +115,7 @@ public class BsGasServiceImpl implements BsGasService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未达到满减金额,无法使用此优惠券");
}
payPriceModel.setDeductionCouponPrice(discountUser.getDiscountPrice());
} else if (DiscountTypeEnum.type2.getCode().equals(discountUser.getDiscountType())) {
payPriceModel.setDeductionCouponPrice(discountUser.getDiscountPrice());
@ -121,7 +125,7 @@ public class BsGasServiceImpl implements BsGasService {
refuelPrice.multiply(discountUser.getDiscountPrice().divide(new BigDecimal("100"))).setScale(2, BigDecimal.ROUND_HALF_DOWN)
));
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油站");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的优惠券类型");
}
}
@ -139,10 +143,14 @@ public class BsGasServiceImpl implements BsGasService {
// 油站直降
BigDecimal gasStationDrop = gasOilPrice.getGasStationDrop();
// 油站优惠价
BigDecimal priceVip = userDiscountId==null?gasOilPrice.getPriceVip():priceGun;
BigDecimal priceVip = gasOilPrice.getPriceVip();
// 嗨森逛平台价 油站优惠价 * 折扣
BigDecimal pricePlatform = priceVip.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP);
if (discountUser != null && discountUser.getOverlayDiscount().equals(false)) {
// 优惠券与油价不叠加
pricePlatform = priceGun;
priceVip = priceGun;
}
// 加油金额
payPriceModel.setOilingPrice(refuelPrice);

@ -206,4 +206,126 @@ public class OrderPaySuccessService {
return gasOrder;
}
/**
* api加油业务
* @param gasOrder
* @return
* @throws Exception
*/
public BsGasOrder oilApiHandle(BsGasOrder gasOrder) throws Exception {
if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type1.getNumber())) {
// 自建站
// 打印小票
if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type1.getNumber())) {
deviceService.printGasOrder(gasOrder.getMerId(), gasOrder, false);
}
// 查询油站
BsMerchant merchant = merchantService.getMerchant(gasOrder.getMerNo());
if (merchant != null) {
// 连锁商户
if (merchant.getChainBrandId() != null) {
if (merchant.getChainBrandSettleType().equals(MerchantChainBrandSettleTypeEnum.type1.getNumber())) {
// 连锁额度
Map<String,Object> consumeMap = new HashMap<>();
consumeMap.put("sourceType", MerchantAccountRecordSourceTypeEnum.type2.getType());
consumeMap.put("sourceId", gasOrder.getId());
consumeMap.put("sourceOrderNo", gasOrder.getOrderNo());
merchantChainBrandAccountService.consume(merchant.getChainBrandId(), gasOrder.getMerNo(), gasOrder.getGasSettlePrice(), consumeMap);
} else if (merchant.getChainBrandSettleType().equals(MerchantChainBrandSettleTypeEnum.type2.getNumber())) {
// 商户额度
Map<String,Object> consumeMap = new HashMap<>();
consumeMap.put("sourceType", MerchantAccountRecordSourceTypeEnum.type2.getType());
consumeMap.put("sourceId", gasOrder.getId());
consumeMap.put("sourceOrderNo", gasOrder.getOrderNo());
merchantAccountService.consume(gasOrder.getMerNo(), gasOrder.getGasSettlePrice(), consumeMap);
}
} else {
// 商户额度
Map<String,Object> consumeMap = new HashMap<>();
consumeMap.put("sourceType", MerchantAccountRecordSourceTypeEnum.type2.getType());
consumeMap.put("sourceId", gasOrder.getId());
consumeMap.put("sourceOrderNo", gasOrder.getOrderNo());
merchantAccountService.consume(gasOrder.getMerNo(), gasOrder.getGasSettlePrice(), consumeMap);
}
}
} else if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type2.getNumber())) {
try {
// 能链【团油】
Map<String, Object> param = new HashMap<>();
param.put("gasId", gasOrder.getMerNo());
param.put("oilNo", gasOrder.getGasOilNo());
param.put("gunNo", Integer.parseInt(gasOrder.getGasGunNo()));
param.put("priceGun", gasOrder.getGasPriceGun()); // 油站价
param.put("priceVip", gasOrder.getGasPriceCost()); // 成本价
param.put("driverPhone", gasOrder.getUserPhone());
param.put("thirdSerialNo", gasOrder.getOrderNo());
param.put("refuelingAmount", gasOrder.getGasRefuelPrice());
// 查询账户
SecDictionary newLinkAccount = dictionaryService.getDictionary("NEW_LINK_ACCOUNT", "" + gasOrder.getGasOilType());
if (newLinkAccount != null) {
param.put("accountNo", newLinkAccount.getCodeName());
}
JSONObject pushResult = NewLinkRequestService.refuelingOrderPush(param);
if (pushResult != null && pushResult.getString("code").equals("200")) {
gasOrder.setChannelOrderNo(pushResult.getJSONObject("result").getString("orderNo"));
gasOrder.setAbnormal(false);
gasOrder.setAbnormalContent(null);
} else {
gasOrder.setAbnormal(true);
gasOrder.setAbnormalContent(pushResult.getString("message"));
}
} catch (Exception e) {
gasOrder.setAbnormal(true);
gasOrder.setAbnormalContent("推送订单未知异常!请稍后重新推送");
}
gasOrderService.updateGasOrder(gasOrder);
} else if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type3.getNumber())) {
try {
// 推送加好油【重庆壳牌】
CqShellPetroleumRequestService.gasSyncPayment(gasOrder.getOrderNo(),
gasOrder.getMerNo(),
gasOrder.getPayTime(),
gasOrder.getGasRefuelPrice(),
gasOrder.getGasOilNo(),
gasOrder.getGasGunNo(),
gasOrder.getPayablePrice(),
gasOrder.getTotalDeductionPrice()
);
gasOrder.setAbnormal(false);
gasOrder.setAbnormalContent(null);
} catch (BaseException e) {
gasOrder.setAbnormal(true);
gasOrder.setAbnormalContent(e.getErrorMsg());
} catch (Exception e) {
gasOrder.setAbnormal(true);
gasOrder.setAbnormalContent("推送订单未知错误!请稍后重新推送");
}
gasOrderService.updateGasOrder(gasOrder);
}
if (StringUtils.isNotBlank(gasOrder.getUserPhone())) {
// 查询商户会员
BsMerchantUser merchantUser = merchantUserService.getUser(gasOrder.getMerNo(), gasOrder.getUserPhone());
if (merchantUser == null) {
// 注册商户会员
merchantUser = new BsMerchantUser();
merchantUser.setMerId(gasOrder.getMerId());
merchantUser.setMerNo(gasOrder.getMerNo());
merchantUser.setMerName(gasOrder.getMerName());
merchantUser.setUserId(gasOrder.getUserId());
merchantUser.setUserPhone(gasOrder.getUserPhone());
merchantUser.setVipLevel(0);
merchantUser.setIntegral(0);
merchantUser.setStatus(1);
merchantUserService.editData(merchantUser);
}
// TODO 赠送积分
}
return gasOrder;
}
}

@ -175,6 +175,9 @@ public class BsOrderServiceImpl implements BsOrderService {
order.setProductTotalPrice(productTotalPrice);
BigDecimal payRealPrice = totalPrice.subtract(order.getDeduction().getTotalDeductionPrice());
if (order.getOrderChildList().get(0).getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) {
payRealPrice = totalPrice;
}
order.setPayRealPrice(payRealPrice.compareTo(new BigDecimal("0")) > 0 ? payRealPrice : new BigDecimal("0"));
order.setOrderStatus(order.getPayRealPrice().compareTo(new BigDecimal("0")) == 0?OrderStatusEnum.status2.getCode():OrderStatusEnum.status1.getCode());
// 订单入库前处理
@ -219,7 +222,9 @@ public class BsOrderServiceImpl implements BsOrderService {
childOrder.getCouponDiscountPrice()
.add(new BigDecimal(childOrder.getIntegralDiscountPrice().toString()).divide(new BigDecimal("100")))
);
childOrder.setProductActualPrice(childOrder.getProductTotalPrice().subtract(childOrder.getTotalDeductionPrice()));
if (!childOrder.getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) {
childOrder.setProductActualPrice(childOrder.getProductTotalPrice().subtract(childOrder.getTotalDeductionPrice()));
}
orderChildService.editData(childOrder);
}
// 订单入库

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

Loading…
Cancel
Save