FengChaoYu vor 7 Monaten
Ursprung
Commit
0ceffe7d98
22 geänderte Dateien mit 576 neuen und 76 gelöschten Zeilen
  1. 161 0
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/bean/material/stock/WebsitStockDTO.java
  2. 10 1
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/commonmapper/stock/MaterialGoodsStockCMapper.java
  3. 7 7
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/material/WorkerStockController.java
  4. 21 0
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/enums/material/BuyPeopleEnum.java
  5. 27 0
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/enums/material/DeliveryTypeEnum.java
  6. 17 11
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/enums/material/PartsAttrEnum.java
  7. 4 4
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/parts/NewRefundManageLogic.java
  8. 125 5
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/parts/WebsitPartsSalesOrderLogic.java
  9. 132 10
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/stock/MaterialGoodsStockLogic.java
  10. 4 4
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/order/PayOrderLogic.java
  11. 23 1
      mall-miniapp-service/src/main/resources/mapper/WorkerStockCMapper.xml
  12. 6 0
      mall-server-api/src/main/java/com/gree/mall/manager/bean/material/stock/WebsitStockDTO.java
  13. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/MaterialGoodsStockCMapper.java
  14. 8 4
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebitPartsOldStockLogic.java
  15. 5 5
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/MaterialGoodsStockLogic.java
  16. 7 5
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WebitPurchaseStockLogic.java
  17. 2 2
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WebitSalesStockLogic.java
  18. 2 2
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WorkSalesStockLogic.java
  19. 2 2
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WorkerStockLogic.java
  20. 7 7
      mall-server-api/src/main/java/com/gree/mall/manager/logic/websit/WebsitPartsRetLogic.java
  21. 4 4
      mall-server-api/src/main/java/com/gree/mall/manager/logic/websit/WebsitSalesRetLogic.java
  22. 1 1
      mall-server-api/src/main/resources/mapper/MaterialGoodsStockCMapper.xml

+ 161 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/bean/material/stock/WebsitStockDTO.java

@@ -0,0 +1,161 @@
+package com.gree.mall.miniapp.bean.material.stock;
+
+import com.gree.mall.miniapp.enums.material.DirectFlagEnum;
+import com.gree.mall.miniapp.enums.material.PartsAttrEnum;
+import com.gree.mall.miniapp.exception.RemoteServiceException;
+import com.gree.mall.miniapp.plus.entity.WebsitStock;
+import com.gree.mall.miniapp.plus.entity.WebsitStockAcc;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Objects;
+
+@Data
+@ApiModel
+public class WebsitStockDTO {
+
+    @ApiModelProperty("商户编号")
+    @NotBlank(message = "商户编号不能空")
+    private String companyWechatId;
+
+    @ApiModelProperty("商户名称")
+    @NotBlank(message = "商户名称不能空")
+    private String companyWechatName;
+
+    @ApiModelProperty("网点编号")
+    @NotBlank(message = "网点编号不能空")
+    private String websitId;
+
+    @ApiModelProperty("网点名称")
+    @NotBlank(message = "网点名称不能空")
+    private String websitName;
+
+    @ApiModelProperty("配件网点编号")
+    private String partsWebsitId;
+
+    @ApiModelProperty("发生时间")
+    @NotNull(message = "发生时间不能空")
+    private Date sdate;
+
+    @ApiModelProperty("商品类型")
+    @NotNull(message = "商品类型不能空")
+    private String goodsType;
+
+    @ApiModelProperty("配件属性 NEW=新件 OLD=旧件")
+    private String partsAttr;
+
+    @ApiModelProperty("商品编码")
+    @NotBlank(message = "商品编码不能空")
+    private String goodsId;
+
+    @ApiModelProperty("商品名称")
+    @NotBlank(message = "商品名称不能空")
+    private String goodsName;
+
+    @ApiModelProperty("发生单价")
+    private BigDecimal price;
+
+    @ApiModelProperty("相关单号")
+    @NotBlank(message = "相关单号不能空")
+    private String ref;
+
+    @ApiModelProperty("相关单据类型")
+    @NotBlank(message = "相关单据类型不能空")
+    private String refType;
+
+    @ApiModelProperty("变动数量")
+    @NotNull(message = "变动数量不能空")
+    private BigDecimal changeQty;
+
+    @ApiModelProperty("发生方向 ADD=增加 SUB=减少")
+    @NotBlank(message = "发生方向不能空")
+    private String directFlag;
+
+    @ApiModelProperty("备注")
+    private String remark;
+
+    @ApiModelProperty("业务对象")
+    private String obj;
+
+    @ApiModelProperty("操作人")
+    @NotBlank(message = "操作人不能空")
+    private String operateBy;
+
+    @ApiModelProperty("操作时间")
+    @NotNull(message = "操作时间不能空")
+    private Date operateTime;
+
+    @ApiModelProperty(value = "仓储id")
+    @NotNull(message = "仓位不能空")
+    private String storageId;
+
+    @ApiModelProperty("采购订单号")
+    private String purchaseId;
+
+    @ApiModelProperty(value = "凭证号")
+    private String voucherNo;
+
+    @ApiModelProperty(value = "申请单号")
+    private String applyNo;
+
+    @ApiModelProperty(value = "物料组名称")
+    private String materialGroupName;
+
+    @ApiModelProperty(value = "单位")
+    private String goodsStockUnit;
+
+    public WebsitStock createPartsStock() {
+        WebsitStock websitStock = new WebsitStock();
+        BeanUtils.copyProperties(this, websitStock);
+        websitStock.setId(null)
+                .setLastCost(BigDecimal.ZERO)
+                .setGoodsType(this.getGoodsType())
+                .setQty(BigDecimal.ZERO)
+                .setOldQty(BigDecimal.ZERO)
+                .setCreateBy(this.operateBy)
+                .setCreateTime(this.operateTime);
+        return websitStock;
+    }
+
+    public void computeWebsitStock(WebsitStock websitStock, WebsitStockAcc websitStockAcc) {
+        BigDecimal qty = websitStock.getQty();
+        if (StringUtils.isNotBlank(this.partsAttr) && this.partsAttr.equals(PartsAttrEnum.OLD.getKey())) {
+            qty = websitStock.getOldQty();
+        }
+        if (Objects.isNull(this.directFlag)) {
+            throw new RemoteServiceException("发生方向不符");
+        }
+        BigDecimal direct = this.directFlag.equals(DirectFlagEnum.ADD.getKey()) ? BigDecimal.ONE : new BigDecimal("-1");
+        BigDecimal closeQty = qty.add(this.changeQty.multiply(direct));
+        if (closeQty.compareTo(BigDecimal.ZERO) < 0 && direct.compareTo(BigDecimal.ZERO) < 0 && !this.getRefType().equals("销售订单")) {
+            throw new RemoteServiceException("\""+ websitStock.getGoodsName() + "\"商品库存不允许为负");
+        }
+        // 注入三级帐
+        BeanUtils.copyProperties(this, websitStockAcc);
+        websitStockAcc.setWebsitId(this.websitId)
+                .setWebsitName(this.websitName)
+                .setPartsWebsitId(this.partsWebsitId)
+                .setQty(qty)
+                .setCloseQty(closeQty)
+                .setOperateBy(this.operateBy)
+                .setOperateTime(this.operateTime)
+                .setStorageId(this.storageId);
+        // 注入库存
+        if (this.partsAttr.equals(PartsAttrEnum.NEW.getKey())) {
+            websitStock.setQty(closeQty);
+        } else if (this.partsAttr.equals(PartsAttrEnum.OLD.getKey())) {
+            websitStock.setOldQty(closeQty);
+        } else {
+            throw new RemoteServiceException("配件属性异常");
+        }
+        websitStock.setUpdateBy(this.operateBy)
+                .setUpdateTime(this.operateTime);
+    }
+}

