From 0bcc922a2674f95cebafb081c3bd5dd945980762 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Thu, 23 Jan 2025 09:35:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B1=87=E8=81=94=E9=80=9Adi?= =?UTF-8?q?stributorId=20=20=E5=8E=9F=E5=8F=82=E6=95=B0aNId4A3X=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BAorjuOND7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/cms/CmsContentController.java | 79 +++++++------------ .../service/order/OrderCancelService.java | 4 +- .../order/impl/BsOrderServiceImpl.java | 10 ++- 3 files changed, 38 insertions(+), 55 deletions(-) diff --git a/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java b/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java index 2b2bb67..ee2d442 100644 --- a/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java +++ b/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java @@ -74,58 +74,35 @@ public class CmsContentController { List goodsMsgs = new ArrayList<>(); - if ( cmsContent.getShowType() != null && cmsContent.getShowType() == 1) { - - if (cmsContent.getAutomatic() == 1) { - goodsMap.put("goodsType", cmsContent.getShowDataId()); - if (cmsContent.getShowDataId() != null) { - cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&goodsType=" + cmsContent.getShowDataId()); - } - } else { - cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&automaticCode=" + cmsContent.getId()); - goodsMap.put("automaticCode" , cmsContent.getId()); - } - goodsMap.put("limit" , 2); - goodsMsgs = goodsMsgService.getListCrest(goodsMap); - } - if (cmsContent.getShowType() != null && cmsContent.getShowType() == 2) { - if (cmsContent.getAutomatic() == 1) { - goodsMap.put("goodsType", cmsContent.getShowDataId()); - if (cmsContent.getShowDataId() != null) { - cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&goodsType=" + cmsContent.getShowDataId()); - } - } else { - cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&automaticCode=" + cmsContent.getId()); - goodsMap.put("automaticCode" , cmsContent.getId()); - } - goodsMap.put("limit" , 4); - goodsMap.put("saleNum" , 2); - - goodsMsgs = goodsMsgService.getListCrest(goodsMap); - } - if (cmsContent.getShowType() != null && cmsContent.getShowType() == 3) { - if (cmsContent.getAutomatic() == 1) { - goodsMap.put("goodsType", cmsContent.getShowDataId()); - if (cmsContent.getShowDataId() != null) { - cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&goodsType=" + cmsContent.getShowDataId()); - } - } else { - cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&automaticCode=" + cmsContent.getId()); - goodsMap.put("automaticCode" , cmsContent.getId()); - } - goodsMap.put("limit" , 10); - goodsMap.put("type" , 1); - goodsMsgs = goodsMsgService.getListCrest(goodsMap); - } - if (cmsContent.getAutomatic() == 1) { - goodsMap.put("goodsType", cmsContent.getShowDataId()); - if (cmsContent.getShowDataId() != null) { - cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&goodsType=" + cmsContent.getShowDataId()); - } - } else { - cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&automaticCode=" + cmsContent.getId()); - goodsMap.put("automaticCode" , cmsContent.getId()); + if (cmsContent.getAutomatic() == 1) { + goodsMap.put("goodsType", cmsContent.getShowDataId()); + if (cmsContent.getShowDataId() != null) { + cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&goodsType=" + cmsContent.getShowDataId()); } + } else { + cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&automaticCode=" + cmsContent.getId()); + goodsMap.put("automaticCode" , cmsContent.getId()); + } + + if ( cmsContent.getShowType() != null && cmsContent.getShowType() == 1) { + + goodsMap.put("limit" , 2); + goodsMsgs = goodsMsgService.getListCrest(goodsMap); + } + if (cmsContent.getShowType() != null && cmsContent.getShowType() == 2) { + + goodsMap.put("limit" , 4); + goodsMap.put("saleNum" , 2); + + goodsMsgs = goodsMsgService.getListCrest(goodsMap); + } + if (cmsContent.getShowType() != null && cmsContent.getShowType() == 3) { + + goodsMap.put("limit" , 10); + goodsMap.put("type" , 1); + goodsMsgs = goodsMsgService.getListCrest(goodsMap); + } + goodsModels.addAll(goodsMsgs); 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 e0eb7df..0da701a 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCancelService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCancelService.java @@ -70,11 +70,11 @@ public class OrderCancelService { public void product(OrderChildModel orderChild) { // 查询产品 GoodsMsg goodsMsg = goodsMsgService.queryDetail(orderChild.getProductId()); + // 归库 + goodsSpecsService.editStockNum(orderChild.getProductSpecId(), orderChild.getProductCount(), 1); if (goodsMsg.getType() == 1) { // 实物 } else if (goodsMsg.getType() == 2) { - // 归库 - goodsSpecsService.editStockNum(orderChild.getProductSpecId(), orderChild.getProductCount(), 1); // 虚拟商品 GoodsVpd vpd = goodsVpdService.queryDetailBySpecsId(orderChild.getProductSpecId()); diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java index 7565613..de0499a 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java @@ -149,6 +149,13 @@ public class BsOrderServiceImpl implements BsOrderService { /************** 处理业务 ***************/ for (OrderChildModel child : order.getOrderChildList()) { + // 查询规格 + GoodsSpecs specs = goodsSpecsService.queryDetail(child.getProductSpecId()); + // 校验商品购买是否超过库存 + if (specs.getStock() < child.getProductCount()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商品库存不足!"); + } + child.setOrderNo(order.getOrderNo()); // 子订单号 交易id + 线程随机数 + 4位随机数 child.setChildOrderNo(order.getId()+ IDGenerator.nextId(1) +RandomUtils.number(4, false)); @@ -156,8 +163,7 @@ public class BsOrderServiceImpl implements BsOrderService { if (child.getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) { child = orderCreateService.goods(order, child); addressId = child.getAddressId(); - // 查询规格 - GoodsSpecs specs = goodsSpecsService.queryDetail(child.getProductSpecId()); + if (specs.getThirdId() != null) { skuInfo.setSkuId(Long.parseLong(specs.getThirdId())); skuInfo.setSkuNum(child.getProductCount());