Forráskód Böngészése

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

‘linchangsheng’ 5 hónapja
szülő
commit
b536de8071
21 módosított fájl, 143 hozzáadás és 133 törlés
  1. 2 1
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/commonmapper/MaterialMapper.java
  2. 4 4
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/commonmapper/stock/MaterialGoodsStockCMapper.java
  3. 4 3
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/common/EventController.java
  4. 7 7
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/WebsitSalesLogic.java
  5. 20 20
      mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/stock/MaterialGoodsStockLogic.java
  6. 1 1
      mall-miniapp-service/src/main/resources/mapper/MaterialMapper.xml
  7. 20 23
      mall-miniapp-service/src/main/resources/mapper/WorkerStockCMapper.xml
  8. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/bean/material/stock/WorkerStockDTO.java
  9. 1 2
      mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/MaterialGoodsStockCMapper.java
  10. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/logic/common/WechatLogic.java
  11. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitGoodsPriceLogic.java
  12. 2 2
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPartsOldOutLogic.java
  13. 16 15
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPartsSalesOrderLogic.java
  14. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPurchaseLogic.java
  15. 1 1
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPurchaseRetLogic.java
  16. 18 17
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitSalesLogic.java
  17. 14 11
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/MaterialGoodsStockLogic.java
  18. 28 21
      mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WorkerStockLogic.java
  19. 1 1
      mall-server-api/src/main/resources/mapper/MaterialGoodsStockCMapper.xml
  20. BIN
      mall-server-api/src/main/resources/template/辅材师傅库存.xlsx
  21. BIN
      mall-server-api/src/main/resources/template/配件师傅库存.xlsx

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

@@ -7,6 +7,7 @@ import com.gree.mall.miniapp.bean.material.*;
 import com.gree.mall.miniapp.bean.material.parts.*;
 import com.gree.mall.miniapp.bean.material.stock.WorkerNormStockBean;
 import com.gree.mall.miniapp.plus.entity.AdminWebsit;
