Ver Fonte

no message

FengChaoYu há 7 meses atrás
pai
commit
5da9478966

+ 2 - 3
mall-server-api/src/main/java/com/gree/mall/manager/SwaggerConfig.java

@@ -4,7 +4,6 @@ package com.gree.mall.manager;
  *
  */
 
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Profile;
@@ -48,8 +47,8 @@ public class SwaggerConfig {
     private ApiInfo apiBInfo() {
 
         return new ApiInfoBuilder()
-                .title("格匠员工培训项目企业运营后台API")
-                .description("格匠员工培训项目企业运营后台API")
+                .title("家盛茂运营后台API")
+                .description("家盛茂运营后台API")
                 .contact(new Contact("格匠", "http://gejiang", "gejiang@gejiang.com"))
                 .version("1.0")
                 .build();

+ 41 - 17
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitSalesLogic.java

@@ -240,6 +240,20 @@ public class WebsitSalesLogic {
 
         Map<String, WebsitGoods> goodsMap = goodsList.stream().collect(Collectors.toMap(WebsitGoods::getGoodsId, Function.identity()));
 
+        // 获取网点辅材库存
+        final List<WebsitStock> websitStockList = websitStockService.lambdaQuery()
+                .eq(WebsitStock::getCompanyWechatId, sales.getCompanyWechatId())
+                .eq(WebsitStock::getWebsitId, sales.getWebsitId())
+                .eq(WebsitStock::getStorageId, sales.getStorageId())
+                .eq(WebsitStock::getGoodsType, WebsitGoodsTypeEnum.M.getKey())
+                .in(WebsitStock::getGoodsId, itemList.stream()
+                        .map(WebsitSalesItem::getGoodsId)
+                        .collect(Collectors.toList()))
+                .list();
+
+        Map<String, WebsitStock> stockMap = websitStockList.stream()
+                .collect(Collectors.toMap(WebsitStock::getGoodsId, Function.identity()));
+
         for (WebsitSalesItem item : itemList) {
             if (!goodsMap.containsKey(item.getGoodsId())) {
                 throw new RemoteServiceException("找不到商品信息:" + item.getGoodsName());
@@ -252,6 +266,16 @@ public class WebsitSalesLogic {
                     .setConvertBitScale(1)
                     .setManageWorkerStock(goods.getManageWorkerStock());
 
+            // 检查辅材库存
+            if (!stockMap.containsKey(item.getGoodsId())) {
+                throw new RemoteServiceException("仓库 " + sales.getStorageName() + " 没有”" + item.getGoodsName() + "”库存信息");
+            }
+
+            if (item.getSalesQty().compareTo(stockMap.get(item.getGoodsId()).getQty()) > 0) {
+                throw new RemoteServiceException("仓库 " + sales.getStorageName() + " 的“" + item.getGoodsName() + "“库存数量" + stockMap.get(item.getGoodsId()).getQty() + "少于销售数量");
+            }
+
+
             // 商品类型为配件时单价要先乘倍率
             if (sales.getGoodsType().equals(WebsitGoodsTypeEnum.P.getKey())) {
                 final MaterialConfig config = materialConfigService.lambdaQuery()
@@ -310,23 +334,23 @@ public class WebsitSalesLogic {
             item.setConvertQty(convertQty)
                     .setConvertPrice(convertPrice);
             // 检查数量是否大于当前库存数
-            final List<WebsitStock> websitStocks = websitStockService.lambdaQuery()
-                    .eq(WebsitStock::getCompanyWechatId, sales.getCompanyWechatId())
-                    .eq(WebsitStock::getWebsitId, sales.getWebsitId())
-                    .eq(WebsitStock::getGoodsType, WebsitGoodsTypeEnum.P.getKey())
-                    .eq(WebsitStock::getStorageId, sales.getStorageId())
-                    .in(WebsitStock::getGoodsId, itemList.stream().map(WebsitSalesItem::getGoodsId).collect(Collectors.toList()))
-                    .list();
-            if (CollectionUtil.isNotEmpty(websitStocks)) {
-                final Map<String, WebsitStock> stockMap = websitStocks.stream()
-                        .collect(Collectors.toMap(WebsitStock::getGoodsId, Function.identity()));
-                for (WebsitSalesItem salesItem : itemList) {
-                    final WebsitStock stock = stockMap.get(salesItem.getGoodsId());
-                    if (Objects.nonNull(stock) && salesItem.getSalesQty().compareTo(stock.getQty()) > 0) {
-                        throw new RemoteServiceException(salesItem.getGoodsName() + " 销售数量不能大于库存数量");
-                    }
-                }
-            }
+//            final List<WebsitStock> websitStocks = websitStockService.lambdaQuery()
+//                    .eq(WebsitStock::getCompanyWechatId, sales.getCompanyWechatId())
+//                    .eq(WebsitStock::getWebsitId, sales.getWebsitId())
+//                    .eq(WebsitStock::getGoodsType, WebsitGoodsTypeEnum.P.getKey())
+//                    .eq(WebsitStock::getStorageId, sales.getStorageId())
+//                    .in(WebsitStock::getGoodsId, itemList.stream().map(WebsitSalesItem::getGoodsId).collect(Collectors.toList()))
+//                    .list();
+//            if (CollectionUtil.isNotEmpty(websitStocks)) {
+//                final Map<String, WebsitStock> stockMap = websitStocks.stream()
+//                        .collect(Collectors.toMap(WebsitStock::getGoodsId, Function.identity()));
+//                for (WebsitSalesItem salesItem : itemList) {
+//                    final WebsitStock stock = stockMap.get(salesItem.getGoodsId());
+//                    if (Objects.nonNull(stock) && salesItem.getSalesQty().compareTo(stock.getQty()) > 0) {
+//                        throw new RemoteServiceException(salesItem.getGoodsName() + " 销售数量不能大于库存数量");
+//                    }
+//                }
+//            }
         }
 
     }