‘linchangsheng’ 6 miesięcy temu
rodzic
commit
e522e3a858

+ 48 - 63
src/main/java/com/zfire/mall/manager/bean/front/CustomerOrderBean.java

@@ -16,12 +16,12 @@ import java.util.Date;
  */
 @ApiModel
 @Data
-public class CustomerOrderBean   {
+public class CustomerOrderBean {
 
-   /* @ZfireField(tbName = "co")
-    @ApiModelProperty(value = "同步嘉贤状态")
-    private SyncStatusEnum syncStatus;
-*/
+    /* @ZfireField(tbName = "co")
+     @ApiModelProperty(value = "同步嘉贤状态")
+     private SyncStatusEnum syncStatus;
+ */
     @ZfireField(tbName = "co")
     @ApiModelProperty(value = "嘉贤订单号")
     private String jiaxianOrderId;
@@ -34,7 +34,7 @@ public class CustomerOrderBean   {
     @ApiModelProperty(value = "状态")
     private JiaXianOrderTypeEnum status;
 
-    @ZfireField(hide = true,frontCode = CodeStatusConstant.CUSTOMER_ORDER_STATUS,tbName = "co",colName = "status",type = "select")
+    @ZfireField(hide = true, frontCode = CodeStatusConstant.CUSTOMER_ORDER_STATUS, tbName = "co", colName = "status", type = "select")
     @ApiModelProperty(value = "状态")
     private String statusName;
 
@@ -50,7 +50,7 @@ public class CustomerOrderBean   {
     @ApiModelProperty(value = "经销商编号")
     private String customerNumber;
 
-    @ZfireField(hide = true,tbName = "co")
+    @ZfireField(hide = true, tbName = "co")
     @ApiModelProperty(value = "经销商id")
     private String customerId;
 
@@ -86,13 +86,6 @@ public class CustomerOrderBean   {
     @ApiModelProperty(value = "收货地址")
     private String receAddress;
 
-    @ZfireField(tbName = "co")
-    @ApiModelProperty(value = "仓库")
-    private JiaXianStockTypeEnum stockType;
-
-    @ZfireField(hide = true,colName = "stock_type" ,frontCode = CodeStatusConstant.STOCK_TYPE,type = "select")
-    @ApiModelProperty(value = "发货仓名称")
-    private String stockTypeName;
 
     @ZfireField(tbName = "coi")
     @ApiModelProperty(value = "物料编号")
@@ -106,7 +99,7 @@ public class CustomerOrderBean   {
     @ApiModelProperty(value = "物料名称")
     private String materialName;
 
-    @ZfireField(hide = true,tbName = "coi")
+    @ZfireField(hide = true, tbName = "coi")
     @ApiModelProperty(value = "物料id")
     private String materialId;
 
@@ -114,25 +107,18 @@ public class CustomerOrderBean   {
     @ApiModelProperty(value = "规格型号")
     private String specification;
 
-    @ZfireField(tbName = "coi",type = "number")
+    @ZfireField(tbName = "coi", type = "number")
     @ApiModelProperty(value = "发货数量")
     private Integer qty;
 
-    @ZfireField(tbName = "coi",hide = true,type = "number")
+    @ZfireField(tbName = "coi", hide = true, type = "number")
     @ApiModelProperty(value = "可退货数量")
     private Integer refundQty;
 
-    @ZfireField(type = "number",tbName = "coi",colName = "real_qty")
+    @ZfireField(type = "number", tbName = "coi", colName = "real_qty")
     @ApiModelProperty(value = "退货数量")
     private Integer refundOrderQty;
 
-    @ZfireField(type = "number",tbName = "cs",isQuery = false)
-    @ApiModelProperty(value = "嘉贤仓库结存数量")
-    private BigDecimal stockQty;
-
-    @ZfireField(type = "number",tbName = "cs",isQuery = false)
-    @ApiModelProperty(value = "自有仓库结存数量")
-    private BigDecimal customerStockQty;
 
     @ZfireField(tbName = "co")
     @ApiModelProperty(value = "备注")
@@ -145,48 +131,47 @@ public class CustomerOrderBean   {
     @ZfireField(tbName = "co")
     @ApiModelProperty(value = "创建时间")
     private Date createTime;
- @ZfireField(tbName = "co")
+    @ZfireField(tbName = "co")
     @ApiModelProperty(value = "安装信息编号")
     private String gongDanId;
 
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "总部信息编号")
- private String pgid;
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "销售网点编号")
- private String salesNumber;
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "销售网点名称")
- private String salesWname;
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "售后网点编号")
- private String installNumber;
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "售后网点名称")
- private String installName;
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "工单状态")
- private GongDanOrderTypeEnum orderState;
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "派工状态")
- private GongDanPaiGongTypeEnum appointState;
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "服务人员名称")
- private String workerName;
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "服务人员编号")
- private String workerNumber;
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "师傅电话")
- private String workerPhone;
-
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "信息员名称")
- private String adminOfficerName;
- @ZfireField(tbName = "co")
- @ApiModelProperty(value = "信息员编号")
- private String adminOfficerNumber;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "总部信息编号")
+    private String pgid;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "销售网点编号")
+    private String salesNumber;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "销售网点名称")
+    private String salesWname;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "售后网点编号")
+    private String installNumber;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "售后网点名称")
+    private String installName;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "工单状态")
+    private GongDanOrderTypeEnum orderState;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "派工状态")
+    private GongDanPaiGongTypeEnum appointState;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "服务人员名称")
+    private String workerName;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "服务人员编号")
+    private String workerNumber;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "师傅电话")
+    private String workerPhone;
 
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "信息员名称")
+    private String adminOfficerName;
+    @ZfireField(tbName = "co")
+    @ApiModelProperty(value = "信息员编号")
+    private String adminOfficerNumber;
 
 
 }

+ 16 - 24
src/main/java/com/zfire/mall/manager/logic/front/CustomerFrontLogic.java

@@ -230,7 +230,7 @@ public class CustomerFrontLogic {
             }*/
 
             stockAcc(customerStockOrderItem.getDirectFlag(), Convert.toInt(customerStockOrderItem.getStockChangeQty()), customerStockInsert.getId(),
-                    "库存调整单-扣除修改后的库存", customerStockOrderItem.getStockType(), customerStock.getMaterialId(), customerStock.getCustomerId(), customerStockOrderItem.getNotes());
+                    "库存调整单-扣除修改后的库存",  customerStock.getMaterialId(), customerStock.getCustomerId(), customerStockOrderItem.getNotes());
 
     /*        customerStockOrderItem.setStockCurQty(customerStock.getStockQty());
             if (customerStockOrderItem.getDirectFlag().equals(false)) {
@@ -293,7 +293,7 @@ public class CustomerFrontLogic {
      * directFlag  true 增加 false 减少  qty 数量  ref 订单   refType 订单类型 stockType 1 前置仓 2商家仓 materialId 物料id  customerId 经销商id  notes 备注
      */
 