+import com.gree.mall.miniapp.plus.entity.User;
 import com.gree.mall.miniapp.plus.entity.WebsitPartsSalesItem;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -21,7 +22,7 @@ public interface MaterialMapper {
      * 购买记录
      */
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
-    IPage<SalesOrderBean> buyList(IPage page, @Param("companyWechatId") String companyWechatId, @Param("userId") String userId, @Param("flag") String flag);
+    IPage<SalesOrderBean> buyList(IPage page, @Param("companyWechatId") String companyWechatId, @Param("user") User user, @Param("flag") String flag);
 
     /**
      * 网点库存分类

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

@@ -5,6 +5,7 @@ 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.User;
 import com.gree.mall.miniapp.plus.entity.WebsitGoodsCategory;
 import com.gree.mall.miniapp.plus.entity.WebsitStock;
 import com.gree.mall.miniapp.plus.entity.WorkerStock;
@@ -20,7 +21,7 @@ public interface MaterialGoodsStockCMapper {
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     List<WebsitGoodsCategory> queryWebsitGoodsCategoryList(
             @Param("websitId") String websitId,
-            @Param("userId") String userId,
+            @Param("user") User user,
             @Param("goodsType") String goodsType
     );
 
@@ -28,7 +29,7 @@ public interface MaterialGoodsStockCMapper {
     IPage<WorkerStockBean> queryWorkerStockList(
             IPage page,
             @Param("websitId") String websitId,
-            @Param("userId") String userId,
+            @Param("user") User user,
             @Param("goodsType") String goodsType,
             @Param("categoryId") String categoryId
     );
@@ -40,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("无效的签名");
         }
     }
 

+ 7 - 7
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/WebsitSalesLogic.java

@@ -83,7 +83,7 @@ public class WebsitSalesLogic {
 
     public IPage<SalesOrderBean> buyList(String flag, Integer pageNum, Integer pageSize, HttpServletRequest request) {
         CurrentCompanyWechat wechat = commonLogic.getCurrentCompanyWechat(request);
-        IPage<SalesOrderBean> page = materialMapper.buyList(new Page<>(pageNum, pageSize), wechat.getCurrentCompanyWechatId(), wechat.getUser().getWorkerNumber(), flag);
+        IPage<SalesOrderBean> page = materialMapper.buyList(new Page<>(pageNum, pageSize), wechat.getCurrentCompanyWechatId(), wechat.getUser(), flag);
         return page;
     }
 
@@ -123,36 +123,36 @@ public class WebsitSalesLogic {
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat(request);
         websitSalesService.lambdaUpdate()
                 .set(WebsitSales::getFlag, "CANCEL")
-                .eq(WebsitSales::getWorkerId, currentCompanyWechat.getUser().getWorkerNumber())
+                .eq(WebsitSales::getIdentity, currentCompanyWechat.getUser().getIdCard())
                 .eq(WebsitSales::getSalesId, salesId)
                 .in(WebsitSales::getFlag, "SAVE", "SUBMIT")
                 .update();
     }
 
-    public PayDetail pay(HttpServletRequest request, String salesId,Boolean miniPay,String openId) {
+    public PayDetail pay(HttpServletRequest request, String salesId, Boolean miniPay, String openId) {
         String ip = IpUtil.getIpAddr(request);
         CurrentCompanyWechat wechat = commonLogic.getCurrentCompanyWechat(request);
         WebsitSales sales = websitSalesService.lambdaQuery()
                 .eq(WebsitSales::getSalesId, salesId)
-                .eq(WebsitSales::getWorkerId, wechat.getUser().getWorkerNumber())
+                .eq(WebsitSales::getIdentity, wechat.getUser().getIdCard())
                 .eq(WebsitSales::getFlag, "SUBMIT")
                 .one();
         if (Objects.isNull(sales)) {
             throw new RemoteServiceException(salesId + "订单号不存在,无法发起支付");
         }
 
-        if ( miniPay != null && miniPay) {
+        if (miniPay != null && miniPay) {
             websitSalesService.lambdaUpdate()
                     .eq(WebsitSales::getSalesId, salesId)
                     .set(WebsitSales::getSource, OrderInfoSourceEnum.A.getRemark())
                     .update();
-        }else {
+        } else {
             websitSalesService.lambdaUpdate()
                     .eq(WebsitSales::getSalesId, salesId)
                     .set(WebsitSales::getSource, OrderInfoSourceEnum.B.getRemark())
                     .update();
         }
-        return wechatLogic.payment(salesId, sales.getTotalAmount(),miniPay != null && miniPay?openId:wechat.getUser().getOpenId(), "N", ip, sales.getCompanyWechatId(),miniPay);
+        return wechatLogic.payment(salesId, sales.getTotalAmount(), miniPay != null && miniPay ? openId : wechat.getUser().getOpenId(), "N", ip, sales.getCompanyWechatId(), miniPay);
     }
 
     public List<WebsitSalesCategoryVO> existStockCategory(HttpServletRequest request, String websitId) {

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

@@ -67,7 +67,7 @@ public class MaterialGoodsStockLogic {
      */
     public List<WebsitGoodsCategory> websitGoodsCategoryList(String webistId, String goodsType) {
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
-        List<WebsitGoodsCategory> websitGoodsCategories = materialGoodsStockCMapper.queryWebsitGoodsCategoryList(webistId, currentCompanyWechat.getUser().getWorkerNumber(), goodsType);
+        List<WebsitGoodsCategory> websitGoodsCategories = materialGoodsStockCMapper.queryWebsitGoodsCategoryList(webistId, currentCompanyWechat.getUser(), goodsType);
         return websitGoodsCategories;
     }
 
@@ -83,7 +83,7 @@ public class MaterialGoodsStockLogic {
     public IPage<WorkerStockBean> workerStockList(String websitId, String goodsType, String categoryId, Integer pageNum, Integer pageSize) {
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
         IPage<WorkerStockBean> workerStockBeanIPage = materialGoodsStockCMapper
-                .queryWorkerStockList(new Page(pageNum, pageSize), websitId, currentCompanyWechat.getUser().getWorkerNumber(), goodsType, categoryId);
+                .queryWorkerStockList(new Page(pageNum, pageSize), websitId, currentCompanyWechat.getUser(), goodsType, categoryId);
 
         return workerStockBeanIPage;
     }
@@ -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);
                 }

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

