fubin 2 лет назад
Родитель
Сommit
5c1dd77217

+ 10 - 0
src/main/java/com/dk/mdm/controller/mac/RecPayController.java

@@ -89,4 +89,14 @@ public class RecPayController{
     public ResponseResultVO<?> update(@RequestBody RecPayVO recPayVO) {
         return recPayService.update(recPayVO);
     }
+
+    /**
+     * @desc :查询收款明细(编辑用)
+     * @author : 付斌
+     * @date : 2024-02-28 13:24
+     */
+    @PostMapping({"get_rp_for_update/{id}"})
+    public ResponseResultVO<?> getRpForUpdate(@PathVariable String id) {
+        return recPayService.getRpForUpdate(id);
+    }
 }

+ 5 - 0
src/main/java/com/dk/mdm/mapper/mac/RecPayItemMapper.xml

@@ -181,4 +181,9 @@
             )
         </foreach>
     </insert>
+
+    <delete id="deleteById">
+        DELETE FROM dkic_b.t_psi_order_item
+        WHERE item_id = #{id}::UUID;
+    </delete>
 </mapper>

+ 41 - 6
src/main/java/com/dk/mdm/mapper/mac/RecPayMapper.xml

@@ -202,11 +202,12 @@
         from dkic_b.t_mac_rec_pay as t
                  left join dkic_b.t_mst_customer tmc
                            on tmc.cus_id = t.object_id and t.rp_type in ('收付款类型-收款', '收付款类型-退收款')
-                 left join sys.t_data_kind as tdk1 on t.rp_type = tdk1.kind_code
+                 left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.rp_type
                  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 dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
         <include refid="Condition"/>
+        order by t.op_create_time desc
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
@@ -223,11 +224,45 @@
     </select>
 
     <!-- 根据主键查询表t_mac_rec_pay的一行数据 -->
-    <select id="selectById" resultMap="BaseResultMap">
-        SELECT
-        <include refid="Base_Column_List"/>
-        FROM t_mac_rec_pay
-        WHERE rp_id = #{rpId}::uuid
+    <select id="selectById" resultMap="BaseResultMapResponse">
+        select t.rp_id,
+               t.rp_no,
+               t.rp_type,
+               sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "rpTypeName",
+               t.object_id,
+               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",
+               t.staff_id,
+               tms.staff_name                                    as "staffName",
+               t.sum_amt_rec,
+               t.sum_amt_pay,
+               t.sum_amt_receivable_handle,
+               t.sum_amt_payable_handle,
+               t.sum_waive_amt,
+               t.acc_date,
+               t.remarks,
+               t.annex_paths,
+               t.biznis_type,
+               t.biznis_id,
+               t.biznis_no,
+               t.flg_lock,
+               t.make_staff,
+               makestaff.staff_name                              as "makeStaffName",
+               t.make_time,
+               t.flg_valid,
+               t.cp_id
+        from dkic_b.t_mac_rec_pay as t
+                 left join dkic_b.t_mst_customer tmc
+                           on tmc.cus_id = t.object_id and t.rp_type in ('收付款类型-收款', '收付款类型-退收款')
+                 left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.rp_type
+                 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 dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
+        WHERE t.rp_id = #{id}::uuid
     </select>
 
     <!-- 根据主键锁定表t_mac_rec_pay的一行数据 -->

+ 3 - 0
src/main/java/com/dk/mdm/model/vo/mac/RecPayVO.java

@@ -287,6 +287,9 @@ public class RecPayVO extends PageInfo<RecPayVO> implements Serializable {
     @ApiModelProperty(value = "明细")
     private List<RecPayItemVO> itemList;
 
+    @ApiModelProperty(value = "删除明细")
+    private List<RecPayItemVO> deleteItemList;
+
     /*
      * 相关属性
      * @TableField(exist = false)

+ 40 - 0
src/main/java/com/dk/mdm/service/mac/RecPayService.java

@@ -36,6 +36,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.util.stream.Collectors;
 
 @Service
 @Transactional
@@ -235,7 +236,46 @@ public class RecPayService extends BaseService<RecPay> {
     )
     public ResponseResultVO<?> update(RecPayVO recPayVO) {
         RecPay recPay = recPayConvert.convertToPo(recPayVO);
+
+        //删除的
+        List<RecPayItemVO> deleteRecPayItemVOList = recPayVO.getDeleteItemList().stream().filter(it -> it.getItemId() != null).collect(Collectors.toList());
+        if (deleteRecPayItemVOList.size() > 0) {
+            for (RecPayItemVO recPayItemVO : deleteRecPayItemVOList) {
+                recPayItemMapper.deleteById(recPayItemVO.getItemId());
+            }
+        }
+        // 新增的
+        List<RecPayItemVO> insertRecPayItemVOList = recPayVO.getItemList().stream().filter(it -> it.getItemId() == null).collect(Collectors.toList());
+        for (RecPayItemVO recPayItemVO : insertRecPayItemVOList) {
+            RecPayItem recPayItem = recPayItemConvert.convertToPo(recPayItemVO);
+            recPayItem.setRpId(recPay.getRpId()).setCpId(recPay.getCpId());
+            recPayItemMapper.insert(recPayItem);
+        }
+        // 编辑的
+        List<RecPayItemVO> editRecPayItemVOList = recPayVO.getItemList().stream().filter(it -> it.getItemId() != null).collect(Collectors.toList());
+        for (RecPayItemVO recPayItemVO : editRecPayItemVOList) {
+            RecPayItem recPayItem = recPayItemConvert.convertToPo(recPayItemVO);
+            recPayItemService.updateByUuid(recPayItem);
+        }
+        
         return ResponseResultUtil.success(super.update(recPay, new UpdateWrapper<RecPay>().lambda().eq(RecPay::getRpId,
                 UUID.fromString(recPay.getRpId()))));
     }
+
+    /**
+     * @desc : 获取订单信息(编辑用)
+     * @author : 付斌
+     * @date : 2024-03-02 17:27
+     */
+    public ResponseResultVO<?> getRpForUpdate(String id) {
+        Map<String, Object> dataInfo = new HashMap<>();
+        RecPayResponse recPayResponse = recPayMapper.selectById(id);
+        dataInfo.put("data", recPayResponse);
+
+        // 收款明细
+        List<RecPayItemResponse> recPayItemResponse = recPayItemMapper.selectByCond(new RecPayItemQuery().setRpId(id));
+        dataInfo.put("dataItem", recPayItemResponse);
+
+        return ResponseResultUtil.success(dataInfo);
+    }
 }

+ 2 - 2
src/main/java/com/dk/mdm/service/sale/OrderService.java

@@ -312,8 +312,8 @@ public class OrderService extends BaseService<Order> {
         dataInfo.put("data", orderResponse);
 
         // 商品明细
-        List<OrderItemResponse> orderItem = orderItemMapper.selectByCond(new OrderItemQuery().setOrderId(id));
-        dataInfo.put("dataItem", orderItem);
+        List<OrderItemResponse> orderItemResponse = orderItemMapper.selectByCond(new OrderItemQuery().setOrderId(id));
+        dataInfo.put("dataItem", orderItemResponse);
         return ResponseResultUtil.success(dataInfo);
     }