From c91e5b70c15cdb86ee69f2771ce00208b0bbf4cb Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Thu, 9 Dec 2021 17:31:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cweb/controller/HighOrderController.java | 3 +- .../controller/pay/UnionPayController.java | 21 ++++++++ .../com/hai/config/UnionStagingPayConfig.java | 20 ++++++++ .../HighDiscountPackageRecordService.java | 13 +++++ .../HighDiscountPackageRecordServiceImpl.java | 23 +++++++++ .../service/impl/HighOrderServiceImpl.java | 48 +++++++++++++++++++ .../pay/impl/GoodsOrderServiceImpl.java | 22 +++++++++ 7 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 hai-service/src/main/java/com/hai/service/HighDiscountPackageRecordService.java create mode 100644 hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageRecordServiceImpl.java diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index f005354a..dc3ea8d9 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -242,7 +242,7 @@ public class HighOrderController { if (childOrder.getGoodsType() == 7) { // 查询优惠券包 - HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(childOrder.getGoodsType().intValue()); + HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(childOrder.getGoodsId().intValue()); if (discountPackage == null) { log.error("HighOrderController --> addOrder() error!", ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到优惠券包"); @@ -259,6 +259,7 @@ public class HighOrderController { childOrder.setGoodsName(discountPackage.getTitle()); childOrder.setGoodsImg(discountPackage.getListImg()); childOrder.setGoodsPrice(discountPackage.getPrice()); + childOrder.setGoodsActualPrice(discountPackage.getPrice()); childOrder.setGoodsSpecName("默认"); } diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java index 67f228d9..ffb1f4a8 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java @@ -93,6 +93,12 @@ public class UnionPayController { @Resource private HighDiscountPackageActualService discountPackageActualService; + @Resource + private HighDiscountPackageService discountPackageService; + + @Resource + private HighDiscountPackageRecordService discountPackageRecordService; + @Resource private HighDiscountUserRelService highDiscountUserRelService; @@ -312,7 +318,22 @@ public class UnionPayController { for (HighDiscountPackageDiscountActual discount : discountList) { highDiscountUserRelService.receiveDiscount(order.getMemId(), discount.getAgentDiscountCodeId()); } + HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(actual.getDiscountPackageId()); + HighDiscountPackageRecord record = new HighDiscountPackageRecord(); + record.setDiscountPackageId(discountPackage.getId()); + record.setDiscountPackageTitle(discountPackage.getTitle()); + record.setUsingAttribution(discountPackage.getUsingAttribution()); + record.setCompanyId(discountPackage.getCompanyId()); + record.setOrderId(order.getId().intValue()); + record.setChildOrderId(highChildOrder.getId().intValue()); + record.setRecordNo(System.currentTimeMillis()+""); + record.setSalesType(1); + record.setPrice(order.getPayPrice()); + record.setUserId(order.getMemId().intValue()); + discountPackageRecordService.insertRecord(record); + actual.setAllocationTime(new Date()); actual.setStatus(3); // 状态: 1: 待分配 2:预分配(售卖)3:已分配 + discountPackageActualService.updateHighDiscountPackageActual(actual); } } } diff --git a/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java b/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java index 79534c6d..f574582f 100644 --- a/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java +++ b/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java @@ -53,6 +53,26 @@ public class UnionStagingPayConfig { return responseParam; } + public static JSONObject query(String orderNo, String orgTrace, BigDecimal payPrice, String openId, String notifyUrl) throws Exception { + Map paramMap = new HashMap<>(); + paramMap.put("orgId", CommonSysConst.getSysConfig().getUnionStagingPayOrgId()); + paramMap.put("orgMerCode", CommonSysConst.getSysConfig().getUnionStagingPayOrgMerCode()); + paramMap.put("orgTermNo", CommonSysConst.getSysConfig().getUnionStagingPayOrgTermNo()); + paramMap.put("orgTrace", orgTrace); + paramMap.put("prodCode", "ISYH"); + paramMap.put("signType", "RSA"); + + Map bizDataMap = new HashMap<>(); + bizDataMap.put("transAmt", payPrice.multiply(new BigDecimal("100")).intValue()); + bizDataMap.put("openId", openId); + bizDataMap.put("notifyUrl", notifyUrl); + paramMap.put("bizData", bizDataMap); + paramMap.put("sign", generateSign(bizDataMap)); + + JSONObject responseParam = HttpsUtils.doPost(CommonSysConst.getSysConfig().getUnionStagingPayUrl()+"cashier/trade/query", paramMap, new HashMap<>()); + return responseParam; + } + /** * 参数排序 * @param param diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountPackageRecordService.java b/hai-service/src/main/java/com/hai/service/HighDiscountPackageRecordService.java new file mode 100644 index 00000000..d16677e9 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighDiscountPackageRecordService.java @@ -0,0 +1,13 @@ +package com.hai.service; + +import com.hai.entity.HighDiscountPackageRecord; + +public interface HighDiscountPackageRecordService { + + /** + * 增加记录 + * @param record + */ + void insertRecord(HighDiscountPackageRecord record); + +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageRecordServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageRecordServiceImpl.java new file mode 100644 index 00000000..63c60a1f --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageRecordServiceImpl.java @@ -0,0 +1,23 @@ +package com.hai.service.impl; + +import com.hai.dao.HighDiscountPackageRecordMapper; +import com.hai.entity.HighDiscountPackageRecord; +import com.hai.service.HighDiscountPackageRecordService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; + +@Service("discountPackageRecordService") +public class HighDiscountPackageRecordServiceImpl implements HighDiscountPackageRecordService { + + @Resource + private HighDiscountPackageRecordMapper highDiscountPackageRecordMapper; + + @Override + public void insertRecord(HighDiscountPackageRecord record) { + record.setCreatedTime(new Date()); + record.setStatus(1); + highDiscountPackageRecordMapper.insert(record); + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index f2c9cfcf..ef956e34 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -74,6 +74,12 @@ public class HighOrderServiceImpl implements HighOrderService { @Resource private HighDiscountAgentCodeService highDiscountAgentCodeService; + @Resource + private HighDiscountPackageService discountPackageService; + + @Resource + private HighDiscountPackageRecordService discountPackageRecordService; + @Resource private HighMerchantStoreService highMerchantStoreService; @@ -179,6 +185,7 @@ public class HighOrderServiceImpl implements HighOrderService { if (list == null || list.size() == 0) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_STOCK_INSUFFICIENT, ""); } + list.get(0).setUserId(highOrder.getMemId().intValue()); list.get(0).setChildOrderId(childOrder.getId()); list.get(0).setStatus(2); // 状态: 1: 待分配 2:预分配(售卖)3:已分配 discountPackageActualService.updateHighDiscountPackageActual(list.get(0)); @@ -339,7 +346,22 @@ public class HighOrderServiceImpl implements HighOrderService { for (HighDiscountPackageDiscountActual discount : discountList) { highDiscountUserRelService.receiveDiscount(highOrder.getMemId(), discount.getAgentDiscountCodeId()); } + HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(actual.getDiscountPackageId()); + HighDiscountPackageRecord record = new HighDiscountPackageRecord(); + record.setDiscountPackageId(discountPackage.getId()); + record.setDiscountPackageTitle(discountPackage.getTitle()); + record.setUsingAttribution(discountPackage.getUsingAttribution()); + record.setCompanyId(discountPackage.getCompanyId()); + record.setOrderId(highOrder.getId().intValue()); + record.setChildOrderId(highChildOrder.getId().intValue()); + record.setRecordNo(System.currentTimeMillis()+""); + record.setSalesType(1); + record.setPrice(highOrder.getPayPrice()); + record.setUserId(highOrder.getMemId().intValue()); + discountPackageRecordService.insertRecord(record); + actual.setAllocationTime(new Date()); actual.setStatus(3); // 状态: 1: 待分配 2:预分配(售卖)3:已分配 + discountPackageActualService.updateHighDiscountPackageActual(actual); } } } @@ -617,7 +639,22 @@ public class HighOrderServiceImpl implements HighOrderService { for (HighDiscountPackageDiscountActual discount : discountList) { highDiscountUserRelService.receiveDiscount(order.getMemId(), discount.getAgentDiscountCodeId()); } + HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(actual.getDiscountPackageId()); + HighDiscountPackageRecord record = new HighDiscountPackageRecord(); + record.setDiscountPackageId(discountPackage.getId()); + record.setDiscountPackageTitle(discountPackage.getTitle()); + record.setUsingAttribution(discountPackage.getUsingAttribution()); + record.setCompanyId(discountPackage.getCompanyId()); + record.setOrderId(order.getId().intValue()); + record.setChildOrderId(highChildOrder.getId().intValue()); + record.setRecordNo(System.currentTimeMillis()+""); + record.setSalesType(1); + record.setPrice(order.getPayPrice()); + record.setUserId(order.getMemId().intValue()); + discountPackageRecordService.insertRecord(record); + actual.setAllocationTime(new Date()); actual.setStatus(3); // 状态: 1: 待分配 2:预分配(售卖)3:已分配 + discountPackageActualService.updateHighDiscountPackageActual(actual); } } } @@ -976,6 +1013,17 @@ public class HighOrderServiceImpl implements HighOrderService { highCouponCodeService.updateCouponCode(couponCode); } } + + if (highChildOrder.getGoodsType() == 7) { + HighDiscountPackageActual actual = discountPackageActualService.getDetailByChildOrderId(highChildOrder.getId()); + if (actual != null) { + actual.setChildOrderId(null); + actual.setUserId(null); + actual.setStatus(1); + discountPackageActualService.updateHighDiscountPackageActual(actual); + } + } + highChildOrder.setChildOrdeStatus(5); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 } diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java index b7735298..c3a0925f 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java @@ -12,6 +12,7 @@ import com.hai.config.CommonSysConst; import com.hai.config.HuiLianTongConfig; import com.hai.config.TuanYouConfig; import com.hai.dao.HighCouponCodeOtherMapper; +import com.hai.dao.HighDiscountPackageRecordMapper; import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighUserCouponMapper; import com.hai.entity.*; @@ -98,6 +99,12 @@ public class GoodsOrderServiceImpl implements PayService { @Resource private HighDiscountPackageActualService discountPackageActualService; + @Resource + private HighDiscountPackageService discountPackageService; + + @Resource + private HighDiscountPackageRecordService discountPackageRecordService; + @Resource private HighDiscountUserRelService highDiscountUserRelService; @@ -302,7 +309,22 @@ public class GoodsOrderServiceImpl implements PayService { for (HighDiscountPackageDiscountActual discount : discountList) { highDiscountUserRelService.receiveDiscount(order.getMemId(), discount.getAgentDiscountCodeId()); } + HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(actual.getDiscountPackageId()); + HighDiscountPackageRecord record = new HighDiscountPackageRecord(); + record.setDiscountPackageId(discountPackage.getId()); + record.setDiscountPackageTitle(discountPackage.getTitle()); + record.setUsingAttribution(discountPackage.getUsingAttribution()); + record.setCompanyId(discountPackage.getCompanyId()); + record.setOrderId(order.getId().intValue()); + record.setChildOrderId(highChildOrder.getId().intValue()); + record.setRecordNo(System.currentTimeMillis()+""); + record.setSalesType(1); + record.setPrice(order.getPayPrice()); + record.setUserId(order.getMemId().intValue()); + discountPackageRecordService.insertRecord(record); + actual.setAllocationTime(new Date()); actual.setStatus(3); // 状态: 1: 待分配 2:预分配(售卖)3:已分配 + discountPackageActualService.updateHighDiscountPackageActual(actual); } } }