fubin 2 rokov pred
rodič
commit
9c82023d15

+ 41 - 8
src/main/java/com/dk/mdm/controller/ivt/outBound/OutboundController.java

@@ -18,7 +18,7 @@ import java.util.Map;
 @Api(tags = "出库单API接口")
 @RestController
 @RequestMapping("/ivt/outbound")
-public class OutboundController{
+public class OutboundController {
 
     public BaseService<Outbound> getService() {
         return outboundService;
@@ -39,9 +39,9 @@ public class OutboundController{
     }
 
     /**
-     * @desc   : 查询明细信息
+     * @desc : 查询明细信息
      * @author : 付斌
-     * @date   : 2024-03-07 16:36
+     * @date : 2024-03-07 16:36
      */
     @PostMapping({"select_outbound_info_by_id/{id}"})
     public ResponseResultVO<Map<String, Object>> selectOutboundInfoById(@PathVariable String id) {
@@ -60,7 +60,7 @@ public class OutboundController{
     }
 
     /**
-     * @desc : 新建出库单
+     * @desc : 新建销售出库单
      * @author : 付斌
      * @date : 2023/1/9 10:48
      */
@@ -71,7 +71,7 @@ public class OutboundController{
     }
 
     /**
-     * @desc : 编辑出库单
+     * @desc : 编辑销售出库单
      * @author : 付斌
      * @date : 2023/1/9 10:49
      */
@@ -82,7 +82,7 @@ public class OutboundController{
     }
 
     /**
-     * @desc : 作废
+     * @desc : 作废销售出库单
      * @author : 付斌
      * @date : 2024-03-08 16:36
      */
@@ -93,13 +93,46 @@ public class OutboundController{
     }
 
     /**
-     * @desc   : 获取出库单信息(编辑用)
+     * @desc : 获取出库单信息(编辑用)
      * @author : 付斌
-     * @date   : 2024-03-03 9:28
+     * @date : 2024-03-03 9:28
      */
     @ApiOperation(value = "编辑出库单", notes = "编辑出库单")
     @PostMapping({"get_outbound_for_update/{id}"})
     public ResponseResultVO<?> getOutboundForUpdate(@PathVariable String id) {
         return outboundService.getOutboundForUpdate(id);
     }
+
+    /**
+     * @desc : 新建销售退货出库单
+     * @author : 付斌
+     * @date : 2023/1/9 10:48
+     */
+    @ApiOperation(value = "新建出库单", notes = "新建出库单")
+    @PostMapping({"insert_out_return"})
+    public ResponseResultVO<?> insertOutReturn(@RequestBody OutboundVO outboundVO) {
+        return outboundService.insertOutReturn(outboundVO);
+    }
+
+    /**
+     * @desc : 编辑销售退货出库单
+     * @author : 付斌
+     * @date : 2023/1/9 10:49
+     */
+    @ApiOperation(value = "编辑出库单", notes = "编辑出库单")
+    @PostMapping({"update_out_return"})
+    public ResponseResultVO<Boolean> updateOutReturn(@RequestBody OutboundVO outboundVO) {
+        return outboundService.updateOutReturn(outboundVO);
+    }
+
+    /**
+     * @desc : 作废销售退货出库单
+     * @author : 付斌
+     * @date : 2024-03-08 16:36
+     */
+    @ApiOperation(value = "作废", notes = "作废")
+    @PostMapping({"invalid_out_return/{id}"})
+    public ResponseResultVO<?> invalidOutReturn(@PathVariable String id) {
+        return outboundService.invalidOutReturn(id);
+    }
 }

+ 5 - 5
src/main/java/com/dk/mdm/mapper/sale/OrderItemMapper.xml

@@ -332,12 +332,12 @@
         order by t.item_index
     </select>
 
-    <!-- 根据条件进行查询(出库用) -->
+    <!-- 根据条件进行查询(退货用) -->
     <select id="selectByCondForReturn" resultMap="BaseResultMapResponse">
-        SELECT tpobi.out_id                                         as "outId",
-               tpobi.item_id                                        as "outItemId",
-               t.order_id                                        as order_id,
-               t.item_id                                         as "orderItemId",
+        SELECT tpobi.out_id                                         as "sOutId",
+               tpobi.item_id                                        as "sOutItemId",
+               t.order_id                                           as "sOrderId",
+               t.item_id                                            as "sOrderItemId",
                t.sku_id,
                tmgs.sku_code                                        as "skuCode",
                tmgs.sku_model                                       as "skuModel",

+ 9 - 8
src/main/java/com/dk/mdm/model/pojo/ivt/OutboundItem.java

@@ -284,16 +284,17 @@ public class OutboundItem extends PageInfo<OutboundItem> implements Serializable
     @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
     private String opDbUser;
 
+    @ApiModelProperty(value = "源出库单ID")
+    private String sOutId;
 
-    /*
-     * 相关属性
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "源出库单明细ID")
+    private String sOutItemId;
 
-    /*
-     * 关联属性 + 查询条件
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "源销售订单ID")
+    private String sOrderId;
+
+    @ApiModelProperty(value = "源销售明细ID")
+    private String sOrderItemId;
 
 
     private static final long serialVersionUID = 1L;

+ 9 - 8
src/main/java/com/dk/mdm/model/query/ivt/OutboundItemQuery.java

@@ -190,16 +190,17 @@ public class OutboundItemQuery extends PageInfo<OutboundItemQuery>{
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
 
+    @ApiModelProperty(value = "源出库单ID")
+    private String sOutId;
 
-    /*
-     * 相关属性
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "源出库单明细ID")
+    private String sOutItemId;
 
-    /*
-     * 关联属性 + 查询条件
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "源销售订单ID")
+    private String sOrderId;
+
+    @ApiModelProperty(value = "源销售明细ID")
+    private String sOrderItemId;
 
 
     private static final long serialVersionUID = 1L;

+ 11 - 8
src/main/java/com/dk/mdm/model/response/ivt/OutboundItemResponse.java

@@ -252,15 +252,18 @@ public class OutboundItemResponse {
 
     @ApiModelProperty(value = "订单明细ID")
     private String orderItemId;
-    /*
-     * 相关属性
-     * @TableField(exist = false)
-     */
 
-    /*
-     * 关联属性 + 查询条件
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "源出库单ID")
+    private String sOutId;
+
+    @ApiModelProperty(value = "源出库单明细ID")
+    private String sOutItemId;
+
+    @ApiModelProperty(value = "源销售订单ID")
+    private String sOrderId;
+
+    @ApiModelProperty(value = "源销售明细ID")
+    private String sOrderItemId;
 
 
     private static final long serialVersionUID = 1L;

+ 9 - 8
src/main/java/com/dk/mdm/model/response/sale/OrderItemResponse.java

@@ -330,16 +330,17 @@ public class OrderItemResponse extends PageInfo<OrderItemResponse> implements Se
     @ApiModelProperty(value = "退货价")
     private BigDecimal priceReturn;
 
-    /*
-     * 相关属性
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "源出库单ID")
+    private String sOutId;
 
-    /*
-     * 关联属性 + 查询条件
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "源出库单明细ID")
+    private String sOutItemId;
+
+    @ApiModelProperty(value = "源销售订单ID")
+    private String sOrderId;
 
+    @ApiModelProperty(value = "源销售明细ID")
+    private String sOrderItemId;
 
     private static final long serialVersionUID = 1L;
 

+ 9 - 8
src/main/java/com/dk/mdm/model/vo/ivt/OutboundItemVO.java

@@ -190,16 +190,17 @@ public class OutboundItemVO {
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
 
+    @ApiModelProperty(value = "源出库单ID")
+    private String sOutId;
 
-    /*
-     * 相关属性
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "源出库单明细ID")
+    private String sOutItemId;
 
-    /*
-     * 关联属性 + 查询条件
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "源销售订单ID")
+    private String sOrderId;
+
+    @ApiModelProperty(value = "源销售明细ID")
+    private String sOrderItemId;
 
 
     private static final long serialVersionUID = 1L;

+ 295 - 8
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundService.java

@@ -36,10 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
 
 @Service
 @Transactional
@@ -258,9 +255,9 @@ public class OutboundService extends BaseService<Outbound> {
      * @date : 2024-03-08 16:38
      */
     public ResponseResultVO<?> invalid(String id) {
-        Outbound outboundForUpdate  = outboundMapper.selectByIdForUpdate(id);
+        Outbound outboundForUpdate = outboundMapper.selectByIdForUpdate(id);
         // 并发校验
-        if(!outboundForUpdate.getFlgValid()){
+        if (!outboundForUpdate.getFlgValid()) {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
         }
         // 如果出库数量或退货数量不是0,不能作废
@@ -278,7 +275,7 @@ public class OutboundService extends BaseService<Outbound> {
             orderItemUpdate.setOutingQty(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()))
                     .setOutingAmt(orderItemForUpdate.getOutingAmt().subtract(outboundItemForUpdate.getOutingAmt()))
                     .setItemId(orderItemForUpdate.getItemId());
-            if(orderItemUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0){
+            if (orderItemUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0) {
                 orderItemUpdate.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
             }
             orderItemService.updateByUuid(orderItemUpdate);
@@ -295,7 +292,7 @@ public class OutboundService extends BaseService<Outbound> {
         // 更新订单上的出库中数量,金额
         Order orderUpdate = new Order();
         orderUpdate.setOutingQty(orderItem.getOutingQty()).setOutingAmt(orderItem.getOutingAmt()).setOrderId(outboundForUpdate.getFromId());
-        if(orderUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0){
+        if (orderUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0) {
             orderUpdate.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
         }
 
@@ -326,6 +323,296 @@ public class OutboundService extends BaseService<Outbound> {
     }
 
     /**
+     * @desc : 新建销售出库退货
+     * @author : 付斌
+     * @date : 2023/1/9 10:49
+     */
+    @Transactional(
+            rollbackFor = {Exception.class}
+    )
+    public ResponseResultVO<?> insertOutReturn(OutboundVO outboundVO) {
+
+        // 获取单号
+        Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.OUTBOUND.getName(), false);
+        outboundVO.setOutId(codeMap.get("outId").toString()).setOutNo(codeMap.get("outNote").toString())
+                .setOutType(Constant.OutType.SALE.getName());
+        // 转化实体
+        Outbound outbound = outboundConvert.convertToPo(outboundVO);
+        // 总单保存
+        super.insert(outbound);
+
+        // 明细保存
+        if (outboundVO.getItemList() != null && outboundVO.getItemList().size() > 0) {
+            OrderItem orderItemForUpdate;
+            OutboundItem outboundItemForUpdate;
+            String sOrderId = null;
+
+            // 出库IdList,一个退货单可能有多个出库单
+            List<String> outIdList = new ArrayList<>();
+            for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
+                // 把出库Id存起来
+                if (!outIdList.contains(outboundItemVO.getSOutId())) {
+                    outIdList.add(outboundItemVO.getSOutId());
+                }
+                OutboundItem outboundItem = outboundItemConvert.convertToPo(outboundItemVO);
+                outboundItem.setOutId(outbound.getOutId()).setCpId(outbound.getCpId()).setOutStatus(Constant.OutStatus.CHUKUZHONG.getName())
+                        .setOutType(Constant.OutType.SALE.getName());
+                outboundItemMapper.insert(outboundItem);
+
+                /*********************  反写出库明细退货数量、金额 begin **********************/
+                outboundItemForUpdate = outboundItemMapper.selectByIdForUpdate(outboundItemVO.getSOutItemId());
+                // 如果出库数量小于订单上已退货+本次退货数量
+                if (outboundItemForUpdate.getOutQty().compareTo(outboundItemForUpdate.getReturnQty().add(outboundItemVO.getOutingQty().abs())) == -1) {
+                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.OUTQTY_NO_LESS_RETURNQTY.getMessage());
+                }
+                OutboundItem outboundItemUpdate = new OutboundItem();
+                outboundItemUpdate.setReturnQty(outboundItemForUpdate.getReturnQty().add(outboundItemVO.getOutingQty().abs()))
+                        .setReturnAmt(outboundItemForUpdate.getReturnAmt().add(outboundItemVO.getOutingAmt().abs()))
+                        .setItemId(outboundItemForUpdate.getItemId());
+                outboundItemService.updateByUuid(outboundItemUpdate);
+                /*********************  反写出库明细退货数量、金额 end **********************/
+
+
+                /*********************  反写订单明细退货数量、金额 begin **********************/
+                // 没有订单的化,不需要更新
+                if (outboundItemVO.getSOrderItemId() != null) {
+                    sOrderId = outboundItemVO.getSOrderId();
+                    orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItemVO.getSOrderItemId());
+                    // 如果出库数量小于订单上已退货+本次退货数量
+                    if (orderItemForUpdate.getOutQty().compareTo(orderItemForUpdate.getReturnQty().add(outboundItemVO.getOutingQty().abs())) == -1) {
+                        throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.OUTQTY_NO_LESS_RETURNQTY.getMessage());
+                    }
+                    OrderItem orderItemUpdate = new OrderItem();
+                    orderItemUpdate.setReturnQty(orderItemForUpdate.getReturnQty().add(outboundItemVO.getOutingQty().abs()))
+                            .setReturnAmt(orderItemForUpdate.getReturnAmt().add(outboundItemVO.getOutingAmt().abs()))
+                            .setItemId(orderItemForUpdate.getItemId());
+                    orderItemService.updateByUuid(orderItemUpdate);
+                }
+                /*********************  反写订单明细退货数量、金额 end **********************/
+
+            }
+            // 可能有多个出库单,所以要循环更新总单
+            for (String outId : outIdList) {
+                // 计算出库明细的退货数量,金额合计
+                List<OutboundItem> outboundItemList = outboundItemMapper.selectByZIdForUpdate(outId);
+                OutboundItem outboundItem = outboundItemList.stream().reduce((x, y) -> {
+                    OutboundItem item = new OutboundItem();
+                    item.setReturnQty(x.getReturnQty().add(y.getReturnQty()));
+                    item.setReturnAmt(x.getReturnAmt().add(y.getReturnAmt()));
+                    return item;
+                }).get();
+                // 更新出库单上的退货数量,金额
+                Outbound outboundUpdate = new Outbound();
+                outboundUpdate.setReturnQty(outboundItem.getReturnQty()).setReturnAmt(outboundItem.getReturnAmt()).setOutId(outId);
+                super.updateByUuid(outboundUpdate);
+            }
+
+            // 如果有订单,更新订单总单
+            if (sOrderId != null) {
+                // 计算订单明细的退货数量,金额合计
+                List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(sOrderId);
+                OrderItem orderItem = orderItemList.stream().reduce((x, y) -> {
+                    OrderItem item = new OrderItem();
+                    item.setReturnQty(x.getReturnQty().add(y.getReturnQty()));
+                    item.setReturnAmt(x.getReturnAmt().add(y.getReturnAmt()));
+                    return item;
+                }).get();
+                // 更新订单上的退货数量,金额
+                Order orderUpdate = new Order();
+                orderUpdate.setReturnQty(orderItem.getReturnQty()).setReturnAmt(orderItem.getReturnAmt()).setOrderId(sOrderId);
+                orderService.updateByUuid(orderUpdate);
+            }
+        }
+        return ResponseResultUtil.success();
+    }
+
+    /**
+     * @desc : 编辑方法
+     * @author : 付斌
+     * @date : 2023/1/9 10:49
+     */
+    @Transactional(
+            rollbackFor = {Exception.class}
+    )
+    public ResponseResultVO<Boolean> updateOutReturn(OutboundVO outboundVO) {
+        // 订单明细实体
+        OrderItem orderItemForUpdate;
+        // 出库明细实体
+        OutboundItem outboundItemForUpdate;// 出库退货明细
+        OutboundItem outboundItemSourceForUpdate;// 源出库明细
+        // 源出库IdList,一个退货单可能有多个出库单
+        List<String> outIdList = new ArrayList<>();
+        String sOrderId = null;
+
+        // 编辑退货明细
+        List<OutboundItemVO> editOutboundItemVOList = outboundVO.getItemList();
+        for (OutboundItemVO outboundItemVO : editOutboundItemVOList) {
+            // 把源出库Id存起来
+            if (!outIdList.contains(outboundItemVO.getSOutId())) {
+                outIdList.add(outboundItemVO.getSOutId());
+            }
+
+            outboundItemForUpdate = outboundItemMapper.selectByIdForUpdate(outboundItemVO.getItemId());
+            outboundItemSourceForUpdate = outboundItemMapper.selectByIdForUpdate(outboundItemVO.getSOutItemId());
+
+            // |出库退货明细出库中数量|不能小于|出库退货明细已出库中数量|
+            if (outboundItemForUpdate.getOutQty().compareTo(outboundItemSourceForUpdate.getReturnQty().subtract(outboundItemForUpdate.getOutingQty().abs()).add(outboundItemVO.getOutingQty().abs())) == -1) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.OUTQTY_NO_LESS_RETURNQTY.getMessage());
+            }
+
+            // 源入库明细已出库数量不能小于|出库退货明细数量|
+            if (outboundItemSourceForUpdate.getOutQty().compareTo(outboundItemVO.getOutingQty().abs()) == -1) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.RETURNQTY_NO_LESS_INTOINGQTY.getMessage());
+            }
+            // 更新出库明细退货数量
+            OutboundItem outboundItemUpdate = new OutboundItem();
+            outboundItemUpdate.setReturnQty(outboundItemSourceForUpdate.getReturnQty().subtract(outboundItemForUpdate.getOutingQty().abs()).add(outboundItemVO.getOutingQty().abs()))
+                    .setReturnAmt(outboundItemSourceForUpdate.getReturnAmt().subtract(outboundItemForUpdate.getOutingAmt().abs()).add(outboundItemVO.getOutingAmt().abs()))
+                    .setItemId(outboundItemSourceForUpdate.getItemId());
+            outboundItemService.updateByUuid(outboundItemUpdate);
+
+            // 没有订单的化,不需要更新
+            if (outboundItemVO.getSOrderItemId() != null) {
+                sOrderId = outboundItemVO.getSOrderId();
+                // 更新订单明细退货数量
+                orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItemVO.getSOrderItemId());
+                OrderItem orderItemUpdate = new OrderItem();
+                orderItemUpdate.setReturnQty(orderItemForUpdate.getReturnQty().subtract(outboundItemForUpdate.getOutingQty().abs()).add(outboundItemVO.getOutingQty().abs()))
+                        .setReturnAmt(orderItemForUpdate.getReturnAmt().subtract(outboundItemForUpdate.getOutingAmt().abs()).add(outboundItemVO.getOutingAmt().abs()))
+                        .setItemId(orderItemForUpdate.getItemId());
+                orderItemService.updateByUuid(orderItemUpdate);
+            }
+
+            // 更新出库明细
+            OutboundItem outboundItem = outboundItemConvert.convertToPo(outboundItemVO);
+            outboundItemService.updateByUuid(outboundItem);
+        }
+
+        // 可能有多个出库单,所以要循环更新总单
+        for (String outId : outIdList) {
+            // 计算出库明细的退货数量,金额合计
+            List<OutboundItem> outboundItemList = outboundItemMapper.selectByZIdForUpdate(outId);
+            OutboundItem outboundItem = outboundItemList.stream().reduce((x, y) -> {
+                OutboundItem item = new OutboundItem();
+                item.setReturnQty(x.getReturnQty().add(y.getReturnQty()));
+                item.setReturnAmt(x.getReturnAmt().add(y.getReturnAmt()));
+                return item;
+            }).get();
+            // 更新订单上的出库中数量,金额
+            Outbound outboundUpdate = new Outbound();
+            outboundUpdate.setReturnQty(outboundItem.getReturnQty()).setReturnAmt(outboundItem.getReturnAmt()).setOutId(outId);
+            super.updateByUuid(outboundUpdate);
+        }
+
+        // 如果有订单,更新订单总单
+        if (sOrderId != null) {
+            // 计算订单明细的退货数量,金额合计
+            List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(sOrderId);
+            OrderItem orderItem = orderItemList.stream().reduce((x, y) -> {
+                OrderItem item = new OrderItem();
+                item.setReturnQty(x.getReturnQty().add(y.getReturnQty()));
+                item.setReturnAmt(x.getReturnAmt().add(y.getReturnAmt()));
+                return item;
+            }).get();
+            // 更新订单上的出库中数量,金额
+            Order orderUpdate = new Order();
+            orderUpdate.setReturnQty(orderItem.getReturnQty()).setReturnAmt(orderItem.getReturnAmt()).setOrderId(sOrderId);
+            orderService.updateByUuid(orderUpdate);
+        }
+
+        // 转化实体、更新出库单总表
+        Outbound outbound = outboundConvert.convertToPo(outboundVO);
+        return ResponseResultUtil.success(super.update(outbound, new UpdateWrapper<Outbound>().lambda().eq(Outbound::getOutId,
+                UUID.fromString(outbound.getOutId()))));
+    }
+
+    /**
+     * @desc : 作废
+     * @author : 付斌
+     * @date : 2024-03-08 16:38
+     */
+    public ResponseResultVO<?> invalidOutReturn(String id) {
+        Outbound outboundForUpdate = outboundMapper.selectByIdForUpdate(id);
+        // 并发校验
+        if (!outboundForUpdate.getFlgValid()) {
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
+        }
+        // 如果出库数量或退货数量不是0,不能作废
+        if (outboundForUpdate.getOutQty().compareTo(BigDecimal.ZERO) != 0 || outboundForUpdate.getReturnQty().compareTo(BigDecimal.ZERO) != 0) {
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_AFTER_OPERATE.getMessage());
+        }
+
+        // 查出并锁定所有的出库明细
+        List<OutboundItem> outboundItemForUpdateList = outboundItemMapper.selectByZIdForUpdate(id);
+        // 出库IdList,一个退货单可能有多个出库单
+        List<String> outIdList = new ArrayList<>();
+        OrderItem orderItemForUpdate;
+        String sOrderId = null;
+
+        for (OutboundItem outboundItemForUpdate : outboundItemForUpdateList) {
+            // 把出库Id存起来
+            if (!outIdList.contains(outboundItemForUpdate.getSOutId())) {
+                outIdList.add(outboundItemForUpdate.getSOutId());
+            }
+            sOrderId = outboundItemForUpdate.getSOrderId();
+
+            // 更新出库明细退货数量
+            outboundItemForUpdate = outboundItemMapper.selectByIdForUpdate(outboundItemForUpdate.getSOutItemId());
+            OutboundItem outboundItemUpdate = new OutboundItem();
+            outboundItemUpdate.setReturnQty(outboundItemForUpdate.getReturnQty().subtract(outboundItemForUpdate.getOutingQty()))
+                    .setReturnAmt(outboundItemForUpdate.getReturnAmt().subtract(outboundItemForUpdate.getOutAmt()))
+                    .setItemId(outboundItemForUpdate.getItemId());
+            outboundItemService.updateByUuid(outboundItemUpdate);
+
+            // 更新订单明细退货数量
+            orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItemForUpdate.getSOrderItemId());
+            OrderItem orderItemUpdate = new OrderItem();
+            orderItemUpdate.setReturnQty(orderItemForUpdate.getReturnQty().subtract(outboundItemForUpdate.getOutingQty()))
+                    .setReturnAmt(orderItemForUpdate.getReturnAmt().subtract(outboundItemForUpdate.getOutAmt()))
+                    .setItemId(orderItemForUpdate.getItemId());
+            orderItemService.updateByUuid(orderItemUpdate);
+        }
+
+        // 可能有多个出库单,所以要循环更新总单
+        for (String outId : outIdList) {
+            // 计算出库明细的退货数量,金额合计
+            List<OutboundItem> outboundItemList = outboundItemMapper.selectByZIdForUpdate(outId);
+            OutboundItem outboundItem = outboundItemList.stream().reduce((x, y) -> {
+                OutboundItem item = new OutboundItem();
+                item.setReturnQty(x.getReturnQty().add(y.getReturnQty()));
+                item.setReturnAmt(x.getReturnAmt().add(y.getReturnAmt()));
+                return item;
+            }).get();
+            // 更新出库单上的退货数量,金额
+            Outbound outboundUpdate = new Outbound();
+            outboundUpdate.setReturnQty(outboundItem.getReturnQty()).setReturnAmt(outboundItem.getReturnAmt()).setOutId(outId);
+            super.updateByUuid(outboundUpdate);
+        }
+
+        if (sOrderId != null) {
+            // 计算订单明细的退货数量,金额合计
+            List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(sOrderId);
+            OrderItem orderItem = orderItemList.stream().reduce((x, y) -> {
+                OrderItem item = new OrderItem();
+                item.setReturnQty(x.getReturnQty().add(y.getReturnQty()));
+                item.setReturnAmt(x.getReturnAmt().add(y.getReturnAmt()));
+                return item;
+            }).get();
+            // 更新订单上的退货数量,金额
+            Order orderUpdate = new Order();
+            orderUpdate.setReturnQty(orderItem.getReturnQty()).setReturnAmt(orderItem.getReturnAmt()).setOrderId(sOrderId);
+            orderService.updateByUuid(orderUpdate);
+        }
+
+        // 作废
+        Outbound outboundUpdate = new Outbound();
+        outboundUpdate.setFlgValid(false).setOutId(id);
+        super.update(outboundUpdate, new UpdateWrapper<Outbound>().lambda().eq(Outbound::getOutId,
+                UUID.fromString(outboundUpdate.getOutId())));
+        return ResponseResultUtil.success();
+    }
+
+    /**
      * @desc : 采购退货出库
      * @author : 于继渤
      * @date : 2023/1/9 10:49