提交 d1852e60 authored 作者: huyufan's avatar huyufan

确认收货处理相关借款逻辑

上级 eaaf2315
...@@ -2,6 +2,7 @@ package com.clx.performance.component; ...@@ -2,6 +2,7 @@ package com.clx.performance.component;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.clx.order.feign.OrderFeign; import com.clx.order.feign.OrderFeign;
import com.clx.order.vo.feign.FeignOrderInfoVO; import com.clx.order.vo.feign.FeignOrderInfoVO;
import com.clx.order.vo.pc.owner.OwnerQuotationDetailVO; import com.clx.order.vo.pc.owner.OwnerQuotationDetailVO;
...@@ -154,14 +155,20 @@ public class OrderChildLoanComponent { ...@@ -154,14 +155,20 @@ public class OrderChildLoanComponent {
} }
public void orderConfirmAfterProcess(SettlementDriverDetail settlementDriverDetail, SettlementOwnerDetail settlementOwnerDetail) { /**
* 运单确认人借款相关处理执行
* @param settlementDriverDetail
* @param settlementOwnerDetail
*/
public void childLoanConfirmAfterProcess(SettlementDriverDetail settlementDriverDetail, SettlementOwnerDetail settlementOwnerDetail) {
log.info("1.运单确认收货后借款相关处理执行");
if (SettlementOwnerEnum.InvoiceType.ORDINARY.getCode().equals(settlementDriverDetail.getInvoiceType())) { if (SettlementOwnerEnum.InvoiceType.ORDINARY.getCode().equals(settlementDriverDetail.getInvoiceType())) {
log.info("当前不是网运单,不需要处理借款标识"); log.info("2.当前不是网运单,不需要处理借款标识");
return; return;
} }
if (settlementOwnerDetail.getPrepayFreight().compareTo(BigDecimal.ZERO) != 0) { if (settlementOwnerDetail.getPrepayFreight().compareTo(BigDecimal.ZERO) != 0) {
log.info("当前是网运单,但预付运费不为0"); log.info("3.当前是网运单,但预付运费不为0,说明已经处理");
return; return;
} }
...@@ -171,8 +178,17 @@ public class OrderChildLoanComponent { ...@@ -171,8 +178,17 @@ public class OrderChildLoanComponent {
settlementDriverDetail.setLoanFlag(1); settlementDriverDetail.setLoanFlag(1);
settlementOwnerDetail.setLoanFreight(settlementOwnerDetail.getSettlementFreight()); settlementOwnerDetail.setLoanFreight(settlementOwnerDetail.getSettlementFreight());
log.info("4.查询当前运单号:{}, 当前货主,{}, 此运单借款冻结记录:{}", childNo, settlementOwnerDetail.getOwnerUserNo(), JSONUtil.parse(runningWaterRecordList));
if (CollectionUtil.isEmpty(runningWaterRecordList)) { if (CollectionUtil.isEmpty(runningWaterRecordList)) {
//说明当初没借款,预付运费够,但是真实结算后,预付运费不够,走此逻辑 //说明当初没借款,预付运费够,但是真实结算后,预付运费不够,走此逻辑
try {
ownerLoanRecordService.getLoanBalance(settlementOwnerDetail.getSettlementFreight(), settlementDriverDetail.getDriverUserNo(), childNo);
} catch (Exception e) {
//TODO 钱不够需要流程卡死
}
runningWaterRecordList = ownerLoanAccountRunningWaterRecordDao.getListByOrderNoAndRunningWaterType
(childNo, OwnerLoanAccountRunningWaterRecordEnum.RunWaterType.APPROVE_FROZEN.getCode());
childWriteOffOwnerLoanAccount(runningWaterRecordList);
} else { } else {
BigDecimal alterationBalance = runningWaterRecordList.stream().map(OwnerLoanAccountRunningWaterRecord::getAlterationBalance).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal alterationBalance = runningWaterRecordList.stream().map(OwnerLoanAccountRunningWaterRecord::getAlterationBalance).reduce(BigDecimal.ZERO, BigDecimal::add);
...@@ -196,7 +212,7 @@ public class OrderChildLoanComponent { ...@@ -196,7 +212,7 @@ public class OrderChildLoanComponent {
try { try {
ownerLoanRecordService.getLoanBalance(subtract.negate(), settlementDriverDetail.getDriverUserNo(), childNo); ownerLoanRecordService.getLoanBalance(subtract.negate(), settlementDriverDetail.getDriverUserNo(), childNo);
} catch (Exception e) { } catch (Exception e) {
//TODO 钱不够 //TODO 钱不够需要流程卡死
} }
runningWaterRecordList = ownerLoanAccountRunningWaterRecordDao.getListByOrderNoAndRunningWaterType runningWaterRecordList = ownerLoanAccountRunningWaterRecordDao.getListByOrderNoAndRunningWaterType
(childNo, OwnerLoanAccountRunningWaterRecordEnum.RunWaterType.APPROVE_FROZEN.getCode()); (childNo, OwnerLoanAccountRunningWaterRecordEnum.RunWaterType.APPROVE_FROZEN.getCode());
......
...@@ -30,7 +30,6 @@ import lombok.AllArgsConstructor; ...@@ -30,7 +30,6 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
...@@ -179,7 +178,7 @@ public class OrderChildSyncTransportListener { ...@@ -179,7 +178,7 @@ public class OrderChildSyncTransportListener {
settlementOwnerDetail.setInvoiceType(invoiceType); settlementOwnerDetail.setInvoiceType(invoiceType);
settlementDriverDetail.setInvoiceType(invoiceType); settlementDriverDetail.setInvoiceType(invoiceType);
//生成借款标识 //生成借款标识
orderChildLoanComponent.orderConfirmAfterProcess(settlementDriverDetail, settlementOwnerDetail); orderChildLoanComponent.childLoanConfirmAfterProcess(settlementDriverDetail, settlementOwnerDetail);
log.info("当前货主结算信息{},车主结算信息:{}", JSONUtil.parse(settlementOwnerDetail), JSONUtil.parse(settlementDriverDetail)); log.info("当前货主结算信息{},车主结算信息:{}", JSONUtil.parse(settlementOwnerDetail), JSONUtil.parse(settlementDriverDetail));
settlementOwnerDetailDao.updateInvoiceType(settlementOwnerDetail); settlementOwnerDetailDao.updateInvoiceType(settlementOwnerDetail);
......
...@@ -330,21 +330,22 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService { ...@@ -330,21 +330,22 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void getLoanBalance(BigDecimal orderChildPrice, Long userNo, String childNo) { public void getLoanBalance(BigDecimal orderChildPrice, Long userNo, String childNo) {
log.info("执行借款,借款金额{}, 货主编号:{}, 运单号:{}", orderChildPrice, userNo, childNo);
//TODO 需要加锁处理 //TODO 需要加锁处理
List<OwnerLoanRecord> updateList = new LinkedList<>(); List<OwnerLoanRecord> updateList = new LinkedList<>();
List<OwnerLoanRecord> ownerLoanRecords = ownerLoanRecordDao.selectLoanBalance(userNo); List<OwnerLoanRecord> ownerLoanRecords = ownerLoanRecordDao.selectLoanBalance(userNo);
BigDecimal orderChildPriceTemp = orderChildPrice; BigDecimal orderChildPriceTemp = orderChildPrice;
for (OwnerLoanRecord ownerLoanRecord : ownerLoanRecords) { for (OwnerLoanRecord ownerLoanRecord : ownerLoanRecords) {
BigDecimal loanResidueBalance = ownerLoanRecord.getLoanResidueBalance(); BigDecimal loanResidueBalance = ownerLoanRecord.getLoanResidueBalance();
log.info("12.当前预估运费金额:{},借款单号{},借款剩余金额{}", orderChildPriceTemp, ownerLoanRecord.getLoanNo(), loanResidueBalance); log.info("当前借款金额:{},借款单号{},借款剩余金额{}", orderChildPriceTemp, ownerLoanRecord.getLoanNo(), loanResidueBalance);
if (loanResidueBalance.compareTo(orderChildPriceTemp) >= 0) { if (loanResidueBalance.compareTo(orderChildPriceTemp) >= 0) {
log.info("当前借款单的剩余金额足够预估运费金额"); log.info("当前借款单的剩余金额足够借款金额");
generateFrozenOwnerLoanRunningWater(ownerLoanRecord, childNo, orderChildPrice); generateFrozenOwnerLoanRunningWater(ownerLoanRecord, childNo, orderChildPrice);
updateList.add(ownerLoanRecord.setLoanResidueBalance(loanResidueBalance.subtract(orderChildPriceTemp))); updateList.add(ownerLoanRecord.setLoanResidueBalance(loanResidueBalance.subtract(orderChildPriceTemp)));
orderChildPriceTemp = BigDecimal.ZERO; orderChildPriceTemp = BigDecimal.ZERO;
break; break;
} else { } else {
log.info("当前借款单的剩余金额不够抵扣预估运费金额,先进行扣除当前借款所有剩余"); log.info("当前借款单的剩余金额不够抵扣借款金额,先进行扣除当前借款所有剩余");
generateFrozenOwnerLoanRunningWater(ownerLoanRecord, childNo, orderChildPrice); generateFrozenOwnerLoanRunningWater(ownerLoanRecord, childNo, orderChildPrice);
updateList.add(ownerLoanRecord.setLoanResidueBalance(BigDecimal.ZERO)); updateList.add(ownerLoanRecord.setLoanResidueBalance(BigDecimal.ZERO));
orderChildPriceTemp = orderChildPriceTemp.subtract(loanResidueBalance); orderChildPriceTemp = orderChildPriceTemp.subtract(loanResidueBalance);
...@@ -358,6 +359,8 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService { ...@@ -358,6 +359,8 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService {
for (OwnerLoanRecord update : updateList) { for (OwnerLoanRecord update : updateList) {
ownerLoanRecordDao.updateEntityByKey(update); ownerLoanRecordDao.updateEntityByKey(update);
} }
log.info("执行借款成功,借款金额{}, 货主编号:{}, 运单号:{}", orderChildPrice, userNo, childNo);
} }
public void generateFrozenOwnerLoanRunningWater(OwnerLoanRecord ownerLoanRecord, String childNo, BigDecimal orderChildPrice) { public void generateFrozenOwnerLoanRunningWater(OwnerLoanRecord ownerLoanRecord, String childNo, BigDecimal orderChildPrice) {
log.info("13.生成借款冻结流水"); log.info("13.生成借款冻结流水");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论