Procházet zdrojové kódy

门店供应链物品管理/记录

zhangkaikai před 1 rokem
rodič
revize
268c07886f

+ 29 - 0
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/ChannelGoodsOrderMgrController.java

@@ -8,6 +8,7 @@ import com.qs.mp.admin.domain.param.ChannelGoodsOrderQueryParam;
 import com.qs.mp.admin.domain.param.ChannelGoodsOrderShipParam;
 import com.qs.mp.admin.service.IGoodsService;
 import com.qs.mp.channel.domain.Channel;
+import com.qs.mp.channel.domain.ChannelGoods;
 import com.qs.mp.channel.domain.ChannelGoodsOrder;
 import com.qs.mp.channel.domain.ChannelGoodsOrderItem;
 import com.qs.mp.channel.domain.excel.ChannelGoodsOrderExcel;
@@ -16,6 +17,7 @@ import com.qs.mp.channel.domain.vo.ChannelGoodsOrderItemVO;
 import com.qs.mp.channel.domain.vo.ChannelGoodsOrderVO;
 import com.qs.mp.channel.service.IChannelGoodsOrderItemService;
 import com.qs.mp.channel.service.IChannelGoodsOrderService;
+import com.qs.mp.channel.service.IChannelGoodsService;
 import com.qs.mp.channel.service.IChannelService;
 import com.qs.mp.common.annotation.Log;
 import com.qs.mp.common.core.domain.AjaxResult;
@@ -71,6 +73,9 @@ public class ChannelGoodsOrderMgrController extends BaseApiController {
     @Autowired
     private IDeliveryCompanyService deliveryCompanyService;
 
+    @Autowired
+    private IChannelGoodsService channelGoodsService;
+
     @Autowired
     private MapperFacade mapperFacade;
 
@@ -178,6 +183,30 @@ public class ChannelGoodsOrderMgrController extends BaseApiController {
                     .set(ChannelGoodsOrder::getStatus, ChannelGoodsOrderStatusEnum.FINISHED)
                     .eq(ChannelGoodsOrder::getOrderId, shipParam.getOrderId()));
 
+            // 商品自动入库
+            List<ChannelGoodsOrderItem> items = channelGoodsOrderItemService.list(new QueryWrapper<ChannelGoodsOrderItem>().eq("order_id", order.getOrderId()));
+            List<ChannelGoods> goodsList = new ArrayList<>();
+            for (ChannelGoodsOrderItem item : items) {
+                Goods goods = goodsService.getById(item.getGoodsId());
+                ChannelGoods channelGoods = new ChannelGoods();
+                channelGoods.setChannelId(item.getChannelId());
+                channelGoods.setGoodsId(item.getGoodsId());
+                channelGoods.setOrderId(item.getOrderId());
+                channelGoods.setSkuId(item.getSkuId());
+                channelGoods.setProperties(item.getProperties());
+                channelGoods.setTitle(item.getTitle());
+                channelGoods.setPicUrl(item.getPicUrl());
+                channelGoods.setStatus(ChannelGoodsSettleStatusTypeEnum.NO);
+                channelGoods.setRefId(goods.getRefId());
+                channelGoods.setSupplierId(item.getSupplierId());
+                channelGoods.setQuantity(item.getGoodsNum());
+                channelGoods.setRemainQty(item.getGoodsNum());
+                channelGoods.setPurchasePrice(item.getPurchasePrice());
+                channelGoods.setPurchaseCost(item.getPurchaseCost());
+                goodsList.add(channelGoods);
+            }
+            channelGoodsService.saveBatch(goodsList);
+
         } else if (DeliverTypeEnum.DELIVER.getValue().equals(deliveryType)) {
             // 快递发货,原逻辑
             rtn = channelGoodsOrderService.update(new LambdaUpdateWrapper<ChannelGoodsOrder>()

+ 4 - 2
mp-admin/src/main/java/com/qs/mp/web/controller/api/channel/ChannelGoodsController.java

@@ -135,7 +135,8 @@ public class ChannelGoodsController extends BaseApiController {
     public TableDataInfo goodsListUnderChannel() {
         startPage();
         Long channelId = SecurityUtils.getLoginUser().getChannelId();
-        QueryWrapper<ChannelGoods> wrapper = new QueryWrapper<ChannelGoods>().eq("t3.channel_id", channelId);
+        QueryWrapper<ChannelGoods> wrapper = new QueryWrapper<ChannelGoods>()
+                .eq("t3.channel_id", channelId);
         List<ChannelGoodsVO> channelGoodsVOs = channelGoodsService.listChannelGoodsUnderChannel(wrapper);
         Map<Long, List<ChannelGoodsVO>> map = channelGoodsVOs.stream().collect(Collectors.groupingBy(ChannelGoodsVO::getChannelId));
         List<ChannelGoodsVO> channelGoodsVOList = new ArrayList<>();
@@ -145,7 +146,8 @@ public class ChannelGoodsController extends BaseApiController {
             int totalQuantity = value.stream().mapToInt(ChannelGoods::getQuantity).sum();
             int totalVerQuantity = value.stream().mapToInt(ChannelGoods::getVerifyQty).sum();
             int remainTotalQuantity = value.stream().mapToInt(ChannelGoodsVO::getRemainQty).sum();
-            int deepQuantity = value.stream().mapToInt(ChannelGoods::getRemainQty).min().getAsInt();
+            List<ChannelGoodsVO> NoSettleGoods = value.stream().filter(g -> ChannelGoodsSettleStatusTypeEnum.NO.equals(g.getStatus())).collect(Collectors.toList());
+            int deepQuantity = NoSettleGoods.stream().mapToInt(ChannelGoods::getRemainQty).min().getAsInt();
             channelGoodsVO.setTotalQuantity(totalQuantity);
             channelGoodsVO.setTotalVerQuantity(totalVerQuantity);
             channelGoodsVO.setRemainTotalQuantity(remainTotalQuantity);