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

Merge remote-tracking branch 'origin/dev_jzg_lipf_v20260622' into dev_jzg_lipf_v20260622

lipf 3 месяцев назад
Родитель
Сommit
22e310a5a8

+ 6 - 0
tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java

@@ -585,6 +585,12 @@ public class ReceivableController {
         return receivableService.deletePlatformSettlementById(id);
     }
 
+    @DeleteMapping("/deleteFollowSettlementById/{id}")
+    @Operation(summary = "删除跟单结算记录")
+    public HttpResult<Boolean> deleteFollowSettlementById(@PathVariable String id) {
+        return HttpResult.ok(receivableService.deleteFollowSettlementById(id) ? "删除成功":"删除失败");
+    }
+
 
     @PostMapping("exportSuperviseSettlementExcel")
     @Operation(summary = "导出应收手续费结算记录excel文件")

+ 7 - 0
tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java

@@ -432,6 +432,13 @@ public interface ReceivableService extends IService<InsPlyIncome> {
      */
     boolean deleteSettlementById(String settlementId);
 
+    /**
+     * 删除跟单结算记录
+     * @param id
+     * @return
+     */
+    boolean deleteFollowSettlementById(String id);
+
     /**
      * 查询所有订单的应收总额
      *

+ 33 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -1568,6 +1568,39 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         }
         return insPlyIncomeInvoiceSettlementMapper.deleteById(settlementId) > 0;
     }
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean deleteFollowSettlementById(String id) {
+        log.info("私有协议-结算记录-删除: id=[{}]",id);
+        InsPlyIncomeInvoiceSettlement settlement = insPlyIncomeInvoiceSettlementMapper.selectById(id);
+        if(settlement == null){
+            throw new SystemException("结算记录不存在");
+        }
+        String invoiceId = settlement.getInvoiceId();
+        if (StrUtil.isBlank(invoiceId)){
+            throw new SystemException("结算记录id不存在");
+        }
+        insPlyIncomeInvoiceMapper.update(null,
+                new LambdaUpdateWrapper<InsPlyIncomeInvoice>()
+                        .set(InsPlyIncomeInvoice::getStatus,"0").eq(InsPlyIncomeInvoice::getId,invoiceId));
+
+        // 查询中间表:使用 QueryWrapper,增加逻辑删除过滤
+        LambdaQueryWrapper<InsPlyFollowInvoiceLink> linkQueryWrapper = new LambdaQueryWrapper<>();
+        linkQueryWrapper.eq(InsPlyFollowInvoiceLink::getInvoiceId, invoiceId);
+        linkQueryWrapper.eq(InsPlyFollowInvoiceLink::getIsDelete, SETTLE_STATUS_RESET);
+        List<InsPlyFollowInvoiceLink> linkList = insPlyFollowInvoiceLinkMapper.selectList(linkQueryWrapper);
+
+        if (CollUtil.isNotEmpty(linkList)){
+            // 删除中间表
+            List<String> followLinkIds = linkList.stream().map(InsPlyFollowInvoiceLink::getId).collect(Collectors.toList());
+            insPlyFollowInvoiceLinkMapper.deleteByIds(followLinkIds);
+
+            // 删除跟单表
+            List<String> followIds = linkList.stream().map(InsPlyFollowInvoiceLink::getFollowId).collect(Collectors.toList());
+            insFeeFollowOrderMapper.deleteByIds(followIds);
+        }
+        return insPlyIncomeInvoiceSettlementMapper.deleteById(id) > 0;
+    }
 
     /**
      * 查询所有订单的应收总额