-    public void stockAcc(Boolean directFlag, Integer qty, String ref, String refType, Integer stockType, String materialId, String customerId, String notes) {
+    public void stockAcc(Boolean directFlag, Integer qty, String ref, String refType, String materialId, String customerId, String notes) {
         KingDeeCustomer kingDeeCustomer = kingDeeCustomerService.getById(customerId);
         KingDeeMaterial kingDeeMaterial = kingDeeMaterialService.getById(materialId);
         CustomerStock customerStock = customerStockService.lambdaQuery()
@@ -305,27 +305,24 @@ public class CustomerFrontLogic {
         customerStockAcc.setChangeTime(new Date());
         customerStockAcc.setDirectFlag(directFlag);
         customerStockAcc.setStockChangeQty(Convert.toBigDecimal(qty));
-        if (stockType.equals(1) && (customerStock == null || customerStock.getFrontStockNum() == null))
-            customerStockAcc.setStockCurQty(new BigDecimal(0));
-        else if (stockType.equals(1))
-            customerStockAcc.setStockCurQty(customerStock.getFrontStockNum());
-
-        if (stockType.equals(2) && (customerStock == null || customerStock.getCustomerStockNum() == null))
-            customerStockAcc.setStockCurQty(new BigDecimal(0));
-        else if (stockType.equals(2))
-            customerStockAcc.setStockCurQty(customerStock.getCustomerStockNum());
-
-        if (customerStockAcc.getDirectFlag().equals(false)) {
-            customerStockAcc.setStockCloseQty(customerStockAcc.getStockCurQty().subtract(Convert.toBigDecimal(customerStockAcc.getStockChangeQty())));
-        } else {
-            customerStockAcc.setStockCloseQty(customerStockAcc.getStockCurQty().add(Convert.toBigDecimal(customerStockAcc.getStockChangeQty())));
-        }
+        if (customerStock == null)
+            customerStockAcc.setStockCurQty(BigDecimal.ZERO);
+        else
+            customerStockAcc.setStockCurQty(customerStock.getStockNum());
+
+        if (directFlag)
+            customerStockAcc.setStockCloseQty(customerStockAcc.getStockCurQty().add(Convert.toBigDecimal(qty)));
+        else
+            customerStockAcc.setStockCloseQty(customerStockAcc.getStockCurQty().subtract(Convert.toBigDecimal(qty)));
+
+
+
         if (customerStockAcc.getStockCloseQty().compareTo(BigDecimal.ZERO) == -1)
             throw new RemoteServiceException("库存数量小于0");
+
         customerStockAcc.setRef(ref);
         customerStockAcc.setRefType(refType);
         customerStockAcc.setNotes(notes);
-        customerStockAcc.setStockType(stockType);
         customerStockAcc.setMaterialId(kingDeeMaterial.getId());
         customerStockAcc.setMaterialCode(kingDeeMaterial.getNumber());
         customerStockAcc.setMaterialName(kingDeeMaterial.getName());
@@ -428,8 +425,6 @@ public class CustomerFrontLogic {
                 customerStockInsert.setCategoryNumber(kingDeeMaterial.getCategoryNumber());
                 customerStockInsert.setCategoryName(kingDeeMaterial.getCategoryName());
 
-                stockAcc(true, Convert.toInt(customerOrderImport.getQty()), kingDeeCustomer.getNumber() + "(" + kingDeeMaterial.getNumber() + ")",
-                        "导入商家库存", kingDeeCustomer.getIsFront() ? 1 : 2, kingDeeMaterial.getId(), kingDeeCustomer.getId(), customerOrderImport.getRemark());
 
                 customerStockInsert.insert();
 
@@ -443,8 +438,6 @@ public class CustomerFrontLogic {
                 if (customerStock.getStockQty().compareTo(BigDecimal.ZERO) < 0) {
                     throw new RemoteServiceException("商家无库存减少库存失败:" + customerOrderImport.getCustomerNumber() + "," + customerOrderImport.getDirectFlag());
                 }*/
-                stockAcc(customerOrderImport.getDirectFlag().equals("减少") ? false : true, Convert.toInt(customerOrderImport.getQty()), kingDeeCustomer.getNumber() + "(" + kingDeeMaterial.getNumber() + ")",
-                        "导入商家库存", kingDeeCustomer.getIsFront() ? 1 : 2, kingDeeMaterial.getId(), kingDeeCustomer.getId(), customerOrderImport.getRemark());
 
                 customerStock.updateById();
 
@@ -515,8 +508,7 @@ public class CustomerFrontLogic {
             KingDeeMaterial kingDeeMaterial = kingDeeMaterialService.lambdaQuery().eq(KingDeeMaterial::getNumber, customerOrderImport.getMaterialCode()).last("limit 1").one();
             if (customerStock != null){
                 customerOrderImport.setId(customerStock.getId());
-                customerOrderImport.setFrontStockNum(customerStock.getFrontStockNum().add(customerOrderImport.getFrontStockNum()));
-                customerOrderImport.setCustomerStockNum(customerStock.getCustomerStockNum().add(customerOrderImport.getCustomerStockNum()));
+
                 continue;
             }
             customerOrderImport.setCustomerId(king.getId());

+ 4 - 79
src/main/java/com/zfire/mall/manager/logic/front/CustomerFrontOrderLogic.java

@@ -172,19 +172,7 @@ public class CustomerFrontOrderLogic {
                 throw new RemoteServiceException("不能重复添加同一机型");
 
             map.put(order.getMaterialCode(), order.getMaterialName());
-            if (Convert.toInt(customerOrderDetail.getStockType().equals(1) ? customerStock.getFrontStockNum() : customerStock.getCustomerStockNum()) < Convert.toInt(order.getQty()) || order.getQty() <= 0) {
-                throw new RemoteServiceException("数量大于可调整数量");
-            }
-
-            customerFrontLogic.stockAcc(false, Convert.toInt(order.getQty()), customerOrderDetail.getId(), "客户销售订单", customerOrderDetail.getStockType(), customerStock.getMaterialId(), customerStock.getCustomerId(), order.getNotes());
 
-            if (customerOrderDetail.getStockType().equals(1)) {
-                customerStock.setFrontStockNum(customerStock.getFrontStockNum().subtract(new BigDecimal(order.getQty())));
-                customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().add(new BigDecimal(order.getQty())));
-            } else {
-                customerStock.setCustomerStockNum(customerStock.getCustomerStockNum().subtract(new BigDecimal(order.getQty())));
-                customerStock.setLockCustomerStockNum(customerStock.getLockCustomerStockNum().add(new BigDecimal(order.getQty())));
-            }
             customerStock.updateById();
 
         }
@@ -214,16 +202,8 @@ public class CustomerFrontOrderLogic {
                     .last("limit 1").one();
 
 
-            customerFrontLogic.stockAcc(true, Convert.toInt(order.getQty()), customerOrderDetail.getId(), "客户销售订单修改-返回修改前得库存", customerOrderDetail.getStockType(), customerStock.getMaterialId(), customerStock.getCustomerId(), order.getNotes());
 
 
-            if (customerOrderDetail.getStockType().equals(1)) {
-                customerStock.setFrontStockNum(customerStock.getFrontStockNum().add(new BigDecimal(order.getQty())));
-                customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().subtract(new BigDecimal(order.getQty())));
-            } else {
-                customerStock.setCustomerStockNum(customerStock.getCustomerStockNum().add(new BigDecimal(order.getQty())));
-                customerStock.setLockCustomerStockNum(customerStock.getLockCustomerStockNum().subtract(new BigDecimal(order.getQty())));
-            }
             customerStock.updateById();
 
         }
@@ -244,20 +224,8 @@ public class CustomerFrontOrderLogic {
                     // .eq(CustomerStock::getStockType, customerOrderDetail.getStockType())
                     .last("limit 1").one();
 
-            if (Convert.toInt(customerOrderDetail.getStockType().equals(1) ? customerStock.getFrontStockNum() : customerStock.getCustomerStockNum()) < Convert.toInt(order.getQty()) || order.getQty() < 0) {
-                throw new RemoteServiceException("数量大于可调整数量");
-            }
 
 
-            customerFrontLogic.stockAcc(false, Convert.toInt(order.getQty()), customerOrderDetail.getId(), "客户销售订单修改-扣除修改后得库存", customerOrderDetail.getStockType(), customerStock.getMaterialId(), customerStock.getCustomerId(), order.getNotes());
-
-            if (customerOrderDetail.getStockType().equals(1)) {
-                customerStock.setFrontStockNum(customerStock.getFrontStockNum().subtract(new BigDecimal(order.getQty())));
-                customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().add(new BigDecimal(order.getQty())));
-            } else {
-                customerStock.setCustomerStockNum(customerStock.getCustomerStockNum().subtract(new BigDecimal(order.getQty())));
-                customerStock.setLockCustomerStockNum(customerStock.getLockCustomerStockNum().add(new BigDecimal(order.getQty())));
-            }
             customerStock.updateById();
 
         }
@@ -356,16 +324,6 @@ public class CustomerFrontOrderLogic {
                     .eq(CustomerStock::getCustomerNumber, customerOrderOne.getCustomerNumber())
                     .eq(CustomerStock::getMaterialCode, customerOrderRefundItem.getMaterialCode())
                     .last("limit 1").one();
-            if (customerOrderOne.getStockType().equals(1)) {
-                customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().subtract(new BigDecimal(customerOrderRefundItem.getQty())));
-                if (Convert.toInt(customerStock.getLockFrontStockNum()) < 0)
-                    throw new RemoteServiceException("库存数量不够");
-            } else {
-                customerStock.setLockCustomerStockNum(customerStock.getLockCustomerStockNum().subtract(new BigDecimal(customerOrderRefundItem.getQty())));
-                if (Convert.toInt(customerStock.getLockCustomerStockNum()) < 0)
-                    throw new RemoteServiceException("库存数量不够");
-            }
-
 
             customerStock.updateById();
 
@@ -441,13 +399,6 @@ public class CustomerFrontOrderLogic {
                     .eq(CustomerStock::getCustomerNumber, customerOrderOne.getCustomerNumber())
                     .eq(CustomerStock::getMaterialCode, customerOrderRefundItem.getMaterialCode())
                     .last("limit 1").one();
-            if (customerOrderOne.getStockType().equals(1)) {
-                customerStock.setFrontStockNum(customerStock.getFrontStockNum().add(new BigDecimal(customerOrderRefundItem.getQty())));
-            } else {
-                customerStock.setCustomerStockNum(customerStock.getCustomerStockNum().add(new BigDecimal(customerOrderRefundItem.getQty())));
-            }
-            customerFrontLogic.stockAcc(true, Convert.toInt(customerOrderRefundItem.getQty()), customerOrderOne.getId(), "客户退货订单",
-                    customerOrderOne.getStockType(), customerStock.getMaterialId(), customerStock.getCustomerId(), customerOrderRefundItem.getNotes());
 
             customerStock.updateById();
 
@@ -545,15 +496,8 @@ public class CustomerFrontOrderLogic {
                     .last("limit 1").one();
 
 
-            customerFrontLogic.stockAcc(true, Convert.toInt(order.getQty()), customerOrder.getId(), "客户销售订单删除", customerOrder.getStockType(), customerStock.getMaterialId(), customerStock.getCustomerId(), order.getNotes());
 
-            if (customerOrder.getStockType().equals(1)) {
-                customerStock.setFrontStockNum(customerStock.getFrontStockNum().add(new BigDecimal(order.getQty())));
-                customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().subtract(new BigDecimal(order.getQty())));
-            } else {
-                customerStock.setCustomerStockNum(customerStock.getCustomerStockNum().add(new BigDecimal(order.getQty())));
-                customerStock.setLockCustomerStockNum(customerStock.getLockCustomerStockNum().subtract(new BigDecimal(order.getQty())));
-            }
+
             customerStock.updateById();
 
         }
@@ -657,11 +601,7 @@ public class CustomerFrontOrderLogic {
                     .eq(CustomerStock::getCustomerNumber, customerOrderOne.getCustomerNumber())
                     .eq(CustomerStock::getMaterialCode, customerOrderRefundItem.getMaterialCode())
                     .last("limit 1").one();
-            if (customerOrderOne.getStockType().equals(1)) {
-                customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().subtract(new BigDecimal(customerOrderRefundItem.getQty())));
-            } else {
-                customerStock.setLockCustomerStockNum(customerStock.getLockCustomerStockNum().subtract(new BigDecimal(customerOrderRefundItem.getQty())));
-            }
+
             customerStock.updateById();
 
         }
@@ -728,18 +668,7 @@ public class CustomerFrontOrderLogic {
                     .eq(CustomerStock::getMaterialCode, customerOrderRefundItem.getMaterialCode())
                     .last("limit 1").one();
 
-            customerFrontLogic.stockAcc(true, Convert.toInt(customerOrderRefundItem.getQty()), customerOrderOne.getId(), "客户销售订单删除",
-                    customerOrderOne.getStockType(), customerStock.getMaterialId(), customerStock.getCustomerId(), customerOrderRefundItem.getNotes());
-
-            if (customerOrderOne.getStockType().equals(1)) {
-                customerStock.setFrontStockNum(customerStock.getFrontStockNum().subtract(new BigDecimal(customerOrderRefundItem.getQty())));
-                if (Convert.toLong(customerStock.getFrontStockNum()) < 0)
-                    throw new RemoteServiceException("库存没有那么多");
-            } else {
-                customerStock.setCustomerStockNum(customerStock.getCustomerStockNum().subtract(new BigDecimal(customerOrderRefundItem.getQty())));
-                if (Convert.toLong(customerStock.getCustomerStockNum()) < 0)
-                    throw new RemoteServiceException("库存没有那么多");
-            }
+
             customerStock.updateById();
 
             CustomerOrderItem customerOrderItem = customerOrderItemService.lambdaQuery().eq(CustomerOrderItem::getMaterialCode, customerOrderRefundItem.getMaterialCode())
@@ -787,11 +716,7 @@ public class CustomerFrontOrderLogic {
                     .eq(CustomerStock::getCustomerNumber, customerOrderOne.getCustomerNumber())
                     .eq(CustomerStock::getMaterialCode, customerOrderRefundItem.getMaterialCode())
                     .last("limit 1").one();
-            if (customerOrderOne.getStockType().equals(1)) {
-                customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().add(new BigDecimal(customerOrderRefundItem.getQty())));
-            } else {
-                customerStock.setLockCustomerStockNum(customerStock.getLockCustomerStockNum().add(new BigDecimal(customerOrderRefundItem.getQty())));
-            }
+
             customerStock.updateById();
 
         }

+ 4 - 39
src/main/java/com/zfire/mall/manager/logic/front/CustomerTransferOrderLogic.java

@@ -113,7 +113,7 @@ public class CustomerTransferOrderLogic {
                 throw new RemoteServiceException("不能重复添加同一机型");
 
             map.put(order.getMaterialCode(), order.getMaterialName());
-            if (Convert.toInt(customerStock.getFrontStockNum()) < Convert.toInt(order.getQty()) || order.getQty() <= 0) {
+/*            if (Convert.toInt(customerStock.getFrontStockNum()) < Convert.toInt(order.getQty()) || order.getQty() <= 0) {
                 throw new RemoteServiceException("数量大于可调整数量");
             }
 
@@ -121,7 +121,7 @@ public class CustomerTransferOrderLogic {
 
 
             customerStock.setFrontStockNum(customerStock.getFrontStockNum().subtract(new BigDecimal(order.getQty())));
-            customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().add(new BigDecimal(order.getQty())));
+            customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().add(new BigDecimal(order.getQty())));*/
             customerStock.updateById();
             order.setTransferOrderId(customerTransferOrderAddOrUp.getId());
         }
@@ -140,13 +140,8 @@ public class CustomerTransferOrderLogic {
                     .last("limit 1").one();
 
 
-            customerFrontLogic.stockAcc(true, Convert.toInt(order.getQty()), customerTransferOrderAddOrUp.getId(), "调拨单修改-返回修改前得库存",
-                    1, customerStock.getMaterialId(), customerStock.getCustomerId(), order.getNotes());
 
 
-            customerStock.setFrontStockNum(customerStock.getFrontStockNum().add(new BigDecimal(order.getQty())));
-            customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().subtract(new BigDecimal(order.getQty())));
-
             customerStock.updateById();
 
         }
@@ -166,15 +161,8 @@ public class CustomerTransferOrderLogic {
                 throw new RemoteServiceException("不能重复添加同一机型");
 
             map.put(order.getMaterialCode(), order.getMaterialName());
-            if (Convert.toInt(customerStock.getFrontStockNum()) < Convert.toInt(order.getQty())) {
-                throw new RemoteServiceException("数量大于可调整数量");
-            }
-
-            customerFrontLogic.stockAcc(false, Convert.toInt(order.getQty()), customerTransferOrderAddOrUp.getId(), "调拨单", 1, customerStock.getMaterialId(), customerStock.getCustomerId(), order.getNotes());
 
 
-            customerStock.setFrontStockNum(customerStock.getFrontStockNum().subtract(new BigDecimal(order.getQty())));
-            customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().add(new BigDecimal(order.getQty())));
             customerStock.updateById();
             order.setTransferOrderId(customerTransferOrderAddOrUp.getId());
         }
@@ -227,9 +215,6 @@ public class CustomerTransferOrderLogic {
                     .eq(CustomerStock::getMaterialCode, customerOrderItem.getMaterialCode())
                     .last("limit 1").one();
 
-            customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().subtract(new BigDecimal(customerOrderItem.getQty())));
-            if (Convert.toInt(customerStock.getLockFrontStockNum()) < 0)
-                throw new RemoteServiceException("库存数量不够");
 
 
             customerStock.updateById();
@@ -246,15 +231,13 @@ public class CustomerTransferOrderLogic {
                 customerStockTwo.setCustomerId(byId.getTransferCustomerId());
                 customerStockTwo.setCustomerNumber(byId.getTransferCustomerNumber());
                 customerStockTwo.setCustomerName(byId.getTransferCustomerName());
-                customerStockTwo.setFrontStockNum(Convert.toBigDecimal(customerOrderItem.getQty()));
+
                 customerStockTwo.insert();
             }else {
-                customerStockCustomer.setFrontStockNum(customerStockCustomer.getFrontStockNum().add(Convert.toBigDecimal(customerOrderItem.getQty())));
+
                 customerStockCustomer.updateById();
             }
 
-            customerFrontLogic.stockAcc(true, Convert.toInt(customerOrderItem.getQty()), byId.getId(), "调拨单", 1, customerStock.getMaterialId(), byId.getTransferCustomerId(), customerOrderItem.getNotes());
-
 
             MerchantAllocationOrderDetailList merchantAllocationOrderDetailList = new MerchantAllocationOrderDetailList();
             merchantAllocationOrderDetailList.setMaterialCode(customerOrderItem.getMaterialOldNumber());
@@ -306,9 +289,6 @@ public class CustomerTransferOrderLogic {
                     .eq(CustomerStock::getMaterialCode, customerOrderItem.getMaterialCode())
                     .last("limit 1").one();
 
-            customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().add(new BigDecimal(customerOrderItem.getQty())));
-            if (Convert.toInt(customerStock.getLockFrontStockNum()) < 0)
-                throw new RemoteServiceException("库存数量不够");
 
 
             customerStock.updateById();
@@ -319,16 +299,6 @@ public class CustomerTransferOrderLogic {
                     .last("limit 1").one();
 
 
-            if (customerStockCustomer == null){
-              throw new RemoteServiceException("库存存在问题");
-            }else {
-                customerStockCustomer.setFrontStockNum(customerStockCustomer.getFrontStockNum().subtract(Convert.toBigDecimal(customerOrderItem.getQty())));
-                if (Convert.toInt(customerStockCustomer.getFrontStockNum()) < 0)
-                    throw new RemoteServiceException("子经销商已经把库存锁定无法弃审");
-                customerStockCustomer.updateById();
-            }
-
-            customerFrontLogic.stockAcc(true, Convert.toInt(customerOrderItem.getQty()), byId.getId(), "调拨单", 1, customerStock.getMaterialId(), byId.getTransferCustomerId(), customerOrderItem.getNotes());
 
 
             MerchantAllocationOrderDetailList merchantAllocationOrderDetailList = new MerchantAllocationOrderDetailList();
@@ -371,11 +341,6 @@ public class CustomerTransferOrderLogic {
 
 
 
-            customerFrontLogic.stockAcc(true, Convert.toInt(order.getQty()), byId.getId(), "调拨单删除", 1, customerStock.getMaterialId(), byId.getCustomerId(), order.getNotes());
-
-
-            customerStock.setFrontStockNum(customerStock.getFrontStockNum().add(new BigDecimal(order.getQty())));
-            customerStock.setLockFrontStockNum(customerStock.getLockFrontStockNum().subtract(new BigDecimal(order.getQty())));
             customerStock.updateById();
 
         }

+ 0 - 123
src/main/java/com/zfire/mall/manager/logic/pick/PickLogic.java

@@ -558,70 +558,6 @@ public class PickLogic {
                             .set(SalesOrder::getLogisticsName,logisticsConfiguration.getLogisticsCompany()).update();
                 }
             }
-
-
-
-            //嘉贤物流仓需要记录订单
-            if (pickManager.getPickType() != null && pickManager.getPickType().equals(2) &&
-                    logisticsConfigurationService.getById(pickManager.getLogisticsId()).getLogisticsNumber().equals(Constant.JIA_XIAN_WU_LIU)){
-
-
-                for (PickManagerShip pickManagerShip : pickManagerShipService.lambdaQuery().eq(PickManagerShip::getPickId, pickManager.getId()).list()) {
-                    InvoiceApplicationOrder byId = invoiceApplicationOrderService.getById(pickManagerShip.getInvoiceOrderId());
-                    InvoiceApplication invoiceApplication = invoiceApplicationService.getById(byId.getInvoiceId());
-                    PickManagerPush pickManagerPushUP = pickManagerPushService.lambdaQuery().eq(PickManagerPush::getInvoiceId, invoiceApplication.getId()).last("limit 1").one();
-
-
-
-                    if (pickManagerPushUP != null) {
-                    }else {
-                        PickManagerPush pickManagerPush = new PickManagerPush();
-                        pickManagerPush.setPickId(pickManager.getId());
-                        pickManagerPush.setPickTime(pickManager.getPickTime());
-
-                        pickManagerPush.setInvoiceId(invoiceApplication.getId());
-                        pickManagerPush.setWarehouseFlag(pickManagerShip.getWarehouseFlag());
-                        pickManagerPush.setReceivingName(pickManagerShip.getReceivingName());
-                        pickManagerPush.setPhone(pickManagerShip.getPhone());
-                        pickManagerPush.setAddress(pickManagerShip.getAddress());
-                        pickManagerPush.setRemark(pickManager.getRemark());
-                        pickManagerPush.setIsUp(pickManager.getIsUp());
-                        pickManagerPush.setIsDischarge(pickManager.getIsDischarge());
-                        pickManagerPush.setCustomerOrderId(pickManagerShip.getCustomerOrderId());
-                        pickManagerPush.setSalesOrderNo(invoiceApplication.getSalesOrderId());
-
-
-         /*               if (StringUtils.isNotEmpty(invoiceApplication.getEnginOrderNo())){
-
-                            pickManagerPush.setInvoiceId(invoiceApplication.getId());
-                            pickManagerPush.setWarehouseFlag(1);
-                            pickManagerPush.setReceivingName(invoiceApplication.getRefLinkman());
-                            pickManagerPush.setPhone(invoiceApplication.getRefPhone());
-                            pickManagerPush.setAddress(invoiceApplication.getRefInstallAddress());
-                        }else {
-                            pickManagerPush.setInvoiceId(invoiceApplication.getId());
-                            if (StringUtils.isNotEmpty(pickManagerShip.getAddress())) {
-                                pickManagerPush.setWarehouseFlag(2);
-                                pickManagerPush.setReceivingName(pickManagerShip.getReceivingName());
-                                pickManagerPush.setPhone(pickManagerShip.getPhone());
-                                pickManagerPush.setAddress(pickManagerShip.getAddress());
-                            }else {
-                                pickManagerPush.setWarehouseFlag(0);
-                            }
-                        }*/
-                        pickManagerPush.insert();
-                    }
-                }
-
-            }
-
-            KingDeeCustomer kingDeeCustomer = kingDeeCustomerService.getById(pickManager.getCustomerId());
-            //增加经销商库存
-            if (pickManager.getPickType() != null && pickManager.getPickType().equals(2) &&
-                    logisticsConfigurationService.getById(pickManager.getLogisticsId()).getLogisticsNumber().equals(Constant.JIA_XIAN_WU_LIU)){
-                customerStockInsert(id,1);
-            }
-
         }
         shipMapper.printAdd(ids);
         shipMapper.printAddInvoice(ids);
