From 147f5da9eff7608cc877a81a859658b036415354 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Fri, 24 May 2024 16:52:11 +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 --- .../java/com/hfkj/service/order/OrderCancelService.java | 7 ++++++- .../java/com/hfkj/service/order/OrderCreateService.java | 6 ++++++ .../com/hfkj/service/order/OrderPaySuccessService.java | 6 ++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/service/src/main/java/com/hfkj/service/order/OrderCancelService.java b/service/src/main/java/com/hfkj/service/order/OrderCancelService.java index 7900217..9f0b154 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCancelService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCancelService.java @@ -8,6 +8,7 @@ import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; import com.hfkj.service.coupon.BsOrderCouponService; import com.hfkj.service.goods.GoodsMsgService; +import com.hfkj.service.goods.GoodsSpecsService; import com.hfkj.sysenum.order.OrderChildProductTypeEnum; import com.hfkj.sysenum.order.OrderChildStatusEnum; import org.slf4j.Logger; @@ -41,7 +42,8 @@ public class OrderCancelService { private BsOrderCouponService orderCouponService; @Resource private GoodsMsgService goodsMsgService; - + @Resource + private GoodsSpecsService goodsSpecsService; /** * 订单业务处理 * @param order @@ -66,6 +68,9 @@ public class OrderCancelService { if (goodsMsg.getType() == 1) { // 实物 } else if (goodsMsg.getType() == 2) { + // 归库 + goodsSpecsService.editStockNum(orderChild.getProductSpecId(), orderChild.getProductCount(), 1); + // 虚拟 BsOrderCoupon orderCoupon = orderCouponService.getDetailByChildOrderNo(orderChild.getChildOrderNo()); orderCoupon.setCancelTime(new Date()); diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index 8d39a51..d69a195 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -78,6 +78,12 @@ public class OrderCreateService { if (goodsSpecs == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商品规格"); } + if (goodsSpecs.getStock() <= 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "库存不足"); + } + // 减少库存 + goodsSpecsService.editStockNum(orderChild.getProductSpecId(), orderChild.getProductCount(), 2); + JSONObject businessObj = orderChild.getBusiness()==null?new JSONObject(): new JSONObject((Map) orderChild.getBusiness()); if (businessObj.getLong("shopCartId") != null) { shoppingCartService.delete(businessObj.getLong("shopCartId")); diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index 54bb06d..0dee65e 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -61,8 +61,7 @@ public class OrderPaySuccessService { try { if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) { goods(order); - } - if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) { + } else if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) { product(order, childOrder); } } catch (Exception e) { @@ -174,6 +173,9 @@ public class OrderPaySuccessService { orderCoupon.setPaySerialNo(order.getPaySerialNo()); orderCouponService.editData(orderCoupon); + // 增加销量 + goodsMsgService.editSaleNum(childOrder.getProductId(), childOrder.getProductCount(), 1); + // 子订单完成 orderService.childOrderComplete(orderCoupon.getChildOrderNo()); }