+ 10 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/commonmapper/stock/WorkerStockCMapper.java → mall-miniapp-service/src/main/java/com/gree/mall/miniapp/commonmapper/stock/MaterialGoodsStockCMapper.java

@@ -2,9 +2,11 @@ package com.gree.mall.miniapp.commonmapper.stock;
 
 import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gree.mall.miniapp.bean.material.stock.WebsitStockDTO;
 import com.gree.mall.miniapp.bean.material.stock.WorkerStockBean;
 import com.gree.mall.miniapp.bean.material.stock.WorkerStockDTO;
 import com.gree.mall.miniapp.plus.entity.WebsitGoodsCategory;
+import com.gree.mall.miniapp.plus.entity.WebsitStock;
 import com.gree.mall.miniapp.plus.entity.WorkerStock;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -12,7 +14,7 @@ import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
 @Mapper
-public interface WorkerStockCMapper {
+public interface MaterialGoodsStockCMapper {
 
 
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
@@ -30,6 +32,13 @@ public interface WorkerStockCMapper {
             @Param("goodsType") String goodsType,
             @Param("categoryId") String categoryId
     );
+
+    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
+    List<WebsitStock> queryExistWebsitStockList(@Param("companyWechatId") String companyWechatId,
+                                                @Param("websitId") String websitId,
+                                                @Param("storageId") String storageId,
+                                                @Param("stockList") List<WebsitStockDTO> stockList);
+
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     List<WorkerStock> queryExistWorkerStockList(@Param("companyWechatId") String companyWechatId,
                                                 @Param("workerId") String workerId,

+ 7 - 7
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/material/WorkerStockController.java

@@ -6,7 +6,7 @@ import com.gree.mall.miniapp.bean.material.stock.WorkerStockAccBean;
 import com.gree.mall.miniapp.bean.material.stock.WorkerStockBean;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.helper.ResponseHelper;
-import com.gree.mall.miniapp.logic.material.stock.WorkerStockLogic;
+import com.gree.mall.miniapp.logic.material.stock.MaterialGoodsStockLogic;
 import com.gree.mall.miniapp.plus.entity.WebsitGoodsCategory;
 import com.gree.mall.miniapp.plus.entity.WorkerStock;
 import io.swagger.annotations.Api;
@@ -28,14 +28,14 @@ import java.util.List;
 public class WorkerStockController {
 
     @Autowired
-    WorkerStockLogic workerStockLogic;
+    MaterialGoodsStockLogic materialGoodsStockLogic;
 
     @PostMapping("/detail")
     @ApiOperation(value = "库存明细表头详情")
     public ResponseHelper<WorkerStock> detail(
             @RequestParam String id
     ) throws RemoteServiceException {
-        WorkerStock detail = workerStockLogic.detail(id);
+        WorkerStock detail = materialGoodsStockLogic.detail(id);
         return ResponseHelper.success(detail);
     }
 
@@ -45,7 +45,7 @@ public class WorkerStockController {
             @ApiParam(value = "网点id",required = false) @RequestParam(required = false) String websitId,
             @ApiParam(value = "M=辅材 P=配件",required = true) @RequestParam String goodsType
     ) throws RemoteServiceException {
-        List<WebsitGoodsCategory> categoryList = workerStockLogic.websitGoodsCategoryList(websitId, goodsType);
+        List<WebsitGoodsCategory> categoryList = materialGoodsStockLogic.websitGoodsCategoryList(websitId, goodsType);
         return ResponseHelper.success(categoryList);
     }
 
@@ -58,7 +58,7 @@ public class WorkerStockController {
             @ApiParam(value = "页号",required = false) @RequestParam Integer pageNum,
             @ApiParam(value = "页大小",required = false) @RequestParam Integer pageSize
     ) throws RemoteServiceException {
-        IPage<WorkerStockBean> workerStockBeanIPage = workerStockLogic.workerStockList(websitId, goodsType, categoryId, pageNum, pageSize);
+        IPage<WorkerStockBean> workerStockBeanIPage = materialGoodsStockLogic.workerStockList(websitId, goodsType, categoryId, pageNum, pageSize);
         return ResponseHelper.success(workerStockBeanIPage);
     }
 
@@ -73,14 +73,14 @@ public class WorkerStockController {
             @ApiParam(value = "页号",required = false) @RequestParam Integer pageNum,
             @ApiParam(value = "页大小",required = false) @RequestParam Integer pageSize
     ) throws RemoteServiceException {
-        IPage<WorkerStockAccBean> workerStockAccIPage = workerStockLogic.workerStockAccList(websitId, websitGoodsId, month, directFlag,pageNum, pageSize);
+        IPage<WorkerStockAccBean> workerStockAccIPage = materialGoodsStockLogic.workerStockAccList(websitId, websitGoodsId, month, directFlag,pageNum, pageSize);
         return ResponseHelper.success(workerStockAccIPage);
     }
 
     @PostMapping("/my/data/count")
     @ApiOperation(value = "我的数据统计")
     public ResponseHelper<MyDataCountBean> myDataCount() throws RemoteServiceException {
-        MyDataCountBean bean = workerStockLogic.myDataCount();
+        MyDataCountBean bean = materialGoodsStockLogic.myDataCount();
         return ResponseHelper.success(bean);
     }
 

+ 21 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/enums/material/BuyPeopleEnum.java

@@ -0,0 +1,21 @@
+package com.gree.mall.miniapp.enums.material;
+
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.gree.mall.miniapp.enums.base.BaseEnum;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+@Getter
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public enum BuyPeopleEnum implements BaseEnum {
+    WORKER("WORKER","内部师傅"),
+    CUSTOMER("CUSTOMER","客户");
+
+    @EnumValue
+    @JsonValue
+    private final String key;
+
+    private final String remark;
+}

+ 27 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/enums/material/DeliveryTypeEnum.java

@@ -0,0 +1,27 @@
+package com.gree.mall.miniapp.enums.material;
+
+
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.baomidou.mybatisplus.annotation.IEnum;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.gree.mall.miniapp.enums.base.BaseEnum;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+@Getter
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public enum DeliveryTypeEnum implements BaseEnum, IEnum<Integer> {
+    EXPRESS("0","快递"),
+    SELF("1","自提"),;
+
+    @EnumValue
+    @JsonValue
+    private final String key;
+    private final String remark;
+
+    @Override
+    public Integer getValue() {
+        return Integer.parseInt(key);
+    }
+}

+ 17 - 11
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/enums/material/PartsAttrEnum.java

@@ -1,19 +1,25 @@
 package com.gree.mall.miniapp.enums.material;
 
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.gree.mall.miniapp.enums.base.BaseEnum;
+import lombok.AccessLevel;
 import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 
 @Getter
-public enum PartsAttrEnum {
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public enum PartsAttrEnum implements BaseEnum {
 
-    NEW("新件"),
-    OLD("旧件"),
-    WAY("在途"),
-    TEMP_NEW("临占新件"),
-    TEMP_OLD("临占旧件"),
-    CHANGE_NEW("转销售新件"),;
+    NEW("NEW", "新件"),
+    OLD("OLD", "旧件"),
+    WAY("WAY", "在途"),
+    TEMP_NEW("TEMP_NEW", "临占新件"),
+    TEMP_OLD("TEMP_OLD", "临占旧件"),
+    CHANGE_NEW("CHANGE_NEW", "转销售新件"),;
 
-    PartsAttrEnum(String name) {
-        this.name = name;
-    }
-    private final String name;
+    @EnumValue
+    @JsonValue
+    private final String key;
+    private final String remark;
 }

+ 4 - 4
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/parts/NewRefundManageLogic.java

@@ -16,7 +16,7 @@ import com.gree.mall.miniapp.enums.admin.AdminWebsitTypeEnum;
 import com.gree.mall.miniapp.enums.material.*;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.logic.common.CommonLogic;
-import com.gree.mall.miniapp.logic.material.stock.WorkerStockLogic;
+import com.gree.mall.miniapp.logic.material.stock.MaterialGoodsStockLogic;
 import com.gree.mall.miniapp.plus.entity.*;
 import com.gree.mall.miniapp.plus.service.AdminWebsitService;
 import com.gree.mall.miniapp.plus.service.WebsitPartsNewRefundManageItemService;
@@ -51,7 +51,7 @@ public class NewRefundManageLogic {
     @Resource
     WebsitPartsNewRefundManageRecordService websitPartsNewRefundManageRecordService;
     @Resource
-    WorkerStockLogic workerStockLogic;
+    MaterialGoodsStockLogic materialGoodsStockLogic;
 
     public IPage<NewRefundManageBean> appList(String applyNo, String flag, String identity, String partsNumber, Integer pageNo, Integer pageSize) {
         IPage<NewRefundManageBean> page = materialMapper.appList(new Page(pageNo, pageSize), applyNo, flag, identity, partsNumber);
@@ -128,10 +128,10 @@ public class NewRefundManageLogic {
         // 提交 暂扣师傅新件库存 增加师傅临占新件库存
         List<WorkerStockDTO> workerStockDTOList = this.createWorkerStockDTO(partsNewRefundManage, partsNewRefundManageItems,
                 partsNewRefundManage.getWorkerName(), partsNewRefundManage.getUpdateTime(), PartsAttrEnum.NEW.toString(), PartsAttrEnum.TEMP_NEW.toString());
-        workerStockLogic.handleWorkerStock(workerStockDTOList);
+        materialGoodsStockLogic.handleWorkerStock(workerStockDTOList);
 
         // 查找销售单并减掉相应数量
-        List<PartsRefundRecordDTO> partsRefundRecordDTOList = workerStockLogic.handleNewRefundWebsitPartsSales(partsNewRefundManage.getReceiveWebsitId(), partsNewRefundManage.getReceivePartsWebsitId(),
+        List<PartsRefundRecordDTO> partsRefundRecordDTOList = materialGoodsStockLogic.handleNewRefundWebsitPartsSales(partsNewRefundManage.getReceiveWebsitId(), partsNewRefundManage.getReceivePartsWebsitId(),
                 partsNewRefundManage.getIdentity(), partsNewRefundManageItems, PartsRefTypeEnum.NEW_REFUND.getKey());
         List<WebsitPartsNewRefundManageRecord> partsNewRefundManageRecordList = new ArrayList<>();
         BigDecimal refundAmount = BigDecimal.ZERO;

+ 125 - 5
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/parts/WebsitPartsSalesOrderLogic.java

@@ -1,20 +1,27 @@
 package com.gree.mall.miniapp.logic.material.parts;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateUtil;
 import com.gree.mall.miniapp.bean.material.WebsitPartsSalesBean;
 import com.gree.mall.miniapp.bean.material.WebsitPartsSalesItemBean;
-import com.gree.mall.miniapp.enums.material.PartsOrderStatusEnum;
-import com.gree.mall.miniapp.enums.material.PartsPayFlagEnum;
+import com.gree.mall.miniapp.bean.material.stock.WebsitStockDTO;
+import com.gree.mall.miniapp.bean.material.stock.WorkerStockDTO;
+import com.gree.mall.miniapp.enums.material.*;
+import com.gree.mall.miniapp.logic.material.stock.MaterialGoodsStockLogic;
 import com.gree.mall.miniapp.plus.entity.WebsitPartsSales;
 import com.gree.mall.miniapp.plus.entity.WebsitPartsSalesItem;
 import com.gree.mall.miniapp.plus.entity.WebsitSalesPayOrder;
 import com.gree.mall.miniapp.plus.service.WebsitPartsSalesItemService;
 import com.gree.mall.miniapp.plus.service.WebsitPartsSalesService;
+import io.jsonwebtoken.lang.Collections;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 @Service
@@ -25,8 +32,10 @@ public class WebsitPartsSalesOrderLogic {
     WebsitPartsSalesService websitPartsSalesService;
     @Resource
     WebsitPartsSalesItemService websitPartsSalesItemService;
+    @Resource
+    MaterialGoodsStockLogic materialGoodsStockLogic;
 
-    public void handlePaySuccessMethod(WebsitSalesPayOrder order) {
+    public void handlePaySuccessMethod(WebsitSalesPayOrder order) throws Exception {
         // 更新配件销售单状态为已支付
         WebsitPartsSales partsSalesOrder = websitPartsSalesService.lambdaQuery()
                 .eq(WebsitPartsSales::getId, order.getOrderId())
@@ -53,11 +62,122 @@ public class WebsitPartsSalesOrderLogic {
                 List<WebsitPartsSalesItemBean> partsSalesOrderItemBeanList = BeanUtil.copyToList(partsSalesOrderItems, WebsitPartsSalesItemBean.class);
 
                 partsSalesOrderBean.setItemList(partsSalesOrderItemBeanList);
-// TODO 补充逻辑
-//                this.handleForwardShopAndWorkerStock(partsSalesOrderBean);
+
+                this.handleForwardShopAndWorkerStock(partsSalesOrderBean);
             }
 
             partsSalesOrder.updateById();
         }
     }
+
+    private void handleForwardShopAndWorkerStock(WebsitPartsSalesBean partsSalesOrderBean) throws Exception {
+        // 扣减网点库存
+        List<WebsitStockDTO> websitStockDTOList = this.getWebsitStock(partsSalesOrderBean, DirectFlagEnum.SUB);
+        materialGoodsStockLogic.handleWebsitStock(websitStockDTOList);
+
+        if (DeliveryTypeEnum.EXPRESS.getValue().equals(partsSalesOrderBean.getDeliveryType())
+                && BuyPeopleEnum.WORKER.getKey().equals(partsSalesOrderBean.getBuyPeople())) {
+            // 如果是快递并且销售类型为“服务人员”的单,需要增加师傅在途库存
+            // 增加师傅在途库存
+            List<WorkerStockDTO> workerStockDTOList = this.getWorkerStock(partsSalesOrderBean,
+                    PartsRefTypeEnum.SALES.toString(), null, PartsAttrEnum.WAY.toString());
+
+            materialGoodsStockLogic.handleWorkerStock(workerStockDTOList);
+        }
+    }
+
+    public List<WebsitStockDTO> getWebsitStock(WebsitPartsSalesBean partsSalesOrderBean, DirectFlagEnum directFlag){
+        if(Collections.isEmpty(partsSalesOrderBean.getItemList())) {
+            return null;
+        }
+        List<WebsitStockDTO> websitStockDTOList = new ArrayList<>();
+        for(WebsitPartsSalesItem item : partsSalesOrderBean.getItemList()) {
+            WebsitStockDTO websitStockDTO = new WebsitStockDTO();
+            websitStockDTO.setCompanyWechatId(partsSalesOrderBean.getCompanyWechatId());
+            websitStockDTO.setCompanyWechatName(partsSalesOrderBean.getCompanyWechatName());
+            websitStockDTO.setWebsitId(partsSalesOrderBean.getWebsitId());
+            websitStockDTO.setWebsitName(partsSalesOrderBean.getWebsitName());
+            websitStockDTO.setSdate(new Date());
+            websitStockDTO.setPartsWebsitId(item.getPartsWebsitId());
+            websitStockDTO.setGoodsId(item.getPartsNumber());
+            websitStockDTO.setGoodsName(item.getPartsName());
+            websitStockDTO.setMaterialGroupName(item.getMaterialGroupName());
+            websitStockDTO.setPrice(item.getMarketPrice());
+            websitStockDTO.setGoodsStockUnit(item.getGoodsStockUnit());
+            websitStockDTO.setVoucherNo(partsSalesOrderBean.getId());
+            websitStockDTO.setApplyNo(partsSalesOrderBean.getId());
+            websitStockDTO.setObj(PartsRefTypeEnum.SALES.getKey());
+            websitStockDTO.setPartsAttr(PartsAttrEnum.NEW.getKey());
+            websitStockDTO.setChangeQty(item.getQty());
+            websitStockDTO.setDirectFlag(directFlag.getKey());
+            websitStockDTO.setRemark(partsSalesOrderBean.getRemark());
+            websitStockDTO.setOperateBy(partsSalesOrderBean.getSubmitBy());
+            websitStockDTO.setOperateTime(new Date());
+            websitStockDTO.setStorageId(partsSalesOrderBean.getStorageId());
+            websitStockDTOList.add(websitStockDTO);
+        }
+        return websitStockDTOList;
+    }
+
+    public List<WorkerStockDTO> getWorkerStock(WebsitPartsSalesBean partsSalesOrderBean, String refType, String partsAttr1,
+                                               String partsAttr2){
+        if(Collections.isEmpty(partsSalesOrderBean.getItemList())) {
+            return null;
+        }
+        List<WorkerStockDTO> workerStockDTOList = new ArrayList<>();
+
+        for (WebsitPartsSalesItem item : partsSalesOrderBean.getItemList()) {
+            if (StringUtils.isNotBlank(partsAttr1)) {
+                WorkerStockDTO workerStockDTO = new WorkerStockDTO();
+                workerStockDTO.setCompanyWechatId(partsSalesOrderBean.getCompanyWechatId());
+                workerStockDTO.setCompanyWechatName(partsSalesOrderBean.getCompanyWechatName());
+                workerStockDTO.setIdentity(item.getIdentity());
+                workerStockDTO.setWorkerId(partsSalesOrderBean.getWorkerId());
+                workerStockDTO.setWorkerName(partsSalesOrderBean.getWorkerName());
+                workerStockDTO.setWebsitId(partsSalesOrderBean.getWebsitId());
+                workerStockDTO.setWebsitName(partsSalesOrderBean.getWebsitName());
+                workerStockDTO.setSdate(DateUtil.date());
+                workerStockDTO.setPartsWebsitId(item.getPartsWebsitId());
+                workerStockDTO.setGoodsId(item.getPartsNumber());
+                workerStockDTO.setGoodsName(item.getPartsName());
+                workerStockDTO.setMaterialGroupName(item.getMaterialGroupName());
+                workerStockDTO.setPrice(item.getMarketPrice());
+                workerStockDTO.setGoodsStockUnit(item.getGoodsStockUnit());
+                workerStockDTO.setRef(partsSalesOrderBean.getId());
+                workerStockDTO.setRefType(refType);
+                workerStockDTO.setPartsAttr(partsAttr1);
+                workerStockDTO.setChangeQty(item.getQty());
+                workerStockDTO.setDirectFlag(DirectFlagEnum.SUB.getKey());
+                workerStockDTO.setRemark(partsSalesOrderBean.getRemark());
+                workerStockDTO.setOperateBy(partsSalesOrderBean.getWorkerName());
+                workerStockDTO.setOperateTime(DateUtil.date());
+                workerStockDTOList.add(workerStockDTO);
+            }
+            if (StringUtils.isNotBlank(partsAttr2)) {
+                WorkerStockDTO workerStockDTO = new WorkerStockDTO();
+                workerStockDTO.setIdentity(item.getIdentity());
+                workerStockDTO.setWorkerId(partsSalesOrderBean.getWorkerId());
+                workerStockDTO.setWorkerName(partsSalesOrderBean.getWorkerName());
+                workerStockDTO.setWebsitId(partsSalesOrderBean.getWebsitId());
+                workerStockDTO.setWebsitName(partsSalesOrderBean.getWebsitName());
+                workerStockDTO.setSdate(DateUtil.date());
+                workerStockDTO.setPartsWebsitId(item.getPartsWebsitId());
+                workerStockDTO.setGoodsId(item.getPartsNumber());
+                workerStockDTO.setGoodsName(item.getPartsName());
+                workerStockDTO.setMaterialGroupName(item.getMaterialGroupName());
+                workerStockDTO.setPrice(item.getMarketPrice());
+                workerStockDTO.setGoodsStockUnit(item.getGoodsStockUnit());
+                workerStockDTO.setRef(partsSalesOrderBean.getId());
+                workerStockDTO.setRefType(refType);
+                workerStockDTO.setPartsAttr(partsAttr2);
+                workerStockDTO.setChangeQty(item.getQty());
+                workerStockDTO.setDirectFlag(DirectFlagEnum.ADD.getKey());
+                workerStockDTO.setRemark(partsSalesOrderBean.getRemark());
+                workerStockDTO.setOperateBy(partsSalesOrderBean.getWorkerName());
+                workerStockDTO.setOperateTime(DateUtil.date());
+                workerStockDTOList.add(workerStockDTO);
+            }
+        }
+        return workerStockDTOList;
+    }
 }

+ 132 - 10
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/stock/WorkerStockLogic.java → mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/stock/MaterialGoodsStockLogic.java

@@ -8,13 +8,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.miniapp.bean.material.MyDataCountBean;
 import com.gree.mall.miniapp.bean.material.parts.PartsRefundRecordDTO;
 import com.gree.mall.miniapp.bean.material.parts.SalesItemRecordDTO;
-import com.gree.mall.miniapp.bean.material.stock.WorkerStockAccBean;
-import com.gree.mall.miniapp.bean.material.stock.WorkerStockBean;
-import com.gree.mall.miniapp.bean.material.stock.WorkerStockDTO;
-import com.gree.mall.miniapp.bean.material.stock.WorkerStockDetailBean;
+import com.gree.mall.miniapp.bean.material.stock.*;
 import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
 import com.gree.mall.miniapp.commonmapper.MaterialMapper;
-import com.gree.mall.miniapp.commonmapper.stock.WorkerStockCMapper;
+import com.gree.mall.miniapp.commonmapper.stock.MaterialGoodsStockCMapper;
 import com.gree.mall.miniapp.constant.Constant;
 import com.gree.mall.miniapp.enums.material.PartsPushFlagEnum;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
@@ -45,18 +42,20 @@ import java.util.stream.Collectors;
 @Slf4j
 @RequiredArgsConstructor
 @Service
-public class WorkerStockLogic {
+public class MaterialGoodsStockLogic {
 
     private final CommonLogic commonLogic;
     private final WorkerStockService workerStockService;
     private final WorkerStockAccService workerStockAccService;
     private final WebsitPartsSalesItemService websitPartsSalesItemService;
-    private final WorkerStockCMapper workerStockCMapper;
+    private final MaterialGoodsStockCMapper materialGoodsStockCMapper;
     private final WebsitPartsRetService websitPartsRetService;
     private final WebsitNormRecordService websitNormRecordService;
     private final WebsitGoodsService websitGoodsService;
     private final RedisLockRegistry redisLockRegistry;
     private final MaterialMapper materialMapper;
+    private final WebsitStockService websitStockService;
+    private final WebsitStockAccService websitStockAccService;
 
     /**
      * 我的库存分类
@@ -67,7 +66,7 @@ public class WorkerStockLogic {
      */
     public List<WebsitGoodsCategory> websitGoodsCategoryList(String webistId, String goodsType) {
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
-        List<WebsitGoodsCategory> websitGoodsCategories = workerStockCMapper.queryWebsitGoodsCategoryList(webistId, currentCompanyWechat.getUser().getWorkerNumber(), goodsType);
+        List<WebsitGoodsCategory> websitGoodsCategories = materialGoodsStockCMapper.queryWebsitGoodsCategoryList(webistId, currentCompanyWechat.getUser().getWorkerNumber(), goodsType);
         return websitGoodsCategories;
     }
 
@@ -82,7 +81,7 @@ public class WorkerStockLogic {
      */
     public IPage<WorkerStockBean> workerStockList(String websitId, String goodsType, String categoryId, Integer pageNum, Integer pageSize) {
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
-        IPage<WorkerStockBean> workerStockBeanIPage = workerStockCMapper
+        IPage<WorkerStockBean> workerStockBeanIPage = materialGoodsStockCMapper
                 .queryWorkerStockList(new Page(pageNum, pageSize), websitId, currentCompanyWechat.getUser().getWorkerNumber(), goodsType, categoryId);
 
         return workerStockBeanIPage;
@@ -183,6 +182,106 @@ public class WorkerStockLogic {
         return bean;
     }
 
+    /**
+     * 单个网点库存处理
+     * @param stockList
+     * @throws Exception
+     */
+    public void handleWebsitStock(List<WebsitStockDTO> stockList) throws Exception {
+        if(!TransactionSynchronizationManager.isSynchronizationActive()) {
+            throw new RemoteServiceException("请先开启事务");
+        }
+//        System.out.println("程序入口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+        if (CollectionUtil.isEmpty(stockList)) {
+            return;
+        }
+//        System.out.println("检查传入的参数入口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+        // 检查传入的参数
+        for (int i = 0; i < stockList.size(); i++) {
+            WebsitStockDTO websitStockDTO = stockList.get(i);
+            try {
+                ValidateUtil.validate(websitStockDTO);
+                if (websitStockDTO.getChangeQty().compareTo(BigDecimal.ZERO) <= 0) {
+                    throw new RuntimeException("变动数量不能少于0");
+                }
+            } catch (ValidationException ve) {
+                throw new RemoteServiceException("执行数据第" + (i+1) + "行" + ve.getMessage());
+            }
+        }
+//        System.out.println("检查传入的参数出口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+        // 锁定网点库存
+//        System.out.println("锁定网点库存入口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+        WebsitStockDTO websitStockDTO = stockList.get(0);
+        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.MATERIAL_STOCK_LOCK +
+                websitStockDTO.getCompanyWechatId() + ":" +
+                websitStockDTO.getWebsitId() + ":" +
+                websitStockDTO.getGoodsType() + ":" +
+                websitStockDTO.getStorageId());
+        if(!obtain.tryLock(10, TimeUnit.SECONDS)){
+            throw new RemoteServiceException("库存已冻结:" + websitStockDTO.getWebsitName());
+        }
+//        System.out.println("锁定网点库存出口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+        // 处理网点库存
+        try{
+            this.saveWebsitStock(websitStockDTO, stockList);
+
+        } finally {
+            this.txCallUnlock(obtain);
+//            System.out.println("程序出口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+        }
+    }
+
+    private void saveWebsitStock(WebsitStockDTO websitStockDTO, List<WebsitStockDTO> stockList) {
+        //        System.out.println("处理网点库存入口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+        // 查询存在的配件库存
+        List<WebsitStock> existWebsitStockList = materialGoodsStockCMapper.queryExistWebsitStockList(websitStockDTO.getCompanyWechatId(),
+                websitStockDTO.getWebsitId(), websitStockDTO.getStorageId(), stockList);
+
+//        System.out.println("计算库存入口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+        // 全部商品库存
+        Map<String, WebsitStock> existShopStockMap = this.createNotExistStock(stockList, existWebsitStockList);
+        // 计算商品库存
+//        List<PartsShopStock> shopStockList = new ArrayList<>();
+        List<WebsitStockAcc> shopStockAccList = new ArrayList<>();
+        this.computeWebsitStock(stockList, existShopStockMap, null, shopStockAccList);
+
+        if (CollectionUtil.isEmpty(shopStockAccList)) {
+            throw new RemoteServiceException("商品库存处理失败");
+        }
+//        System.out.println("计算商品库存出口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+//        System.out.println("保存商品库存入口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+//        partsShopStockService.saveOrUpdateBatch(shopStockList);
+        websitStockService.saveOrUpdateBatch(existShopStockMap.values());
+//        System.out.println("保存商品库存出口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+//        System.out.println("保存商品库存三级帐入口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+        websitStockAccService.saveBatch(shopStockAccList);
+//        System.out.println("保存商品库存三级帐出口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
+    }
+
+    private Map<String, WebsitStock> createNotExistStock(List<WebsitStockDTO> stockList, List<WebsitStock> existWebsitStockList) {
+        // 已存在的配件库存转成Map
+        Map<String, WebsitStock> existStockMap = existWebsitStockList.stream()
+                .collect(Collectors.toMap(WebsitStock::getGoodsId, Function.identity()));
+
+        // 找出不存在的配件库存并存入新配件库存List
+        for (WebsitStockDTO websitStockDTO : stockList) {
+            WebsitStock shopStock = existStockMap.get(websitStockDTO.getGoodsId());
+            if (Objects.isNull(shopStock)) {
+                shopStock = websitStockDTO.createPartsStock();
+                existStockMap.put(websitStockDTO.getGoodsId(), shopStock);
+            }
+        }
+        return existStockMap;
+    }
+
+    private void computeWebsitStock(List<WebsitStockDTO> stockList, Map<String, WebsitStock> existShopStockMap, Object o, List<WebsitStockAcc> shopStockAccList) {
+        for (WebsitStockDTO shopStockDTO : stockList) {
+            WebsitStock shopStock = existShopStockMap.get(shopStockDTO.getGoodsId());
+            WebsitStockAcc shopStockAcc = new WebsitStockAcc();
+            shopStockDTO.computeWebsitStock(shopStock, shopStockAcc);
+            shopStockAccList.add(shopStockAcc);
+        }
+    }
 
     /**
      * 单个师傅库存处理
@@ -228,7 +327,7 @@ public class WorkerStockLogic {
 
     private void saveWorkerStock(WorkerStockDTO workerStockDTO, List<WorkerStockDTO> stockList) throws Exception {
         // 查询存在的商品库存
-        List<WorkerStock> existWorkerStockList = workerStockCMapper.queryExistWorkerStockList(workerStockDTO.getCompanyWechatId()
+        List<WorkerStock> existWorkerStockList = materialGoodsStockCMapper.queryExistWorkerStockList(workerStockDTO.getCompanyWechatId()
                 , workerStockDTO.getWorkerId(), stockList);
         // 全部商品库存
         Map<String, WorkerStock> existWorkerStockMap = this.createNotExistWorkerStock(stockList, existWorkerStockList);
@@ -377,6 +476,28 @@ public class WorkerStockLogic {
         }
     }
 
+    private void txCallUnlock(Lock obtain){
+        //事务提交完成后才释放锁,此方法禁止执行mysql相关操作,否则将导致重大问题。
+        if (TransactionSynchronizationManager.isActualTransactionActive()) {
+            TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
+                @Override
+                public void afterCompletion(int status) {
+
+                    if(TransactionSynchronization.STATUS_COMMITTED == status){
+                        log.info("=========【网点商品库存】======事务提交==============");
+                    }else if(TransactionSynchronization.STATUS_ROLLED_BACK == status){
+                        log.info("========【网点商品库存】=========事务回滚============");
+                    }
+
+                    obtain.unlock();
+                }
+            });
+        } else {
+            log.info("【网点商品库存】====没有事务===释放锁");
+            obtain.unlock();
+        }
+    }
+
     public void txCallUnlockSalesItem(Lock obtain){
         //事务提交完成后才释放锁,此方法禁止执行mysql相关操作,否则将导致重大问题。
         if (TransactionSynchronizationManager.isActualTransactionActive()) {
@@ -398,4 +519,5 @@ public class WorkerStockLogic {
             obtain.unlock();
         }
     }
+
 }

+ 4 - 4
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/order/PayOrderLogic.java

@@ -22,7 +22,7 @@ import com.gree.mall.miniapp.enums.material.WebsitGoodsTypeEnum;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.logic.common.CommonLogic;
 import com.gree.mall.miniapp.logic.common.outside.WechatLogic;
-import com.gree.mall.miniapp.logic.material.stock.WorkerStockLogic;
+import com.gree.mall.miniapp.logic.material.stock.MaterialGoodsStockLogic;
 import com.gree.mall.miniapp.plus.entity.*;
 import com.gree.mall.miniapp.plus.service.*;
 import com.gree.mall.miniapp.utils.DateUtils;
@@ -81,7 +81,7 @@ public class PayOrderLogic {
     WebsitNormRecordService websitNormRecordService;
 
     @Autowired
-    WorkerStockLogic workerStockLogic;
+    MaterialGoodsStockLogic materialGoodsStockLogic;
 
     @Autowired
     AdminCompanyWechatService adminCompanyWechatService;
@@ -503,7 +503,7 @@ public class PayOrderLogic {
                 }
                 if (CollectionUtil.isNotEmpty(workerStockDTOS)) {
                     // 开始处理库存
-                    workerStockLogic.handleWorkerStock(workerStockDTOS);
+                    materialGoodsStockLogic.handleWorkerStock(workerStockDTOS);
                 }
             }
         } catch (Exception e) {
@@ -518,7 +518,7 @@ public class PayOrderLogic {
 
                 if (CollectionUtil.isNotEmpty(workerStockDTOS)) {
                     // 开始处理库存
-                    workerStockLogic.handleWorkerStock(workerStockDTOS);
+                    materialGoodsStockLogic.handleWorkerStock(workerStockDTOS);
                 }
             }
         } catch (Exception e) {

+ 23 - 1
mall-miniapp-service/src/main/resources/mapper/WorkerStockCMapper.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.gree.mall.miniapp.commonmapper.stock.WorkerStockCMapper">
+<mapper namespace="com.gree.mall.miniapp.commonmapper.stock.MaterialGoodsStockCMapper">
 
 
     <select id="queryWebsitGoodsCategoryList" resultType="com.gree.mall.miniapp.plus.entity.WebsitGoodsCategory">
@@ -50,6 +50,27 @@
             </if>
         </where>
     </select>
+
+    <select id="queryExistWebsitStockList" resultType="com.gree.mall.miniapp.plus.entity.WebsitStock">
+        SELECT
+        *
+        FROM
+        websit_stock
+        WHERE
+        company_wechat_id = #{companyWechatId}
+        AND
+        websit_id = #{websitId}
+        AND
+        storage_id = #{storageId}
+        AND
+        goods_id IN
+        <foreach item="item" index="index" collection="stockList" open="(" separator=","
+                 close=")">
+            #{item.goodsId}
+        </foreach>
+        FOR UPDATE
+    </select>
+
     <select id="queryExistWorkerStockList" resultType="com.gree.mall.miniapp.plus.entity.WorkerStock">
         SELECT
         *
@@ -68,4 +89,5 @@
         FOR UPDATE
     </select>
 
+
 </mapper>

+ 6 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/stock/WebsitStockDTO.java

@@ -105,6 +105,12 @@ public class WebsitStockDTO {
     @ApiModelProperty(value = "申请单号")
     private String applyNo;
 
+    @ApiModelProperty(value = "物料组名称")
+    private String materialGroupName;
+
+    @ApiModelProperty(value = "单位")
+    private String goodsStockUnit;
+
     public WebsitStock createPartsStock() {
         WebsitStock websitStock = new WebsitStock();
         BeanUtils.copyProperties(this, websitStock);

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/WebsitStockCMapper.java → mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/MaterialGoodsStockCMapper.java

@@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
-public interface WebsitStockCMapper {
+public interface MaterialGoodsStockCMapper {
     /**
      * 带锁查询
      *

+ 8 - 4
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebitPartsOldStockLogic.java

@@ -7,7 +7,7 @@ import com.gree.mall.manager.enums.material.DirectFlagEnum;
 import com.gree.mall.manager.enums.material.PartsAttrEnum;
 import com.gree.mall.manager.enums.material.PartsObjectTypeEnum;
 import com.gree.mall.manager.enums.material.WebsitGoodsTypeEnum;
-import com.gree.mall.manager.logic.material.stock.WebsitGoodsStockLogic;
+import com.gree.mall.manager.logic.material.stock.MaterialGoodsStockLogic;
 import com.gree.mall.manager.plus.entity.WebsitPartsOldOutRecord;
 import com.gree.mall.manager.plus.entity.WebsitPartsOldOutRecordBak;
 import com.gree.mall.manager.plus.service.WebsitPartsOldOutRecordService;
@@ -24,7 +24,7 @@ import java.util.List;
 public class WebitPartsOldStockLogic {
 
     @Resource
-    WebsitGoodsStockLogic websitGoodsStockLogic;
+    MaterialGoodsStockLogic materialGoodsStockLogic;
 
     public void oldOutStock(WebsitPartsOldOutRecordDTO oldOutRecord, WebsitPartsOldOutRecordService websitPartsOldOutRecordService, boolean isImport) throws Exception {
         List<WebsitStockDTO> shopStockDTOS = new ArrayList<>();
@@ -53,10 +53,12 @@ public class WebitPartsOldStockLogic {
         websitStockDTO.setOperateTime(isImport ? oldOutRecord.getCreateTime() : oldOutRecord.getImportDate());
         websitStockDTO.setObj("网点");
         websitStockDTO.setStorageId(oldOutRecord.getStorageId());
+        websitStockDTO.setGoodsStockUnit(oldOutRecord.getGoodsStockUnit());
+        websitStockDTO.setMaterialGroupName(oldOutRecord.getMaterialGroupName());
         shopStockDTOS.add(websitStockDTO);
 
         // 开始处理库存
-        websitGoodsStockLogic.handleWebsitStock(shopStockDTOS);
+        materialGoodsStockLogic.handleWebsitStock(shopStockDTOS);
 
         // 库存处理完后保存记录
         if (isImport) {
@@ -95,8 +97,10 @@ public class WebitPartsOldStockLogic {
         sendShopStockDTO.setOperateTime(outRecord.getCreateTime());
         sendShopStockDTO.setObj("网点");
         sendShopStockDTO.setStorageId(outRecord.getStorageId());
+        sendShopStockDTO.setGoodsStockUnit(outRecord.getGoodsStockUnit());
+        sendShopStockDTO.setMaterialGroupName(outRecord.getMaterialGroupName());
 
-        websitGoodsStockLogic.handleWebsitStock(new ArrayList<WebsitStockDTO>(){{ this.add(sendShopStockDTO); }});
+        materialGoodsStockLogic.handleWebsitStock(new ArrayList<WebsitStockDTO>(){{ this.add(sendShopStockDTO); }});
 
         // 库存处理完后删除记录及备份
         outRecord.deleteById();

+ 5 - 5
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WebsitGoodsStockLogic.java → mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/MaterialGoodsStockLogic.java

@@ -3,7 +3,7 @@ package com.gree.mall.manager.logic.material.stock;
 import cn.hutool.core.collection.CollectionUtil;
 import com.gree.mall.manager.bean.material.stock.WebsitStockDTO;
 import com.gree.mall.manager.bean.material.stock.WorkerStockDTO;
-import com.gree.mall.manager.commonmapper.WebsitStockCMapper;
+import com.gree.mall.manager.commonmapper.MaterialGoodsStockCMapper;
 import com.gree.mall.manager.constant.Constant;
 import com.gree.mall.manager.enums.material.DirectFlagEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
@@ -32,10 +32,10 @@ import java.util.stream.Collectors;
 @Slf4j
 @Service
 @RequiredArgsConstructor
-public class WebsitGoodsStockLogic {
+public class MaterialGoodsStockLogic {
 
     private final RedisLockRegistry redisLockRegistry;
-    private final WebsitStockCMapper websitStockCMapper;
+    private final MaterialGoodsStockCMapper materialGoodsStockCMapper;
     private final WebsitStockService websitStockService;
     private final WebsitStockAccService websitStockAccService;
     private final WorkerStockService workerStockService;
@@ -137,7 +137,7 @@ public class WebsitGoodsStockLogic {
 
     private void saveWorkerStock(WorkerStockDTO workerStockDTO, List<WorkerStockDTO> stockList) throws Exception {
         // 查询存在的商品库存
-        List<WorkerStock> existWorkerStockList = websitStockCMapper.queryExistWorkerStockList(workerStockDTO.getCompanyWechatId(),
+        List<WorkerStock> existWorkerStockList = materialGoodsStockCMapper.queryExistWorkerStockList(workerStockDTO.getCompanyWechatId(),
                 workerStockDTO.getWorkerId(), stockList);
         // 全部商品库存
         Map<String, WorkerStock> existWorkerStockMap = this.createNotExistWorkerStock(stockList, existWorkerStockList);
@@ -182,7 +182,7 @@ public class WebsitGoodsStockLogic {
     private void saveWebsitStock(WebsitStockDTO websitStockDTO, List<WebsitStockDTO> stockList) {
         //        System.out.println("处理网点库存入口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));
         // 查询存在的配件库存
-        List<WebsitStock> existWebsitStockList = websitStockCMapper.queryExistWebsitStockList(websitStockDTO.getCompanyWechatId(),
+        List<WebsitStock> existWebsitStockList = materialGoodsStockCMapper.queryExistWebsitStockList(websitStockDTO.getCompanyWechatId(),
                 websitStockDTO.getWebsitId(), websitStockDTO.getStorageId(), stockList);
 
 //        System.out.println("计算库存入口:" + DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss.SSS"));

+ 7 - 5
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WebitPurchaseStockLogic.java

@@ -26,7 +26,7 @@ import java.util.Objects;
 public class WebitPurchaseStockLogic {
 
     @Resource
-    WebsitGoodsStockLogic websitGoodsStockLogic;
+    MaterialGoodsStockLogic materialGoodsStockLogic;
     @Resource
     StorageService storageService;
 
@@ -66,7 +66,7 @@ public class WebitPurchaseStockLogic {
         }
 
         // 开始处理库存
-        websitGoodsStockLogic.handleWebsitStock(shopStockDTOS);
+        materialGoodsStockLogic.handleWebsitStock(shopStockDTOS);
     }
 
     public void newRetStock(WebsitPurchaseRet purchaseRet, List<WebsitPurchaseRetItem> purchaseRetItems, String refType) throws Exception {
@@ -97,7 +97,7 @@ public class WebitPurchaseStockLogic {
         }
 
         // 开始处理库存
-        websitGoodsStockLogic.handleWebsitStock(shopStockDTOS);
+        materialGoodsStockLogic.handleWebsitStock(shopStockDTOS);
     }
 
     public void adjustmentStock(WebsitPurchaseAdjustment purchaseAdjustment, List<WebsitPurchaseAdjustmentItem> changeAdjustList, String refType) throws Exception {
@@ -155,7 +155,7 @@ public class WebitPurchaseStockLogic {
         }
 
         // 开始处理库存
-        websitGoodsStockLogic.handleWebsitStock(shopStockDTOS);
+        materialGoodsStockLogic.handleWebsitStock(shopStockDTOS);
     }
 
     public void newInStock(List<WebsitPartsNewInRecord> shopNewInRecords) throws Exception {
@@ -185,6 +185,8 @@ public class WebitPurchaseStockLogic {
             websitStockDTO.setOperateTime(inRecord.getCheckTime());
             websitStockDTO.setObj("网点");
             websitStockDTO.setStorageId(inRecord.getStorageId());
+            websitStockDTO.setGoodsStockUnit(inRecord.getGoodsStockUnit());
+            websitStockDTO.setMaterialGroupName(inRecord.getMaterialGroupName());
             shopStockDTOS.add(websitStockDTO);
         }
 
@@ -193,7 +195,7 @@ public class WebitPurchaseStockLogic {
         }
 
         // 开始处理库存
-        websitGoodsStockLogic.handleWebsitStock(shopStockDTOS);
+        materialGoodsStockLogic.handleWebsitStock(shopStockDTOS);
     }
 
     public Storage handleStorage(AdminUserCom adminUser, String websitId, String goodsType, String storageId) {

+ 2 - 2
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WebitSalesStockLogic.java

@@ -23,7 +23,7 @@ import java.util.Objects;
 public class WebitSalesStockLogic {
 
     @Resource
-    WebsitGoodsStockLogic websitGoodsStockLogic;
+    MaterialGoodsStockLogic materialGoodsStockLogic;
     @Resource
     StorageService storageService;
 
@@ -56,7 +56,7 @@ public class WebitSalesStockLogic {
         }
 
         // 开始处理库存
-        websitGoodsStockLogic.handleWebsitStock(shopStockDTOS);
+        materialGoodsStockLogic.handleWebsitStock(shopStockDTOS);
     }
 
     public Storage handleStorage(AdminUserCom adminUser, String websitId, String goodsType, String storageId) {

+ 2 - 2
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WorkSalesStockLogic.java

@@ -22,7 +22,7 @@ import java.util.List;
 public class WorkSalesStockLogic {
 
     @Resource
-    WebsitGoodsStockLogic websitGoodsStockLogic;
+    MaterialGoodsStockLogic materialGoodsStockLogic;
 
     public void salesInStock(WebsitSales sales, List<WebsitSalesItem> salesItems, String refType) throws Exception {
         List<WorkerStockDTO> workerStockDTOS = new ArrayList<>();
@@ -74,7 +74,7 @@ public class WorkSalesStockLogic {
         }
         if (CollectionUtil.isNotEmpty(workerStockDTOS)) {
             // 开始处理库存
-            websitGoodsStockLogic.handleWorkerStock(workerStockDTOS);
+            materialGoodsStockLogic.handleWorkerStock(workerStockDTOS);
         }
     }
 

+ 2 - 2
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WorkerStockLogic.java

@@ -49,7 +49,7 @@ public class WorkerStockLogic {
     private final WorkerStockAccService workerStockAccService;
     private final AdminWebsitService adminWebsitService;
     private final UserService userService;
-    private final WebsitGoodsStockLogic websitGoodsStockLogic;
+    private final MaterialGoodsStockLogic materialGoodsStockLogic;
     private final WebsitGoodsService websitGoodsService;
     private final WorkerStockBakService workerStockBakService;
     private final WorkerStockAccBakService workerStockAccBakService;
@@ -277,7 +277,7 @@ public class WorkerStockLogic {
             }
         }
         // 开始处理库存
-        websitGoodsStockLogic.handleWorkerStock(workerStockDTOS);
+        materialGoodsStockLogic.handleWorkerStock(workerStockDTOS);
     }
 
     @Transactional

+ 7 - 7
mall-server-api/src/main/java/com/gree/mall/manager/logic/websit/WebsitPartsRetLogic.java

@@ -18,7 +18,7 @@ import com.gree.mall.manager.enums.material.*;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.logic.engin.WebsitGoodsMangerLogic;
-import com.gree.mall.manager.logic.material.stock.WebsitGoodsStockLogic;
+import com.gree.mall.manager.logic.material.stock.MaterialGoodsStockLogic;
 import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.*;
 import com.gree.mall.manager.utils.StringUtil;
@@ -51,7 +51,7 @@ public class WebsitPartsRetLogic {
     WebsitPartsRetItemService websitPartsRetItemService;
 
     @Autowired
-    WebsitGoodsStockLogic websitGoodsStockLogic;
+    MaterialGoodsStockLogic materialGoodsStockLogic;
 
     @Autowired
     WebsitSalesService websitSalesService;
@@ -369,7 +369,7 @@ public class WebsitPartsRetLogic {
                 workerStockDTOS.add(workerStockDTO);
 
             }
-            websitGoodsStockLogic.handleWorkerStock(workerStockDTOS);
+            materialGoodsStockLogic.handleWorkerStock(workerStockDTOS);
         }
 
         for (WebsitPartsRetOldRecord websitPartsRetOldRecord : websitPartsRetOldRecords) {
@@ -396,7 +396,7 @@ public class WebsitPartsRetLogic {
             websitStockDTOS.add(websitStockDTO);
         }
 
-        websitGoodsStockLogic.handleWebsitStock(websitStockDTOS);
+        materialGoodsStockLogic.handleWebsitStock(websitStockDTOS);
 
     }
 
@@ -465,9 +465,9 @@ public class WebsitPartsRetLogic {
             websitStockDTOS.add(websitStockDTO);
         }
 
-        websitGoodsStockLogic.handleWebsitStock(websitStockDTOS);
+        materialGoodsStockLogic.handleWebsitStock(websitStockDTOS);
         if (websitPartsRet.getBuyPeople().equals(BuyPeopleEnum.WORKER.getKey())) {
-            websitGoodsStockLogic.handleWorkerStock(workerStockDTOS);
+            materialGoodsStockLogic.handleWorkerStock(workerStockDTOS);
         }
 
     }
@@ -639,7 +639,7 @@ public class WebsitPartsRetLogic {
                 websitStockDTOS.add(websitStockDTO);
             }
 
-            websitGoodsStockLogic.handleWebsitStock(websitStockDTOS);
+            materialGoodsStockLogic.handleWebsitStock(websitStockDTOS);
 
 
         }

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

@@ -18,7 +18,7 @@ import com.gree.mall.manager.enums.material.*;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.logic.engin.WebsitGoodsMangerLogic;
-import com.gree.mall.manager.logic.material.stock.WebsitGoodsStockLogic;
+import com.gree.mall.manager.logic.material.stock.MaterialGoodsStockLogic;
 import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.WebsitSalesItemService;
 import com.gree.mall.manager.plus.service.WebsitSalesRetItemService;
@@ -54,7 +54,7 @@ public class WebsitSalesRetLogic {
     WebsitSalesRetService websitSalesRetService;
 
     @Autowired
-    WebsitGoodsStockLogic websitGoodsStockLogic;
+    MaterialGoodsStockLogic materialGoodsStockLogic;
 
     @Autowired
     WebsitSalesService websitSalesService;
@@ -339,9 +339,9 @@ public class WebsitSalesRetLogic {
             websitStockDTOS.add(websitStockDTO);
         }
 
-        websitGoodsStockLogic.handleWebsitStock(websitStockDTOS);
+        materialGoodsStockLogic.handleWebsitStock(websitStockDTOS);
         if (websitSalesRet.getBuyPeople().equals(BuyPeopleEnum.WORKER.getKey())) {
-            websitGoodsStockLogic.handleWorkerStock(workerStockDTOS);
+            materialGoodsStockLogic.handleWorkerStock(workerStockDTOS);
         }
     }
 

+ 1 - 1
mall-server-api/src/main/resources/mapper/WebsitStockCMapper.xml → mall-server-api/src/main/resources/mapper/MaterialGoodsStockCMapper.xml

@@ -1,5 +1,5 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.gree.mall.manager.commonmapper.WebsitStockCMapper">
+<mapper namespace="com.gree.mall.manager.commonmapper.MaterialGoodsStockCMapper">
 
     <select id="queryExistWebsitStockList" resultType="com.gree.mall.manager.plus.entity.WebsitStock">
         SELECT