@@ -193,7 +193,7 @@
             websit_sales a
         <where>
             a.company_wechat_id = #{companyWechatId}
-            AND worker_id = #{userId}
+            AND a.identity = #{user.idCard}
             <if test="flag!=null and flag!=''">
                 AND a.flag = #{flag}
             </if>

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

@@ -17,20 +17,18 @@
             <if test="websitId != null and websitId !=''">
                 and c.websit_id = #{websitId}
             </if>
-            <if test="userId != null and userId !=''">
-                and c.worker_id = #{userId}
-            </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
@@ -42,8 +40,9 @@
             <if test="websitId != null and websitId !=''">
                 and a.websit_id = #{websitId}
             </if>
-            <if test="userId != null and userId !=''">
-                and a.worker_id = #{userId}
+            and a.identity = #{user.idCard}
+            <if test="goodsType == null">
+                and a.worker_id = ''
             </if>
             <if test="categoryId != null and categoryId !=''">
                 and b.goods_category_id = #{categoryId}
@@ -73,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)) {

+ 16 - 15
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPartsSalesOrderLogic.java

@@ -566,27 +566,28 @@ public class WebsitPartsSalesOrderLogic {
         partsSalesOrderBean.setStatus(PartsOrderStatusEnum.PAYED.getKey());
         partsSalesOrderBean.setPayFlag(PartsPayFlagEnum.PAY_NOT_TAKE.getKey());
         partsSalesOrderBean.setPayType(PayTypeEnum.CASH.getKey());
+        partsSalesOrderBean.setPayTime(DateUtil.date());
 
         this.handleForwardWebsitAndWorkerStock(partsSalesOrderBean);
 
 
         websitPartsSalesService.saveOrUpdate(partsSalesOrderBean);
 
-        new WebsitSalesPayOrder()
-                .setCompanyWechatId(partsSalesOrderBean.getCompanyWechatId())
-                .setCompanyWechatName(partsSalesOrderBean.getCompanyWechatName())
-                .setGoodsType(WebsitGoodsTypeEnum.P.getKey())
-                .setWebsitId(partsSalesOrderBean.getWebsitId())
-                .setWebsitName(partsSalesOrderBean.getWebsitName())
-                .setOrderId(partsSalesOrderBean.getId())
-                .setPayType(PayTypeEnum.CASH.getKey())
-                .setPayFlag(IsYesNoEnum.YES.getKey())
-                .setOrderCreateTime(partsSalesOrderBean.getCreateTime())
-                .setPayValue(partsSalesOrderBean.getTotalAmount())
-                .setPayTime(DateUtil.date())
-                .setOrderType(PayOrderTypeEnum.S.getKey())
-                .setOrderSource(SalesPayOrderSourceEnum.P_SALES.getKey())
-                .insert();
+//        new WebsitSalesPayOrder()
+//                .setCompanyWechatId(partsSalesOrderBean.getCompanyWechatId())
+//                .setCompanyWechatName(partsSalesOrderBean.getCompanyWechatName())
+//                .setGoodsType(WebsitGoodsTypeEnum.P.getKey())
+//                .setWebsitId(partsSalesOrderBean.getWebsitId())
+//                .setWebsitName(partsSalesOrderBean.getWebsitName())
+//                .setOrderId(partsSalesOrderBean.getId())
+//                .setPayType(PayTypeEnum.CASH.getKey())
+//                .setPayFlag(IsYesNoEnum.YES.getKey())
+//                .setOrderCreateTime(partsSalesOrderBean.getCreateTime())
+//                .setPayValue(partsSalesOrderBean.getTotalAmount())
+//                .setPayTime(DateUtil.date())
+//                .setOrderType(PayOrderTypeEnum.S.getKey())
+//                .setOrderSource(SalesPayOrderSourceEnum.P_SALES.getKey())
+//                .insert();
 
         return partsSalesOrderBean;
     }

+ 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)) {

+ 18 - 17
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,11 +553,12 @@ 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())
                 .set(WebsitSales::getPayType, PayTypeEnum.CASH.getKey())
+                .set(WebsitSales::getPayTime, DateUtil.date())
                 .eq(WebsitSales::getSalesId, salesId)
                 .update();
 
