浏览代码

修改销售出库、退货

fubin 2 年之前
父节点
当前提交
bb00ebcc41

+ 119 - 115
src/main/java/com/dk/mdm/controller/ivt/outBound/OutboundController.java

@@ -1,19 +1,12 @@
 package com.dk.mdm.controller.ivt.outBound;
 
-import com.dk.common.model.pojo.PageList;
-import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.model.pojo.ivt.Outbound;
 import com.dk.common.service.BaseService;
-import com.dk.mdm.model.query.ivt.OutboundQuery;
-import com.dk.mdm.model.response.ivt.OutboundResponse;
-import com.dk.mdm.model.vo.ivt.OutboundVO;
-import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import io.swagger.annotations.Api;
 import com.dk.mdm.service.ivt.outbound.OutboundService;
 
-import java.util.Map;
 
 @Api(tags = "出库单API接口")
 @RestController
@@ -27,112 +20,123 @@ public class OutboundController {
     @Autowired
     private OutboundService outboundService;
 
-    /**
-     * @desc : 条件查询
-     * @author : 付斌
-     * @date : 2023/1/9 10:36
-     */
-    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
-    @PostMapping({"list_by"})
-    public ResponseResultVO<PageList<OutboundResponse>> selectByCond(@RequestBody OutboundQuery outboundQuery) {
-        return outboundService.selectByCond(outboundQuery);
-    }
-
-    /**
-     * @desc : 查询明细信息
-     * @author : 付斌
-     * @date : 2024-03-07 16:36
-     */
-    @PostMapping({"select_outbound_info_by_id/{id}"})
-    public ResponseResultVO<Map<String, Object>> selectOutboundInfoById(@PathVariable String id) {
-        return outboundService.selectOutboundInfoById(id);
-    }
-
-
-    /**
-     * @desc : 查询明细信息
-     * @author : 付斌
-     * @date : 2024/3/6 10:36
-     */
-    @PostMapping({"/{id}"})
-    public ResponseResultVO selectById(@PathVariable String id) {
-        return outboundService.selectById(id);
-    }
-
-    /**
-     * @desc : 新建销售出库单
-     * @author : 付斌
-     * @date : 2023/1/9 10:48
-     */
-    @ApiOperation(value = "新建出库单", notes = "新建出库单")
-    @PostMapping({"insert"})
-    public ResponseResultVO<?> insert(@RequestBody OutboundVO outboundVO) {
-        return outboundService.insert(outboundVO);
-    }
-
-    /**
-     * @desc : 编辑销售出库单
-     * @author : 付斌
-     * @date : 2023/1/9 10:49
-     */
-    @ApiOperation(value = "编辑出库单", notes = "编辑出库单")
-    @PostMapping({"update"})
-    public ResponseResultVO<Boolean> update(@RequestBody OutboundVO outboundVO) {
-        return outboundService.update(outboundVO);
-    }
-
-    /**
-     * @desc : 作废销售出库单
-     * @author : 付斌
-     * @date : 2024-03-08 16:36
-     */
-    @ApiOperation(value = "作废", notes = "作废")
-    @PostMapping({"invalid/{id}"})
-    public ResponseResultVO<?> invalid(@PathVariable String id) {
-        return outboundService.invalid(id);
-    }
-
-    /**
-     * @desc : 获取出库单信息(编辑用)
-     * @author : 付斌
-     * @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);
-    }
+//    /**
+//     * @desc : 一览页销售出库
+//     * @author : 付斌
+//     * @date : 2023/1/9 10:36
+//     */
+//    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+//    @PostMapping({"list_by"})
+//    public ResponseResultVO<PageList<OutboundResponse>> selectByCond(@RequestBody OutboundQuery outboundQuery) {
+//        return outboundService.selectByCond(outboundQuery);
+//    }
+//
+//    /**
+//     * @desc : 一览页销售出库明细(货物、附件)
+//     * @author : 付斌
+//     * @date : 2024-03-07 16:36
+//     */
+//    @PostMapping({"select_outbound_info_by_id/{id}"})
+//    public ResponseResultVO<Map<String, Object>> selectOutboundInfoById(@PathVariable String id) {
+//        return outboundService.selectOutboundInfoById(id);
+//    }
+//
+//
+//    /**
+//     * @desc : 查询出库明细(货物、附件)
+//     * @author : 付斌
+//     * @date : 2024/3/6 10:36
+//     */
+//    @PostMapping({"/{id}"})
+//    public ResponseResultVO selectById(@PathVariable String id) {
+//        return outboundService.selectById(id);
+//    }
+//
+//    /**
+//     * @desc : 获取销售出库信息(编辑用)
+//     * @author : 付斌
+//     * @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 : 2024-03-03 9:28
+//     */
+//    @ApiOperation(value = "编辑出库单", notes = "编辑出库单")
+//    @PostMapping({"get_out_return_for_update/{id}"})
+//    public ResponseResultVO<?> getOutReturnForUpdate(@PathVariable String id) {
+//        return outboundService.getOutReturnForUpdate(id);
+//    }
+
+//    /**
+//     * @desc : 新建销售出库单
+//     * @author : 付斌
+//     * @date : 2023/1/9 10:48
+//     */
+//    @ApiOperation(value = "新建出库单", notes = "新建出库单")
+//    @PostMapping({"insert"})
+//    public ResponseResultVO<?> insert(@RequestBody OutboundVO outboundVO) {
+//        return outboundService.insert(outboundVO);
+//    }
+
+//    /**
+//     * @desc : 编辑销售出库单
+//     * @author : 付斌
+//     * @date : 2023/1/9 10:49
+//     */
+//    @ApiOperation(value = "编辑出库单", notes = "编辑出库单")
+//    @PostMapping({"update"})
+//    public ResponseResultVO<Boolean> update(@RequestBody OutboundVO outboundVO) {
+//        return outboundService.update(outboundVO);
+//    }
+
+//    /**
+//     * @desc : 作废销售出库单
+//     * @author : 付斌
+//     * @date : 2024-03-08 16:36
+//     */
+//    @ApiOperation(value = "作废", notes = "作废")
+//    @PostMapping({"invalid/{id}"})
+//    public ResponseResultVO<?> invalid(@PathVariable String id) {
+//        return outboundService.invalid(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);
+//    }
 }

+ 74 - 30
src/main/java/com/dk/mdm/controller/ivt/outBound/OutboundSaleOrderController.java

@@ -7,6 +7,7 @@ import com.dk.common.service.BaseService;
 import com.dk.mdm.model.pojo.ivt.Outbound;
 import com.dk.mdm.model.query.ivt.OutboundQuery;
 import com.dk.mdm.model.response.ivt.InboundResponse;
+import com.dk.mdm.model.response.ivt.OutboundResponse;
 import com.dk.mdm.model.vo.ivt.OutboundVO;
 import com.dk.mdm.service.ivt.outbound.OutboundSaleOrderService;
 import io.swagger.annotations.Api;
