FengChaoYu hace 7 meses
padre
commit
61deeb0e71

+ 22 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/WebsitSalesLogic.java

@@ -78,6 +78,8 @@ public class WebsitSalesLogic {
     WorkerGoodsRelaService workerGoodsRelaService;
     @Resource
     WorkerGoodsService workerGoodsService;
+    @Resource
+    WebsitStockService websitStockService;
 
     public IPage<SalesOrderBean> buyList(String flag, Integer pageNum, Integer pageSize, HttpServletRequest request) {
         CurrentCompanyWechat wechat = commonLogic.getCurrentCompanyWechat(request);
@@ -407,6 +409,18 @@ public class WebsitSalesLogic {
 
         List<WebsitShoppingCartList> shoppingCartLists = this.queryShoppingCart(wechat.getUserId(), websitId, goodsType);
 
+        final List<WebsitStock> websitStockList = websitStockService.lambdaQuery()
+                .eq(WebsitStock::getCompanyWechatId, wechat.getCompanyWechatId())
+                .eq(WebsitStock::getWebsitId, websitId)
+                .eq(WebsitStock::getGoodsType, WebsitGoodsTypeEnum.M.toString())
+                .in(WebsitStock::getGoodsId, shoppingCartLists.stream()
+                        .map(WebsitShoppingCartList::getGoodsId)
+                        .collect(Collectors.toList()))
+                .list();
+
+        final Map<String, WebsitStock> stockMap = websitStockList.stream()
+                .collect(Collectors.toMap(WebsitStock::getGoodsId, Function.identity()));
+
         //订单
         WebsitSales sales = new WebsitSales();
 
@@ -430,6 +444,14 @@ public class WebsitSalesLogic {
         String salesId = commonLogic.generateNo("X" + goodsType, "SalesOrder" + goodsType, 15);
         //新增订单详情
         for (WebsitShoppingCartList bean : shoppingCartLists) {
+            final WebsitStock stock = stockMap.get(bean.getGoodsId());
+            if (Objects.isNull(stock)) {
+                throw new RemoteServiceException(bean.getGoodsName() + "库存数量为0");
+            }
+            if (bean.getSalesQty().compareTo(stock.getQty()) > 0) {
+                throw new RemoteServiceException(bean.getGoodsName() + "销售数量不能大于库存数量" + stock.getQty());
+            }
+
             WebsitSalesItem detail = new WebsitSalesItem();
             detail.setSalesId(salesId);
             detail.setCompanyWechatId(bean.getCompanyWechatId());

+ 2 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminWebsitLogic.java

@@ -749,6 +749,7 @@ public class AdminWebsitLogic {
                 .list();
 
         List<String> titleList = new ArrayList<>();
+        titleList.add("网点编号");
         titleList.add("网点名称");
         titleList.add("联系人");
         titleList.add("详细地址");
@@ -811,6 +812,7 @@ public class AdminWebsitLogic {
             final List<AdminWebsitPayConfig> items = itemMap.get(websit.getWebsitId());
             if (CollectionUtil.isNotEmpty(items)) {
                 for (AdminWebsitPayConfig item : items) {
+                    row.add(item.getWebsitId());
                     row.add(item.getName());
                     row.add(item.getOrgId());
                     row.add(item.getType().equals(WebsitGoodsTypeEnum.M.getKey()) ? WebsitGoodsTypeEnum.M.getRemark() : WebsitGoodsTypeEnum.P.getRemark());