Kaynağa Gözat

师傅辅材配件库存处理换为身份证作为唯一条件

FengChaoYu 7 ay önce
ebeveyn
işleme
ee81ff583a
14 değiştirilmiş dosya ile 67 ekleme ve 80 silme
  1. 1 2
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/commonmapper/stock/MaterialGoodsStockCMapper.java
  2. 4 3
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/common/EventController.java
  3. 18 18
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/stock/MaterialGoodsStockLogic.java
  4. 18 33
      mall-miniapp-service/src/main/resources/mapper/WorkerStockCMapper.xml
  5. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/bean/material/stock/WorkerStockDTO.java
  6. 1 2
      mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/MaterialGoodsStockCMapper.java
  7. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/logic/common/WechatLogic.java
  8. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitGoodsPriceLogic.java
  9. 2 2
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPartsOldOutLogic.java
  10. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPurchaseLogic.java
  11. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPurchaseRetLogic.java
  12. 3 3
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitSalesLogic.java
  13. 14 11
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/MaterialGoodsStockLogic.java
  14. 1 1
      mall-server-api/src/main/resources/mapper/MaterialGoodsStockCMapper.xml

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

@@ -41,8 +41,7 @@ public interface MaterialGoodsStockCMapper {
                                                 @Param("stockList") List<WebsitStockDTO> stockList);
 
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
-    List<WorkerStock> queryExistWorkerStockList(@Param("companyWechatId") String companyWechatId,
-                                                @Param("workerId") String workerId,
+    List<WorkerStock> queryExistWorkerStockList(@Param("dto") WorkerStockDTO workerStockDTO,
                                                 @Param("stockList") List<WorkerStockDTO> stockList);
 
 }

+ 4 - 3
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/common/EventController.java

@@ -2,6 +2,7 @@ package com.gree.mall.miniapp.controller.common;
 
 import cn.hutool.json.JSONUtil;
 import com.gree.mall.miniapp.annotation.ApiNotAuth;
+import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.logic.common.EventLogic;
 import com.gree.mall.miniapp.logic.common.outside.WechatLogic;
 import com.gree.mall.miniapp.utils.CommonUtils;