@@ -572,20 +573,20 @@ public class WebsitSalesLogic {
         }
 
         // 生成现金支付记录
-        WebsitSalesPayOrder order = new WebsitSalesPayOrder();
-        order.setCompanyWechatId(sales.getCompanyWechatId());
-        order.setCompanyWechatName(sales.getCompanyWechatName());
-        order.setGoodsType(sales.getGoodsType());
-        order.setWebsitId(sales.getWebsitId());
-        order.setWebsitName(sales.getWebsitName());
-        order.setOrderId(sales.getSalesId());
-        order.setPayType(PayTypeEnum.CASH.getKey());
-        order.setPayFlag(IsYesNoEnum.YES.getKey());
-        order.setPayTime(sales.getSubmitTime());
-        order.setPayValue(sales.getTotalAmount());
-        order.setOrderType(PayOrderTypeEnum.S.getKey());
-        order.setOrderSource(sales.getGoodsType().equals(WebsitGoodsTypeEnum.M.getKey()) ? SalesPayOrderSourceEnum.M_SALES.getKey() : SalesPayOrderSourceEnum.P_SALES.getKey());
-        order.insert();
+//        WebsitSalesPayOrder order = new WebsitSalesPayOrder();
+//        order.setCompanyWechatId(sales.getCompanyWechatId());
+//        order.setCompanyWechatName(sales.getCompanyWechatName());
+//        order.setGoodsType(sales.getGoodsType());
+//        order.setWebsitId(sales.getWebsitId());
+//        order.setWebsitName(sales.getWebsitName());
+//        order.setOrderId(sales.getSalesId());
+//        order.setPayType(PayTypeEnum.CASH.getKey());
+//        order.setPayFlag(IsYesNoEnum.YES.getKey());
+//        order.setPayTime(sales.getSubmitTime());
+//        order.setPayValue(sales.getTotalAmount());
+//        order.setOrderType(PayOrderTypeEnum.S.getKey());
+//        order.setOrderSource(sales.getGoodsType().equals(WebsitGoodsTypeEnum.M.getKey()) ? SalesPayOrderSourceEnum.M_SALES.getKey() : SalesPayOrderSourceEnum.P_SALES.getKey());
+//        order.insert();
     }
 
     public List<WebsitSalesCategoryVO> existStockCategory(String websitId, String storageId) {

+ 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);
                 }

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

@@ -17,6 +17,7 @@ import com.gree.mall.manager.bean.material.stock.WorkerStockDTO;
 import com.gree.mall.manager.bean.material.worker.OldRefundManageBean;
 import com.gree.mall.manager.bean.material.worker.OldRefundManageItemBean;
 import com.gree.mall.manager.commonmapper.CommonMapper;
+import com.gree.mall.manager.enums.UserTypeEnum;
 import com.gree.mall.manager.enums.material.*;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.inf.ValidGroup;
