Selaa lähdekoodia

Merge remote-tracking branch 'origin/develop' into develop

‘linchangsheng’ 7 kuukautta sitten
vanhempi
commit
008bd8745f

+ 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 - 2
mall-server-api/src/main/java/com/gree/mall/manager/bean/listvo/UserVO.java

@@ -2,7 +2,6 @@ package com.gree.mall.manager.bean.listvo;
 
 import com.gree.mall.manager.annotation.ZfireField;
 import com.gree.mall.manager.enums.ExamineStatusEnum;
-import com.gree.mall.manager.enums.IsEnum;
 import com.gree.mall.manager.enums.UserTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -27,7 +26,8 @@ public class UserVO {
 //    @ApiModelProperty("商户名称")
 //    private String companyName;
 
-    @ZfireField(hide = true, tbName = "b", ignoreSelect = true)
+    @ZfireField(tbName = "b")
+    @ApiModelProperty("网点编号")
     private String websitId;
 
     @ZfireField(tbName = "c", colName = "name", ignoreSelect = true)

+ 3 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/base/WebsitGoodsBean.java

@@ -134,4 +134,7 @@ public class WebsitGoodsBean {
 
     @ApiModelProperty(value = "物料组名称")
     private String materialGroupName;
+
+    @ApiModelProperty(value = "辅材限制售价倍数")
+    private BigDecimal limitPriceMultiples;
 }

+ 3 - 3
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/base/WebsitGoodsPVO.java

@@ -60,9 +60,9 @@ public class WebsitGoodsPVO {
     @ApiModelProperty(value = "销售价格")
     private BigDecimal marketPrice;
 
-    @ApiModelProperty(value = "收费标准")
-    private BigDecimal normAmount;
-
+//    @ApiModelProperty(value = "收费标准")
+//    private BigDecimal normAmount;
+//
 //    @ApiModelProperty(value = "自有库存师傅分账金额(师傅分账比例)")
 //    private BigDecimal selfWorkerAmount;
 //

+ 6 - 8
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/manage/WebsitTradeVO.java

@@ -2,10 +2,8 @@ package com.gree.mall.manager.bean.material.manage;
 
 import com.gree.mall.manager.annotation.ZfireField;
 import com.gree.mall.manager.enums.IsYesNoEnum;
-import com.gree.mall.manager.enums.material.PayOrderTypeEnum;
 import com.gree.mall.manager.enums.material.PayTypeEnum;
 import com.gree.mall.manager.enums.material.SalesPayOrderSourceEnum;
-import com.gree.mall.manager.enums.material.WebsitGoodsTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -28,12 +26,12 @@ public class WebsitTradeVO {
 //
 //    @ApiModelProperty(value = "商户名称")
 //    private String companyWechatName;
-
-    @ApiModelProperty(value = "商品类型")
-    private WebsitGoodsTypeEnum goodsType;
-
-    @ApiModelProperty(value = "订单类型")
-    private PayOrderTypeEnum orderType;
+//
+//    @ApiModelProperty(value = "商品类型")
+//    private WebsitGoodsTypeEnum goodsType;
+//
+//    @ApiModelProperty(value = "订单类型")
+//    private PayOrderTypeEnum orderType;
 
     @ZfireField(hide = true)
     @ApiModelProperty(value = "订单来源")

+ 41 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/report/MaterialSalesSumBean.java

@@ -0,0 +1,41 @@
+package com.gree.mall.manager.bean.material.report;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@ApiModel
+@Data
+public class MaterialSalesSumBean {
+
+    @ApiModelProperty(value = "网点编号")
+    private String websitId;
+    @ApiModelProperty(value = "网点名称")
+    private String websitName;
+    @ApiModelProperty(value = "工程师手机号")
+    private String mobile;
+    @ApiModelProperty(value = "工程师编号")
+    private String workerId;
+    @ApiModelProperty(value = "工程师名称")
+    private String workerName;
+    @ApiModelProperty(value = "安装台数")
+    private int qty;
+    @ApiModelProperty(value = "排除台数")
+    private int rejectQty;
+    @ApiModelProperty(value = "实装台数")
+    private int realQty;
+    @ApiModelProperty(value = "总销售金额")
+    private BigDecimal totalSaleValue;
+    @ApiModelProperty(value = "现金支付次数")
+    private int cash;
+    @ApiModelProperty(value = "通联支付次数")
+    private int allinpay;
+    @ApiModelProperty(value = "现金销售金额")
+    private BigDecimal cashSaleValue;
+    @ApiModelProperty(value = "通联销售金额")
+    private BigDecimal allinpaySaleValue;
+    @ApiModelProperty(value = "退货金额")
+    private BigDecimal retValue;
+}

+ 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("详细地址");
@@ -801,6 +802,7 @@ public class AdminWebsitLogic {
             List<Object> row = new ArrayList<>();
 
             final AdminCompanyWechatPayConfig wechatPayConfig = wechatPayConfigMap.get(websit.getPayWorkerCodeId());
+            row.add(websit.getWebsitId());
             row.add(websit.getName());
             row.add(websit.getLinkName());
             row.add(websit.getAddress());

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

@@ -258,6 +258,9 @@ public class WebsitSalesLogic {
             if (!goodsMap.containsKey(item.getGoodsId())) {
                 throw new RemoteServiceException("找不到商品信息:" + item.getGoodsName());
             }
+            if (item.getPrice().compareTo(BigDecimal.ZERO) <= 0) {
+                throw new RemoteServiceException(item.getGoodsName() + "售价不能为0");
+            }
             WebsitGoods goods = goodsMap.get(item.getGoodsId());
             item.setGoodsSalesUnit(goods.getGoodsSalesUnit())
                     .setGoodsStockUnit(goods.getGoodsStockUnit())
@@ -266,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())

+ 5 - 5
mall-server-api/src/main/java/com/gree/mall/manager/logic/user/UserLogic.java

@@ -214,7 +214,7 @@ public class UserLogic {
                 .eq(AdminWebsit::getCompanyWechatId, adminUser.getCompanyWechatId())
                 .eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey())
                 .list();
-        Map<String, AdminWebsit> websitMap = list.stream().collect(Collectors.toMap(AdminWebsit::getName, Function.identity()));
+        Map<String, AdminWebsit> websitMap = list.stream().collect(Collectors.toMap(AdminWebsit::getWebsitId, Function.identity()));
         int index = 0;
         //先删除
         userWaitService.lambdaUpdate()
@@ -231,7 +231,7 @@ public class UserLogic {
             String idcard = (String) row.get(1);
             String mobile = (String) row.get(2);
             String userType = (String) row.get(3);
-            String websitName = (String) row.get(4);
+            String websitId = (String) row.get(4);
             String bankAccount = (String) row.get(5);
             String workerNumber = (String) row.get(6);
             if (StringUtils.isAnyBlank(name, mobile, userType)) {
@@ -246,10 +246,10 @@ public class UserLogic {
             }
             AdminWebsit adminWebsit = null;
             if (userTypeEnum == UserTypeEnum.WORKER) {
-                if (StringUtils.isBlank(websitName)) {
-                    throw new RemoteServiceException(errPrefix + "网点名称不能为空");
+                if (StringUtils.isBlank(websitId)) {
+                    throw new RemoteServiceException(errPrefix + "网点编号不能为空");
                 }
-                adminWebsit = websitMap.get(websitName);
+                adminWebsit = websitMap.get(websitId);
                 if (Objects.isNull(adminWebsit)) {
                     throw new RemoteServiceException(errPrefix + "网点不存在");
                 }

+ 4 - 2
mall-server-api/src/main/java/com/gree/mall/manager/logic/websit/WebsitSalesRetLogic.java

@@ -197,7 +197,7 @@ public class WebsitSalesRetLogic {
 
         websitSalesRetAddUP.setCompanyWechatId(adminUser.getCompanyWechatId());
         websitSalesRetAddUP.setCompanyName(adminUser.getCompanyName());
-        websitSalesRetAddUP.setPayType(oldWebsitSales.getPayType().equals(PayTypeEnum.ENGIN.getKey()) ? oldWebsitSales.getPayType() : "CASH");
+        websitSalesRetAddUP.setPayType(oldWebsitSales.getPayType());
         websitSalesRetAddUP.updateById();
 
 
@@ -211,7 +211,9 @@ public class WebsitSalesRetLogic {
 
             this.refundOk(websitSalesRetAddUP.getSalesRetId());
 
-            this.refundAddPayOrder(websitSalesRetAddUP.getSalesRetId());
+            if (websitSalesRetAddUP.getPayType().equals(PayTypeEnum.CASH.getKey())) {
+                this.refundAddPayOrder(websitSalesRetAddUP.getSalesRetId());
+            }
             websitSalesRetAddUP.setConfirmTime(new Date());
             websitSalesRetAddUP.setConfirmBy(adminUser.getNickName());
             websitSalesRetAddUP.updateById();

+ 3 - 0
mall-server-api/src/main/resources/mapper/MaterialMapper.xml

@@ -308,6 +308,9 @@
         ${ex.selected}
         FROM websit_sales_pay_order a
         ${ex.query}
+        AND goods_type = 'M'
+        AND pay_type IN ('WECHAT', 'ALLINPAY')
+        AND order_type = 'S'
         <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
             AND a.websit_id IN
             <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">

BIN
mall-server-api/src/main/resources/template/师傅分销员资料初始化.xlsx