@@ -79,7 +80,7 @@ public class EventController {
             String echostr = request.getParameter("echostr");
             String appid = request.getParameter("appid");
             if (StringUtils.isBlank(echostr)) {
-                throw new RuntimeException("无效的请求参数");
+                throw new RemoteServiceException("无效的请求参数");
             }
             log.info("get微信公众号事件消息" + JSONUtil.toJsonStr(echostr)+",appid:"+appid);
             checkCallbackSign(request);
@@ -100,12 +101,12 @@ public class EventController {
         if (StringUtils.isBlank(signature) || StringUtils.isBlank(timestamp)
                 || StringUtils.isBlank(nonce)) {
 
-            throw new RuntimeException("无效的请求参数");
+            throw new RemoteServiceException("无效的请求参数");
         }
 
         String checkSign = getCallbackSign(timestamp, nonce);
         if (!signature.equals(checkSign)) {
-            throw new RuntimeException("无效的签名");
+            throw new RemoteServiceException("无效的签名");
         }
     }
 

+ 18 - 18
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/stock/MaterialGoodsStockLogic.java

@@ -116,7 +116,7 @@ public class MaterialGoodsStockLogic {
         Page page = workerStockAccService.lambdaQuery()
                 .eq(StringUtils.isNotBlank(websitId), WorkerStockAcc::getWebsitId, websitId)
                 .eq(StringUtils.isNotBlank(directFlag), WorkerStockAcc::getDirectFlag, directFlag)
-                .eq(WorkerStockAcc::getWorkerId, currentCompanyWechat.getUser().getWorkerNumber())
+                .eq(WorkerStockAcc::getIdentity, currentCompanyWechat.getUser().getIdCard())
                 .eq(WorkerStockAcc::getGoodsId, websitGoodsId)
                 .between(startTime != null && endTime != null, WorkerStockAcc::getOperTime, startTime, endTime)
                 .orderByDesc(WorkerStockAcc::getOperTime).page(new Page<>(pageNum, pageSize));
@@ -140,13 +140,13 @@ public class MaterialGoodsStockLogic {
         Integer newRefundCount = websitPartsRetService.lambdaQuery()
                 .eq(WebsitPartsRet::getType, "NEW")
                 .eq(WebsitPartsRet::getFlag, "SUBMIT")
-                .eq(WebsitPartsRet::getWorkerId, wechat.getUser().getWorkerNumber())
+                .eq(WebsitPartsRet::getIdentity, wechat.getUser().getIdCard())
                 .eq(WebsitPartsRet::getCompanyWechatId, wechat.getCurrentCompanyWechatId())
                 .count();
         Integer oldRefundCount = websitPartsRetService.lambdaQuery()
                 .eq(WebsitPartsRet::getType, "OLD")
                 .eq(WebsitPartsRet::getFlag, "SUBMIT")
-                .eq(WebsitPartsRet::getWorkerId, wechat.getUser().getWorkerNumber())
+                .eq(WebsitPartsRet::getIdentity, wechat.getUser().getIdCard())
                 .eq(WebsitPartsRet::getCompanyWechatId, wechat.getCurrentCompanyWechatId())
                 .count();
         Integer materialSalesCount = websitNormRecordService.query()
@@ -207,7 +207,7 @@ public class MaterialGoodsStockLogic {
             try {
                 ValidateUtil.validate(websitStockDTO);
                 if (websitStockDTO.getChangeQty().compareTo(BigDecimal.ZERO) <= 0) {
-                    throw new RuntimeException("变动数量不能少于0");
+                    throw new RemoteServiceException("变动数量不能少于0");
                 }
             } catch (ValidationException ve) {
                 throw new RemoteServiceException("执行数据第" + (i+1) + "行" + ve.getMessage());
@@ -307,21 +307,22 @@ public class MaterialGoodsStockLogic {
             try {
                 ValidateUtil.validate(workerStockDTO);
                 if (workerStockDTO.getChangeQty().compareTo(BigDecimal.ZERO) <= 0) {
-                    throw new RuntimeException("变动数量不能少于0");
-                }
-                if (workerStockDTO.getGoodsType().equals(WebsitGoodsTypeEnum.P.toString()) && StringUtils.isBlank(workerStockDTO.getWorkerId())) {
-                    throw new RuntimeException("师傅编号不能空");
+                    throw new RemoteServiceException("变动数量不能少于0");
                 }
+//                if (workerStockDTO.getGoodsType().equals(WebsitGoodsTypeEnum.P.toString()) && StringUtils.isBlank(workerStockDTO.getWorkerId())) {
+//                    throw new RemoteServiceException("师傅编号不能空");
+//                }
             } catch (ValidationException ve) {
                 throw new RemoteServiceException("第" + (i + 1) + "行" + ve.getMessage());
             }
         }
         // 锁定师傅配件库存
         WorkerStockDTO workerStockDTO = stockList.get(0);
-        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.MATERIAL_STOCK_LOCK +
+        String key = Constant.RedisPrefix.MATERIAL_STOCK_LOCK +
                 workerStockDTO.getCompanyWechatId() + ":" +
-                workerStockDTO.getWorkerId() + ":" +
-                workerStockDTO.getGoodsType());
+                workerStockDTO.getIdentity() + ":" +
+                workerStockDTO.getGoodsType();
+        Lock obtain = redisLockRegistry.obtain(key);
         if (!obtain.tryLock(10, TimeUnit.SECONDS)) {
             throw new RemoteServiceException("库存已冻结:" + workerStockDTO.getWorkerName());
         }
@@ -335,8 +336,7 @@ public class MaterialGoodsStockLogic {
 
     private void saveWorkerStock(WorkerStockDTO workerStockDTO, List<WorkerStockDTO> stockList) throws Exception {
         // 查询存在的商品库存
-        List<WorkerStock> existWorkerStockList = materialGoodsStockCMapper.queryExistWorkerStockList(workerStockDTO.getCompanyWechatId()
-                , workerStockDTO.getWorkerId(), stockList);
+        List<WorkerStock> existWorkerStockList = materialGoodsStockCMapper.queryExistWorkerStockList(workerStockDTO, stockList);
         // 全部商品库存
         Map<String, WorkerStock> existWorkerStockMap = this.createNotExistWorkerStock(workerStockDTO.getGoodsType(), stockList, existWorkerStockList);
         // 计算商品库存
@@ -344,7 +344,7 @@ public class MaterialGoodsStockLogic {
         this.computeWorkerStock(stockList, existWorkerStockMap, null, workerStockAccList);
 
         if (CollectionUtil.isEmpty(workerStockAccList)) {
-            throw new RemoteServiceException("师傅配件库存处理失败");
+            throw new RemoteServiceException("师傅库存处理失败");
         }
 
         workerStockService.saveOrUpdateBatch(existWorkerStockMap.values());
@@ -354,7 +354,7 @@ public class MaterialGoodsStockLogic {
     private void computeWorkerStock(List<WorkerStockDTO> stockList, Map<String, WorkerStock> existWorkerStockMap,
                                     List<WorkerStock> workerStockList, List<WorkerStockAcc> workerStockAccList) throws Exception {
         for (WorkerStockDTO workerStockDTO : stockList) {
-            WorkerStock workerStock = existWorkerStockMap.get(workerStockDTO.getGoodsId());
+            WorkerStock workerStock = existWorkerStockMap.get(workerStockDTO.getCompanyWechatId() + workerStockDTO.getGoodsId());
             if (workerStockDTO.getGoodsType().equals(WebsitGoodsTypeEnum.P.toString())) {
                 workerStock = existWorkerStockMap.get(workerStockDTO.getCompanyWechatId() + workerStockDTO.getWebsitId() + workerStockDTO.getPartsWebsitId() +  workerStockDTO.getGoodsId());
             }
@@ -370,7 +370,7 @@ public class MaterialGoodsStockLogic {
 
         if (goodsType.equals(WebsitGoodsTypeEnum.M.toString())) {
             existShopStockMap = existWorkerStockList.stream()
-                    .collect(Collectors.toMap(WorkerStock::getGoodsId, Function.identity()));
+                    .collect(Collectors.toMap(o -> o.getCompanyWechatId() + o.getGoodsId(), Function.identity()));
         } else {
             existShopStockMap = existWorkerStockList.stream()
                     .collect(Collectors.toMap(o -> o.getCompanyWechatId() + o.getWebsitId() + o.getPartsWebsitId() +  o.getGoodsId(), Function.identity()));
@@ -378,7 +378,7 @@ public class MaterialGoodsStockLogic {
 
         // 找出不存在的商品库存并存入新商品库存List
         for (WorkerStockDTO workerStockDTO : stockList) {
-            WorkerStock workerStock = existShopStockMap.get(workerStockDTO.getGoodsId());
+            WorkerStock workerStock = existShopStockMap.get(workerStockDTO.getCompanyWechatId() + workerStockDTO.getGoodsId());
             if (goodsType.equals(WebsitGoodsTypeEnum.P.toString())) {
                 workerStock = existShopStockMap.get(workerStockDTO.getCompanyWechatId() + workerStockDTO.getWebsitId() + workerStockDTO.getPartsWebsitId() +  workerStockDTO.getGoodsId());
             }
@@ -386,7 +386,7 @@ public class MaterialGoodsStockLogic {
             if (Objects.isNull(workerStock)) {
                 workerStock = workerStockDTO.createWorkerStock();
                 if (goodsType.equals(WebsitGoodsTypeEnum.M.toString())) {
-                    existShopStockMap.put(workerStockDTO.getGoodsId(), workerStock);
+                    existShopStockMap.put(workerStockDTO.getCompanyWechatId() + workerStockDTO.getGoodsId(), workerStock);
                 } else {
                     existShopStockMap.put(workerStockDTO.getCompanyWechatId() + workerStockDTO.getWebsitId() + workerStockDTO.getPartsWebsitId() +  workerStockDTO.getGoodsId(), workerStock);
                 }

+ 18 - 33
mall-miniapp-service/src/main/resources/mapper/WorkerStockCMapper.xml

@@ -17,26 +17,18 @@
             <if test="websitId != null and websitId !=''">
                 and c.websit_id = #{websitId}
             </if>
-            <if test="goodsType != null and goodsType == 'M'">
-                and c.identity = #{user.idCard}
-            </if>
-            <if test="goodsType != null and goodsType == 'P'">
-                and c.worker_id = #{user.workerNumber}
-            </if>
-            <if test="goodsType == null">
-                and c.worker_id = ''
-            </if>
+            and c.identity = #{user.idCard}
         </where>
     </select>
 
     <select id="queryWorkerStockList" resultType="com.gree.mall.miniapp.bean.material.stock.WorkerStockBean">
-          select
-                a.*,
-        <if test="goodsType != null and goodsType == 'M'.toString()">
-                c.category_name,
-        </if>
-                b.goods_category_id
-            from worker_stock a
+        select
+            a.*,
+            <if test="goodsType != null and goodsType == 'M'.toString()">
+            c.category_name,
+            </if>
+            b.goods_category_id
+        from worker_stock a
         join worker_goods b on a.goods_id=b.goods_id
         <if test="goodsType != null and goodsType == 'M'.toString()">
             join websit_goods_category c on c.category_id = b.goods_category_id
@@ -48,12 +40,7 @@
             <if test="websitId != null and websitId !=''">
                 and a.websit_id = #{websitId}
             </if>
-            <if test="goodsType != null and goodsType == 'M'">
-                and a.identity = #{user.idCard}
-            </if>
-            <if test="goodsType != null and goodsType == 'P'">
-                and a.worker_id = #{user.workerNumber}
-            </if>
+            and a.identity = #{user.idCard}
             <if test="goodsType == null">
                 and a.worker_id = ''
             </if>
@@ -85,19 +72,17 @@
 
     <select id="queryExistWorkerStockList" resultType="com.gree.mall.miniapp.plus.entity.WorkerStock">
         SELECT
-        *
+            *
         FROM
-        worker_stock
+            worker_stock
         WHERE
-        company_wechat_id = #{companyWechatId}
-        AND
-        worker_id = #{workerId}
-        AND
-        goods_id IN
-        <foreach item="item" index="index" collection="stockList" open="(" separator=","
-                 close=")">
-            #{item.goodsId}
-        </foreach>
+            company_wechat_id = #{dto.companyWechatId}
+            AND identity = #{dto.identity}
+            AND goods_id IN
+            <foreach item="item" index="index" collection="stockList" open="(" separator=","
+                     close=")">
+                #{item.goodsId}
+            </foreach>
         FOR UPDATE
     </select>
 

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/stock/WorkerStockDTO.java

@@ -32,7 +32,7 @@ public class WorkerStockDTO {
     private String identity;
 
     @ApiModelProperty("师傅编号")
-    @NotBlank(message = "师傅编号不能空")
+//    @NotBlank(message = "师傅编号不能空")
     private String workerId;
 
     @ApiModelProperty("师傅名称")

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

@@ -24,8 +24,7 @@ public interface MaterialGoodsStockCMapper {
                                                 @Param("storageId") String storageId,
                                                 @Param("stockList") List<WebsitStockDTO> stockList);
 
-    List<WorkerStock> queryExistWorkerStockList(@Param("companyWechatId") String companyWechatId,
-                                                @Param("workerId") String workerId,
+    List<WorkerStock> queryExistWorkerStockList(@Param("dto") WorkerStockDTO workerStockDTO,
                                                 @Param("stockList") List<WorkerStockDTO> stockList);
 
     /**

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/common/WechatLogic.java

@@ -1006,7 +1006,7 @@ public class WechatLogic {
         if(httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK){
             log.info("调用微信接口失败:"+httpPost.getURI());
             log.info("返回数据:"+s);
-            throw new RuntimeException("调用微信接口失败");
+            throw new RemoteServiceException("调用微信接口失败");
         }
         log.info("调用微信接口成功:"+httpPost.getURI());
         log.info("微信接口返回数据:"+s);

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitGoodsPriceLogic.java

@@ -147,7 +147,7 @@ public class WebsitGoodsPriceLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         WebsitPriceUpd priceUpd = websitPriceUpdService.getById(sheetId);
         if (!priceUpd.getCompanyWechatId().equals(adminUser.getCompanyWechatId())) {
-            throw new RuntimeException("关键信息错误");
+            throw new RemoteServiceException("关键信息错误");
         }
 
         websitPriceUpdService.lambdaUpdate()

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

@@ -63,7 +63,7 @@ public class WebsitPartsOldOutLogic {
     public void add(List<WebsitStockOutListBean> beans) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         if (adminUser.getType() != 0) {
-            throw new RuntimeException("非网点账号不能添加");
+            throw new RemoteServiceException("非网点账号不能添加");
         }
 
         final List<AdminWebsit> websitList = adminWebsitService.lambdaQuery()
@@ -282,7 +282,7 @@ public class WebsitPartsOldOutLogic {
     public void confirm(List<String> ids) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         if (adminUser.getType() == 2) {
-            throw new RuntimeException("网点账号不能审核");
+            throw new RemoteServiceException("网点账号不能审核");
         }
         List<WebsitPartsOldOutRecord> recordList = websitPartsOldOutRecordService.listByIds(ids);
         if (CollectionUtil.isNotEmpty(recordList)) {

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPurchaseLogic.java

@@ -212,7 +212,7 @@ public class WebsitPurchaseLogic {
         }
 
         if (!purchase.getCompanyWechatId().equals(adminUser.getCompanyWechatId())) {
-            throw new RuntimeException("关键信息错误");
+            throw new RemoteServiceException("关键信息错误");
         }
 
         if (purchase.getIsImport() && StringUtils.isBlank(storageId)) {

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPurchaseRetLogic.java

@@ -248,7 +248,7 @@ public class WebsitPurchaseRetLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         WebsitPurchaseRet purchaseRet = websitPurchaseRetService.getById(purchaseRetId);
         if (!purchaseRet.getCompanyWechatId().equals(adminUser.getCompanyWechatId())) {
-            throw new RuntimeException("关键信息错误");
+            throw new RemoteServiceException("关键信息错误");
         }
 
         if (purchaseRet.getIsImport() && StringUtils.isBlank(storageId)) {

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

@@ -428,7 +428,7 @@ public class WebsitSalesLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         WebsitSales sales = websitSalesService.getById(salesId);
         if (!sales.getCompanyWechatId().equals(adminUser.getCompanyWechatId())) {
-            throw new RuntimeException("关键信息错误");
+            throw new RemoteServiceException("关键信息错误");
         }
 
         sales.setSubmitTime(DateUtil.date());
@@ -499,7 +499,7 @@ public class WebsitSalesLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         WebsitSales sales = websitSalesService.getById(salesId);
         if (!sales.getCompanyWechatId().equals(adminUser.getCompanyWechatId())) {
-            throw new RuntimeException("关键信息错误");
+            throw new RemoteServiceException("关键信息错误");
         }
         if (!sales.getFlag().equals(MaterialSalesFlagEnum.PAY_NOT_TAKE.getKey())) {
             MaterialSalesFlagEnum flagEnum = BaseEnum.keyToEnumNotNull(MaterialSalesFlagEnum.class, sales.getFlag());
@@ -553,7 +553,7 @@ public class WebsitSalesLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         WebsitSales sales = websitSalesService.getById(salesId);
         if (!sales.getCompanyWechatId().equals(adminUser.getCompanyWechatId())) {
-            throw new RuntimeException("关键信息错误");
+            throw new RemoteServiceException("关键信息错误");
         }
         websitSalesService.lambdaUpdate()
                 .set(WebsitSales::getFlag, MaterialSalesFlagEnum.PAY_NOT_TAKE.getKey())

+ 14 - 11
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/MaterialGoodsStockLogic.java

@@ -64,7 +64,7 @@ public class MaterialGoodsStockLogic {
             try {
                 ValidateUtil.validate(websitStockDTO);
                 if (websitStockDTO.getChangeQty().compareTo(BigDecimal.ZERO) <= 0) {
-                    throw new RuntimeException("变动数量不能少于0");
+                    throw new RemoteServiceException("变动数量不能少于0");
                 }
             } catch (ValidationException ve) {
                 throw new RemoteServiceException("执行数据第" + (i+1) + "行" + ve.getMessage());
@@ -114,18 +114,22 @@ public class MaterialGoodsStockLogic {
                     throw new RemoteServiceException("销售网点编号不能空");
                 }
                 if (workerStockDTO.getChangeQty().compareTo(BigDecimal.ZERO) <= 0) {
-                    throw new RuntimeException("变动数量不能少于0");
+                    throw new RemoteServiceException("变动数量不能少于0");
                 }
+//                if (workerStockDTO.getGoodsType().equals(WebsitGoodsTypeEnum.P.getKey()) && StringUtils.isBlank(workerStockDTO.getWorkerId())) {
+//                    throw new RemoteServiceException("师傅编号不能空");
+//                }
             } catch (ValidationException ve) {
                 throw new RemoteServiceException("第" + (i+1) + "行" + ve.getMessage());
             }
         }
         // 锁定师傅配件库存
         WorkerStockDTO workerStockDTO = stockList.get(0);
-        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.MATERIAL_STOCK_LOCK +
+        String key = Constant.RedisPrefix.MATERIAL_STOCK_LOCK +
                 workerStockDTO.getCompanyWechatId() + ":" +
-                workerStockDTO.getWorkerId() + ":" +
-                workerStockDTO.getGoodsType());
+                workerStockDTO.getIdentity() + ":" +
+                workerStockDTO.getGoodsType();
+        Lock obtain = redisLockRegistry.obtain(key);
         if(!obtain.tryLock(10, TimeUnit.SECONDS)){
             throw new RemoteServiceException("库存已冻结:" + workerStockDTO.getWorkerName());
         }
@@ -139,8 +143,7 @@ public class MaterialGoodsStockLogic {
 
     private void saveWorkerStock(WorkerStockDTO workerStockDTO, List<WorkerStockDTO> stockList) throws Exception {
         // 查询存在的商品库存
-        List<WorkerStock> existWorkerStockList = materialGoodsStockCMapper.queryExistWorkerStockList(workerStockDTO.getCompanyWechatId(),
-                workerStockDTO.getWorkerId(), stockList);
+        List<WorkerStock> existWorkerStockList = materialGoodsStockCMapper.queryExistWorkerStockList(workerStockDTO, stockList);
         // 全部商品库存
         Map<String, WorkerStock> existWorkerStockMap = this.createNotExistWorkerStock(workerStockDTO.getGoodsType(), stockList, existWorkerStockList);
         // 计算商品库存
@@ -158,7 +161,7 @@ public class MaterialGoodsStockLogic {
     private void computeWorkerStock(List<WorkerStockDTO> stockList, Map<String, WorkerStock> existWorkerStockMap,
                                     List<WorkerStockAcc> workerStockAccList) throws Exception {
         for (WorkerStockDTO workerStockDTO : stockList) {
-            WorkerStock workerStock = existWorkerStockMap.get(workerStockDTO.getGoodsId());
+            WorkerStock workerStock = existWorkerStockMap.get(workerStockDTO.getCompanyWechatId() + workerStockDTO.getGoodsId());
             if (workerStockDTO.getGoodsType().equals(WebsitGoodsTypeEnum.P.getKey())) {
                 workerStock = existWorkerStockMap.get(workerStockDTO.getCompanyWechatId() + workerStockDTO.getWebsitId() + workerStockDTO.getPartsWebsitId() +  workerStockDTO.getGoodsId());
             }
@@ -174,7 +177,7 @@ public class MaterialGoodsStockLogic {
 
         if (goodsType.equals(WebsitGoodsTypeEnum.M.getKey())) {
             existShopStockMap = existWorkerStockList.stream()
-                    .collect(Collectors.toMap(WorkerStock::getGoodsId, Function.identity()));
+                    .collect(Collectors.toMap(o -> o.getCompanyWechatId() + o.getGoodsId(), Function.identity()));
         } else {
             existShopStockMap = existWorkerStockList.stream()
                     .collect(Collectors.toMap(o -> o.getCompanyWechatId() + o.getWebsitId() + o.getPartsWebsitId() +  o.getGoodsId(), Function.identity()));
@@ -182,7 +185,7 @@ public class MaterialGoodsStockLogic {
 
         // 找出不存在的商品库存并存入新商品库存List
         for (WorkerStockDTO workerStockDTO : stockList) {
-            WorkerStock workerStock = existShopStockMap.get(workerStockDTO.getGoodsId());
+            WorkerStock workerStock = existShopStockMap.get(workerStockDTO.getCompanyWechatId() + workerStockDTO.getGoodsId());
             if (goodsType.equals(WebsitGoodsTypeEnum.P.getKey())) {
                 workerStock = existShopStockMap.get(workerStockDTO.getCompanyWechatId() + workerStockDTO.getWebsitId() + workerStockDTO.getPartsWebsitId() +  workerStockDTO.getGoodsId());
             }
@@ -190,7 +193,7 @@ public class MaterialGoodsStockLogic {
             if (Objects.isNull(workerStock)) {
                 workerStock = workerStockDTO.createWorkerStock();
                 if (goodsType.equals(WebsitGoodsTypeEnum.M.getKey())) {
-                    existShopStockMap.put(workerStockDTO.getGoodsId(), workerStock);
+                    existShopStockMap.put(workerStockDTO.getCompanyWechatId() + workerStockDTO.getGoodsId(), workerStock);
                 } else {
                     existShopStockMap.put(workerStockDTO.getCompanyWechatId() + workerStockDTO.getWebsitId() + workerStockDTO.getPartsWebsitId() +  workerStockDTO.getGoodsId(), workerStock);
                 }

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

@@ -29,7 +29,7 @@
         WHERE
         company_wechat_id = #{companyWechatId}
         AND
-        worker_id = #{workerId}
+        identity = #{dto.identity}
         AND
         goods_id IN
         <foreach item="item" index="index" collection="stockList" open="(" separator=","