Просмотр исходного кода

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

songyang 2 лет назад
Родитель
Сommit
0afc142638
34 измененных файлов с 1288 добавлено и 104 удалено
  1. 14 1
      src/main/java/com/dk/mdm/controller/ivt/IntoReturnController.java
  2. 22 0
      src/main/java/com/dk/mdm/controller/mac/AccountController.java
  3. 18 6
      src/main/java/com/dk/mdm/controller/mac/RecPayController.java
  4. 23 0
      src/main/java/com/dk/mdm/controller/mac/RecPayHandleItemController.java
  5. 4 0
      src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.java
  6. 19 0
      src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml
  7. 1 0
      src/main/java/com/dk/mdm/mapper/ivt/InboundMapper.java
  8. 10 0
      src/main/java/com/dk/mdm/mapper/ivt/InboundMapper.xml
  9. 3 1
      src/main/java/com/dk/mdm/mapper/ivt/IntoReturnItemMapper.xml
  10. 1 0
      src/main/java/com/dk/mdm/mapper/ivt/IntoReturnMapper.java
  11. 23 0
      src/main/java/com/dk/mdm/mapper/ivt/IntoReturnMapper.xml
  12. 9 3
      src/main/java/com/dk/mdm/mapper/mac/AccountItemMapper.java
  13. 51 28
      src/main/java/com/dk/mdm/mapper/mac/AccountItemMapper.xml
  14. 1 1
      src/main/java/com/dk/mdm/mapper/mac/AccountMapper.java
  15. 44 10
      src/main/java/com/dk/mdm/mapper/mac/AccountMapper.xml
  16. 14 0
      src/main/java/com/dk/mdm/mapper/mac/RecPayHandleItemMapper.java
  17. 157 0
      src/main/java/com/dk/mdm/mapper/mac/RecPayHandleItemMapper.xml
  18. 3 2
      src/main/java/com/dk/mdm/mapper/mst/CustomerMapper.xml
  19. 3 0
      src/main/java/com/dk/mdm/mapper/pur/PurchaseMapper.xml
  20. 126 0
      src/main/java/com/dk/mdm/model/pojo/mac/RecPayHandleItem.java
  21. 2 0
      src/main/java/com/dk/mdm/model/query/ivt/IntoReturnQuery.java
  22. 2 0
      src/main/java/com/dk/mdm/model/query/mac/AccountItemQuery.java
  23. 128 0
      src/main/java/com/dk/mdm/model/query/mac/RecPayHandleItemQuery.java
  24. 3 0
      src/main/java/com/dk/mdm/model/response/ivt/IntoReturnItemResponse.java
  25. 7 0
      src/main/java/com/dk/mdm/model/response/ivt/IntoReturnResponse.java
  26. 3 0
      src/main/java/com/dk/mdm/model/response/mac/AccountItemResponse.java
  27. 128 0
      src/main/java/com/dk/mdm/model/response/mac/RecPayHandleItemResponse.java
  28. 3 0
      src/main/java/com/dk/mdm/model/response/mst/CustomerResponse.java
  29. 3 0
      src/main/java/com/dk/mdm/model/response/pur/PurchaseResponse.java
  30. 128 0
      src/main/java/com/dk/mdm/model/vo/mac/RecPayHandleItemVO.java
  31. 205 47
      src/main/java/com/dk/mdm/service/ivt/IntoReturnService.java
  32. 24 2
      src/main/java/com/dk/mdm/service/mac/AccountService.java
  33. 28 0
      src/main/java/com/dk/mdm/service/mac/RecPayHandleItemService.java
  34. 78 3
      src/main/java/com/dk/mdm/service/mac/RecPayService.java

+ 14 - 1
src/main/java/com/dk/mdm/controller/ivt/IntoReturnController.java

@@ -22,7 +22,7 @@ import java.util.List;
 @Api(tags = "入库退货API接口")
 @RestController
 @RequestMapping("/ivt/intoReturn")
