FengChaoYu hai 10 meses
pai
achega
c6f3db5d8e

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

@@ -30,6 +30,7 @@ import com.gree.mall.manager.logic.material.stock.WebitSalesStockLogic;
 import com.gree.mall.manager.logic.material.stock.WorkSalesStockLogic;
 import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.*;
+import com.gree.mall.manager.utils.CommonUtils;
 import com.gree.mall.manager.utils.excel.ExcelUtils;
 import com.gree.mall.manager.zfire.bean.WebsitSalesParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
@@ -986,6 +987,10 @@ public class WebsitSalesLogic {
         String batchId = StrUtil.uuid();
         AdminUserCom adminUser = commonLogic.getAdminUser();
 
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+
         String companyWechatId = Objects.nonNull(adminUser.getAdminCompanyWechat()) ? adminUser.getAdminCompanyWechat().getCompanyWechatId() : null;
         String companyName = Objects.nonNull(adminUser.getAdminCompanyWechat()) ? adminUser.getAdminCompanyWechat().getCompanyName() : null;
 
@@ -1043,11 +1048,16 @@ public class WebsitSalesLogic {
                 .filter(Storage::getIsDefault)
                 .collect(Collectors.toMap(Storage::getWebsitId, Function.identity()));
 
+        final MaterialConfig config = materialConfigService.lambdaQuery()
+                .eq(MaterialConfig::getCompanyWechatId, companyWechatId)
+                .one();
+
         List<Object> objects = ExcelUtils.importExcel(file);
         List<ImportMaterialSalesBean> beanList = new ArrayList<>();
 
         for (int i = 0; i < objects.size(); i++) {
             List<Object> row = (List<Object>) objects.get(i);
+            CommonUtils.initList2(row, 10);
             if (row.size() < 6) {
                 row.add("");
             }
@@ -1067,9 +1077,9 @@ public class WebsitSalesLogic {
             if (Objects.isNull(row.get(3))) {
                 throw new RemoteServiceException("第" + (i+1) + "行, 数量不能为空");
             }
-            if (Objects.isNull(row.get(4))) {
-                throw new RemoteServiceException("第" + (i+1) + "行, 销售价格不能为空");
-            }
+//            if (Objects.isNull(row.get(4))) {
+//                throw new RemoteServiceException("第" + (i+1) + "行, 销售价格不能为空");
+//            }
 //            if (Objects.isNull(row.get(5))) {
 //                throw new RemoteServiceException("第" + (i+1) + "行, 销售时间不能为空");
 //            }
@@ -1078,9 +1088,9 @@ public class WebsitSalesLogic {
             String mobileStr = (String) row.get(1);
             String goodsNameStr = (String) row.get(2);
             String qtyStr = (String) row.get(3);
-            String salesPriceStr = (String) row.get(4);
-            String customerStr = (String) row.get(5);
-            String storageStr = (String) row.get(6);
+//            String salesPriceStr = (String) row.get(4);
+            String customerStr = (String) row.get(4);
+            String storageStr = (String) row.get(5);
 
             if (!websitMap.containsKey(websitStr)) {
                 throw new RemoteServiceException("第" + (i+1) + "行, 网点名称不存在");
@@ -1114,13 +1124,28 @@ public class WebsitSalesLogic {
                 throw new RemoteServiceException("第" + (i+1) + "行, 数量转换异常");
             }
             BigDecimal salesPrice;
-            try {
-                salesPrice = new BigDecimal(salesPriceStr);
-                if (qty.compareTo(BigDecimal.ZERO) < 0) {
-                    throw new RemoteServiceException("第" + (i+1) + "行, 请输入有效销售价格");
-                }
-            } catch (Exception e) {
-                throw new RemoteServiceException("第" + (i+1) + "行, 销售价格转换异常");
+//            try {
+//                salesPrice = new BigDecimal(salesPriceStr);
+//                if (qty.compareTo(BigDecimal.ZERO) < 0) {
+//                    throw new RemoteServiceException("第" + (i+1) + "行, 请输入有效销售价格");
+//                }
+//            } catch (Exception e) {
+//                throw new RemoteServiceException("第" + (i+1) + "行, 销售价格转换异常");
+//            }
+
+            final WebsitGoods goods = goodsMap.get(goodsNameStr);
+            switch (goods.getPartType()) {
+                case "空调":
+                    salesPrice = goods.getMarketPrice().multiply(config.getPriceRate1());
+                    break;
+                case "冰箱":
+                    salesPrice = goods.getMarketPrice().multiply(config.getPriceRate2());
+                    break;
+                case "生活电器":
+                    salesPrice = goods.getMarketPrice().multiply(config.getPriceRate3());
+                    break;
+                default:
+                    throw new RemoteServiceException("未找到对应配件类型倍率");
             }
 
             ImportMaterialSalesBean bean = new ImportMaterialSalesBean();
@@ -1128,7 +1153,7 @@ public class WebsitSalesLogic {
             bean.setIndex(i+1);
             bean.setAdminWebsit(websitMap.get(websitStr));
             bean.setUser(userMap.containsKey(mobileStr) ? userMap.get(mobileStr) : userMap.get(customerStr + mobileStr));
-            bean.setGoods(goodsMap.get(goodsNameStr));
+            bean.setGoods(goods);
             bean.setQty(qty);
             bean.setPrice(salesPrice);
 

BIN=BIN
mall-server-api/src/main/resources/template/配件销售订单导入模板.xlsx