@@ -30,29 +31,6 @@ public class OutboundSaleOrderController {
     @Autowired
     private OutboundSaleOrderService outboundSaleOrderService;
 
-
-    /**
-     * @desc : 条件查询
-     * @date : 2024/3/18 15:23
-     * @author : 寇珊珊
-     */
-    @ApiOperation(value = "条件查询", notes = "条件查询")
-    @PostMapping({"list_by"})
-    public ResponseResultVO<PageList<InboundResponse>> selectByCond(@RequestBody OutboundQuery outboundQuery) {
-        return outboundSaleOrderService.selectByCond(outboundQuery);
-    }
-
-    /**
-     * @desc : 明细信息条件查询
-     * @date : 2024/3/18 15:23
-     * @author : 寇珊珊
-     */
-    @ApiOperation(value = "明细信息条件查询", notes = "明细信息条件查询")
-    @PostMapping({"select_item_info_by_id/{id}"})
-    public ResponseResultVO<Map<String, Object>> selectOutBoundSaleOrderItemInfoById(@PathVariable String id) {
-        return outboundSaleOrderService.selectOutBoundSaleOrderItemInfoById(id);
-    }
-
     /**
      * @desc :  销售出库新建
      * @date : 2024/3/18 15:22
@@ -95,15 +73,81 @@ public class OutboundSaleOrderController {
         return outboundSaleOrderService.saleOrderOutboundCancel(outboundVO);
     }
 
+    /********************************************** 销售出库查询相关方法begin *************************************/
     /**
-     * @desc : 获取单据信息(编辑用)
-     * @date : 2024/3/18 15:22
-     * @author : 寇珊珊
+     * @desc : 一览页销售出库
+     * @author : 付斌
+     * @date : 2023/1/9 10:36
      */
-    @ApiOperation(value = "获取单据信息(编辑用)", notes = "获取单据信息(编辑用)")
-    @PostMapping({"select_by_update/{id}"})
-    public ResponseResultVO<?> selectByUpdate(@PathVariable String id) {
-        return outboundSaleOrderService.selectByUpdate(id);
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"list_by"})
+    public ResponseResultVO<PageList<OutboundResponse>> selectByCond(@RequestBody OutboundQuery outboundQuery) {
+        return outboundSaleOrderService.selectByCond(outboundQuery);
+    }
+
+    /**
+     * @desc : 一览页销售出库明细(货物、附件)
+     * @author : 付斌
+     * @date : 2024-03-07 16:36
+     */
+    @PostMapping({"select_outbound_info_by_id/{id}"})
+    public ResponseResultVO<Map<String, Object>> selectOutboundInfoById(@PathVariable String id) {
+        return outboundSaleOrderService.selectOutboundInfoById(id);
     }
 
+    /**
+     * @desc : 获取销售出库信息(编辑用)
+     * @author : 付斌
+     * @date : 2024-03-03 9:28
+     */
+    @ApiOperation(value = "编辑出库单", notes = "编辑出库单")
+    @PostMapping({"get_outbound_for_update/{id}"})
+    public ResponseResultVO<?> getOutboundForUpdate(@PathVariable String id) {
+        return outboundSaleOrderService.getOutboundForUpdate(id);
+    }
+
+    /**
+     * @desc : 查询出库明细(货物、附件)
+     * @author : 付斌
+     * @date : 2024/3/6 10:36
+     */
+    @PostMapping({"/{id}"})
+    public ResponseResultVO selectById(@PathVariable String id) {
+        return outboundSaleOrderService.selectById(id);
+    }
+    /********************************************** 销售出库查询相关方法end *************************************/
+
+
+//    /**
+//     * @desc : 条件查询
+//     * @date : 2024/3/18 15:23
+//     * @author : 寇珊珊
+//     */
+//    @ApiOperation(value = "条件查询", notes = "条件查询")
+//    @PostMapping({"list_by"})
+//    public ResponseResultVO<PageList<InboundResponse>> selectByCond(@RequestBody OutboundQuery outboundQuery) {
+//        return outboundSaleOrderService.selectByCond(outboundQuery);
+//    }
+//
+//    /**
+//     * @desc : 明细信息条件查询
+//     * @date : 2024/3/18 15:23
+//     * @author : 寇珊珊
+//     */
+//    @ApiOperation(value = "明细信息条件查询", notes = "明细信息条件查询")
+//    @PostMapping({"select_item_info_by_id/{id}"})
+//    public ResponseResultVO<Map<String, Object>> selectOutBoundSaleOrderItemInfoById(@PathVariable String id) {
+//        return outboundSaleOrderService.selectOutBoundSaleOrderItemInfoById(id);
+//    }
+//    /**
+//     * @desc : 获取单据信息(编辑用)
+//     * @date : 2024/3/18 15:22
+//     * @author : 寇珊珊
+//     */
+//    @ApiOperation(value = "获取单据信息(编辑用)", notes = "获取单据信息(编辑用)")
+//    @PostMapping({"select_by_update/{id}"})
+//    public ResponseResultVO<?> selectByUpdate(@PathVariable String id) {
+//        return outboundSaleOrderService.selectByUpdate(id);
+//    }
+
 }

+ 63 - 30
src/main/java/com/dk/mdm/controller/ivt/outBound/OutboundSaleReturnController.java

@@ -7,6 +7,7 @@ import com.dk.common.service.BaseService;
 import com.dk.mdm.model.pojo.ivt.Outbound;
 import com.dk.mdm.model.query.ivt.OutboundQuery;
 import com.dk.mdm.model.response.ivt.InboundResponse;
+import com.dk.mdm.model.response.ivt.OutboundResponse;
 import com.dk.mdm.model.vo.ivt.OutboundVO;
 import com.dk.mdm.service.ivt.outbound.OutboundSaleReturnService;
 import io.swagger.annotations.Api;
@@ -30,29 +31,6 @@ public class OutboundSaleReturnController {
     @Autowired
     private OutboundSaleReturnService outboundSaleReturnService;
 
-
-    /**
-     * @desc : 条件查询
-     * @date : 2024/3/18 15:23
-     * @author : 寇珊珊
-     */
-    @ApiOperation(value = "条件查询", notes = "条件查询")
-    @PostMapping({"list_by"})
-    public ResponseResultVO<PageList<InboundResponse>> selectByCond(@RequestBody OutboundQuery outboundQuery) {
-        return outboundSaleReturnService.selectByCond(outboundQuery);
-    }
-
-    /**
-     * @desc : 明细信息条件查询
-     * @date : 2024/3/18 15:23
-     * @author : 寇珊珊
-     */
-    @ApiOperation(value = "明细信息条件查询", notes = "明细信息条件查询")
-    @PostMapping({"select_item_info_by_id/{id}"})
-    public ResponseResultVO<Map<String, Object>> selectOutBoundSaleReturnItemInfoById(@PathVariable String id) {
-        return outboundSaleReturnService.selectOutBoundSaleReturnItemInfoById(id);
-    }
-
     /**
      * @desc :  销售退货出库新建
      * @date : 2024/3/18 15:22
@@ -95,15 +73,70 @@ public class OutboundSaleReturnController {
         return outboundSaleReturnService.saleReturnOutboundCancel(outboundVO);
     }
 
+    /********************************************** 销售退货查询相关方法begin *************************************/
     /**
-     * @desc : 获取单据信息(编辑用)
-     * @date : 2024/3/18 15:22
-     * @author : 寇珊珊
+     * @desc : 一览页退货出库
+     * @author : 付斌
+     * @date : 2023/1/9 10:36
+     */
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"list_by"})
+    public ResponseResultVO<PageList<OutboundResponse>> selectByCond(@RequestBody OutboundQuery outboundQuery) {
+        return outboundSaleReturnService.selectByCond(outboundQuery);
+    }
+
+    /**
+     * @desc : 一览页销售退货明细(货物、附件)
+     * @author : 付斌
+     * @date : 2024-03-07 16:36
+     */
+    @PostMapping({"select_outbound_info_by_id/{id}"})
+    public ResponseResultVO<Map<String, Object>> selectOutboundInfoById(@PathVariable String id) {
+        return outboundSaleReturnService.selectOutboundInfoById(id);
+    }
+    /**
+     * @desc : 获取销售退货信息(编辑用)
+     * @author : 付斌
+     * @date : 2024-03-03 9:28
      */