@@ -629,65 +565,6 @@ public class PickLogic {
     }
 
 
-    /*
-    * id  提货id
-    * i   1前置仓  2商家仓
-    * */
-    private void customerStockInsert(String id, int i) {
-
-        for (PickManagerShip pickManagerShip : pickManagerShipService.lambdaQuery().eq(PickManagerShip::getPickId, id).list()) {
-
-
-            InvoiceApplicationOrder invoiceApplicationOrder = invoiceApplicationOrderService.getById(pickManagerShip.getInvoiceOrderId());
-            InvoiceApplication invoiceApplication = invoiceApplicationService.getById(invoiceApplicationOrder.getInvoiceId());
-            if (pickManagerShip.getStatus().equals(0)){
-
-                if (i == 1 && pickManagerShip.getWarehouseFlag().equals(0)){
-                customerFrontLogic.stockAcc(true,Convert.toInt(invoiceApplicationOrder.getRefundableQty()+invoiceApplicationOrder.getRetiredQty()),invoiceApplication.getId(),
-                        "打印发货单增加商家库存",i,invoiceApplicationOrder.getMaterialId(),invoiceApplication.getCustomerId(),invoiceApplication.getRemark());
-                }else if((i == 1 && pickManagerShip.getWarehouseFlag().equals(2))) {
-                    customerFrontLogic.stockAcc(true,Convert.toInt(invoiceApplicationOrder.getRefundableQty()+invoiceApplicationOrder.getRetiredQty()),invoiceApplication.getId(),
-                            "打印发货单增加商家库存",i,invoiceApplicationOrder.getMaterialId(),invoiceApplication.getCustomerId(),invoiceApplication.getRemark());
-                }
-
-                if (CollectionUtils.isEmpty(customerStockService.lambdaQuery()
-                        .eq(CustomerStock::getMaterialCode, pickManagerShip.getMaterialCode()).eq(CustomerStock::getCustomerId, invoiceApplication.getCustomerId()).list())) {
-                    CustomerStock customerStock = new CustomerStock();
-                    customerStock.setCustomerId(invoiceApplication.getCustomerId());
-                    customerStock.setCustomerName(invoiceApplication.getCustomerName());
-                    customerStock.setCustomerNumber(invoiceApplication.getCustomerNumber());
-                    customerStock.setMaterialCode(invoiceApplicationOrder.getMaterialCode());
-                    customerStock.setMaterialId(invoiceApplicationOrder.getMaterialId());
-                    customerStock.setMaterialName(invoiceApplicationOrder.getMaterialName());
-                    customerStock.setMaterialOldNumber(invoiceApplicationOrder.getMaterialOldNumber());
-                    customerStock.setSpecification(invoiceApplicationOrder.getSpecification());
-                    customerStock.setCategoryId(invoiceApplicationOrder.getCategoryId());
-                    customerStock.setCategoryName(invoiceApplicationOrder.getCategoryName());
-                    customerStock.setCategoryNumber(invoiceApplicationOrder.getCategoryNumber());
-                    if (i == 1 && pickManagerShip.getWarehouseFlag().equals(0)){
-                        customerStock.setFrontStockNum(Convert.toBigDecimal(invoiceApplicationOrder.getRefundableQty()+invoiceApplicationOrder.getRetiredQty()));
-                    }else if((i == 1 && pickManagerShip.getWarehouseFlag().equals(2))) {
-                        customerStock.setCustomerStockNum(Convert.toBigDecimal(invoiceApplicationOrder.getRefundableQty()+invoiceApplicationOrder.getRetiredQty()));
-                    }
-                    customerStock.insert();
-                }else {
-                    CustomerStock customerStockOne = customerStockService.lambdaQuery()
-                            .eq(CustomerStock::getMaterialCode, pickManagerShip.getMaterialCode()).eq(CustomerStock::getCustomerId, invoiceApplication.getCustomerId()).last("limit 1").one();
-                    if (i == 1  && pickManagerShip.getWarehouseFlag().equals(0)){
-                        customerStockOne.setFrontStockNum(customerStockOne.getFrontStockNum().add(Convert.toBigDecimal(invoiceApplicationOrder.getRefundableQty()+invoiceApplicationOrder.getRetiredQty())));
-                    }else if((i == 1 && pickManagerShip.getWarehouseFlag().equals(2))) {
-                        customerStockOne.setCustomerStockNum(customerStockOne.getCustomerStockNum().add(Convert.toBigDecimal(invoiceApplicationOrder.getRefundableQty()+invoiceApplicationOrder.getRetiredQty())));
-                    }
-                    customerStockOne.updateById();
-                }
-            }
-
-
-
-        }
-    }
-
-
     public List<InvoicePickBean> listInvoice(String correspondId) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         String customerId = adminUser.getIsCustomer() ? adminUser.getCustomerId() : "";

