From aaeb3473ffeaf028924166406f9fa03f9917e80c Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 26 Oct 2022 11:34:59 +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 --- .../main/java/com/web/config/SysConfig.java | 2 +- .../src/main/resources/dev/config.properties | 2 - .../order/model/CreateOrderChildModel.java | 5 ++ .../service/OrderCreateHandleService.java | 4 +- .../hai/order/service/OrderServiceExt.java | 1 - .../impl/OrderCreateHandleServiceImpl.java | 88 ++++++++++++++++++- .../order/service/impl/OrderServiceImpl.java | 8 +- 7 files changed, 98 insertions(+), 12 deletions(-) diff --git a/hai-order/src/main/java/com/web/config/SysConfig.java b/hai-order/src/main/java/com/web/config/SysConfig.java index 5fd90baa..652612a2 100644 --- a/hai-order/src/main/java/com/web/config/SysConfig.java +++ b/hai-order/src/main/java/com/web/config/SysConfig.java @@ -11,7 +11,7 @@ import org.springframework.stereotype.Component; @Data public class SysConfig { - private String fileUrl; + private String fileUrl; private String wxPayMchAppId; private String wxPayMchId; diff --git a/hai-order/src/main/resources/dev/config.properties b/hai-order/src/main/resources/dev/config.properties index 0ac44cee..21943d95 100644 --- a/hai-order/src/main/resources/dev/config.properties +++ b/hai-order/src/main/resources/dev/config.properties @@ -6,8 +6,6 @@ wxPayMchId=1289663601 wxPayApiKey=Skufk5oi85wDFGl888i6wsRSTkdd5df5 wxPayUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder - - wxPayNotifyUrl=https://hsgcs.dctpay.com/order/payNotify/wechatPay unionPayNotifyUrl=https://hsgcs.dctpay.com/order/payNotify/unionPay diff --git a/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java b/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java index 35aeff5b..e480885f 100644 --- a/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java +++ b/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java @@ -44,6 +44,11 @@ public class CreateOrderChildModel { */ private Long goodsId; + /** + * 产品规格 + */ + private String goodsSpecName; + /** * 产品价格 */ diff --git a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java index c34dfaa2..c410698a 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java @@ -47,14 +47,14 @@ public interface OrderCreateHandleService { * @param createOrderChild * @return */ - ResponseData couponPackage(CreateOrderChildModel createOrderChild); + HighChildOrder couponPackage(CreateOrderChildModel createOrderChild); /** * 汇联通充值校验 * @param createOrderChild * @return */ - ResponseData hltUnionCardRecharge(CreateOrderChildModel createOrderChild); + HighChildOrder hltUnionCardRecharge(CreateOrderChildModel createOrderChild); /** * @Author Sum1Dream diff --git a/hai-service/src/main/java/com/hai/order/service/OrderServiceExt.java b/hai-service/src/main/java/com/hai/order/service/OrderServiceExt.java index 34ba2a6a..e2e1c726 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderServiceExt.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderServiceExt.java @@ -1,6 +1,5 @@ package com.hai.order.service; - import com.hai.order.model.OrderCouponModel; import com.hai.order.model.OrderIntegralRechargeModel; diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index 4063ae9e..aafe8691 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -112,6 +112,12 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { @Resource private ApiMemberProductService apiMemberProductService; + @Resource + private HighDiscountPackageService discountPackageService; + + @Resource + private HighDiscountPackageActualService discountPackageActualService; + @Override public List couponHandle(HighDiscountUserRel discountUserRel, CreateOrderChildModel createOrderChild) throws Exception { if (createOrderChild.getSaleCount() != 1) { @@ -496,13 +502,87 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { } @Override - public ResponseData couponPackage(CreateOrderChildModel createOrderChild) { - return null; + public HighChildOrder couponPackage(CreateOrderChildModel createOrderChild) { + // 查询优惠券包 + HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(createOrderChild.getGoodsId().intValue()); + if (discountPackage == null) { + log.error("HighOrderController --> addOrder() error!", ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到优惠券包"); + } + if (discountPackage.getStatus() != 1) { + log.error("HighOrderController --> addOrder() error!", ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券包不可用"); + } + if (discountPackageActualService.getStockByPackageId(discountPackage.getId()) == 0) { + log.error("HighOrderController --> addOrder() error!", ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "库存数量不足"); + } + if (discountPackage.getPurchaseNum() < discountPackageActualService.userPurchaseByUserId(createOrderChild.getMemId().intValue(), discountPackage.getId())) { + log.error("HighOrderController --> addOrder() error!", ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "超过购买限制"); + } + // 生成交易子订单 + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setMemId(createOrderChild.getMemId()); + childOrder.setMemName(createOrderChild.getMemName()); + childOrder.setMemPhone(createOrderChild.getMemPhone()); + childOrder.setChildOrderNo(OrderUtil.generateChildOrderNo()); + childOrder.setGoodsType(OrderChildGoodsType.TYPE7.getNumber()); + childOrder.setGoodsId(discountPackage.getId().longValue()); + childOrder.setGoodsName(discountPackage.getTitle()); + childOrder.setGoodsImg(discountPackage.getListImg()); + childOrder.setGoodsSpecName("默认"); + childOrder.setGoodsPrice(discountPackage.getPrice()); + childOrder.setGoodsActualPrice(discountPackage.getPrice()); + childOrder.setSaleCount(createOrderChild.getSaleCount()); + childOrder.setGiveawayType(false); + childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); + childOrder.setTotalPrice(new BigDecimal(childOrder.getSaleCount().toString()).multiply(childOrder.getGoodsPrice())); + childOrder.setTotalActualPrice(new BigDecimal(childOrder.getSaleCount().toString()).multiply(childOrder.getGoodsActualPrice())); + childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); + childOrder.setPraiseStatus(0); + childOrder.setCreateTime(new Date()); + return childOrder; } @Override - public ResponseData hltUnionCardRecharge(CreateOrderChildModel createOrderChild) { - return null; + public HighChildOrder hltUnionCardRecharge(CreateOrderChildModel createOrderChild) { + if (createOrderChild.getGoodsPrice() == null) { + log.error("HighOrderController --> hltUnionCardRecharge() error!", "请设置充值金额"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置充值金额"); + } + if (StringUtils.isBlank(createOrderChild.getGoodsSpecName()) ) { + log.error("HighOrderController --> hltUnionCardRecharge() error!", "请设置充值卡号"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置充值卡号"); + } + // 查询用户信息 + HighUser user = highUserService.findByUserId(createOrderChild.getMemId()); + if (user == null) { + log.error("HighOrderController --> hltUnionCardRecharge() error!", "未找到用户"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, ""); + } + // 生成交易子订单 + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setMemId(createOrderChild.getMemId()); + childOrder.setMemName(createOrderChild.getMemName()); + childOrder.setMemPhone(createOrderChild.getMemPhone()); + childOrder.setChildOrderNo(OrderUtil.generateChildOrderNo()); + childOrder.setGoodsType(OrderChildGoodsType.TYPE8.getNumber()); + childOrder.setGoodsId(user.getId()); + childOrder.setGoodsName("贵州汇联通工会卡充值"); + childOrder.setGoodsImg(CommonSysConst.getSysConfig().getHsgDomainName()+"/filesystem/wxApplets/hlt_logo.png"); + childOrder.setGoodsSpecName(createOrderChild.getGoodsSpecName()); + childOrder.setGoodsPrice(createOrderChild.getGoodsPrice()); + childOrder.setGoodsActualPrice(createOrderChild.getGoodsPrice()); + childOrder.setSaleCount(createOrderChild.getSaleCount()); + childOrder.setGiveawayType(false); + childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); + childOrder.setTotalPrice(new BigDecimal(childOrder.getSaleCount().toString()).multiply(childOrder.getGoodsPrice())); + childOrder.setTotalActualPrice(new BigDecimal(childOrder.getSaleCount().toString()).multiply(childOrder.getGoodsActualPrice())); + childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); + childOrder.setPraiseStatus(0); + childOrder.setCreateTime(new Date()); + return childOrder; } @Override diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 905dfd93..bd539df5 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -221,12 +221,16 @@ public class OrderServiceImpl implements OrderService { // 优惠券包 } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE7.getNumber())) { order.setProductType(OrderProductType.PRODUCT_TYPE9.getNumber()); - orderCreateHandleService.couponPackage(child); + HighChildOrder childOrder = orderCreateHandleService.couponPackage(child); + childOrderList.add(childOrder); + order.setTitle(childOrder.getGoodsName()); // 贵州汇联通工会卡充值 } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE8.getNumber())) { order.setProductType(OrderProductType.PRODUCT_TYPE8.getNumber()); - orderCreateHandleService.hltUnionCardRecharge(child); + HighChildOrder childOrder = orderCreateHandleService.hltUnionCardRecharge(child); + childOrderList.add(childOrder); + order.setTitle(childOrder.getGoodsName()); // 星巴克 } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE9.getNumber())) {