-    @ApiOperation(value = "获取单据信息(编辑用)", notes = "获取单据信息(编辑用)")
-    @PostMapping({"select_by_update/{id}"})
-    public ResponseResultVO<?> selectByUpdate(@PathVariable String id) {
-        return outboundSaleReturnService.selectByUpdate(id);
+    @ApiOperation(value = "编辑出库单", notes = "编辑出库单")
+    @PostMapping({"get_out_return_for_update/{id}"})
+    public ResponseResultVO<?> getOutReturnForUpdate(@PathVariable String id) {
+        return outboundSaleReturnService.getOutReturnForUpdate(id);
     }
+    /********************************************** 销售退货查询相关方法end *************************************/
+
+//    /**
+//     * @desc : 条件查询
+//     * @date : 2024/3/18 15:23
+//     * @author : 寇珊珊
+//     */
+//    @ApiOperation(value = "条件查询", notes = "条件查询")
+//    @PostMapping({"list_by"})
+//    public ResponseResultVO<PageList<InboundResponse>> selectByCond(@RequestBody OutboundQuery outboundQuery) {
+//        return outboundSaleReturnService.selectByCond(outboundQuery);
+//    }
+//
+//    /**
+//     * @desc : 明细信息条件查询
+//     * @date : 2024/3/18 15:23
+//     * @author : 寇珊珊
+//     */
+//    @ApiOperation(value = "明细信息条件查询", notes = "明细信息条件查询")
+//    @PostMapping({"select_item_info_by_id/{id}"})
+//    public ResponseResultVO<Map<String, Object>> selectOutBoundSaleReturnItemInfoById(@PathVariable String id) {
+//        return outboundSaleReturnService.selectOutBoundSaleReturnItemInfoById(id);
+//    }
+//
+//    /**
+//     * @desc : 获取单据信息(编辑用)
+//     * @date : 2024/3/18 15:22
+//     * @author : 寇珊珊
+//     */
+//    @ApiOperation(value = "获取单据信息(编辑用)", notes = "获取单据信息(编辑用)")
+//    @PostMapping({"select_by_update/{id}"})
+//    public ResponseResultVO<?> selectByUpdate(@PathVariable String id) {
+//        return outboundSaleReturnService.selectByUpdate(id);
+//    }
 
 }

+ 89 - 30
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundSaleOrderService.java

@@ -76,36 +76,6 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
     @Autowired
     private OrderItemMapper  orderItemMapper;
 
-
-    /**
-     * @desc : 条件查询
-     * @date : 2024/3/18 11:20
-     * @author : 寇珊珊
-     */
-    @Pagination
-    public ResponseResultVO<PageList<InboundResponse>> selectByCond(OutboundQuery outboundQuery) {
-        return super.mergeListWithCount(outboundQuery, outboundMapper.selectByCond(outboundQuery),
-                outboundMapper.countByCond(outboundQuery));
-    }
-
-    /**
-     * @desc : 查询明细
-     * @date : 2024/3/15 16:43
-     * @author : 寇珊珊
-     */
-    @Pagination
-    public ResponseResultVO<Map<String, Object>> selectOutBoundSaleOrderItemInfoById(String id) {
-        Map<String, Object> result = new HashMap<>();
-        // 商品明细
-        List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
-        result.put("itemList", outboundItemResponseList);
-        // 收款
-
-        // 附件
-        return ResponseResultUtil.success(result);
-    }
-
-
     /**
      * @desc : 销售出库新建
      * @date : 2024/3/7 14:13
@@ -649,5 +619,94 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
         return ResponseResultUtil.success(dataInfo);
     }
 
+    /********************************************** 销售出库查询相关方法begin *************************************/
+    /**
+     * @desc : 一览页销售出库
+     * @author : 付斌
+     * @date : 2023/1/9 10:40
+     */
+    @Pagination
+    public ResponseResultVO<PageList<OutboundResponse>> selectByCond(OutboundQuery outboundQuery) {
+        return super.mergeListWithCount(outboundQuery, outboundMapper.selectByCond(outboundQuery),
+                outboundMapper.countByCond(outboundQuery));
+    }
+
+    /**
+     * @desc : 一览页销售出库明细(货物、附件)
+     * @author : 付斌
+     * @date : 2024-02-28 13:25
+     */
+    @Pagination
+    public ResponseResultVO<Map<String, Object>> selectOutboundInfoById(String id) {
+        Map<String, Object> result = new HashMap<>();
+        // 商品明细
+        List<OutboundItemResponse> outboundItem = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
+        result.put("outboundItem", outboundItem);
+
+        // 附件
+        return ResponseResultUtil.success(result);
+    }
+
+    /**
+     * @desc : 获取销售出库信息(编辑用)
+     * @author : 付斌
+     * @date : 2024-03-02 17:27
+     */
+    public ResponseResultVO<?> getOutboundForUpdate(String id) {
+        Map<String, Object> dataInfo = new HashMap<>();
+        OutboundResponse outboundResponse = outboundMapper.selectById(id);
+        dataInfo.put("data", outboundResponse);
+
+        // 商品明细
+        List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCondForOutEdit(id);
+        dataInfo.put("dataItem", outboundItemResponseList);
+        return ResponseResultUtil.success(dataInfo);
+    }
+
+    /**
+     * @desc : 查询出库明细(货物、附件)
+     * @author : 付斌
+     * @date : 2024-02-28 13:25
+     */
+    @Pagination
+    public ResponseResultVO selectById(String id) {
+
+        OutboundResponse outboundResponse = outboundMapper.selectById(id);
+        // 商品明细
+        List<OutboundItemResponse> outboundItem = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
+        outboundResponse.setGoodsList(outboundItem);
+
+        // 附件
+        return ResponseResultUtil.success(outboundResponse);
+    }
+    /********************************************** 销售出库查询相关方法end *************************************/
+
+//    /**
+//     * @desc : 条件查询
+//     * @date : 2024/3/18 11:20
+//     * @author : 寇珊珊
+//     */
+//    @Pagination
+//    public ResponseResultVO<PageList<InboundResponse>> selectByCond(OutboundQuery outboundQuery) {
+//        return super.mergeListWithCount(outboundQuery, outboundMapper.selectByCond(outboundQuery),
+//                outboundMapper.countByCond(outboundQuery));
+//    }
+//
+//    /**
+//     * @desc : 查询明细
+//     * @date : 2024/3/15 16:43
+//     * @author : 寇珊珊
+//     */
+//    @Pagination
+//    public ResponseResultVO<Map<String, Object>> selectOutBoundSaleOrderItemInfoById(String id) {
+//        Map<String, Object> result = new HashMap<>();
+//        // 商品明细
+//        List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
+//        result.put("itemList", outboundItemResponseList);
+//        // 收款
+//
+//        // 附件
+//        return ResponseResultUtil.success(result);
+//    }
 
 }

