Przeglądaj źródła

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

zhangkaikai 1 rok temu
rodzic
commit
cb36a8421b

+ 5 - 1
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/ChannelGoodsSettleMgrController.java

@@ -118,7 +118,11 @@ public class ChannelGoodsSettleMgrController extends BaseApiController {
             channelGoodsOrderSettleVO.setTotalRemainQty(channelGoodsList.stream().mapToInt(ChannelGoods::getRemainQty).sum());
             channelGoodsOrderSettleVO.setTotalSettleQty(channelGoodsList.stream().mapToInt(ChannelGoods::getSettleQty).sum());
             channelGoodsOrderSettleVO.setTotalVerifyQty(channelGoodsList.stream().mapToInt(ChannelGoods::getVerifyQty).sum());
-            channelGoodsOrderSettleVO.setTotalPurchaseCost(channelGoodsList.stream().mapToInt(ChannelGoods::getPurchaseCost).sum());
+            Integer totalPurchaseCost = 0;
+            for (ChannelGoods channelGoods : channelGoodsList) {
+                totalPurchaseCost += channelGoods.getPurchaseCost() * channelGoods.getRemainQty();
+            }
+            channelGoodsOrderSettleVO.setTotalPurchaseCost(totalPurchaseCost);
             channelGoodsOrderSettleVO.setStatus(channelGoodsList.get(0).getStatus());
 
             ChannelGoodsSettleOrderItem settleOrderItem = settleOrderItemService.getOne(new LambdaQueryWrapper<ChannelGoodsSettleOrderItem>().eq(ChannelGoodsSettleOrderItem::getChannelGoodsId, channelGoodsList.get(0).getId()));

+ 9 - 10
mp-service/src/main/java/com/qs/mp/channel/service/impl/ChannelGoodsSettleOrderServiceImpl.java

@@ -64,7 +64,7 @@ public class ChannelGoodsSettleOrderServiceImpl extends ServiceImpl<ChannelGoods
         settleOrder.setSettleNum(channelGoodsList.stream().mapToInt(ChannelGoods::getSettleQty).sum());
         Integer orderAmt = 0;
         for (ChannelGoods channelGoods : channelGoodsList) {
-            orderAmt += channelGoods.getPurchaseCost() * channelGoods.getSettleQty();
+            orderAmt += channelGoods.getPurchaseCost() * channelGoods.getRemainQty();
         }
         settleOrder.setChannelId(channelGoodsList.get(0).getChannelId());
         settleOrder.setOrderAmt(orderAmt);
@@ -85,14 +85,15 @@ public class ChannelGoodsSettleOrderServiceImpl extends ServiceImpl<ChannelGoods
             settleOrderItem.setRemainQty(channelGoods.getRemainQty());
             settleOrderItem.setSettleQty(channelGoods.getRemainQty());
             settleOrderItemService.save(settleOrderItem);
-        }
 
-        boolean update = channelGoodsService.update(
-                new LambdaUpdateWrapper<ChannelGoods>()
-                        .set(ChannelGoods::getStatus, ChannelGoodsSettleStatusTypeEnum.DOING)
-                        .set(ChannelGoods::getRemainQty, 0)
-                        .eq(ChannelGoods::getOrderId, settleVO.getOrderId()));
-        Assert.isTrue(update, "更新门店采购商品信息失败:order_id =" + settleVO.getOrderId());
+            boolean update = channelGoodsService.update(
+                    new LambdaUpdateWrapper<ChannelGoods>()
+                            .set(ChannelGoods::getStatus, ChannelGoodsSettleStatusTypeEnum.DOING)
+                            .set(ChannelGoods::getSettleQty,channelGoods.getRemainQty())
+                            .set(ChannelGoods::getRemainQty, 0)
+                            .eq(ChannelGoods::getId, channelGoods.getId()));
+            Assert.isTrue(update, "更新门店采购商品信息失败:order_id =" + settleVO.getOrderId());
+        }
 
         return settleOrder.getOrderId();
     }
@@ -119,11 +120,9 @@ public class ChannelGoodsSettleOrderServiceImpl extends ServiceImpl<ChannelGoods
             throw new ServiceException("渠道采购商品订单结算支付成功时,更新订单状态失败");
         }
         List<ChannelGoodsSettleOrderItem> items = settleOrderItemService.list(new LambdaQueryWrapper<ChannelGoodsSettleOrderItem>().eq(ChannelGoodsSettleOrderItem::getOrderId, settleOrder.getOrderId()));
-        int settleQty = items.stream().mapToInt(ChannelGoodsSettleOrderItem::getSettleQty).sum();
         List<Long> channelGoodsIdList = items.stream().map(ChannelGoodsSettleOrderItem::getChannelGoodsId).collect(Collectors.toList());
         boolean updateRst = channelGoodsService.update(new LambdaUpdateWrapper<ChannelGoods>()
                 .set(ChannelGoods::getStatus, ChannelGoodsSettleStatusTypeEnum.FINISHED)
-                .set(ChannelGoods::getSettleQty, settleQty)
                 .set(ChannelGoods::getSettleTime, DateUtils.parseDate(payOrder.getCompleteDate()))
                 .in(ChannelGoods::getId, channelGoodsIdList));