|
@@ -201,21 +201,34 @@ public class WorkNodeProcessable {
|
|
|
.eq(ProductionFund::getProductionNo, productionReturn.getProductionNo())
|
|
|
.eq(ProductionFund::getProductionType, productionReturn.getProductionType())
|
|
|
.eq(ProductionFund::getOrderFundId, orderFund.getId()));
|
|
|
- FinanceFine financeFine = financeFineService.getFineByFundInfo(orderFund.getId(), productionFund != null ? productionFund.getId() : null);
|
|
|
- // 判断罚款记录是否为空,为空说明没有已确认的罚款,不新增罚款退款记录
|
|
|
+ // 罚款记录查询
|
|
|
+ LambdaUpdateWrapper<FinanceFine> fineLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ fineLambdaUpdateWrapper.eq(BaseEntity::getDeleted, false).eq(FinanceFine::getOrderFundId, orderFund.getId());
|
|
|
+ // 会有产品收款信息为空的业务(如个贷)所以判断一下
|
|
|
+ if (ObjectUtil.isNotNull(productionFund)) {
|
|
|
+ fineLambdaUpdateWrapper.eq(FinanceFine::getProductionFundId, productionFund.getId());
|
|
|
+ }
|
|
|
+ FinanceFine financeFine = financeFineService.getOne(fineLambdaUpdateWrapper);
|
|
|
+ // 判断罚款记录是否为空
|
|
|
if (ObjectUtil.isNotNull(financeFine)) {
|
|
|
- FinanceFineRefund financeFineRefund = FinanceFineRefund
|
|
|
- .builder()
|
|
|
- .fineId(financeFine.getId())
|
|
|
- .refundAmount(financeFine.getRealFineAmount())
|
|
|
- .status(NOT_RETURNED.getCode())
|
|
|
- .build();
|
|
|
- if (productionReturn.getReturnInvoice()) {
|
|
|
- financeFineRefund.setRefundReason(RETURN_PRODUCTION_INVOICE.getCode());
|
|
|
- } else {
|
|
|
- financeFineRefund.setRefundReason(RETURN_PRODUCTION.getCode());
|
|
|
+ // 判断罚款记录是否已经确认
|
|
|
+ if (financeFine.getStatus()) { // 已确认新增退款记录
|
|
|
+ FinanceFineRefund financeFineRefund = FinanceFineRefund
|
|
|
+ .builder()
|
|
|
+ .fineId(financeFine.getId())
|
|
|
+ .refundAmount(financeFine.getRealFineAmount())
|
|
|
+ .status(NOT_RETURNED.getCode())
|
|
|
+ .build();
|
|
|
+ if (productionReturn.getReturnInvoice()) {
|
|
|
+ financeFineRefund.setRefundReason(RETURN_PRODUCTION_INVOICE.getCode());
|
|
|
+ } else {
|
|
|
+ financeFineRefund.setRefundReason(RETURN_PRODUCTION.getCode());
|
|
|
+ }
|
|
|
+ financeFineRefundService.saveIfNotExists(financeFineRefund);
|
|
|
+ }else { // 未确认的罚款记录直接删除
|
|
|
+ financeFineService.delete(financeFine.getId());
|
|
|
}
|
|
|
- financeFineRefundService.saveIfNotExists(financeFineRefund);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
break;
|