+ 85 - 43
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundSaleReturnService.java

@@ -78,35 +78,6 @@ public class OutboundSaleReturnService extends BaseService<Outbound> {
 
 
     /**
-     * @desc : 条件查询
-     * @date : 2024/3/18 11:20
-     * @author : 寇珊珊
-     */
-    @Pagination
-    public ResponseResultVO<PageList<InboundResponse>> selectByCond(OutboundQuery outboundQuery) {
-        return super.mergeListWithCount(outboundQuery, outboundMapper.selectByCond(outboundQuery),
-                outboundMapper.countByCond(outboundQuery));
-    }
-
-    /**
-     * @desc : 查询明细
-     * @date : 2024/3/15 16:43
-     * @author : 寇珊珊
-     */
-    @Pagination
-    public ResponseResultVO<Map<String, Object>> selectOutBoundSaleReturnItemInfoById(String id) {
-        Map<String, Object> result = new HashMap<>();
-        // 商品明细
-        List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
-        result.put("itemList", outboundItemResponseList);
-        // 收款
-
-        // 附件
-        return ResponseResultUtil.success(result);
-    }
-
-
-    /**
      * @desc : 销售退货出库新建
      * @date : 2024/3/7 14:13
      * @author : 寇珊珊
@@ -636,27 +607,98 @@ public class OutboundSaleReturnService extends BaseService<Outbound> {
         return outStatus;
     }
 
+    /********************************************** 销售退货查询相关方法begin *************************************/
+    /**
+     * @desc : 一览页销售退货
+     * @author : 付斌
+     * @date : 2023/1/9 10:40
+     */
+    @Pagination
+    public ResponseResultVO<PageList<OutboundResponse>> selectByCond(OutboundQuery outboundQuery) {
+        return super.mergeListWithCount(outboundQuery, outboundMapper.selectByCond(outboundQuery),
+                outboundMapper.countByCond(outboundQuery));
+    }
 
     /**
-     * @desc : 获取单据信息(编辑用)
-     * @date : 2024/3/16 16:28
-     * @author : 寇珊珊
+     * @desc : 一览页销售退货明细(货物、附件
+     * @author : 付斌
+     * @date : 2024-02-28 13:25
      */
-    public ResponseResultVO<?> selectByUpdate(String id) {
+    @Pagination
+    public ResponseResultVO<Map<String, Object>> selectOutboundInfoById(String id) {
+        Map<String, Object> result = new HashMap<>();
+        // 商品明细
+        List<OutboundItemResponse> outboundItem = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
+        result.put("outboundItem", outboundItem);
+
+        // 附件
+        return ResponseResultUtil.success(result);
+    }
+    /**
+     * @desc : 获取销售退货信息(编辑用)
+     * @author : 付斌
+     * @date : 2024-03-02 17:27
+     */
+    public ResponseResultVO<?> getOutReturnForUpdate(String id) {
         Map<String, Object> dataInfo = new HashMap<>();
-        //总单
-        OutboundResponse outboundResponse = outboundMapper.selectMessageByOtherQuery(new OutboundQuery().setOutId(id).setOutStatus(Constant.OutStatus.CHUKUZHONG.getName()));
-        //单据不存在
-        if (outboundResponse == null) {
-            return ResponseResultUtil.error(ErrorCodeEnum.THERE_ORDER_IS_NOT_CAN_OUTBOUND_QUANTITY.getCode(),
-                    ErrorCodeEnum.THERE_ORDER_IS_NOT_CAN_OUTBOUND_QUANTITY.getMessage());
-        }
+        OutboundResponse outboundResponse = outboundMapper.selectById(id);
         dataInfo.put("data", outboundResponse);
-        // 明细
-        List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(outboundResponse.getOutId()));
-        dataInfo.put("dataItem", outboundItemResponseList);
+
+        // 商品明细
+        List<OutboundItemResponse> outboundItemResponse = outboundItemMapper.selectByCondForReturnEdit(id);
+        dataInfo.put("dataItem", outboundItemResponse);
         return ResponseResultUtil.success(dataInfo);
     }
+    /********************************************** 销售退货查询相关方法end *************************************/
+
+//    /**
+//     * @desc : 条件查询
+//     * @date : 2024/3/18 11:20
+//     * @author : 寇珊珊
+//     */
+//    @Pagination
+//    public ResponseResultVO<PageList<InboundResponse>> selectByCond(OutboundQuery outboundQuery) {
+//        return super.mergeListWithCount(outboundQuery, outboundMapper.selectByCond(outboundQuery),
+//                outboundMapper.countByCond(outboundQuery));
+//    }
+//
+//    /**
+//     * @desc : 查询明细
+//     * @date : 2024/3/15 16:43
+//     * @author : 寇珊珊
+//     */
+//    @Pagination
+//    public ResponseResultVO<Map<String, Object>> selectOutBoundSaleReturnItemInfoById(String id) {
+//        Map<String, Object> result = new HashMap<>();
+//        // 商品明细
+//        List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
+//        result.put("itemList", outboundItemResponseList);
+//        // 收款
+//
+//        // 附件
+//        return ResponseResultUtil.success(result);
+//    }
+//
+//    /**
+//     * @desc : 获取单据信息(编辑用)
+//     * @date : 2024/3/16 16:28
+//     * @author : 寇珊珊
+//     */
+//    public ResponseResultVO<?> selectByUpdate(String id) {
+//        Map<String, Object> dataInfo = new HashMap<>();
+//        //总单
+//        OutboundResponse outboundResponse = outboundMapper.selectMessageByOtherQuery(new OutboundQuery().setOutId(id).setOutStatus(Constant.OutStatus.CHUKUZHONG.getName()));
+//        //单据不存在
+//        if (outboundResponse == null) {
+//            return ResponseResultUtil.error(ErrorCodeEnum.THERE_ORDER_IS_NOT_CAN_OUTBOUND_QUANTITY.getCode(),
+//                    ErrorCodeEnum.THERE_ORDER_IS_NOT_CAN_OUTBOUND_QUANTITY.getMessage());
+//        }
+//        dataInfo.put("data", outboundResponse);
+//        // 明细
+//        List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(outboundResponse.getOutId()));
+//        dataInfo.put("dataItem", outboundItemResponseList);
+//        return ResponseResultUtil.success(dataInfo);
+//    }
 
 
 }