+ 129 - 81
src/main/java/com/zfire/mall/manager/logic/saletype/SaleOrderLogic.java

@@ -34,6 +34,7 @@ import com.zfire.mall.manager.enums.OrderTypeStatusEnum;
 import com.zfire.mall.manager.exception.RemoteServiceException;
 import com.zfire.mall.manager.logic.common.CommonLogic;
 import com.zfire.mall.manager.logic.customer.CustomerProductTypeLogic;
+import com.zfire.mall.manager.logic.front.CustomerFrontLogic;
 import com.zfire.mall.manager.logic.invoice.InvoiceLogic;
 import com.zfire.mall.manager.logic.k3.K3CustomerLogic;
 import com.zfire.mall.manager.logic.k3.K3GeJiangLogic;
@@ -122,6 +123,9 @@ public class SaleOrderLogic {
     K3CustomerLogic k3CustomerLogic;
 
     @Autowired
+    CustomerStockService customerStockService;
+
+    @Autowired
     SalesOutStockLogic salesOutStockLogic;
 
     @Autowired
@@ -190,6 +194,8 @@ public class SaleOrderLogic {
     @Autowired
     RetailOrderService retailOrderService;
 
+    @Autowired
+    CustomerFrontLogic customerFrontLogic;
 
 
     final static String orgId = "1";
@@ -289,48 +295,48 @@ public class SaleOrderLogic {
 
             for (InvoiceApplicationOrder order : detail.getSaleOrderData()) {
 
-                Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.INVOICE_APPLICATION+order.getOrderId());
+                Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.INVOICE_APPLICATION + order.getOrderId());
                 try {
                     if (!obtain.tryLock(5, TimeUnit.SECONDS)) {
                         throw new RemoteServiceException("系统繁忙,请稍后再试");
                     }
 
-                //记录台账记录
-                String customerWalletId = null;
-                if (order.getOrderType().equals("RETAIL") || order.getOrderType().equals("RETAIL_POLICY")) {
-                    RetailOrderItem retailOrderItem = retailOrderItemService.getById(order.getOrderId());
-                    retailOrderItem.setHasSendQty(retailOrderItem.getHasSendQty() + order.getRefundableQty());
+                    //记录台账记录
+                    String customerWalletId = null;
+                    if (order.getOrderType().equals("RETAIL") || order.getOrderType().equals("RETAIL_POLICY")) {
+                        RetailOrderItem retailOrderItem = retailOrderItemService.getById(order.getOrderId());
+                        retailOrderItem.setHasSendQty(retailOrderItem.getHasSendQty() + order.getRefundableQty());
 
-                    if (retailOrderItem.getQty() < retailOrderItem.getHasSendQty())
-                        throw new RemoteServiceException("出库数量大于了订单数量");
+                        if (retailOrderItem.getQty() < retailOrderItem.getHasSendQty())
+                            throw new RemoteServiceException("出库数量大于了订单数量");
 
-                    retailOrderItem.updateById();
-                    customerWalletId = retailOrderItem.getCustomerWalletId();
-                }
+                        retailOrderItem.updateById();
+                        customerWalletId = retailOrderItem.getCustomerWalletId();
+                    }
 
-                if (order.getOrderType().equals("TRADE") || order.getOrderType().equals("HOME")) {
-                    EnginOrderItem enginOrderItem = enginOrderItemService.getById(order.getOrderId());
-                    enginOrderItem.setHasSendQty(enginOrderItem.getHasSendQty() + order.getRefundableQty());
+                    if (order.getOrderType().equals("TRADE") || order.getOrderType().equals("HOME")) {
+                        EnginOrderItem enginOrderItem = enginOrderItemService.getById(order.getOrderId());
+                        enginOrderItem.setHasSendQty(enginOrderItem.getHasSendQty() + order.getRefundableQty());
 
-                    if (enginOrderItem.getQty() < enginOrderItem.getHasSendQty())
-                        throw new RemoteServiceException("出库数量大于了订单数量");
+                        if (enginOrderItem.getQty() < enginOrderItem.getHasSendQty())
+                            throw new RemoteServiceException("出库数量大于了订单数量");
 
 
-                    if (order.getOrderType().equals("TRADE")) {
-                        EnginInfoOrderItem one = enginInfoOrderItemService.lambdaQuery().eq(EnginInfoOrderItem::getEnginInfoNo, enginOrderItem.getRefEnginRecordNo())
-                                .eq(EnginInfoOrderItem::getSaleTypeId, enginOrderItem.getSaleTypeId())
-                                .eq(EnginInfoOrderItem::getMaterialNumber, enginOrderItem.getMaterialNumber())
-                                .one();
+                        if (order.getOrderType().equals("TRADE")) {
+                            EnginInfoOrderItem one = enginInfoOrderItemService.lambdaQuery().eq(EnginInfoOrderItem::getEnginInfoNo, enginOrderItem.getRefEnginRecordNo())
+                                    .eq(EnginInfoOrderItem::getSaleTypeId, enginOrderItem.getSaleTypeId())
+                                    .eq(EnginInfoOrderItem::getMaterialNumber, enginOrderItem.getMaterialNumber())
+                                    .one();
 
-                        if (one != null) {
-                            one.setHasDeliverQty(one.getHasDeliverQty() + order.getRefundableQty());
-                            one.updateById();
+                            if (one != null) {
+                                one.setHasDeliverQty(one.getHasDeliverQty() + order.getRefundableQty());
+                                one.updateById();
+                            }
                         }
-                    }
 
-                    enginOrderItem.updateById();
-                    customerWalletId = enginOrderItem.getCustomerWalletId();
-                }
+                        enginOrderItem.updateById();
+                        customerWalletId = enginOrderItem.getCustomerWalletId();
+                    }
 
                 } finally {
                     obtain.unlock();
@@ -363,12 +369,57 @@ public class SaleOrderLogic {
             salesOrder.setApprovalName(adminUser.getNickName());
             salesOrder.setApprovalTime(new Date());
             salesOrder.updateById();
+
+            this.addCustStock(detail);
         }
 
         invoiceMapper.updateStatus(salesOrder.getOrderNo());
         saleOrderMapper.updateInvoice(salesOrder.getId());
     }
 
+    private void addCustStock(SaleOrderBody detail) {
+        List<SalesOrderItem> salesOrderItems = salesOrderItemService.lambdaQuery().eq(SalesOrderItem::getSalesOrderNo, detail.getId()).list();
+        for (SalesOrderItem salesOrderItem : salesOrderItems) {
+
+
+            customerFrontLogic.stockAcc(true, Convert.toInt(salesOrderItem.getRefundableQty()), detail.getId(),
+                    "审批出库单增加商家库存", salesOrderItem.getMaterialId(), detail.getCustomerId(), detail.getRemark());
+
+
+            CustomerStock customerStock = customerStockService.lambdaQuery()
+                    .eq(CustomerStock::getCustomerId, detail.getCustomerId())
+                    .eq(CustomerStock::getMaterialCode, salesOrderItem.getMaterialCode())
+                    .last("limit 1").one();
+
+            if (customerStock != null) {
+
+                customerStock.setStockNum(customerStock.getStockNum().add(Convert.toBigDecimal(salesOrderItem.getRefundableQty())));
+                customerStock.updateById();
+            } else {
+
+
+                customerStock = new CustomerStock();
+                customerStock.setCustomerId(detail.getCustomerId());
+                customerStock.setCustomerName(detail.getCustomerName());
+                customerStock.setCustomerNumber(detail.getCustomerNumber());
+                customerStock.setMaterialCode(salesOrderItem.getMaterialCode());
+                customerStock.setMaterialId(salesOrderItem.getMaterialId());
+                customerStock.setMaterialName(salesOrderItem.getMaterialName());
+                customerStock.setMaterialOldNumber(salesOrderItem.getMaterialOldNumber());
+                customerStock.setSpecification(salesOrderItem.getSpecification());
+                customerStock.setCategoryId(salesOrderItem.getK3CategoryId());
+                customerStock.setCategoryName(salesOrderItem.getK3CategoryName());
+                customerStock.setCategoryNumber(salesOrderItem.getK3CategoryNumber());
+
+                customerStock.setStockNum(Convert.toBigDecimal(salesOrderItem.getRefundableQty()));
+                customerStock.insert();
+
+            }
+        }
+    }
+
+
+
 
     private void checkApproval(List<SaleOrderData> orders, String correspondId, String status) throws Exception {
         for (SaleOrderData order : orders) {
@@ -439,7 +490,7 @@ public class SaleOrderLogic {
      */
     public ExcelData export(List<SaleOrderBean> saleOrderBeanList) {
         String[] titles = new String[]{"状态", "打印时间", "发票号码", "出库单号", "发货单号", "订单号", "仓库",
-                "经销商编码", "经销商名称", "销售类型", "物料编码", "厂产品代码", "产品名称", "规格型号", "存货类别", "单位", "数量", "单价", "订单金额", "表头备注", "表体备注", "业务员", "表头业务员", "审核时间","金蝶部门"};
+                "经销商编码", "经销商名称", "销售类型", "物料编码", "厂产品代码", "产品名称", "规格型号", "存货类别", "单位", "数量", "单价", "订单金额", "表头备注", "表体备注", "业务员", "表头业务员", "审核时间", "金蝶部门"};
         List<List<Object>> rows = new ArrayList<>();
         for (SaleOrderBean saleOrderBean : saleOrderBeanList) {
             List<Object> row = new ArrayList<>();
@@ -594,7 +645,7 @@ public class SaleOrderLogic {
 
     public ExcelData exportChuKu(List<SaleOrderBean> records) {
         String[] titles = new String[]{"状态", "打印时间", "订单类型", "出库单号", "发货单号", "订单号", "仓库",
-                "经销商编码", "经销商名称", "物料编码", "厂产品代码", "产品名称", "规格型号", "存货类别", "单位", "审核人", "审核时间","数量","金蝶部门"};
+                "经销商编码", "经销商名称", "物料编码", "厂产品代码", "产品名称", "规格型号", "存货类别", "单位", "审核人", "审核时间", "数量", "金蝶部门"};
         List<List<Object>> rows = new ArrayList<>();
         for (SaleOrderBean saleOrderBean : records) {
             List<Object> row = new ArrayList<>();
@@ -628,19 +679,19 @@ public class SaleOrderLogic {
         return excelData;
     }
 
-    public IPage<StorageFeeBean> listStorageFee(List<String> categoryNum,String approvalStartTime, String approvalEndTime, String saleExamineStatus, String saleStartTime, String saleEndTime, String invoiceStartTime, String invoiceEndTime, String mainOrderId, List<String> id, List<String> orderNo, String materialNumber, String customerName,
+    public IPage<StorageFeeBean> listStorageFee(List<String> categoryNum, String approvalStartTime, String approvalEndTime, String saleExamineStatus, String saleStartTime, String saleEndTime, String invoiceStartTime, String invoiceEndTime, String mainOrderId, List<String> id, List<String> orderNo, String materialNumber, String customerName,
                                                 List<String> correspondId, String specification, String materialName, String customerNumber, String startTime, String endTime, Integer pageNum,
                                                 Integer pageSize) {
 
         AdminUserCom adminUser = commonLogic.getAdminUser();
         String customerId = adminUser.getIsCustomer() ? adminUser.getCustomerNumber() : customerNumber;
 
-        Integer count = saleOrderMapper.listStorageFeeCount(categoryNum,approvalStartTime, approvalEndTime,
+        Integer count = saleOrderMapper.listStorageFeeCount(categoryNum, approvalStartTime, approvalEndTime,
                 saleExamineStatus, saleStartTime, saleEndTime, invoiceStartTime, invoiceEndTime, mainOrderId, id, materialNumber, orderNo,
                 customerName, correspondId, specification, materialName, customerId, startTime, endTime, adminUser.getServiceIds(),
                 adminUser.getAdminUserId(), adminUser.getK3CategoryIds());
 
-        IPage<StorageFeeBean> list = saleOrderMapper.listStorageFee(new Page<>(pageNum, pageSize,false),categoryNum, approvalStartTime, approvalEndTime,
+        IPage<StorageFeeBean> list = saleOrderMapper.listStorageFee(new Page<>(pageNum, pageSize, false), categoryNum, approvalStartTime, approvalEndTime,
                 saleExamineStatus, saleStartTime, saleEndTime, invoiceStartTime, invoiceEndTime, mainOrderId, id, materialNumber, orderNo,
                 customerName, correspondId, specification, materialName, customerId, startTime, endTime, adminUser.getServiceIds(),
                 adminUser.getAdminUserId(), adminUser.getK3CategoryIds());
@@ -655,15 +706,15 @@ public class SaleOrderLogic {
         List<String> mainOrderIds = list.getRecords().stream().map(StorageFeeBean::getMainOrderId).collect(Collectors.toList());
 
         List<InvoiceApplicationOrder> listInvoice = invoiceApplicationOrderService.lambdaQuery()
-                .in(InvoiceApplicationOrder::getOrderId,collect1)
+                .in(InvoiceApplicationOrder::getOrderId, collect1)
                 .select(InvoiceApplicationOrder::getOrderId, InvoiceApplicationOrder::getRefundableQty).list();
 
         List<RetailOrder> retailOrderItems = retailOrderService.lambdaQuery()
-                .select(RetailOrder::getId,RetailOrder::getExamineTime)
+                .select(RetailOrder::getId, RetailOrder::getExamineTime)
                 .in(RetailOrder::getId, mainOrderIds).list();
 
         List<EnginOrder> enginOrderList = enginOrderService.lambdaQuery()
-                .select(EnginOrder::getEnginOrderNo,EnginOrder::getConfirmTime,EnginOrder::getRefUseUnit)
+                .select(EnginOrder::getEnginOrderNo, EnginOrder::getConfirmTime, EnginOrder::getRefUseUnit)
                 .in(EnginOrder::getEnginOrderNo, mainOrderIds).list();
 
         for (StorageFeeBean record : list.getRecords()) {
@@ -679,17 +730,16 @@ public class SaleOrderLogic {
                     .filter(item -> item.getEnginOrderNo().equals(record.getMainOrderId()))
                     .collect(Collectors.toList());
 
-            if (!CollectionUtils.isEmpty(retailOrderList)){
+            if (!CollectionUtils.isEmpty(retailOrderList)) {
                 RetailOrder retailOrder = retailOrderList.get(0);
-                record.setExamineTime(DateUtil.format(retailOrder.getExamineTime(),"yyyy-MM-dd HH:mm:ss"));
-            }else {
+                record.setExamineTime(DateUtil.format(retailOrder.getExamineTime(), "yyyy-MM-dd HH:mm:ss"));
+            } else {
                 EnginOrder enginOrder = enginOrders.get(0);
-                record.setExamineTime(DateUtil.format(enginOrder.getConfirmTime(),"yyyy-MM-dd HH:mm:ss"));
+                record.setExamineTime(DateUtil.format(enginOrder.getConfirmTime(), "yyyy-MM-dd HH:mm:ss"));
                 record.setRefUseUnit(enginOrder.getRefUseUnit());
             }
 
 
-
             record.setSendQty(record.getQty() - collect.stream().mapToInt(InvoiceApplicationOrder::getRefundableQty).sum());
 
             /*
@@ -712,11 +762,11 @@ public class SaleOrderLogic {
             record.setEndCalculationTime(record.getSalesApprovalTime());
             if (record.getEndCalculationTime() == null || StringUtils.isEmpty(record.getSalesExamineStatus()) || !record.getSalesExamineStatus().equals(ExamineStatusEnum.OK.toString()))
                 continue;
-            if ( DateUtil.parse(DateUtil.format(record.getStartCalculationTime(), "yyyy-MM-dd"))
-                    .compareTo(DateUtil.parse(DateUtil.format(record.getEndCalculationTime(), "yyyy-MM-dd"),"yyyy-MM-dd")) > 0 )
+            if (DateUtil.parse(DateUtil.format(record.getStartCalculationTime(), "yyyy-MM-dd"))
+                    .compareTo(DateUtil.parse(DateUtil.format(record.getEndCalculationTime(), "yyyy-MM-dd"), "yyyy-MM-dd")) > 0)
                 continue;
-            record.setCalculationDays(Convert.toInt(DateUtil.between( DateUtil.parse(DateUtil.format(record.getStartCalculationTime(), "yyyy-MM-dd"),"yyyy-MM-dd")
-                    , DateUtil.parse(DateUtil.format(record.getEndCalculationTime(), "yyyy-MM-dd"),"yyyy-MM-dd"), DateUnit.DAY)) + 1);
+            record.setCalculationDays(Convert.toInt(DateUtil.between(DateUtil.parse(DateUtil.format(record.getStartCalculationTime(), "yyyy-MM-dd"), "yyyy-MM-dd")
+                    , DateUtil.parse(DateUtil.format(record.getEndCalculationTime(), "yyyy-MM-dd"), "yyyy-MM-dd"), DateUnit.DAY)) + 1);
             if (record.getCalculationDays() > 0) {
                 record.setWarehouseRent((record.getCalculationDays() < 15 ?
                         record.getShipmentAmount().multiply(Constant.STORAGE_FEE_ONE) : record.getShipmentAmount().multiply(Constant.STORAGE_FEE_TWO))
@@ -728,10 +778,10 @@ public class SaleOrderLogic {
     }
 
     public ExcelData listStorageFeeExport(List<StorageFeeBean> records) {
-        String[] titles = new String[]{"订单类型", "订单号", "订单日期", "订单审核时间", "预留单日期", "预留单号", "发货单号","使用单位",
+        String[] titles = new String[]{"订单类型", "订单号", "订单日期", "订单审核时间", "预留单日期", "预留单号", "发货单号", "使用单位",
                 "发货单日期", "发货单审核时间", "出库状态", "出库审核时间", "出库审核人", "仓库", "客户编码", "客户名称",
-                "存货编码", "规格型号", "订单数量", "价税合计", "返利金额","格力折扣额", "合计", "发货数量", "钱包", "钱包对应业务", "金蝶部门", "发货金额", "起算日期", "结算日期",
-                "计算天数", "仓租金额","存货类别"};
+                "存货编码", "规格型号", "订单数量", "价税合计", "返利金额", "格力折扣额", "合计", "发货数量", "钱包", "钱包对应业务", "金蝶部门", "发货金额", "起算日期", "结算日期",
+                "计算天数", "仓租金额", "存货类别"};
         List<List<Object>> rows = new ArrayList<>();
         for (StorageFeeBean storageFeeBean : records) {
             List<Object> row = new ArrayList<>();
@@ -739,7 +789,7 @@ public class SaleOrderLogic {
             row.add(storageFeeBean.getMainOrderId());
             row.add(storageFeeBean.getTheTime());
             row.add(storageFeeBean.getExamineTime());
-             row.add(DateUtil.format(storageFeeBean.getReservedCreateTime(),"yyyy-MM-dd HH:mm:ss"));
+            row.add(DateUtil.format(storageFeeBean.getReservedCreateTime(), "yyyy-MM-dd HH:mm:ss"));
             row.add(storageFeeBean.getReservedId());
             row.add(storageFeeBean.getInvoiceId());
             row.add(storageFeeBean.getRefUseUnit());
@@ -1218,29 +1268,29 @@ public class SaleOrderLogic {
                         purchaseInStockBean.setSupplier(InvoiceCustomerEnum.GEJIANG_FOSHAN_SUPPLIER.getCode());
 
                         //芦苞佛山
-                     if (invoiceApplication.getCorrespondName().equals(InvoiceCustomerEnum.GEJIANG_LUBAOFOSHAN_STOCK.getCode())) {
-                        purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_LUBAO_NUMBER.getCode());
-                        //三水佛山
-                    } else if (invoiceApplication.getCorrespondName().equals(InvoiceCustomerEnum.GEJIANG_SANSHUIFOSHAN_STOCK.getCode())) {
-                        purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_SANSHUI_NUMBER.getCode());
-                        //三水珠海佛山
-                    } else if (invoiceApplication.getCorrespondName().equals(InvoiceCustomerEnum.GEJIANG_SHANSHUIZHUHAIFOSHAN_STOCK.getCode())) {
-                        purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_SANSHUI_NUMBER.getCode());
-                         //三水珠海仓
-                     } else if (invoiceApplication.getCorrespondName().equals(InvoiceCustomerEnum.GEJIANG_SANSHUIFOSHANZHUHAI_STOCK.getCode())) {
-                         purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_SANSHUI_NUMBER.getCode());
-                        //芦苞仓
-                     } else if (invoiceApplication.getCorrespondName().equals(InvoiceCustomerEnum.GEJIANG_LUBAO_STOCK.getCode())) {
-                         purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_LUBAO_NUMBER.getCode());
-
-                     } else if (invoiceApplication.getCorrespondName().equals("三水仓")) {
-                         purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_SANSHUI_NUMBER.getCode());
-                     } else if (invoiceApplication.getCorrespondName().equals("虚拟仓")) {
-                         purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_LUBAO_NUMBER.getCode());
-                     }else {
-
-                        purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_LUBAO_NUMBER.getCode());
-                    }
+                        if (invoiceApplication.getCorrespondName().equals(InvoiceCustomerEnum.GEJIANG_LUBAOFOSHAN_STOCK.getCode())) {
+                            purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_LUBAO_NUMBER.getCode());
+                            //三水佛山
+                        } else if (invoiceApplication.getCorrespondName().equals(InvoiceCustomerEnum.GEJIANG_SANSHUIFOSHAN_STOCK.getCode())) {
+                            purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_SANSHUI_NUMBER.getCode());
+                            //三水珠海佛山
+                        } else if (invoiceApplication.getCorrespondName().equals(InvoiceCustomerEnum.GEJIANG_SHANSHUIZHUHAIFOSHAN_STOCK.getCode())) {
+                            purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_SANSHUI_NUMBER.getCode());
+                            //三水珠海仓
+                        } else if (invoiceApplication.getCorrespondName().equals(InvoiceCustomerEnum.GEJIANG_SANSHUIFOSHANZHUHAI_STOCK.getCode())) {
+                            purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_SANSHUI_NUMBER.getCode());
+                            //芦苞仓
+                        } else if (invoiceApplication.getCorrespondName().equals(InvoiceCustomerEnum.GEJIANG_LUBAO_STOCK.getCode())) {
+                            purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_LUBAO_NUMBER.getCode());
+
+                        } else if (invoiceApplication.getCorrespondName().equals("三水仓")) {
+                            purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_SANSHUI_NUMBER.getCode());
+                        } else if (invoiceApplication.getCorrespondName().equals("虚拟仓")) {
+                            purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_LUBAO_NUMBER.getCode());
+                        } else {
+
+                            purchaseInStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_LUBAO_NUMBER.getCode());
+                        }
 
                     }
                     purchaseInStockBean.setDate(DateUtil.formatDate(invoiceApplication.getCreateTime()));
@@ -1307,7 +1357,7 @@ public class SaleOrderLogic {
                     invoiceApplication.setGejiangSync(1);
                     invoiceApplication.setGejiangSyncRemark(null);
                     invoiceApplication.updateById();
-                } else{
+                } else {
 
                     List<InvoiceApplicationOrder> invoiceApplicationOrders = invoiceApplicationOrderService.lambdaQuery().eq(InvoiceApplicationOrder::getInvoiceId, invoiceApplicationSyncGejiang.getInvoiceId()).list();
                     InvoiceApplication invoiceApplication = invoiceApplicationService.getById(invoiceApplicationSyncGejiang.getInvoiceId());
@@ -1317,8 +1367,8 @@ public class SaleOrderLogic {
 
                     SalesOrder salesOrderOne = salesOrderService.getById(salesOrder.getSalesOrderNo());
 
-                    if (salesOrderOne != null){
-                         correspondName = salesOrderOne.getCorrespondName();
+                    if (salesOrderOne != null) {
+                        correspondName = salesOrderOne.getCorrespondName();
                     }
 
                     PurchaseOutStockBean purchaseOutStockBean = new PurchaseOutStockBean();
@@ -1391,7 +1441,7 @@ public class SaleOrderLogic {
                             purchaseOutStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_SANSHUI_NUMBER.getCode());
                         } else if (invoiceApplication.getCorrespondName().equals("虚拟仓")) {
                             purchaseOutStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_LUBAO_NUMBER.getCode());
-                        }else {
+                        } else {
 
                             purchaseOutStockBean.setStock(InvoiceCustomerEnum.GEJIANG_GUANGZHOU_STOCK_LUBAO_NUMBER.getCode());
                         }
@@ -1430,7 +1480,7 @@ public class SaleOrderLogic {
                             k3Item.setPriceUnit(objects.get(0).getBaseUnitCode());
                             k3Item.setRemainInStockUnit(objects.get(0).getBaseUnitCode());
                             k3Item.setStock(purchaseOutStockBean.getStock());
-                            k3Item.setFRmrealqty(new BigDecimal(item.getRefundableQty()*-1));
+                            k3Item.setFRmrealqty(new BigDecimal(item.getRefundableQty() * -1));
                             k3Item.setPrice(item.getSinglePayPrice().divide(new BigDecimal("1.13"), 6, BigDecimal.ROUND_HALF_UP).setScale(6, BigDecimal.ROUND_UP));
                             k3Item.setFTaxPrice(item.getSinglePayPrice());
                             k3Item.setFAllAmount(item.getPayAmount());
@@ -1752,14 +1802,13 @@ public class SaleOrderLogic {
                 .stream().map(AdminUserStock::getCorrespondId).distinct().collect(Collectors.toList());
 
 
-
         zfireParamBean = FieldUtils.supplyParam(zfireParamBean);
 
 
         Integer count = saleOrderMapper.listCountV2(zfireParamBean, customerId, adminUser.getServiceIds(), collect, adminUser.getK3CategoryIds());
 
 
-        IPage<SaleOrderVO> stockBeanToDayIPage = saleOrderMapper.listV2(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize(),count,false), zfireParamBean
+        IPage<SaleOrderVO> stockBeanToDayIPage = saleOrderMapper.listV2(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize(), count, false), zfireParamBean
                 , customerId, adminUser.getServiceIds(), collect, adminUser.getK3CategoryIds());
 
         return stockBeanToDayIPage;
@@ -1773,14 +1822,13 @@ public class SaleOrderLogic {
                 .stream().map(AdminUserStock::getCorrespondId).distinct().collect(Collectors.toList());
 
 
-
         zfireParamBean = FieldUtils.supplyParam(zfireParamBean);
 
 
         Integer count = saleOrderMapper.listCountV2(zfireParamBean, customerId, adminUser.getServiceIds(), collect, adminUser.getK3CategoryIds());
 
 
-        IPage<SaleOrderVOV> stockBeanToDayIPage = saleOrderMapper.listV3(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize(),count,false), zfireParamBean
+        IPage<SaleOrderVOV> stockBeanToDayIPage = saleOrderMapper.listV3(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize(), count, false), zfireParamBean
                 , customerId, adminUser.getServiceIds(), collect, adminUser.getK3CategoryIds());
 
         return stockBeanToDayIPage;

+ 2 - 46
src/main/resources/mapper/CustomerFrontOrderMapper.xml

@@ -4,55 +4,11 @@
 
     <select id="list" resultType="com.zfire.mall.manager.bean.front.CustomerOrderBean">
 		SELECT
-		co.id,
-		co.`status`,
-		co.order_time,
-		co.pick_time,
-		co.customer_id,
-		co.customer_name,
-		co.customer_number,
-		co.user_name,
-		co.phone,
-		co.province,
-		co.city,
-		co.area,
-		co.street,
-		co.rece_address,
-		co.jiaxian_order_id,
-		co.sync_status,
-		co.stock_type,
-		IF(co.stock_type = 1,'前置仓','商家仓') as stock_type_name,
-		coi.material_id,
-		coi.material_old_number,
-		coi.material_code,
-		coi.material_name,
-		coi.specification,
-		coi.qty,
-		coi.refund_qty,
-		coi.qty- coi.real_qty as refund_order_qty,
-		co.notes,
-		co.create_by,
-		co.create_time,
-		cs.front_stock_num as stock_qty,
-		cs.customer_stock_num as customer_stock_qty,
-		co.gong_dan_id,
-		co.pgid,
-		co.sales_number,
-		co.sales_wname,
-		co.install_number,
-		co.install_name,
-		co.order_state,
-		co.appoint_state,
-		co.worker_name,
-		co.worker_number,
-		co.worker_phone,
-		co.admin_officer_id,
-		co.admin_officer_name,
-		co.admin_officer_number
+		co.*,
+		coi.*
 		FROM
 		customer_order co
 		JOIN customer_order_item coi ON co.id = coi.order_id
-		join customer_stock cs on coi.material_id = cs.material_id and co.customer_id = cs.customer_id
 		${ex.query}
 		<if test="customers != null and customers.size > 0">
 		and co.customer_number in