@@ -162,10 +163,10 @@ public class WorkerStockLogic {
             CommonUtils.initList(row, 10);
             if (websitGoodsTypeEnum.getKey().equals(WebsitGoodsTypeEnum.M.getKey())) {
                 String goodsId = row.get(0);
-                String workerNumber = row.get(1);
+                String idCard = row.get(1);
                 String qty = row.get(2);
                 String price = row.get(3);
-                if (StringUtils.isAnyBlank(goodsId, workerNumber, qty, price)) {
+                if (StringUtils.isAnyBlank(goodsId, idCard, qty, price)) {
                     throw new RemoteServiceException("第" + (i + 1) + "行请补充完整内容");
                 }
                 WorkerGoods workerGoods = workerGoodsService.lambdaQuery()
@@ -177,18 +178,21 @@ public class WorkerStockLogic {
                 }
 
                 //判断师傅信息
-                User user = userService.lambdaQuery()
-                        .eq(User::getWorkerNumber, workerNumber)
+                List<User> userList = userService.lambdaQuery()
+                        .eq(User::getIdCard, idCard)
+                        .eq(User::getType, UserTypeEnum.WORKER.getKey())
+                        .eq(User::getStatus, true)
                         .eq(User::getCompanyWechatId, adminUser.getCompanyWechatId())
-                        .last("limit 1")
-                        .one();
-                if (user == null) {
-                    throw new RemoteServiceException("师傅编号【" + workerNumber + "】不存在");
+                        .list();
+                if (CollectionUtil.isEmpty(userList)) {
+                    throw new RemoteServiceException("师傅身份证【" + idCard + "】不存在");
                 }
+                User user = userList.get(0);
                 Integer count = workerStockService.lambdaQuery()
                         .eq(WorkerStock::getCompanyWechatId, adminUser.getCompanyWechatId())
-                        .eq(WorkerStock::getWorkerId, user.getUserId())
-                        .eq(WorkerStock::getGoodsId, goodsId).count();
+                        .eq(WorkerStock::getIdentity, user.getIdCard())
+                        .eq(WorkerStock::getGoodsId, goodsId)
+                        .count();
                 if (count > 0) {
                     throw new RemoteServiceException(tipsGoodsName + "编号【" + goodsId + "】的库存记录已存在于系统,导入失败");
                 }
@@ -223,8 +227,8 @@ public class WorkerStockLogic {
                 String stock = row.get(1);
                 String oldQty = row.get(2);
                 //String websitName = row.get(4);
-                String workerId = row.get(4);
-                if (StringUtils.isAnyBlank(goodsId, stock, oldQty, workerId)) {
+                String idCard = row.get(4);
+                if (StringUtils.isAnyBlank(goodsId, stock, oldQty, idCard)) {
                     throw new RemoteServiceException("第" + (i + 1) + "行请补充完整内容");
                 }
                 WebsitGoods websitGoods = websitGoodsService.lambdaQuery()
@@ -237,17 +241,19 @@ public class WorkerStockLogic {
                 }
 
                 //判断师傅信息
-                User user = userService.lambdaQuery()
-                        .eq(User::getWorkerNumber, workerId)
+                List<User> userList = userService.lambdaQuery()
+                        .eq(User::getIdCard, idCard)
+                        .eq(User::getType, UserTypeEnum.WORKER.getKey())
+                        .eq(User::getStatus, true)
                         .eq(User::getCompanyWechatId, adminUser.getCompanyWechatId())
-                        .last("limit 1")
-                        .one();
-                if (user == null) {
-                    throw new RemoteServiceException("师傅编号【" + workerId + "】不存在");
+                        .list();
+                if (CollectionUtil.isEmpty(userList)) {
+                    throw new RemoteServiceException("师傅编号【" + idCard + "】不存在");
                 }
+                User user = userList.get(0);
                 Integer count = workerStockService.lambdaQuery()
                         .eq(WorkerStock::getCompanyWechatId, adminUser.getCompanyWechatId())
-                        .eq(WorkerStock::getWorkerId, user.getWorkerNumber())
+                        .eq(WorkerStock::getIdentity, user.getIdCard())
                         .eq(WorkerStock::getGoodsId, goodsId)
                         .count();
                 if (count > 0) {
@@ -332,12 +338,13 @@ public class WorkerStockLogic {
             List<WorkerStockAcc> workerStockRemoveAccs = new ArrayList<>();
             // 按师傅分组
             final Map<String, List<WorkerStock>> workerGroupMap = stockList.stream()
-                    .collect(Collectors.groupingBy(WorkerStock::getWorkerId));
+                    .collect(Collectors.groupingBy(WorkerStock::getIdentity));
 
             for (Map.Entry<String, List<WorkerStock>> workerStock : workerGroupMap.entrySet()) {
                 // 需要删除的商品编号
                 final List<String> goodsIds = workerStock.getValue().stream()
-                        .map(WorkerStock::getGoodsId).collect(Collectors.toList());
+                        .map(WorkerStock::getGoodsId)
+                        .collect(Collectors.toList());
                 final List<WorkerStockAcc> workerStockAccs = workerStockAccService.lambdaQuery()
                         .eq(WorkerStockAcc::getCompanyWechatId, adminUser.getCompanyWechatId())
                         .in(WorkerStockAcc::getGoodsId, goodsIds)

+ 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=","

BIN
mall-server-api/src/main/resources/template/辅材师傅库存.xlsx


BIN
mall-server-api/src/main/resources/template/配件师傅库存.xlsx