+ 601 - 648
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundService.java

@@ -1,45 +1,17 @@
 package com.dk.mdm.service.ivt.outbound;
 
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.dk.common.exception.BaseBusinessException;
-import com.dk.common.infrastructure.annotaiton.Pagination;
-import com.dk.common.infrastructure.constant.Constant;
-import com.dk.common.infrastructure.enums.ErrorCodeEnum;
-import com.dk.common.model.pojo.PageList;
-import com.dk.common.response.ResponseCodeEnum;
-import com.dk.common.response.ResponseResultUtil;
-import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.infrastructure.convert.ivt.OutboundConvert;
 import com.dk.mdm.infrastructure.convert.ivt.OutboundItemConvert;
 import com.dk.mdm.mapper.ivt.OutboundItemMapper;
-import com.dk.mdm.mapper.pur.PurchaseItemMapper;
-import com.dk.mdm.mapper.sale.OrderItemMapper;
-import com.dk.mdm.mapper.sale.OrderMapper;
 import com.dk.mdm.model.pojo.ivt.Outbound;
 import com.dk.mdm.mapper.ivt.OutboundMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
-import com.dk.mdm.model.pojo.ivt.OutboundItem;
-import com.dk.mdm.model.pojo.sale.Order;
-import com.dk.mdm.model.pojo.sale.OrderItem;
-import com.dk.mdm.model.query.ivt.OutboundItemQuery;
-import com.dk.mdm.model.query.ivt.OutboundQuery;
-import com.dk.mdm.model.response.ivt.OutboundItemResponse;
-import com.dk.mdm.model.response.ivt.OutboundResponse;
-import com.dk.mdm.model.response.sale.OutReturnItemResponse;
-import com.dk.mdm.model.response.sale.OutReturnResponse;
-import com.dk.mdm.model.vo.ivt.OutboundItemVO;
-import com.dk.mdm.model.vo.ivt.OutboundVO;
 import com.dk.mdm.service.common.CommonService;
