FengChaoYu hai 7 meses
pai
achega
1df4b63834

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

@@ -269,38 +269,34 @@ 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() + "少于销售数量");
+            final WebsitStock websitStock = stockMap.get(item.getGoodsId());
+            if (item.getSalesQty().compareTo(websitStock.getQty()) > 0) {
+                throw new RemoteServiceException("仓库 " + sales.getStorageName() + " 的“" + item.getGoodsName() + "“库存数量" + websitStock.getQty() + "少于销售数量");
             }
 
+            // 检查限售价
+            BigDecimal priceMultiples = goods.getLimitPriceMultiples();
+            if (Objects.nonNull(priceMultiples) && priceMultiples.compareTo(BigDecimal.ONE) > 0) {
+                BigDecimal limitPrice = websitStock.getLastCost().multiply(priceMultiples);
+                BigDecimal remainder = limitPrice.subtract(item.getPrice());
+                if (remainder.compareTo(BigDecimal.ZERO) < 0) {
+                    throw new RemoteServiceException("辅材编号:" +
+                            item.getGoodsId() +
+                            " " +
+                            item.getGoodsName() +
+                            "的售价不能大于" +
+                            limitPrice +
+                            ",请检查!");
+                }
+            }
 
-            // 商品类型为配件时单价要先乘倍率
-//            if (sales.getGoodsType().equals(WebsitGoodsTypeEnum.P.getKey())) {
-//                final MaterialConfig config = materialConfigService.lambdaQuery()
-//                        .eq(MaterialConfig::getCompanyWechatId, goods.getCompanyWechatId())
-//                        .one();
-//                BigDecimal afterPrice;
-//                switch (goods.getPartType()) {
-//                    case "空调":
-//                        afterPrice = goods.getMarketPrice().multiply(config.getPriceRate1());
-//                        break;
-//                    case "冰箱":
-//                        afterPrice = goods.getMarketPrice().multiply(config.getPriceRate2());
-//                        break;
-//                    case "生活电器":
-//                        afterPrice = goods.getMarketPrice().multiply(config.getPriceRate3());
-//                        break;
-//                    default:
-//                        throw new RemoteServiceException("未找到对应配件类型倍率");
-//                }
-//                item.setPrice(afterPrice);
-//                item.setOrigPartsPrice(goods.getMarketPrice());
-//            }
 
             // 商品类型为辅材并且库存单位与销售单位一致时转换系数为1
             if (sales.getGoodsType().equals(WebsitGoodsTypeEnum.M.getKey())