|
|
@@ -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;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 查询所有订单的应收总额
|