-import com.dk.mdm.service.sale.OrderItemService;
-import com.dk.mdm.service.sale.OrderService;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.math.BigDecimal;
-import java.util.*;
-
 @Service
 @Transactional
 public class OutboundService extends BaseService<Outbound> {
@@ -58,24 +30,9 @@ public class OutboundService extends BaseService<Outbound> {
     private OutboundMapper outboundMapper;
 
     @Autowired
-    private OutboundItemService outboundItemService;
-
-    @Autowired
     private OutboundItemMapper outboundItemMapper;
 
     @Autowired
-    private OrderService orderService;
-
-    @Autowired
-    private OrderMapper orderMapper;
-
-    @Autowired
-    private OrderItemService orderItemService;
-
-    @Autowired
-    private OrderItemMapper orderItemMapper;
-
-    @Autowired
     private CommonService commonService;
 
     @Autowired
@@ -84,610 +41,606 @@ public class OutboundService extends BaseService<Outbound> {
     @Autowired
     private OutboundItemConvert outboundItemConvert;
 
-    @Autowired
-    private PurchaseItemMapper purchaseItemMapper;
-
-    /**
-     * @desc : 条件查询
-     * @author : 付斌
-     * @date : 2023/1/9 10:40
-     */
-    @Pagination
-    public ResponseResultVO<PageList<OutboundResponse>> selectByCond(OutboundQuery outboundQuery) {
-        return super.mergeListWithCount(outboundQuery, outboundMapper.selectByCond(outboundQuery),
-                outboundMapper.countByCond(outboundQuery));
-    }
-
-    /**
-     * @desc : 查询订单明细(货物、收款、附件)
-     * @author : 付斌
-     * @date : 2024-02-28 13:25
-     */
-    @Pagination
-    public ResponseResultVO<Map<String, Object>> selectOutboundInfoById(String id) {
-        Map<String, Object> result = new HashMap<>();
-        // 商品明细
-        List<OutboundItemResponse> outboundItem = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
-        result.put("outboundItem", outboundItem);
-
-        // 收款
-
-        // 附件
-        return ResponseResultUtil.success(result);
-    }
-
-    /**
-     * @desc : 查询订单明细(货物、收款、附件)
-     * @author : 付斌
-     * @date : 2024-02-28 13:25
-     */
-    @Pagination
-    public ResponseResultVO selectById(String id) {
-
-        OutboundResponse outboundResponse = outboundMapper.selectById(id);
-        // 商品明细
-        List<OutboundItemResponse> outboundItem = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
-        outboundResponse.setGoodsList(outboundItem);
-
-        // 收款
-
-        // 附件
-        return ResponseResultUtil.success(outboundResponse);
-    }
-
-    /**
-     * @desc : 新建方法
-     * @author : 付斌
-     * @date : 2023/1/9 10:49
-     */
-    @Transactional(
-            rollbackFor = {Exception.class}
-    )
-    public ResponseResultVO<?> insert(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) {
-            double sumOutingQty = 0;    // 合计出库中数量
-            double sumOutingAmt = 0;    // 合计出库中金额
-            OrderItem orderItemForUpdate;
-            for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
-                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);
-
-                // 反写订单出库中数量、金额
-                orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItem.getFromItemId());
-                // 如果(商品数量-已出库数量) 小于(订单出库中数量+本次出库单出库中数量)
-                if ((orderItemForUpdate.getItemQty().subtract(orderItemForUpdate.getOutQty())).compareTo(orderItemForUpdate.getOutingQty().add(outboundItem.getOutingQty())) == -1) {
-                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ITEMQTY_NO_LESS_OUTQTY.getMessage());
-                }
-                OrderItem orderItemUpdate = new OrderItem();
-                orderItemUpdate.setOutingQty(orderItemForUpdate.getOutingQty().add(outboundItem.getOutingQty()))
-                        .setOutingAmt(orderItemForUpdate.getOutingAmt().add(outboundItem.getOutingAmt()))
-                        .setItemId(orderItemForUpdate.getItemId());
-                orderItemService.updateByUuid(orderItemUpdate);
-                // 累加出库中数量,金额
-                sumOutingQty += outboundItem.getOutingQty().doubleValue();
-                sumOutingAmt += outboundItem.getOutingAmt().doubleValue();
-
-            }
-            // 更新订单上的出库中数量,金额,状态
-            Order orderForUpdate = orderMapper.selectByIdForUpdate(outboundVO.getFromId());
-            Order orderUpdate = new Order();
-            orderUpdate.setOutingQty(orderForUpdate.getOutingQty().add(new BigDecimal(sumOutingQty)))
-                    .setOutingAmt(orderForUpdate.getOutingAmt().add(new BigDecimal(sumOutingAmt)))
-                    .setOutStatus(Constant.OutStatus.CHUKUZHONG.getName())
-                    .setOrderId(outboundVO.getFromId());
-            orderService.updateByUuid(orderUpdate);
-        }
-        return ResponseResultUtil.success();
-    }
-
-    /**
-     * @desc : 编辑方法
-     * @author : 付斌
-     * @date : 2023/1/9 10:49
-     */
-    @Transactional(
-            rollbackFor = {Exception.class}
-    )
-    public ResponseResultVO<Boolean> update(OutboundVO outboundVO) {
-        // 订单明细实体
-        OrderItem orderItemForUpdate;
-        // 出库明细实体
-        OutboundItem outboundItemForUpdate;
-
-        // 编辑出库明细
-        List<OutboundItemVO> editOutboundItemVOList = outboundVO.getItemList();
-        for (OutboundItemVO outboundItemVO : editOutboundItemVOList) {
-            outboundItemForUpdate = outboundItemMapper.selectByIdForUpdate(outboundItemVO.getItemId());
-            // 出库中数量不能小于出库数量
-            if (outboundItemForUpdate.getOutingQty().compareTo(outboundItemVO.getOutQty()) == -1) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.OUTINGQTY_NO_LESS_OUTQTY.getMessage());
-            }
-            orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItemVO.getFromItemId());
-
-            // (订单的商品数量-订单已出库数量)不能小于(订单之前的出库中数量 - 出库明细之前的出库中数量 + 出库明细现在的出库中数量)
-            if ((orderItemForUpdate.getItemQty().subtract(orderItemForUpdate.getOutQty())).compareTo(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()).add(outboundItemVO.getOutingQty())) == -1) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ITEMQTY_NO_LESS_OUTQTY.getMessage());
-            }
-            // 更新订单明细出库中数量
-            OrderItem orderItemUpdate = new OrderItem();
-            orderItemUpdate.setOutingQty(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()).add(outboundItemVO.getOutingQty()))
-                    .setOutingAmt(orderItemForUpdate.getOutingAmt().subtract(outboundItemForUpdate.getOutingAmt()).add(outboundItemVO.getOutingAmt()))
-                    .setItemId(orderItemForUpdate.getItemId());
-            orderItemService.updateByUuid(orderItemUpdate);
-            // 更新出库明细
-            OutboundItem outboundItem = outboundItemConvert.convertToPo(outboundItemVO);
-            outboundItemService.updateByUuid(outboundItem);
-        }
-
-        // 计算订单明细的出库中数量,金额合计
-        List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(outboundVO.getFromId());
-        OrderItem orderItem = orderItemList.stream().reduce((x, y) -> {
-            OrderItem item = new OrderItem();
-            item.setOutingQty(x.getOutingQty().add(y.getOutingQty()));
-            item.setOutingAmt(x.getOutingAmt().add(y.getOutingAmt()));
-            return item;
-        }).get();
-        // 更新订单上的出库中数量,金额
-        Order orderUpdate = new Order();
-        orderUpdate.setOutingQty(orderItem.getOutingQty()).setOutingAmt(orderItem.getOutingAmt()).setOrderId(outboundVO.getFromId());
-        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<?> invalid(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> outboundItemList = outboundItemMapper.selectByZIdForUpdate(id);
-        OrderItem orderItemForUpdate;
-        for (OutboundItem outboundItemForUpdate : outboundItemList) {
-            orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItemForUpdate.getFromItemId());
-            // 更新订单明细出库中数量
-            OrderItem orderItemUpdate = new OrderItem();
-            orderItemUpdate.setOutingQty(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()))
-                    .setOutingAmt(orderItemForUpdate.getOutingAmt().subtract(outboundItemForUpdate.getOutingAmt()))
-                    .setItemId(orderItemForUpdate.getItemId());
-            if (orderItemUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0) {
-                orderItemUpdate.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
-            }
-            orderItemService.updateByUuid(orderItemUpdate);
-        }
-
-        // 计算订单明细的出库中数量,金额合计
-        List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(outboundForUpdate.getFromId());
-        OrderItem orderItem = orderItemList.stream().reduce((x, y) -> {
-            OrderItem item = new OrderItem();
-            item.setOutingQty(x.getOutingQty().add(y.getOutingQty()));
-            item.setOutingAmt(x.getOutingAmt().add(y.getOutingAmt()));
-            return item;
-        }).get();
-        // 更新订单上的出库中数量,金额
-        Order orderUpdate = new Order();
-        orderUpdate.setOutingQty(orderItem.getOutingQty()).setOutingAmt(orderItem.getOutingAmt()).setOrderId(outboundForUpdate.getFromId());
-        if (orderUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0) {
-            orderUpdate.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
-        }
-
-        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 : 2024-03-02 17:27
-     */
-    public ResponseResultVO<?> getOutboundForUpdate(String id) {
-        Map<String, Object> dataInfo = new HashMap<>();
-        OutboundResponse outboundResponse = outboundMapper.selectById(id);
-        dataInfo.put("data", outboundResponse);
-
-        // 商品明细
-        List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCondForOutEdit(id);
-        dataInfo.put("dataItem", outboundItemResponseList);
-        return ResponseResultUtil.success(dataInfo);
-    }
-
-    /**
-     * @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 : 2024-03-02 17:27
-     */
-    public ResponseResultVO<?> getOutReturnForUpdate(String id) {
-        Map<String, Object> dataInfo = new HashMap<>();
-        OutboundResponse outboundResponse = outboundMapper.selectById(id);
-        dataInfo.put("data", outboundResponse);
-
-        // 商品明细
-        List<OutboundItemResponse> outboundItemResponse = outboundItemMapper.selectByCondForReturnEdit(id);
-        dataInfo.put("dataItem", outboundItemResponse);
-        return ResponseResultUtil.success(dataInfo);
-    }
-
-    /**
-     * @desc : 采购退货出库
-     * @author : 于继渤
-     * @date : 2023/1/9 10:49
-     */
-    @Transactional(
-            rollbackFor = {Exception.class}
-    )
-    public ResponseResultVO<?> insertOutBound(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.PURRETURN.getName());
-        // 转化实体
-        Outbound outbound = outboundConvert.convertToPo(outboundVO);
-        // 总单保存
-        super.insert(outbound);
-
-        // 明细保存
-        if (outboundVO.getItemList() != null && outboundVO.getItemList().size() > 0) {
-            double sumOutingQty = 0;    // 合计出库中数量
-            double sumOutingAmt = 0;    // 合计出库中金额
-            for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
-                OutboundItem outboundItem = outboundItemConvert.convertToPo(outboundItemVO);
-                outboundItem
-                        .setOutId(outbound.getOutId())
-                        .setCpId(outbound.getCpId())
-                        .setOutStatus(Constant.OutStatus.CHUKUZHONG.getName())
-                        .setOutType(Constant.OutType.PURRETURN.getName());
-                outboundItemMapper.insert(outboundItem);
-
-//				PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(outboundItem.getFromItemId());
-
-                // 如果商品数量小于订单+本次出库单上的出库中数量
-//				if(orderItem.getItemQty().compareTo(orderItem.getOutingQty().add(outboundItem.getOutingQty())) == -1){
-//					throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ITEMQTY_NO_LESS_OUTQTY.getMessage());
-//				}else{
-//					OrderItem orderItemUpdate = new OrderItem();
-//					orderItemUpdate.setOutingQty(orderItem.getOutingQty().add(outboundItem.getOutingQty()))
-//							.setOutingAmt(orderItem.getOutingAmt().add(outboundItem.getOutingAmt()))
-//							.setItemId(orderItem.getItemId());
-//					orderItemService.updateByUuid(orderItemUpdate);
-//					// 累加出库中数量,金额
-//					sumOutingQty += outboundItem.getOutingQty().doubleValue();
-//					sumOutingAmt += outboundItem.getOutingAmt().doubleValue();
-//				}
-            }
-//			// 更新订单上的出库中数量,金额,状态
-//			OrderResponse orderResponse = orderMapper.selectById(outboundVO.getFromId());
-//			Order orderUpdate = new Order();
-//			orderUpdate.setOutingQty(orderResponse.getOutingQty().add(new BigDecimal(sumOutingQty)))
-//					.setOutingAmt(orderResponse.getOutingAmt().add(new BigDecimal(sumOutingAmt)))
-//					.setOutStatus(Constant.OutStatus.CHUKUZHONG.getName())
-//					.setOrderId(outboundVO.getFromId());
-//			orderService.updateByUuid(orderUpdate);
-        }
-        return ResponseResultUtil.success();
-    }
 