-public class IntoReturnController{
+public class IntoReturnController {
 
     public BaseService<IntoReturn> getService() {
         return intoReturnService;
@@ -44,6 +44,7 @@ public class IntoReturnController{
     public ResponseResultVO<PageList<IntoReturnResponse>> selectByCond(@RequestBody IntoReturnQuery intoReturnQuery) {
         return intoReturnService.selectByCond(intoReturnQuery);
     }
+
     /**
      * @desc : 新建采购退货
      * @author : 于继渤
@@ -81,4 +82,16 @@ public class IntoReturnController{
     public ResponseResultVO<?> selectByUpdate(@PathVariable String id) {
         return intoReturnService.selectByUpdate(id);
     }
+
+    /**
+     * @desc : 采购退货编辑
+     * @author : 于继渤
+     * @date : 2023/1/5 9:39
+     */
+    @ApiOperation(value = "编辑", notes = "编辑")
+    @PostMapping({"update"})
+    public ResponseResultVO<?> update(@RequestBody IntoReturnVO intoReturnVO) {
+        return intoReturnService.update(intoReturnVO);
+    }
+
 }

+ 22 - 0
src/main/java/com/dk/mdm/controller/mac/AccountController.java

@@ -38,6 +38,28 @@ public class AccountController extends BaseController<Account> {
 
 
     /**
+     * @desc : 只查询总单, 不包含总单加明细
+     * @author : 姜永辉
+     * @date : 2024/3/6 10:36
+     */
+    @PostMapping({"/get_account/{id}"})
+    public ResponseResultVO selectAccountById(@PathVariable String id) {
+        return accountService.selectAccountById(id);
+    }
+
+    /**
+     * @desc :  总单加明细总数量
+     * @author : 姜永辉
+     * @date : 2024/3/6 10:36
+     */
+    @PostMapping({"/get_account_item_count"})
+    public ResponseResultVO countByCond(@RequestBody AccountItemQuery accountItemQuery) {
+        return accountService.countByCond(accountItemQuery);
+    }
+
+
+
+    /**
      * @desc : 查询应收账款明细
      * @author : 付斌
      * @date : 2023/1/9 10:36

+ 18 - 6
src/main/java/com/dk/mdm/controller/mac/RecPayController.java

@@ -58,33 +58,33 @@ public class RecPayController{
     }
 
     /**
-     * @desc : 新建
+     * @desc : 新建客户收款
      * @author : 付斌
      * @date : 2023/1/9 10:48
      */
-    @ApiOperation(value = "新建收款", notes = "新建收款")
+    @ApiOperation(value = "新建客户收款", notes = "新建客户收款")
     @PostMapping({"insert_receipt"})
     public ResponseResultVO<?> insertReceipt(@RequestBody RecPayVO recPayVO) {
         return recPayService.insertReceipt(recPayVO);
     }
 
     /**
-     * @desc : 新建
+     * @desc : 新建客户退款
      * @author : 付斌
      * @date : 2023/1/9 10:48
      */
-    @ApiOperation(value = "新建退款", notes = "新建退款")
+    @ApiOperation(value = "新建客户退款", notes = "新建客户退款")
     @PostMapping({"insert_refund"})
     public ResponseResultVO<?> insertRefund(@RequestBody RecPayVO recPayVO) {
         return recPayService.insertRefund(recPayVO);
     }
 
     /**
-     * @desc : 编辑
+     * @desc : 编辑客户收款/退款
      * @author : 付斌
      * @date : 2023/1/9 10:49
      */
-    @ApiOperation(value = "编辑", notes = "编辑")
+    @ApiOperation(value = "编辑客户收款/退款", notes = "编辑客户收款/退款")
     @PostMapping({"update"})
     public ResponseResultVO<?> update(@RequestBody RecPayVO recPayVO) {
         return recPayService.update(recPayVO);
@@ -95,8 +95,20 @@ public class RecPayController{
      * @author : 付斌
      * @date : 2024-02-28 13:24
      */
+    @ApiOperation(value = "查询收款明细(编辑用)", notes = "查询收款明细(编辑用)")
     @PostMapping({"get_rp_for_update/{id}"})
     public ResponseResultVO<?> getRpForUpdate(@PathVariable String id) {
         return recPayService.getRpForUpdate(id);
     }
+
+    /**
+     * @desc : 新建应收收款(收款+冲应收)
+     * @author : 付斌
+     * @date : 2023/1/9 10:48
+     */
+    @ApiOperation(value = "新建应收收款", notes = "新建应收收款")
+    @PostMapping({"insert_receivable_receipt"})
+    public ResponseResultVO<?> insertReceivableReceipt(@RequestBody RecPayVO recPayVO) {
+        return recPayService.insertReceivableReceipt(recPayVO);
+    }
 }

+ 23 - 0
src/main/java/com/dk/mdm/controller/mac/RecPayHandleItemController.java

@@ -0,0 +1,23 @@
+package com.dk.mdm.controller.mac;
+
+import com.dk.mdm.model.pojo.mac.RecPayHandleItem;
+import com.dk.common.service.BaseService;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RestController;
+import io.swagger.annotations.Api;
+import com.dk.mdm.service.mac.RecPayHandleItemService;
+
+@Api(tags = "账务冲抵明细API接口")
+@RestController
+@RequestMapping("/recPayHandleItem")
+public class RecPayHandleItemController{
+
+    public BaseService<RecPayHandleItem> getService() {
+        return recPayHandleItemService;
+    }
+
+    @Autowired
+    private RecPayHandleItemService recPayHandleItemService;
+
+}

+ 4 - 0
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.java

@@ -1,5 +1,6 @@
 package com.dk.mdm.mapper.ivt;
 
+import com.dk.mdm.model.pojo.ivt.Inbound;
 import com.dk.mdm.model.pojo.ivt.InboundItem;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.ivt.InboundItemQuery;
@@ -47,6 +48,9 @@ public interface InboundItemMapper extends BaseMapper<InboundItem>{
     int  updateAmount(InboundItem inboundItem);
 
 
+    int  deleteByFromId(InboundItem inboundItem);
+
+    int updateIntoStatus(InboundItem inboundItem);
 
 }
 

+ 19 - 0
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml

@@ -266,4 +266,23 @@
     </update>
 
 
+    <delete id="deleteByFromId" parameterType="com.dk.mdm.model.pojo.ivt.InboundItem">
+
+        DELETE FROM dkic_b.t_psi_inbound_item WHERE from_item_id =  #{fromItemId}::uuid
+    </delete>
+
+
+
+    <update id="updateIntoStatus" parameterType="com.dk.mdm.model.pojo.ivt.InboundItem">
+        update dkic_b.t_psi_inbound_item
+        <set>
+            <if test="intoStatus!= null">
+                into_status= #{intoStatus},
+            </if>
+
+        </set>
+        where item_id = #{itemId}::uuid
+    </update>
+
+
 </mapper>

+ 1 - 0
src/main/java/com/dk/mdm/mapper/ivt/InboundMapper.java

@@ -71,5 +71,6 @@ public interface InboundMapper extends BaseMapper<Inbound>{
      */
     InboundResponse selectMessageByOtherQuery(InboundQuery inboundQuery);
 
+    int updateIntoStatus(Inbound inbound);
 }
 

+ 10 - 0
src/main/java/com/dk/mdm/mapper/ivt/InboundMapper.xml

@@ -585,4 +585,14 @@
     </select>
 
 
+    <update id="updateIntoStatus" parameterType="com.dk.mdm.model.pojo.ivt.InboundItem">
+        update dkic_b.t_psi_inbound
+        <set>
+            <if test="intoStatus!= null">
+                into_status= #{intoStatus},
+            </if>
+
+        </set>
+        where into_id = #{intoId}::uuid
+    </update>
 </mapper>

+ 3 - 1
src/main/java/com/dk/mdm/mapper/ivt/IntoReturnItemMapper.xml

@@ -84,6 +84,7 @@
         <result column="sku_name" property="skuName"/>
         <result column="sku_model" property="skuModel"/>
         <result column="sku_images" property="skuImages"/>
+        <result column="reject_qty" property="rejectQty"/>
         <result column="wh_id" property="whId" typeHandler="UuidTypeHandler"/>
     </resultMap>
 
@@ -220,7 +221,8 @@
         tpii.into_qty as "intoQty",
         tpii.into_amt as "intoAmt",
         tpii.return_qty as "returnQty",
-        tpii.return_amt as "returnAmt"
+        tpii.return_amt as "returnAmt",
+        (tpii.into_qty - tpii.return_qty) AS reject_qty
         FROM dkic_b.t_psi_into_return_item  tpiri
         left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpiri.sku_id
         left join dkic_b.t_psi_inbound_item tpii on tpiri.into_item_id = tpii.item_id

+ 1 - 0
src/main/java/com/dk/mdm/mapper/ivt/IntoReturnMapper.java

@@ -47,5 +47,6 @@ public interface IntoReturnMapper extends BaseMapper<IntoReturn>{
 
 
     IntoReturnResponse selectByIntoReturnQuery(IntoReturnQuery intoReturnQuery);
+    int updateByUuId(@Param("et")IntoReturn intoReturn);
 }
 

+ 23 - 0
src/main/java/com/dk/mdm/mapper/ivt/IntoReturnMapper.xml

@@ -105,6 +105,7 @@
         <result column="return_address" property="returnAddress"/>
         <result column="out_status_name" property="outStatusName"/>
         <result column="return_status_name" property="returnStatusName"/>
+        <result column="into_id" property="intoId"/>
 
     </resultMap>
 
@@ -204,6 +205,9 @@
 
     <sql id="Condition_Response">
         <where>
+            <if test="isShowCancel == null">
+             AND tpir.return_status != '退货状态-作废'
+            </if>
             <if test="returnNo != null and returnNo != ''">
                 AND tpir.return_no = #{returnNo}
             </if>
@@ -342,12 +346,14 @@
         SELECT
         <include refid="Base_Column_List_Response"/>,
         <include refid="Base_Column_List_Join"/>
+        ,tpi.into_id as into_id
         FROM dkic_b.t_psi_into_return  tpir
         left join  dkic_b.t_mst_supplier tms  on  tms.sup_id = tpir.sup_id
         left join  dkic_b.t_mst_staff tmsf  on  tmsf.staff_id = tpir.staff_id
         left join  dkic_b.t_mst_org tmo  on  tmo.org_id = tpir.org_id
         left join  sys.t_data_kind tdk1 on  tdk1.kind_code = tpir.out_status
         left join  sys.t_data_kind tdk2 on  tdk2.kind_code = tpir.return_status
+        left join  dkic_b.t_psi_inbound tpi on tpi.from_id = tpir.return_id
         <include refid="Condition_Response"/>
             order by tpir.op_create_time desc
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
@@ -582,4 +588,21 @@
         <include refid="Condition_Response"/>
     </select>
 
+
+
+    <update id="updateByUuId" parameterType="com.dk.mdm.model.pojo.ivt.IntoReturn">
+        update dkic_b.t_psi_into_return
+        <set>
+            <if test=" et!=null and et.remarks != null">
+                remarks = #{et.remarks,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.annexPaths != null">
+                annex_paths = #{et.annexPaths,typeHandler=JsonTypeHandler},
+            </if>
+
+        </set>
+        where return_id = #{et.returnId} ::uuid
+
+    </update>
+
 </mapper>

+ 9 - 3
src/main/java/com/dk/mdm/mapper/mac/AccountItemMapper.java

@@ -15,14 +15,20 @@ import java.util.Map;
 @Repository
 public interface AccountItemMapper extends BaseMapper<AccountItem>{
     /**
-     * @desc : 根据条件进行查询
+     * @desc : 查询应收账款明细-数量
      * @author : 付斌
      * @date : 2024-02-28 10:18
      */
-    List<AccountItemResponse> selectByCond(AccountItemQuery accountItemQuery);
+    Long countByCond(AccountItemQuery accountItemQuery);
+    /**
+     * @desc : 查询应收账款明细
+     * @author : 付斌
+     * @date : 2024-02-28 10:18
+     */
+    List<AccountItemResponse> getReceivableAccountItem(AccountItemQuery accountItemQuery);
 
     /**
-     * @desc : 根据条件进行查询
+     * @desc : 查询应付账款明细
      * @author : 付斌
      * @date : 2024-02-28 10:18
      */

+ 51 - 28
src/main/java/com/dk/mdm/mapper/mac/AccountItemMapper.xml

@@ -58,6 +58,9 @@
                 <result column="cp_id" property="cpId"/>
     </resultMap>
 
+
+
+
     <!-- 通用条件列 -->
     <sql id="Condition">
             <if test="accItemType != null and accItemType != ''">
@@ -102,6 +105,9 @@
             <if test="amtWaive != null">
                 AND t.amt_waive = #{amtWaive}
             </if>
+            <if test="amtResidueFlg != null">
+                AND t.amt_residue > 0
+            </if>
             <if test="amtResidue != null">
                 AND t.amt_residue = #{amtResidue}
             </if>
@@ -130,24 +136,44 @@
         </foreach>
     </sql>
 
-    <!-- 查询表t_mac_account_item,(条件查询+分页)列表 -->
-    <select id="getPayableAccountItem" resultMap="BaseResultMapResponse">
+    <!-- 根据主键查询表t_mac_account_item的一行数据 -->
+    <select id="selectByCond" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM dkic_b.t_mac_account_item as t
+        where 1 = 1
+        <include refid="Condition"/>
+    </select>
+
+    <!-- 查询表t_mac_account_item,(条件查询)个数 -->
+    <select id="countByCond" resultType="Long">
+        SELECT
+        count(1)
+        FROM dkic_b.t_mac_account_item as t
+        where 1 = 1
+        <include refid="Condition"/>
+    </select>
+
+
+    <!-- 查询应收账款明细 -->
+    <select id="getReceivableAccountItem" resultMap="BaseResultMapResponse">
         SELECT t.item_id,
                t.acc_item_type,
                t.object_id,
-               tms.sup_code       as "supCode",
-               tms.sup_name       as "supName",
-               tms.contact_phone  as "contactPhone",
-               tms.return_address as "returnAddress",
+               tmc.cus_code                                      as "cusCode",
+               tmc.cus_name                                      as "cusName",
+               tmc.cus_phone                                     as "cusPhone",
+               tmc.address_full                                  as "addressFull",
                t.org_id,
-               tmo.org_name       as "orgName",
+               tmo.org_name                                      as "orgName",
                t.staff_id,
-               tms.staff_name     as "staffName",
+               tms.staff_name                                    as "staffName",
                t.biznis_type,
                t.biznis_id,
                t.biznis_no,
                t.acc_date,
                t.rec_status,
+               sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "recStatusName",
                t.amt_rec,
                t.amt_pay,
                t.amt_should,
@@ -160,35 +186,38 @@
                t.flg_valid,
                t.cp_id
         FROM dkic_b.t_mac_account_item as t
-                 left join dkic_b.t_mst_supplier tms on tms.sup_id = t.object_id
+                 left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.object_id
                  left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
                  left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
+                 left join sys.t_data_kind as tdk1 on t.rec_status = tdk1.kind_code
         where t.flg_valid
-          and t.acc_item_type = '账款类型-应付'
+          and t.acc_item_type = '账款类型-应收'
+          and t.amt_residue > 0
         <include refid="Condition"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
     </select>
 
-    <!-- 查询表t_mac_account_item,(条件查询+分页)列表 -->
-    <select id="selectByCond" resultMap="BaseResultMapResponse">
+    <!-- 查询应付账款明细 -->
+    <select id="getPayableAccountItem" resultMap="BaseResultMapResponse">
         SELECT t.item_id,
                t.acc_item_type,
                t.object_id,
-               tmc.cus_code     as "cusCode",
-               tmc.cus_name     as "cusName",
-               tmc.cus_phone    as "cusPhone",
-               tmc.address_full as "addressFull",
+               tms.sup_code       as "supCode",
+               tms.sup_name       as "supName",
+               tms.contact_phone  as "contactPhone",
+               tms.return_address as "returnAddress",
                t.org_id,
-               tmo.org_name     as "orgName",
+               tmo.org_name       as "orgName",
                t.staff_id,
-               tms.staff_name   as "staffName",
+               tms.staff_name     as "staffName",
                t.biznis_type,
                t.biznis_id,
                t.biznis_no,
                t.acc_date,
                t.rec_status,
+               sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "recStatusName",
                t.amt_rec,
                t.amt_pay,
                t.amt_should,
@@ -201,25 +230,19 @@
                t.flg_valid,
                t.cp_id
         FROM dkic_b.t_mac_account_item as t
-                 left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.object_id
+                 left join dkic_b.t_mst_supplier tms on tms.sup_id = t.object_id
                  left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
                  left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
+                 left join sys.t_data_kind as tdk1 on t.rec_status = tdk1.kind_code
         where t.flg_valid
-          and t.acc_item_type = '账款类型-应收'
+          and t.acc_item_type = '账款类型-应付'
+          and t.amt_residue > 0
         <include refid="Condition"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
     </select>
 
-    <!-- 查询表t_mac_account_item,(条件查询)个数 -->
-    <select id="countByCond" resultType="Long">
-        SELECT
-        count(1)
-        FROM dkic_b.t_mac_account_item
-        where 1=1
-        <include refid="Condition"/>
-    </select>
 
     <!-- 根据主键查询表t_mac_account_item的一行数据 -->
     <select id="selectById" resultMap="BaseResultMap">

+ 1 - 1
src/main/java/com/dk/mdm/mapper/mac/AccountMapper.java

@@ -17,6 +17,6 @@ public interface AccountMapper extends BaseMapper<Account>{
      * @date   : 2024/3/9 9:14
      * @author :  姜永辉
      */
-    AccountResponse selectById(@Param("intoId") String intoId);
+    AccountResponse selectById(@Param("objectId") String objectId);
 }
 

+ 44 - 10
src/main/java/com/dk/mdm/mapper/mac/AccountMapper.xml

@@ -5,7 +5,10 @@
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <sql id="Base_Column_List">
-        object_id, object_type, receipt, receipt_lock, contract_assets, receivable, receivable_handle, receivable_waive, receivable_residue, receipt_residue, payment, pur_estimate, payable, payable_handle, payable_waive, payable_residue, payment_residue, remarks, flg_valid, cp_id
+        ac.object_id, ac.object_type, ac.receipt, ac.receipt_lock, ac.contract_assets, ac.receivable,
+        ac.receivable_handle, ac.receivable_waive, ac.receivable_residue, ac.receipt_residue, ac.payment,
+        ac.pur_estimate, ac.payable, ac.payable_handle, ac.payable_waive, ac.payable_residue,
+        ac.payment_residue, ac.remarks, ac.flg_valid, ac.cp_id
     </sql>
 
     <!-- 通用查询映射结果 -->
@@ -32,6 +35,30 @@
                 <result column="cp_id" property="cpId"/>
     </resultMap>
 
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mac.AccountResponse">
+        <id column="object_id" property="objectId"/>
+        <result column="object_type" property="objectType"/>
+        <result column="receipt" property="receipt"/>
+        <result column="receipt_lock" property="receiptLock"/>
+        <result column="contract_assets" property="contractAssets"/>
+        <result column="receivable" property="receivable"/>
+        <result column="receivable_handle" property="receivableHandle"/>
+        <result column="receivable_waive" property="receivableWaive"/>
+        <result column="receivable_residue" property="receivableResidue"/>
+        <result column="receipt_residue" property="receiptResidue"/>
+        <result column="payment" property="payment"/>
+        <result column="pur_estimate" property="purEstimate"/>
+        <result column="payable" property="payable"/>
+        <result column="payable_handle" property="payableHandle"/>
+        <result column="payable_waive" property="payableWaive"/>
+        <result column="payable_residue" property="payableResidue"/>
+        <result column="payment_residue" property="paymentResidue"/>
+        <result column="remarks" property="remarks"/>
+        <result column="flg_valid" property="flgValid"/>
+        <result column="cp_id" property="cpId"/>
+    </resultMap>
+
     <!-- 通用条件列 -->
     <sql id="Condition">
         <where>
@@ -97,7 +124,7 @@
 
     <sql id="idsForeach">
         <!-- 根据主键objectId批量操作 -->
-        WHERE object_id in
+        WHERE  ac.object_id in
         <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
             #{item}
         </foreach>
@@ -107,7 +134,7 @@
     <select id="selectByCond" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM dkic_b.t_mac_account
+        FROM dkic_b.t_mac_account  ac
         <include refid="Condition"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
@@ -118,24 +145,31 @@
     <select id="countByCond" resultType="Long">
         SELECT
         count(1)
-        FROM dkic_b.t_mac_account
+        FROM dkic_b.t_mac_account ac
         <include refid="Condition"/>
     </select>
 
     <!-- 根据主键查询表t_mac_account的一行数据 -->
-    <select id="selectById" resultMap="BaseResultMap">
+    <select id="selectById" resultMap="BaseResultMapResponse">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM dkic_b.t_mac_account
-        WHERE object_id = #{objectId}::uuid
+        ,sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS  "objectTypeName"
+        ,tmp.sup_name                              AS "supplierName"
+        ,tmc.cus_name                                      as "cusName"
+        ,tmc.cus_phone                                     as "cusPhone"
+        FROM dkic_b.t_mac_account ac
+        LEFT JOIN sys.t_data_kind tdk   ON tdk.kind_code = ac.object_type
+        Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = ac.object_id
+        left join dkic_b.t_mst_customer tmc on ac.object_id = tmc.cus_id
+        WHERE ac.object_id = #{objectId}::uuid
     </select>
 
     <!-- 根据主键锁定表t_mac_account的一行数据 -->
     <select id="selectByIdForUpdate" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM dkic_b.t_mac_account
-        WHERE object_id = #{id}::uuid
+        FROM dkic_b.t_mac_account  ac
+        WHERE  ac.object_id = #{id}::uuid
         for update
     </select>
 
@@ -143,7 +177,7 @@
     <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM dkic_b.t_mac_account
+        FROM dkic_b.t_mac_account  ac
         <include refid="idsForeach"/>
         for update
     </select>

+ 14 - 0
src/main/java/com/dk/mdm/mapper/mac/RecPayHandleItemMapper.java

@@ -0,0 +1,14 @@
+package com.dk.mdm.mapper.mac;
+
+import com.dk.mdm.model.pojo.mac.RecPayHandleItem;
+import com.dk.common.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+*  账务冲抵明细 Mapper
+*/
+@Repository
+public interface RecPayHandleItemMapper extends BaseMapper<RecPayHandleItem>{
+	
+}
+

+ 157 - 0
src/main/java/com/dk/mdm/mapper/mac/RecPayHandleItemMapper.xml

@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.dk.mdm.mapper.mac.RecPayHandleItemMapper">
+
+    <!-- 通用设置 -->
+    <!-- 通用查询列 -->
+    <sql id="Base_Column_List">
+        item_id, rp_id, acc_item_id, amt_receivable_handle, amt_payable_handle, amt_waive, acc_date, remarks, flg_valid, cp_id
+    </sql>
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mac.RecPayHandleItem">
+        <id column="item_id" property="itemId"/>
+                <result column="rp_id" property="rpId" typeHandler="UuidTypeHandler"/>
+                <result column="acc_item_id" property="accItemId" typeHandler="UuidTypeHandler"/>
+                <result column="amt_receivable_handle" property="amtReceivableHandle"/>
+                <result column="amt_payable_handle" property="amtPayableHandle"/>
+                <result column="amt_waive" property="amtWaive"/>
+            <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
+                <result column="remarks" property="remarks"/>
+                <result column="flg_valid" property="flgValid"/>
+                <result column="cp_id" property="cpId"/>
+    </resultMap>
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mac.RecPayHandleItemResponse">
+        <id column="item_id" property="itemId"/>
+                <result column="rp_id" property="rpId" typeHandler="UuidTypeHandler"/>
+                <result column="acc_item_id" property="accItemId" typeHandler="UuidTypeHandler"/>
+                <result column="amt_receivable_handle" property="amtReceivableHandle"/>
+                <result column="amt_payable_handle" property="amtPayableHandle"/>
+                <result column="amt_waive" property="amtWaive"/>
+            <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
+                <result column="remarks" property="remarks"/>
+                <result column="flg_valid" property="flgValid"/>
+                <result column="cp_id" property="cpId"/>
+    </resultMap>
+
+    <!-- 通用条件列 -->
+    <sql id="Condition">
+        <where>
+            <if test="rpId != null and rpId != ''">
+                AND rp_id = #{rpId}
+            </if>
+            <if test="accItemId != null and accItemId != ''">
+                AND acc_item_id = #{accItemId}
+            </if>
+            <if test="amtReceivableHandle != null">
+                AND amt_receivable_handle = #{amtReceivableHandle}
+            </if>
+            <if test="amtPayableHandle != null">
+                AND amt_payable_handle = #{amtPayableHandle}
+            </if>
+            <if test="amtWaive != null">
+                AND amt_waive = #{amtWaive}
+            </if>
+            <if test="accDate != null">
+                AND acc_date = #{accDate}
+            </if>
+            <if test="remarks != null and remarks != ''">
+                AND remarks = #{remarks}
+            </if>
+            <if test="flgValid != null">
+                AND flg_valid = #{flgValid}
+            </if>
+            <if test="cpId != null">
+                AND cp_id = #{cpId}
+            </if>
+        </where>
+    </sql>
+
+    <sql id="idsForeach">
+        <!-- 根据主键itemId批量操作 -->
+        WHERE item_id in
+        <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+    </sql>
+
+    <!-- 查询表t_mac_rec_pay_handle_item,(条件查询+分页)列表 -->
+    <select id="selectByCond" resultMap="BaseResultMapResponse">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM t_mac_rec_pay_handle_item
+        <include refid="Condition"/>
+        <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
+            limit #{end} offset #{start}
+        </if>
+    </select>
+
+    <!-- 查询表t_mac_rec_pay_handle_item,(条件查询)个数 -->
+    <select id="countByCond" resultType="Long">
+        SELECT
+        count(1)
+        FROM t_mac_rec_pay_handle_item
+        <include refid="Condition"/>
+    </select>
+
+    <!-- 根据主键查询表t_mac_rec_pay_handle_item的一行数据 -->
+    <select id="selectById" resultMap="BaseResultMapResponse">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM t_mac_rec_pay_handle_item
+        WHERE item_id = #{itemId}::uuid
+    </select>
+
+    <!-- 根据主键锁定表t_mac_rec_pay_handle_item的一行数据 -->
+    <select id="selectByIdForUpdate" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM t_mac_rec_pay_handle_item
+        WHERE item_id = #{id}::uuid
+        for update
+    </select>
+
+    <!-- 根据主键锁定表t_mac_rec_pay_handle_item的多行数据 -->
+    <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM t_mac_rec_pay_handle_item
+        <include refid="idsForeach"/>
+        for update
+    </select>
+
+    <insert id="insertBatch">
+        insert into t_mac_rec_pay_handle_item
+        (
+        <trim suffixOverrides=",">
+            rp_id,
+            acc_item_id,
+            amt_receivable_handle,
+            amt_payable_handle,
+            amt_waive,
+            acc_date,
+            remarks,
+            cp_id,
+            op_app_code,
+        </trim>
+        )
+        values
+        <foreach collection="list" index="index" item="item" separator=",">
+            (
+            <trim suffixOverrides=",">
+                #{item.rpId}::uuid,
+                #{item.accItemId}::uuid,
+                #{item.amtReceivableHandle},
+                #{item.amtPayableHandle},
+                #{item.amtWaive},
+                #{item.accDate},
+                #{item.remarks},
+                #{item.cpId},
+                #{item.opAppCode},
+            </trim>
+            )
+        </foreach>
+    </insert>
+</mapper>

+ 3 - 2
src/main/java/com/dk/mdm/mapper/mst/CustomerMapper.xml

@@ -96,7 +96,7 @@
         <result column="follow_staff" property="followStaff"/>
         <result column="follow_staff_name" property="followStaffName"/>
         <result column="receivable_residue" property="receivableResidue"/>
-
+        <result column="receipt_residue" property="receiptResidue"/>
     </resultMap>
 
     <!-- 通用条件列 -->
@@ -211,7 +211,8 @@
         tms2.staff_name  AS  "reportStaffName",
         tdk.kind_name_i18n  ->> 'zh_CN' AS "saleStatusName",
         tcf.next_follow_time,
-        tma.receivable_residue
+        tma.receivable_residue,
+        tma.receipt_residue
         FROM dkic_b.t_mst_customer tmc
         LEFT JOIN  ( select tccff.cus_id, max (tccff.next_follow_time)as next_follow_time from dkic_b.t_crm_cus_follow tccff group by tccff.cus_id )  tcf on tmc.cus_id = tcf.cus_id
         LEFT JOIN  dkic_b.t_mst_dictionary_data tmd  on tmd.data_id =  tmc.cus_from

+ 3 - 0
src/main/java/com/dk/mdm/mapper/pur/PurchaseMapper.xml

@@ -144,6 +144,7 @@
         <result column="displayedStatus" property="displayedStatus"/>
         <result column="intoStatusName" property="intoStatusName"/>
         <result column="purStatusName" property="purStatusName"/>
+        <result column="returnAddress" property="returnAddress"/>
 
         <collection property="purchaseItemResponseList" resultMap="purchaseItemListMap" columnPrefix="list_"/>
     </resultMap>
@@ -452,6 +453,7 @@
         ,tms.staff_name as "staffName"
         ,tms1.staff_name as "makeStaffName"
         ,tmp.sup_name as "supplierName"
+        ,tmp.return_address as "returnAddress"
         ,tmw.wh_name as "whName"
         ,sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "intoStatusName"
         ,sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n}) as "purStatusName"
@@ -468,6 +470,7 @@
         left join sys.t_data_kind tdk1 on tdk1.kind_code = tpp.into_status
         left join sys.t_data_kind tdk2 on tdk2.kind_code = tpp.pur_status
         <include refid="Condition_1"/>
+            order by  tpp.op_create_time desc
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>

+ 126 - 0
src/main/java/com/dk/mdm/model/pojo/mac/RecPayHandleItem.java

@@ -0,0 +1,126 @@
+package com.dk.mdm.model.pojo.mac;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.*;
+import java.io.Serializable;
+
+import com.dk.common.infrastructure.annotaiton.ExportTitle;
+import com.dk.common.infrastructure.handler.*;
+import com.dk.common.model.pojo.PageInfo;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ *  账务冲抵明细
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@ExportTitle("账务冲抵明细")
+@TableName(value = "t_mac_rec_pay_handle_item", autoResultMap = true)
+@ApiModel(value="实体类:账务冲抵明细", description="表名:t_mac_rec_pay_handle_item")
+public class RecPayHandleItem extends PageInfo<RecPayHandleItem> implements Serializable {
+
+    /*
+     * 数据库字段
+     */
+
+    /**
+     * 明细ID
+     */
+//    @TableId(value = "item_id", type = IdType.AUTO)
+    @ApiModelProperty(value = "明细ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String itemId;
+
+
+    /**
+     * 收付款单ID
+     */
+    @Excel(name = "收付款单ID")
+    @ApiModelProperty(value = "收付款单ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String rpId;
+
+
+    /**
+     * 账款明细ID
+     */
+    @Excel(name = "账款明细ID")
+    @ApiModelProperty(value = "账款明细ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String accItemId;
+
+
+    /**
+     * 应收冲抵金额
+     */
+    @Excel(name = "应收冲抵金额")
+    @ApiModelProperty(value = "应收冲抵金额")
+    private BigDecimal amtReceivableHandle;
+
+
+    /**
+     * 应付冲抵金额
+     */
+    @Excel(name = "应付冲抵金额")
+    @ApiModelProperty(value = "应付冲抵金额")
+    private BigDecimal amtPayableHandle;
+
+
+    /**
+     * 优惠金额
+     */
+    @Excel(name = "优惠金额")
+    @ApiModelProperty(value = "优惠金额")
+    private BigDecimal amtWaive;
+
+
+    /**
+     * 还款日期
+     */
+    @Excel(name = "还款日期")
+    @ApiModelProperty(value = "还款日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDate accDate;
+
+
+    /**
+     * 备注
+     */
+    @Excel(name = "备注")
+    @ApiModelProperty(value = "备注")
+    private String remarks;
+
+
+    /**
+     * 有效标识 (1:正常 0:停用)
+     */
+    @Excel(name = "有效标识 (1:正常 0:停用)")
+    @ApiModelProperty(value = "有效标识 (1:正常 0:停用)")
+    private Boolean flgValid;
+
+
+    /**
+     * 企业ID
+     */
+    @TableField(fill = FieldFill.INSERT)
+    @Excel(name = "企业ID")
+    @ApiModelProperty(value = "企业ID")
+    private Integer cpId;
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 2 - 0
src/main/java/com/dk/mdm/model/query/ivt/IntoReturnQuery.java

@@ -279,6 +279,8 @@ public class IntoReturnQuery extends PageInfo<IntoReturnQuery> {
 
     private String searchText;
 
+    private String isShowCancel;
+
     private static final long serialVersionUID = 1L;
 
 }

+ 2 - 0
src/main/java/com/dk/mdm/model/query/mac/AccountItemQuery.java

@@ -215,6 +215,8 @@ public class AccountItemQuery extends PageInfo<AccountItemQuery> implements Seri
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
 
+    @ApiModelProperty(value = "剩余金额是否大于0")
+    private Boolean amtResidueFlg;
 
     /*
      * 相关属性

+ 128 - 0
src/main/java/com/dk/mdm/model/query/mac/RecPayHandleItemQuery.java

@@ -0,0 +1,128 @@
+package com.dk.mdm.model.query.mac;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.dk.common.infrastructure.annotaiton.ExportTitle;
+import com.dk.common.infrastructure.handler.TimestampTypeHandler;
+import com.dk.common.infrastructure.handler.UuidTypeHandler;
+import com.dk.common.model.pojo.PageInfo;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ *  账务冲抵明细
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@ExportTitle("账务冲抵明细")
+@TableName(value = "t_mac_rec_pay_handle_item", autoResultMap = true)
+@ApiModel(value="实体类:账务冲抵明细", description="表名:t_mac_rec_pay_handle_item")
+public class RecPayHandleItemQuery extends PageInfo<RecPayHandleItemQuery> implements Serializable {
+
+    /*
+     * 数据库字段
+     */
+
+    /**
+     * 明细ID
+     */
+//    @TableId(value = "item_id", type = IdType.AUTO)
+    @ApiModelProperty(value = "明细ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String itemId;
+
+
+    /**
+     * 收付款单ID
+     */
+    @Excel(name = "收付款单ID")
+    @ApiModelProperty(value = "收付款单ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String rpId;
+
+
+    /**
+     * 账款明细ID
+     */
+    @Excel(name = "账款明细ID")
+    @ApiModelProperty(value = "账款明细ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String accItemId;
+
+
+    /**
+     * 应收冲抵金额
+     */
+    @Excel(name = "应收冲抵金额")
+    @ApiModelProperty(value = "应收冲抵金额")
+    private BigDecimal amtReceivableHandle;
+
+
+    /**
+     * 应付冲抵金额
+     */
+    @Excel(name = "应付冲抵金额")
+    @ApiModelProperty(value = "应付冲抵金额")
+    private BigDecimal amtPayableHandle;
+
+
+    /**
+     * 优惠金额
+     */
+    @Excel(name = "优惠金额")
+    @ApiModelProperty(value = "优惠金额")
+    private BigDecimal amtWaive;
+
+
+    /**
+     * 还款日期
+     */
+    @Excel(name = "还款日期")
+    @ApiModelProperty(value = "还款日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDate accDate;
+
+
+    /**
+     * 备注
+     */
+    @Excel(name = "备注")
+    @ApiModelProperty(value = "备注")
+    private String remarks;
+
+
+    /**
+     * 有效标识 (1:正常 0:停用)
+     */
+    @Excel(name = "有效标识 (1:正常 0:停用)")
+    @ApiModelProperty(value = "有效标识 (1:正常 0:停用)")
+    private Boolean flgValid;
+
+
+    /**
+     * 企业ID
+     */
+    @TableField(fill = FieldFill.INSERT)
+    @Excel(name = "企业ID")
+    @ApiModelProperty(value = "企业ID")
+    private Integer cpId;
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 3 - 0
src/main/java/com/dk/mdm/model/response/ivt/IntoReturnItemResponse.java

@@ -278,6 +278,9 @@ public class IntoReturnItemResponse  {
     @ApiModelProperty(value = "已入库退货金额")
     private BigDecimal returnAmt;
 
+    @ApiModelProperty(value = "可退数量")
+    private BigDecimal rejectQty;
+
 
     private static final long serialVersionUID = 1L;
 

+ 7 - 0
src/main/java/com/dk/mdm/model/response/ivt/IntoReturnResponse.java

@@ -324,6 +324,13 @@ public class IntoReturnResponse  {
     @ApiModelProperty(value = "退货状态")
     private String returnStatusName;
 
+    /**
+     * 入库ID
+     */
+    @Excel(name = "入库ID")
+    @ApiModelProperty(value = "入库ID")
+    private String intoId;
+
     private static final long serialVersionUID = 1L;
 
 }

+ 3 - 0
src/main/java/com/dk/mdm/model/response/mac/AccountItemResponse.java

@@ -233,6 +233,9 @@ public class AccountItemResponse extends PageInfo<AccountItemResponse> implement
     @ApiModelProperty(value = "详细地址")
     private String addressFull;
 
+    @ApiModelProperty(value = "账务状态")
+    private String recStatusName;
+
     private static final long serialVersionUID = 1L;
 
 }

+ 128 - 0
src/main/java/com/dk/mdm/model/response/mac/RecPayHandleItemResponse.java

@@ -0,0 +1,128 @@
+package com.dk.mdm.model.response.mac;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.dk.common.infrastructure.annotaiton.ExportTitle;
+import com.dk.common.infrastructure.handler.TimestampTypeHandler;
+import com.dk.common.infrastructure.handler.UuidTypeHandler;
+import com.dk.common.model.pojo.PageInfo;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ *  账务冲抵明细
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@ExportTitle("账务冲抵明细")
+@TableName(value = "t_mac_rec_pay_handle_item", autoResultMap = true)
+@ApiModel(value="实体类:账务冲抵明细", description="表名:t_mac_rec_pay_handle_item")
+public class RecPayHandleItemResponse extends PageInfo<RecPayHandleItemResponse> implements Serializable {
+
+    /*
+     * 数据库字段
+     */
+
+    /**
+     * 明细ID
+     */
+//    @TableId(value = "item_id", type = IdType.AUTO)
+    @ApiModelProperty(value = "明细ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String itemId;
+
+
+    /**
+     * 收付款单ID
+     */
+    @Excel(name = "收付款单ID")
+    @ApiModelProperty(value = "收付款单ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String rpId;
+
+
+    /**
+     * 账款明细ID
+     */
+    @Excel(name = "账款明细ID")
+    @ApiModelProperty(value = "账款明细ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String accItemId;
+
+
+    /**
+     * 应收冲抵金额
+     */
+    @Excel(name = "应收冲抵金额")
+    @ApiModelProperty(value = "应收冲抵金额")
+    private BigDecimal amtReceivableHandle;
+
+
+    /**
+     * 应付冲抵金额
+     */
+    @Excel(name = "应付冲抵金额")
+    @ApiModelProperty(value = "应付冲抵金额")
+    private BigDecimal amtPayableHandle;
+
+
+    /**
+     * 优惠金额
+     */
+    @Excel(name = "优惠金额")
+    @ApiModelProperty(value = "优惠金额")
+    private BigDecimal amtWaive;
+
+
+    /**
+     * 还款日期
+     */
+    @Excel(name = "还款日期")
+    @ApiModelProperty(value = "还款日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDate accDate;
+
+
+    /**
+     * 备注
+     */
+    @Excel(name = "备注")
+    @ApiModelProperty(value = "备注")
+    private String remarks;
+
+
+    /**
+     * 有效标识 (1:正常 0:停用)
+     */
+    @Excel(name = "有效标识 (1:正常 0:停用)")
+    @ApiModelProperty(value = "有效标识 (1:正常 0:停用)")
+    private Boolean flgValid;
+
+
+    /**
+     * 企业ID
+     */
+    @TableField(fill = FieldFill.INSERT)
+    @Excel(name = "企业ID")
+    @ApiModelProperty(value = "企业ID")
+    private Integer cpId;
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 3 - 0
src/main/java/com/dk/mdm/model/response/mst/CustomerResponse.java

@@ -309,6 +309,9 @@ public class CustomerResponse extends PageInfo<CustomerResponse> implements Seri
     @ApiModelProperty(value = "总剩余应收 (总应收账款-总应收收款金额-总应收优惠金额)")
     private BigDecimal receivableResidue;
 
+    @ApiModelProperty(value = "总收款金额-总应收收款金额+总应收优惠金额(现金池)")
+    private BigDecimal receiptResidue;
+
 
     private static final long serialVersionUID = 1L;
 

+ 3 - 0
src/main/java/com/dk/mdm/model/response/pur/PurchaseResponse.java

@@ -423,6 +423,9 @@ public class PurchaseResponse extends PageInfo<PurchaseResponse> implements Seri
     @ApiModelProperty(value = "订单状态名称")
     private String purStatusName;
 
+    @ApiModelProperty(value = "供应商地址")
+    private String returnAddress;
+
 
     /*
      * 相关属性

+ 128 - 0
src/main/java/com/dk/mdm/model/vo/mac/RecPayHandleItemVO.java

@@ -0,0 +1,128 @@
+package com.dk.mdm.model.vo.mac;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.dk.common.infrastructure.annotaiton.ExportTitle;
+import com.dk.common.infrastructure.handler.TimestampTypeHandler;
+import com.dk.common.infrastructure.handler.UuidTypeHandler;
+import com.dk.common.model.pojo.PageInfo;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ *  账务冲抵明细
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@ExportTitle("账务冲抵明细")
+@TableName(value = "t_mac_rec_pay_handle_item", autoResultMap = true)
+@ApiModel(value="实体类:账务冲抵明细", description="表名:t_mac_rec_pay_handle_item")
+public class RecPayHandleItemVO extends PageInfo<RecPayHandleItemVO> implements Serializable {
+
+    /*
+     * 数据库字段
+     */
+
+    /**
+     * 明细ID
+     */
+//    @TableId(value = "item_id", type = IdType.AUTO)
+    @ApiModelProperty(value = "明细ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String itemId;
+
+
+    /**
+     * 收付款单ID
+     */
+    @Excel(name = "收付款单ID")
+    @ApiModelProperty(value = "收付款单ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String rpId;
+
+
+    /**
+     * 账款明细ID
+     */
+    @Excel(name = "账款明细ID")
+    @ApiModelProperty(value = "账款明细ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String accItemId;
+
+
+    /**
+     * 应收冲抵金额
+     */
+    @Excel(name = "应收冲抵金额")
+    @ApiModelProperty(value = "应收冲抵金额")
+    private BigDecimal amtReceivableHandle;
+
+
+    /**
+     * 应付冲抵金额
+     */
+    @Excel(name = "应付冲抵金额")
+    @ApiModelProperty(value = "应付冲抵金额")
+    private BigDecimal amtPayableHandle;
+
+
+    /**
+     * 优惠金额
+     */
+    @Excel(name = "优惠金额")
+    @ApiModelProperty(value = "优惠金额")
+    private BigDecimal amtWaive;
+
+
+    /**
+     * 还款日期
+     */
+    @Excel(name = "还款日期")
+    @ApiModelProperty(value = "还款日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDate accDate;
+
+
+    /**
+     * 备注
+     */
+    @Excel(name = "备注")
+    @ApiModelProperty(value = "备注")
+    private String remarks;
+
+
+    /**
+     * 有效标识 (1:正常 0:停用)
+     */
+    @Excel(name = "有效标识 (1:正常 0:停用)")
+    @ApiModelProperty(value = "有效标识 (1:正常 0:停用)")
+    private Boolean flgValid;
+
+
+    /**
+     * 企业ID
+     */
+    @TableField(fill = FieldFill.INSERT)
+    @Excel(name = "企业ID")
+    @ApiModelProperty(value = "企业ID")
+    private Integer cpId;
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 205 - 47
src/main/java/com/dk/mdm/service/ivt/IntoReturnService.java

@@ -105,6 +105,16 @@ public class IntoReturnService extends BaseService<IntoReturn> {
     private InboundPurchaseReturnService inboundPurchaseReturnService;
 
     /**
+     * @desc : 重写主键
+     * @author : 于继渤
+     * @date : 2024/2/29 20:29
+     */
+    @Override
+    public String getPrimaryKey() {
+        return "return_id";
+    }
+
+    /**
      * @desc : 查询
      * @author : 于继渤
      * @date : 2023/1/5 9:39
@@ -196,7 +206,7 @@ public class IntoReturnService extends BaseService<IntoReturn> {
         inboundVO.setIntoingAmt(intoReturnVO.getSumAmount().multiply(new BigDecimal(-1)));
         List<InboundItemVO> list = new ArrayList<>();
         for (IntoReturnItemVO intoReturnItemVO : intoReturnItemVOList) {
-            System.out.println("'id==='"+intoReturnItemVO.getItemId());
+            System.out.println("'id==='" + intoReturnItemVO.getItemId());
             InboundItemVO inboundItemVO = new InboundItemVO();
             inboundItemVO.setIntoingQty(intoReturnItemVO.getItemQty().multiply(new BigDecimal(-1)));
             inboundItemVO.setIntoingAmt(intoReturnItemVO.getItemAmt().multiply(new BigDecimal(-1)));
@@ -296,7 +306,7 @@ public class IntoReturnService extends BaseService<IntoReturn> {
 //            } else {
 //                intoReturnItemVO.setOutingQty(intoReturnItemVO.getItemQty());
 //                intoReturnItemVO.setOutingAmt(intoReturnItemVO.getItemAmt());
-                intoReturnItemVO.setOutStatus(Constant.OutStatus.CHUKUZHONG.getName());
+            intoReturnItemVO.setOutStatus(Constant.OutStatus.CHUKUZHONG.getName());
 //            }
 //            //新建明细
             IntoReturnItem intoReturnItem = intoReturnItemConvert.convertToPo(intoReturnItemVO);
@@ -307,7 +317,6 @@ public class IntoReturnService extends BaseService<IntoReturn> {
     }
 
 
-
     /**
      * @desc : 作废
      * @date : 2022/6/28 16:58
@@ -316,43 +325,42 @@ public class IntoReturnService extends BaseService<IntoReturn> {
     @Transactional(rollbackFor = {Exception.class})
     public ResponseResultVO<String> cancel(IntoReturnVO intoReturnVO) {
         //根据入库退货单id查询到退货单
-        IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(intoReturnVO.getReturnId());
-        if(intoReturnResponse.getReturnStatus().equals(Constant.returnStatus.OUT_REJECT_STATUS_RIGHTING_NOT.getName())){
-            //当前单据已经作废,不能重复操
-            return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
-        }
 
-        //查询入库单 修改 已入库退货数量/金额
-        InboundResponse inboundResponse = inboundMapper.selectById(intoReturnVO.getIntoId());
-        if (inboundResponse == null ) {
-            //返回 单据所对应的原始单据不存在,请重新操作
-            return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
-        }
-        inboundMapper.updateAmount(new Inbound()
-                .setReturnQty(inboundResponse.getReturnQty().subtract(intoReturnResponse.getSumQuantity()))
-                .setReturnAmt(inboundResponse.getReturnAmt().subtract(intoReturnResponse.getSumAmount())));
-
-        //查询采购单
-        PurchaseResponse purchaseResponse = purchaseMapper.selectById(intoReturnResponse.getPurId());
-        if (purchaseResponse == null ) {
-            //返回 单据所对应的原始单据不存在,请重新操作
-            return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
-        }
-        //修改采购单 已入库数量/金额
-        purchaseMapper.updateAmount(
-                new Purchase().setReturnQty(purchaseResponse.getReturnQty().subtract(intoReturnResponse.getSumQuantity()))
-                        .setReturnAmt(purchaseResponse.getReturnAmt().subtract(intoReturnResponse.getSumAmount())).setPurId(intoReturnResponse.getPurId())
-        );
+        List<IntoReturnResponse> intoReturnResponses = intoReturnMapper.selectByCond(new IntoReturnQuery().setReturnId(intoReturnVO.getReturnId()));
 
-        //查询入库退货单明细
-        List<IntoReturnItemResponse> intoReturnItemList = intoReturnItemService.selectByCond(new IntoReturnItemQuery().setReturnId(intoReturnResponse.getReturnId())).getData().getList();
-        //明细不存在
-        if (intoReturnItemList == null || intoReturnItemList.size() == 0) {
-            //返回 采购退货明细不可为空,请重新操作
-            return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.PURCHASE_RETURN_DETAIL_NOT_EXIST.getMessage());
-        }
 
-        if (intoReturnItemList != null && intoReturnItemList.size() > 0) {
+        if (intoReturnResponses != null && intoReturnResponses.size() > 0) {
+            IntoReturnResponse intoReturnResponse = intoReturnResponses.get(0);
+            if (intoReturnResponse.getReturnStatus().equals(Constant.returnStatus.OUT_REJECT_STATUS_RIGHTING_NOT.getName())) {
+                //当前单据已经作废,不能重复操
+                return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
+            }
+            //非出库中单据不能作废
+            if (intoReturnResponse.getOutStatus().equals(Constant.OutStatus.YICHUKU.getName())) {
+                return ResponseResultUtil.error(ErrorCodeEnum.NO_WAIT_INTO_RETURN_CANCEL.getCode(),
+                        ErrorCodeEnum.NO_WAIT_INTO_RETURN_CANCEL.getMessage());
+            }
+
+            //查询采购单
+            PurchaseResponse purchaseResponse = purchaseMapper.selectById(intoReturnResponse.getPurId());
+            if (purchaseResponse == null) {
+                //返回 单据所对应的原始单据不存在,请重新操作
+                return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
+            }
+            //修改采购单 已入库数量/金额
+            purchaseMapper.updateAmount(
+                    new Purchase().setReturnQty(purchaseResponse.getReturnQty().subtract(intoReturnResponse.getSumQuantity()))
+                            .setReturnAmt(purchaseResponse.getReturnAmt().subtract(intoReturnResponse.getSumAmount())).setPurId(purchaseResponse.getPurId())
+            );
+
+            //查询入库退货单明细
+            List<IntoReturnItemResponse> intoReturnItemList = intoReturnItemService.selectByCond(new IntoReturnItemQuery().setReturnId(intoReturnResponse.getReturnId())).getData().getList();
+            //明细不存在
+            if (intoReturnItemList == null || intoReturnItemList.size() == 0) {
+                //返回 采购退货明细不可为空,请重新操作
+                return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.PURCHASE_RETURN_DETAIL_NOT_EXIST.getMessage());
+            }
+
             for (IntoReturnItemResponse intoReturnItemResponse : intoReturnItemList) {
                 //查询入库单明细
                 InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(intoReturnItemResponse.getIntoItemId());
@@ -361,14 +369,24 @@ public class IntoReturnService extends BaseService<IntoReturn> {
                     return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
                 }
                 //修改入库单明细 已入库退货数量/金额
-                inboundItemService.updateByUuid(new InboundItem()
+                inboundItemMapper.updateAmount(new InboundItem()
                         .setItemId(intoReturnItemResponse.getIntoItemId())
                         .setReturnQty(inboundItemResponse.getReturnQty().subtract(intoReturnItemResponse.getItemQty()))
                         .setReturnAmt(inboundItemResponse.getReturnAmt().subtract(intoReturnItemResponse.getItemAmt()))
                 );
+                //查询入库单 修改 已入库退货数量/金额
+                InboundResponse inboundResponse = inboundMapper.selectById(intoReturnItemResponse.getIntoId());
+                if (inboundResponse == null) {
+                    //返回 单据所对应的原始单据不存在,请重新操作
+                    return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
+                }
+                inboundMapper.updateAmount(new Inbound().setIntoId(inboundResponse.getIntoId())
+                        .setReturnQty(inboundResponse.getReturnQty().subtract(intoReturnItemResponse.getItemQty()))
+                        .setReturnAmt(inboundResponse.getReturnAmt().subtract(intoReturnItemResponse.getItemAmt())));
+
                 //查询采购单明细
-                PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(intoReturnItemResponse.getPurId());
-                if (purchaseItemResponse == null ) {
+                PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(intoReturnItemResponse.getPurItemId());
+                if (purchaseItemResponse == null) {
                     //返回 单据所对应的原始单据不存在,请重新操作
                     return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
                 }
@@ -381,7 +399,21 @@ public class IntoReturnService extends BaseService<IntoReturn> {
 
                 );
             }
-            //TODO 未处理出库单
+
+            //修改 负向入库单 状态
+            inboundMapper.updateIntoStatus(new Inbound()
+                    .setIntoId(intoReturnResponse.getIntoId())
+                    .setIntoStatus(Constant.IntoStatus.ZUOFEI.getName()));
+
+            //修改 负向入库单明细 状态
+
+            List<InboundItemResponse> inboundItemResponses = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(intoReturnResponse.getIntoId()));
+            if (inboundItemResponses != null && inboundItemResponses.size() > 0) {
+                for (InboundItemResponse inboundItemRespons : inboundItemResponses) {
+                    inboundItemMapper.updateIntoStatus(new InboundItem().setItemId(inboundItemRespons.getItemId()).setIntoStatus(Constant.IntoStatus.ZUOFEI.getName()));
+                }
+            }
+
 
             //修改入库退货单明细
             super.updateByUuid(
@@ -390,17 +422,16 @@ public class IntoReturnService extends BaseService<IntoReturn> {
                             //修改退货状态 作废
                             .setReturnStatus(Constant.returnStatus.OUT_REJECT_STATUS_RIGHTING_NOT.getName())
             );
-
         }
-        return ResponseResultUtil.success();
-    }
 
 
+        return ResponseResultUtil.success();
+    }
 
 
     /**
-     * @desc   : 获取单据信息(编辑用)
-     * @date   : 2024/3/16 16:28
+     * @desc : 获取单据信息(编辑用)
+     * @date : 2024/3/16 16:28
      * @author : 于继渤
      */
     public ResponseResultVO<?> selectByUpdate(String id) {
@@ -408,7 +439,7 @@ public class IntoReturnService extends BaseService<IntoReturn> {
         //总单
         IntoReturnResponse intoReturnResponse = intoReturnMapper.selectByIntoReturnQuery(new IntoReturnQuery().setReturnId(id));
         //单据不存在
-        if(intoReturnResponse==null){
+        if (intoReturnResponse == null) {
             return ResponseResultUtil.error(ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getCode(),
                     ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
         }
@@ -418,4 +449,131 @@ public class IntoReturnService extends BaseService<IntoReturn> {
         dataInfo.put("dataItem", intoReturnItemResponses);
         return ResponseResultUtil.success(dataInfo);
     }
+
+    /**
+     * @desc :出库中 编辑
+     * @date : 2024/3/16 16:28
+     * @author : 于继渤
+     */
+    @Transactional(
+            rollbackFor = {Exception.class}
+    )
+    public ResponseResultVO<?> update(IntoReturnVO intoReturnVO) {
+        //校验单据
+        if (intoReturnVO.getReturnId() == null) {
+            return ResponseResultUtil.error(ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getCode(),
+                    ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
+        }
+//        //非出库中单据不能编辑
+//        if (intoReturnVO.getOutStatus().equals(Constant.OutStatus.YICHUKU.getName())) {
+//            return ResponseResultUtil.error(ErrorCodeEnum.NO_WAIT_INTO_RETURN.getCode(),
+//                    ErrorCodeEnum.NO_WAIT_INTO_RETURN.getMessage());
+//        }
+        IntoReturn intoReturn = intoReturnConvert.convertToPo(intoReturnVO);
+//        //查询原始退货总单
+//        IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(intoReturnVO.getReturnId());
+//        //负数转正数
+//        intoReturnVO.setSumQuantity(intoReturnVO.getSumQuantity().abs());
+//        intoReturnVO.setSumAmount(intoReturnVO.getSumAmount().abs());
+//        //查询采购订单
+//        PurchaseResponse purchaseResponse = purchaseMapper.selectById(intoReturnVO.getPurId());
+//        //采购订单原始退货数量 - 原始退货单退货数量
+//        BigDecimal purchaseReturnQty = purchaseResponse.getReturnQty().subtract(intoReturnResponse.getSumQuantity());
+//        BigDecimal purchaseReturnAmt = purchaseResponse.getReturnAmt().subtract(intoReturnResponse.getSumAmount());
+//        //反写采购订单已入库退货数量、金额
+//        purchaseMapper.updateAmount(new Purchase().setPurId(intoReturnVO.getPurId())
+//                .setReturnQty(purchaseReturnQty.add(intoReturnVO.getSumQuantity()))
+//                .setReturnAmt(purchaseReturnAmt.add(intoReturnVO.getSumAmount()))
+//        );
+//        //校验明细
+//        if (intoReturnVO.getIntoReturnItemVOList() != null && intoReturnVO.getIntoReturnItemVOList().size() > 0) {
+//
+//            for (IntoReturnItemVO intoReturnItemVO : intoReturnVO.getIntoReturnItemVOList()) {
+//                //负数转正数
+//                intoReturnItemVO.setPriceReturn(intoReturnItemVO.getPriceReturn().abs());
+//                intoReturnItemVO.setItemQty(intoReturnItemVO.getItemQty().abs());
+//                intoReturnItemVO.setItemAmt(intoReturnItemVO.getItemAmt().abs());
+//                //查询原始采购退货明细
+//                IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(intoReturnItemVO.getItemId());
+//                //查询采购订单明细数据
+//                PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(intoReturnItemVO.getPurItemId());
+//                BigDecimal purchaseItemReturnQty = purchaseItemResponse.getReturnQty().subtract(intoReturnItemResponse.getItemQty());
+//                BigDecimal purchaseItemReturnAmt = purchaseItemResponse.getReturnAmt().subtract(intoReturnItemResponse.getItemAmt());
+//                //反写采购订单明细退货数量和退货金额
+//                purchaseItemMapper.updateAmount(
+//                        new PurchaseItem()
+//                                .setItemId(intoReturnItemVO.getPurItemId())
+//                                .setReturnQty(purchaseItemReturnQty.add(intoReturnItemVO.getItemQty().setScale(6, BigDecimal.ROUND_HALF_UP)))
+//                                .setReturnAmt(purchaseItemReturnAmt.add(intoReturnItemVO.getItemAmt().setScale(6, BigDecimal.ROUND_HALF_UP)))
+//
+//                );
+//                //根据退货明细中入库明细id查询入库明细数据
+//                InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(intoReturnItemVO.getIntoItemId());
+//                BigDecimal inboundItemReturnQty = inboundItemResponse.getReturnQty().subtract(intoReturnItemResponse.getItemQty());
+//                BigDecimal inboundItemReturnAmt = inboundItemResponse.getReturnAmt().subtract(intoReturnItemResponse.getItemAmt());
+//
+//
+//                BigDecimal ReturnQty = inboundItemReturnQty.add(intoReturnItemVO.getItemQty().setScale(6, BigDecimal.ROUND_HALF_UP));
+//                BigDecimal ReturnAm = inboundItemReturnAmt.add(intoReturnItemVO.getItemAmt().setScale(6, BigDecimal.ROUND_HALF_UP));
+//                //反写原始入库单明细 不是负向的入库单
+//                inboundItemMapper.updateAmount(
+//                        new InboundItem()
+//                                .setItemId(inboundItemResponse.getItemId())
+//                                .setReturnQty(ReturnQty)
+//                                .setReturnAmt(ReturnAm)
+//                );
+//                //反写原始入库单
+//                InboundResponse inboundResponse = inboundMapper.selectById(intoReturnItemVO.getIntoId());
+//                BigDecimal inboundReturnQty = inboundResponse.getReturnQty().subtract(intoReturnItemResponse.getItemQty());
+//                BigDecimal inboundReturnAmt = inboundResponse.getReturnAmt().subtract(intoReturnItemResponse.getItemAmt());
+//                inboundMapper.updateAmount(new Inbound().setIntoId(intoReturnItemVO.getIntoId())
+//                        .setReturnQty(inboundReturnQty.add(intoReturnItemVO.getItemQty()))
+//                        .setReturnAmt(inboundReturnAmt.add(intoReturnItemVO.getItemAmt())));
+//                IntoReturnItem intoReturnItem = intoReturnItemConvert.convertToPo(intoReturnItemVO);
+//                //新建编辑操作
+//                if (intoReturnItemVO.getItemId() != null) {
+//                    //编辑明细
+//                    intoReturnItemMapper.updateById(intoReturnItem);
+//                } else {
+//                    Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.PURCHASEOUT.getName(), false);
+//                    intoReturnItemResponse.setItemId(codeMap.get("outId").toString());
+//                    intoReturnItemMapper.insert(intoReturnItem);
+//                }
+//            }
+//        }
+        intoReturnMapper.updateByUuId(intoReturn);
+//        //生成逆向  负数的 入库单
+//        InboundVO inboundVO = new InboundVO();
+//        //自动标识
+//        inboundVO.setAutomaticFlg(intoReturnVO.getAutomaticFlg());
+//        inboundVO.setFromId(intoReturnVO.getReturnId());
+//        inboundVO.setFromNo(intoReturnVO.getReturnNo());
+//        inboundVO.setStaffId(intoReturnVO.getStaffId());
+//        inboundVO.setOrgId(intoReturnVO.getOrgId());
+//        inboundVO.setMakeStaff(authUtils.getStaff().getStaffId());
+//        inboundVO.setMakeTime(LocalDateTime.now());
+//        inboundVO.setIntoingQty(intoReturnVO.getSumQuantity().multiply(new BigDecimal(-1)));
+//        inboundVO.setIntoingAmt(intoReturnVO.getSumAmount().multiply(new BigDecimal(-1)));
+//        List<InboundItemVO> list = new ArrayList<>();
+//        for (IntoReturnItemVO intoReturnItemVO : intoReturnVO.getIntoReturnItemVOList()) {
+//            //删除原始负数入库单
+//            if (intoReturnItemVO.getFromItemId() != null) {
+//                inboundItemMapper.deleteByFromId(new InboundItem().setFromItemId(intoReturnItemVO.getItemId()));
+//            }
+//            InboundItemVO inboundItemVO = new InboundItemVO();
+//            inboundItemVO.setIntoingQty(intoReturnItemVO.getItemQty().multiply(new BigDecimal(-1)));
+//            inboundItemVO.setIntoingAmt(intoReturnItemVO.getItemAmt().multiply(new BigDecimal(-1)));
+//            inboundItemVO.setPriceInto(intoReturnItemVO.getPriceReturn());
+//            inboundItemVO.setFromItemId(intoReturnItemVO.getItemId());
+//            inboundItemVO.setSkuId(intoReturnItemVO.getSkuId());
+//            inboundItemVO.setItemIndex(intoReturnItemVO.getItemIndex());
+//            inboundItemVO.setNonStdCode(intoReturnItemVO.getNonStdCode());
+//            inboundItemVO.setReturnQty(intoReturnItemVO.getItemQty());
+//            inboundItemVO.setReturnAmt(intoReturnItemVO.getItemAmt());
+//            list.add(inboundItemVO);
+//        }
+//        inboundVO.setItemList(list);
+//        inboundPurchaseReturnService.purchaseReturnInboundInsert(inboundVO);
+        return ResponseResultUtil.success();
+    }
 }

+ 24 - 2
src/main/java/com/dk/mdm/service/mac/AccountService.java

@@ -60,19 +60,41 @@ public class AccountService extends BaseService<Account> {
     public ResponseResultVO selectById(String id) {
         //根据id查询
         AccountResponse accountResponse = accountMapper.selectById(id);
-        List<AccountItemResponse> accountItemResponses = accountItemMapper.selectByCond(new AccountItemQuery().setObjectId(id));
+        List<AccountItemResponse> accountItemResponses = accountItemMapper.getReceivableAccountItem(new AccountItemQuery().setObjectId(id));
         accountResponse.setList(accountItemResponses);
         return ResponseResultUtil.success(accountResponse);
     }
 
     /**
+     * @desc : 只查询总单, 不包含总单加明细
+     * @author : 姜永辉
+     * @date : 2024/3/6 10:36
+     */
+    public ResponseResultVO selectAccountById(String id) {
+        //根据id查询
+        AccountResponse accountResponse = accountMapper.selectById(id);
+        return ResponseResultUtil.success(accountResponse);
+    }
+
+    /**
+     * @desc : 查询明细的总数量
+     * @author : 姜永辉
+     * @date : 2024/3/6 10:36
+     */
+    public ResponseResultVO countByCond(AccountItemQuery accountItemQuery) {
+        //根据id查询
+        Long aLong = accountItemMapper.countByCond(accountItemQuery);
+        return ResponseResultUtil.success(aLong);
+    }
+
+    /**
      * @desc : 查询应收账款明细
      * @author : 付斌
      * @date : 2024-02-28 13:25
      */
     @Pagination
     public ResponseResultVO<?> getReceivableAccountItem(AccountItemQuery accountItemQuery) {
-        List<AccountItemResponse> accountItemResponse = accountItemMapper.selectByCond(accountItemQuery);
+        List<AccountItemResponse> accountItemResponse = accountItemMapper.getReceivableAccountItem(accountItemQuery);
         return ResponseResultUtil.success(accountItemResponse);
     }
 

+ 28 - 0
src/main/java/com/dk/mdm/service/mac/RecPayHandleItemService.java

@@ -0,0 +1,28 @@
+package com.dk.mdm.service.mac;
+
+import com.dk.mdm.model.pojo.mac.RecPayHandleItem;
+import com.dk.mdm.mapper.mac.RecPayHandleItemMapper;
+import com.dk.common.service.BaseService;
+import com.dk.common.mapper.BaseMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional
+public class RecPayHandleItemService extends BaseService<RecPayHandleItem> {
+
+	@Override
+	public String getPrimaryKey() {
+		return "item_id";
+	}
+
+	@Override
+	public BaseMapper<RecPayHandleItem> getRepository() {
+		return recPayHandleItemMapper;
+	}
+
+	@Autowired
+	private RecPayHandleItemMapper recPayHandleItemMapper;
+
+}

+ 78 - 3
src/main/java/com/dk/mdm/service/mac/RecPayService.java

@@ -120,7 +120,7 @@ public class RecPayService extends BaseService<RecPay> {
     }
 
     /**
-     * @desc : 新建收款
+     * @desc : 新建客户收款
      * @author : 付斌
      * @date : 2023/1/9 10:49
      */
@@ -195,7 +195,7 @@ public class RecPayService extends BaseService<RecPay> {
     }
 
     /**
-     * @desc : 新建退款
+     * @desc :  新建客户退款
      * @author : 付斌
      * @date : 2023/1/9 10:49
      */
@@ -271,7 +271,7 @@ public class RecPayService extends BaseService<RecPay> {
     }
 
     /**
-     * @desc : 编辑方法
+     * @desc : 编辑客户收款/退款
      * @author : 付斌
      * @date : 2023/1/9 10:49
      */
@@ -356,4 +356,79 @@ public class RecPayService extends BaseService<RecPay> {
 
         return ResponseResultUtil.success(dataInfo);
     }
+
+    /**
+     * @desc : 新建应收收款(收款+冲应收)
+     * @author : 付斌
+     * @date : 2023/1/9 10:49
+     */
+    @Transactional(
+            rollbackFor = {Exception.class}
+    )
+    public ResponseResultVO<?> insertReceivableReceipt(RecPayVO recPayVO) {
+
+        // 获取单号
+        Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.RECPAY.getName(), false);
+        recPayVO.setRpId(codeMap.get("outId").toString()).setRpNo(codeMap.get("outNote").toString());
+        // 转化实体
+        RecPay recPay = recPayConvert.convertToPo(recPayVO);
+        // 总单保存
+        super.insert(recPay);
+
+        // 明细保存
+        if (recPayVO.getItemList() != null && recPayVO.getItemList().size() > 0) {
+            for (RecPayItemVO recPayItemVO : recPayVO.getItemList()) {
+                RecPayItem recPayItem = recPayItemConvert.convertToPo(recPayItemVO);
+                recPayItem.setRpId(recPay.getRpId()).setCpId(recPay.getCpId()).setMakeStaff(recPay.getMakeStaff()).setAccDate(recPay.getAccDate());
+                recPayItemMapper.insert(recPayItem);
+
+                // 插入账款明细
+                AccountItem accountItem = new AccountItem();
+                accountItem.setAccItemType(Constant.accItemType.SHOU_KUAN.getName())
+                        .setObjectId(recPayVO.getObjectId()).setOrgId(recPayVO.getOrgId()).setStaffId(recPayVO.getStaffId())
+                        .setAccDate(recPayVO.getAccDate()).setRecStatus(Constant.recStatuse.QUE_DING.getName()).setAmtRec(recPayItem.getAmtRec())
+                        .setBiznisType("t_mac_rec_pay_item").setBiznisId(recPayItem.getItemId()).setBiznisNo(recPayVO.getRpNo())
+                        .setMakeStaff(recPayVO.getMakeStaff()).setCpId(recPayVO.getCpId());
+                accountItemMapper.insert(accountItem);
+
+                // 更新收款单上的账款明细Id
+                RecPayItem recPayItemUpdate = new RecPayItem();
+                recPayItemUpdate.setAccItemId(accountItem.getItemId()).setRpId(recPayVO.getRpId());
+                recPayItemService.updateByUuid(recPayItemUpdate);
+
+                // 插入资金流水
+                MoneyAccountItem moneyAccountItem = new MoneyAccountItem();
+                moneyAccountItem.setMacId(recPayItem.getMacId()).setFlowType(Constant.FlowType.SHOU_FU_KUAN.getName())
+                        .setInvoiceId(recPayItem.getItemId()).setAmtInflow(recPayItem.getAmtRec()).setAccDate(recPayVO.getAccDate())
+                        .setMakeStaff(recPayItem.getMakeStaff()).setCpId(recPayItem.getCpId());
+                moneyAccountItemMapper.insert(moneyAccountItem);
+
+                // 更新资金账户
+                MoneyAccount moneyAccountForUpdate = moneyAccountMapper.selectByIdForUpdate(recPayItem.getMacId());
+                MoneyAccount moneyAccountUpdate = new MoneyAccount();
+                moneyAccountUpdate.setBalance(moneyAccountForUpdate.getBalance().add(recPayItem.getAmtRec()))
+                        .setMacId(moneyAccountForUpdate.getMacId());
+                moneyAccountService.updateByUuid(moneyAccountUpdate);
+            }
+        }
+
+        // 插入账款总表
+        Account accountForUpdate = accountMapper.selectByIdForUpdate(recPayVO.getObjectId());
+
+        // 没有账款对象,需要新建
+        if (accountForUpdate == null) {
+            accountForUpdate = new Account();
+            accountForUpdate.setObjectId(recPayVO.getObjectId()).setObjectType(Constant.ObjectType.CUS.getName());
+            accountMapper.insert(accountForUpdate);
+            accountForUpdate = accountMapper.selectByIdForUpdate(recPayVO.getObjectId());
+        }
+
+        // 更新账款总表上收款的相关字段
+        Account accountUpdate = new Account();
+        accountUpdate.setReceipt(accountForUpdate.getReceipt().add(recPayVO.getSumAmtRec()))// 总收款金额
+                .setReceiptResidue(accountForUpdate.getReceiptResidue().add(recPayVO.getSumAmtRec()))//  可退金额
+                .setObjectId(accountForUpdate.getObjectId());
+        accountService.updateByUuid(accountUpdate);
+        return ResponseResultUtil.success();
+    }
 }