+//    /**
+//     * @desc : 一览页销售出库
+//     * @author : 付斌
+//     * @date : 2023/1/9 10:40
+//     */
+//    @Pagination
+//    public ResponseResultVO<PageList<OutboundResponse>> selectByCond(OutboundQuery outboundQuery) {
+//        return super.mergeListWithCount(outboundQuery, outboundMapper.selectByCond(outboundQuery),
+//                outboundMapper.countByCond(outboundQuery));
+//    }
+//
+//    /**
+//     * @desc : 一览页销售出库明细(货物、附件)
+//     * @author : 付斌
+//     * @date : 2024-02-28 13:25
+//     */
+//    @Pagination
+//    public ResponseResultVO<Map<String, Object>> selectOutboundInfoById(String id) {
+//        Map<String, Object> result = new HashMap<>();
+//        // 商品明细
+//        List<OutboundItemResponse> outboundItem = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
+//        result.put("outboundItem", outboundItem);
+//
+//
+//        // 附件
+//        return ResponseResultUtil.success(result);
+//    }
+//
+//    /**
+//     * @desc : 查询出库明细(货物、附件)
+//     * @author : 付斌
+//     * @date : 2024-02-28 13:25
+//     */
+//    @Pagination
+//    public ResponseResultVO selectById(String id) {
+//
+//        OutboundResponse outboundResponse = outboundMapper.selectById(id);
+//        // 商品明细
+//        List<OutboundItemResponse> outboundItem = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
+//        outboundResponse.setGoodsList(outboundItem);
+//
+//        // 附件
+//        return ResponseResultUtil.success(outboundResponse);
+//    }
+//
+//    /**
+//     * @desc : 获取销售出库信息(编辑用)
+//     * @author : 付斌
+//     * @date : 2024-03-02 17:27
+//     */
+//    public ResponseResultVO<?> getOutboundForUpdate(String id) {
+//        Map<String, Object> dataInfo = new HashMap<>();
+//        OutboundResponse outboundResponse = outboundMapper.selectById(id);
+//        dataInfo.put("data", outboundResponse);
+//
+//        // 商品明细
+//        List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCondForOutEdit(id);
+//        dataInfo.put("dataItem", outboundItemResponseList);
+//        return ResponseResultUtil.success(dataInfo);
+//    }
+//
+//    /**
+//     * @desc : 获取销售退货信息(编辑用)
+//     * @author : 付斌
+//     * @date : 2024-03-02 17:27
+//     */
+//    public ResponseResultVO<?> getOutReturnForUpdate(String id) {
+//        Map<String, Object> dataInfo = new HashMap<>();
+//        OutboundResponse outboundResponse = outboundMapper.selectById(id);
+//        dataInfo.put("data", outboundResponse);
+//
+//        // 商品明细
+//        List<OutboundItemResponse> outboundItemResponse = outboundItemMapper.selectByCondForReturnEdit(id);
+//        dataInfo.put("dataItem", outboundItemResponse);
+//        return ResponseResultUtil.success(dataInfo);
+//    }
+
+
+//    /**
+//     * @desc : 新建方法
+//     * @author : 付斌
+//     * @date : 2023/1/9 10:49
+//     */
+//    @Transactional(
+//            rollbackFor = {Exception.class}
+//    )
+//    public ResponseResultVO<?> insert(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) {
+//            double sumOutingQty = 0;    // 合计出库中数量
+//            double sumOutingAmt = 0;    // 合计出库中金额
+//            OrderItem orderItemForUpdate;
+//            for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
+//                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);
+//
+//                // 反写订单出库中数量、金额
+//                orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItem.getFromItemId());
+//                // 如果(商品数量-已出库数量) 小于(订单出库中数量+本次出库单出库中数量)
+//                if ((orderItemForUpdate.getItemQty().subtract(orderItemForUpdate.getOutQty())).compareTo(orderItemForUpdate.getOutingQty().add(outboundItem.getOutingQty())) == -1) {
+//                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ITEMQTY_NO_LESS_OUTQTY.getMessage());
+//                }
+//                OrderItem orderItemUpdate = new OrderItem();
+//                orderItemUpdate.setOutingQty(orderItemForUpdate.getOutingQty().add(outboundItem.getOutingQty()))
+//                        .setOutingAmt(orderItemForUpdate.getOutingAmt().add(outboundItem.getOutingAmt()))
+//                        .setItemId(orderItemForUpdate.getItemId());
+//                orderItemService.updateByUuid(orderItemUpdate);
+//                // 累加出库中数量,金额
+//                sumOutingQty += outboundItem.getOutingQty().doubleValue();
+//                sumOutingAmt += outboundItem.getOutingAmt().doubleValue();
+//
+//            }
+//            // 更新订单上的出库中数量,金额,状态
+//            Order orderForUpdate = orderMapper.selectByIdForUpdate(outboundVO.getFromId());
+//            Order orderUpdate = new Order();
+//            orderUpdate.setOutingQty(orderForUpdate.getOutingQty().add(new BigDecimal(sumOutingQty)))
+//                    .setOutingAmt(orderForUpdate.getOutingAmt().add(new BigDecimal(sumOutingAmt)))
+//                    .setOutStatus(Constant.OutStatus.CHUKUZHONG.getName())
+//                    .setOrderId(outboundVO.getFromId());
+//            orderService.updateByUuid(orderUpdate);
+//        }
+//        return ResponseResultUtil.success();
+//    }
+//
+//    /**
+//     * @desc : 编辑方法
+//     * @author : 付斌
+//     * @date : 2023/1/9 10:49
+//     */
+//    @Transactional(
+//            rollbackFor = {Exception.class}
+//    )
+//    public ResponseResultVO<Boolean> update(OutboundVO outboundVO) {
+//        // 订单明细实体
+//        OrderItem orderItemForUpdate;
+//        // 出库明细实体
+//        OutboundItem outboundItemForUpdate;
+//
+//        // 编辑出库明细
+//        List<OutboundItemVO> editOutboundItemVOList = outboundVO.getItemList();
+//        for (OutboundItemVO outboundItemVO : editOutboundItemVOList) {
+//            outboundItemForUpdate = outboundItemMapper.selectByIdForUpdate(outboundItemVO.getItemId());
+//            // 出库中数量不能小于出库数量
+//            if (outboundItemForUpdate.getOutingQty().compareTo(outboundItemVO.getOutQty()) == -1) {
+//                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.OUTINGQTY_NO_LESS_OUTQTY.getMessage());
+//            }
+//            orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItemVO.getFromItemId());
+//
+//            // (订单的商品数量-订单已出库数量)不能小于(订单之前的出库中数量 - 出库明细之前的出库中数量 + 出库明细现在的出库中数量)
+//            if ((orderItemForUpdate.getItemQty().subtract(orderItemForUpdate.getOutQty())).compareTo(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()).add(outboundItemVO.getOutingQty())) == -1) {
+//                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ITEMQTY_NO_LESS_OUTQTY.getMessage());
+//            }
+//            // 更新订单明细出库中数量
+//            OrderItem orderItemUpdate = new OrderItem();
+//            orderItemUpdate.setOutingQty(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()).add(outboundItemVO.getOutingQty()))
+//                    .setOutingAmt(orderItemForUpdate.getOutingAmt().subtract(outboundItemForUpdate.getOutingAmt()).add(outboundItemVO.getOutingAmt()))
+//                    .setItemId(orderItemForUpdate.getItemId());
+//            orderItemService.updateByUuid(orderItemUpdate);
+//            // 更新出库明细
+//            OutboundItem outboundItem = outboundItemConvert.convertToPo(outboundItemVO);
+//            outboundItemService.updateByUuid(outboundItem);
+//        }
+//
+//        // 计算订单明细的出库中数量,金额合计
+//        List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(outboundVO.getFromId());
+//        OrderItem orderItem = orderItemList.stream().reduce((x, y) -> {
+//            OrderItem item = new OrderItem();
+//            item.setOutingQty(x.getOutingQty().add(y.getOutingQty()));
+//            item.setOutingAmt(x.getOutingAmt().add(y.getOutingAmt()));
+//            return item;
+//        }).get();
+//        // 更新订单上的出库中数量,金额
+//        Order orderUpdate = new Order();
+//        orderUpdate.setOutingQty(orderItem.getOutingQty()).setOutingAmt(orderItem.getOutingAmt()).setOrderId(outboundVO.getFromId());
+//        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<?> invalid(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> outboundItemList = outboundItemMapper.selectByZIdForUpdate(id);
+//        OrderItem orderItemForUpdate;
+//        for (OutboundItem outboundItemForUpdate : outboundItemList) {
+//            orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItemForUpdate.getFromItemId());
+//            // 更新订单明细出库中数量
+//            OrderItem orderItemUpdate = new OrderItem();
+//            orderItemUpdate.setOutingQty(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()))
+//                    .setOutingAmt(orderItemForUpdate.getOutingAmt().subtract(outboundItemForUpdate.getOutingAmt()))
+//                    .setItemId(orderItemForUpdate.getItemId());
+//            if (orderItemUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0) {
+//                orderItemUpdate.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
+//            }
+//            orderItemService.updateByUuid(orderItemUpdate);
+//        }
+//
+//        // 计算订单明细的出库中数量,金额合计
+//        List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(outboundForUpdate.getFromId());
+//        OrderItem orderItem = orderItemList.stream().reduce((x, y) -> {
+//            OrderItem item = new OrderItem();
+//            item.setOutingQty(x.getOutingQty().add(y.getOutingQty()));
+//            item.setOutingAmt(x.getOutingAmt().add(y.getOutingAmt()));
+//            return item;
+//        }).get();
+//        // 更新订单上的出库中数量,金额
+//        Order orderUpdate = new Order();
+//        orderUpdate.setOutingQty(orderItem.getOutingQty()).setOutingAmt(orderItem.getOutingAmt()).setOrderId(outboundForUpdate.getFromId());
+//        if (orderUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0) {
+//            orderUpdate.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
+//        }
+//
+//        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
+//     */
+//    @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
+//     */
+//    @Transactional(
+//            rollbackFor = {Exception.class}
+//    )
+//    public ResponseResultVO<?> insertOutBound(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.PURRETURN.getName());
+//        // 转化实体
+//        Outbound outbound = outboundConvert.convertToPo(outboundVO);
+//        // 总单保存
+//        super.insert(outbound);
+//
+//        // 明细保存
+//        if (outboundVO.getItemList() != null && outboundVO.getItemList().size() > 0) {
+//            double sumOutingQty = 0;    // 合计出库中数量
+//            double sumOutingAmt = 0;    // 合计出库中金额
+//            for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
+//                OutboundItem outboundItem = outboundItemConvert.convertToPo(outboundItemVO);
+//                outboundItem
+//                        .setOutId(outbound.getOutId())
+//                        .setCpId(outbound.getCpId())
+//                        .setOutStatus(Constant.OutStatus.CHUKUZHONG.getName())
+//                        .setOutType(Constant.OutType.PURRETURN.getName());
+//                outboundItemMapper.insert(outboundItem);
+//
+////				PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(outboundItem.getFromItemId());
+//
+//                // 如果商品数量小于订单+本次出库单上的出库中数量
+////				if(orderItem.getItemQty().compareTo(orderItem.getOutingQty().add(outboundItem.getOutingQty())) == -1){
+////					throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ITEMQTY_NO_LESS_OUTQTY.getMessage());
+////				}else{
+////					OrderItem orderItemUpdate = new OrderItem();
+////					orderItemUpdate.setOutingQty(orderItem.getOutingQty().add(outboundItem.getOutingQty()))
+////							.setOutingAmt(orderItem.getOutingAmt().add(outboundItem.getOutingAmt()))
+////							.setItemId(orderItem.getItemId());
+////					orderItemService.updateByUuid(orderItemUpdate);
+////					// 累加出库中数量,金额
+////					sumOutingQty += outboundItem.getOutingQty().doubleValue();
+////					sumOutingAmt += outboundItem.getOutingAmt().doubleValue();
+////				}
+//            }
+////			// 更新订单上的出库中数量,金额,状态
+////			OrderResponse orderResponse = orderMapper.selectById(outboundVO.getFromId());
+////			Order orderUpdate = new Order();
+////			orderUpdate.setOutingQty(orderResponse.getOutingQty().add(new BigDecimal(sumOutingQty)))
+////					.setOutingAmt(orderResponse.getOutingAmt().add(new BigDecimal(sumOutingAmt)))
+////					.setOutStatus(Constant.OutStatus.CHUKUZHONG.getName())
+////					.setOrderId(outboundVO.getFromId());
+////			orderService.updateByUuid(orderUpdate);
+//        }
+//        return ResponseResultUtil.success();
+//    }
 }