提交 6ab20a44 authored 作者: huyufan's avatar huyufan

借款相关

上级 028e94b5
......@@ -28,11 +28,7 @@ import com.clx.performance.model.loan.OwnerLoanAccountRunningWaterRecord;
import com.clx.performance.model.loan.OwnerRepayment;
import com.clx.performance.model.settle.SettlementDriverDetail;
import com.clx.performance.model.settle.SettlementOwnerDetail;
import com.clx.performance.param.app.OrderChildSaveParam;
import com.clx.performance.service.OrderChildService;
import com.clx.performance.service.loan.OwnerLoanRecordService;
import com.clx.performance.utils.spring.ApplicationContextUtils;
import com.clx.performance.vo.app.SaveOrderChildVO;
import com.clx.user.vo.feign.OwnerInfoFeignVO;
import com.msl.common.base.Optional;
import com.msl.common.exception.ServiceSystemException;
......@@ -48,10 +44,6 @@ import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@Component
@AllArgsConstructor
......@@ -163,20 +155,16 @@ public class OrderChildLoanComponent {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_SAVE_FAIL, "货主已欠款");
}
//TODO 加锁
//查询审批通过并且未用完的借款
LoanBalanceDTO param = new LoanBalanceDTO();
param.setOrderChildPrice(orderChildPrice);
param.setOwnerUserNo(ownerLoanAccount.getOwnerUserNo());
param.setChildNo(childNo);
getLoanBalanceLock(param);
}
/**
* 运单确认借款相关处理执行
* 运单确认借款相关处理执行
*
* @param settlementDriverDetail
* @param settlementOwnerDetail
......@@ -210,7 +198,7 @@ public class OrderChildLoanComponent {
param.setChildNo(childNo);
param.setSettlementDriverDetail(settlementDriverDetail);
param.setSettlementOwnerDetail(settlementOwnerDetail);
//TODO 钱不够需要流程卡死
//扣钱,获取锁,此处有可能钱不够,抛异常,走网络货运重试
getLoanBalanceLock(param);
runningWaterRecordList = ownerLoanAccountRunningWaterRecordDao.getListByOrderNoAndRunningWaterType
......@@ -249,7 +237,7 @@ public class OrderChildLoanComponent {
param.setChildNo(childNo);
param.setSettlementDriverDetail(settlementDriverDetail);
param.setSettlementOwnerDetail(settlementOwnerDetail);
//TODO 钱不够需要流程卡死
//扣钱,获取锁,此处有可能钱不够,抛异常,走网络货运重试
getLoanBalanceLock(param);
runningWaterRecordList = ownerLoanAccountRunningWaterRecordDao.getListByOrderNoAndRunningWaterType
......
......@@ -18,9 +18,11 @@ import org.apache.ibatis.annotations.Update;
*/
public interface OwnerLoanAccountMapper extends BaseMapper<OwnerLoanAccount> {
@Update("update owner_loan_account set funding_amount = funding_amount + #{account.fundingAmount}"
+ ",virtually_amount = virtually_amount + #{account.virtuallyAmount}"
+ ",modified_time= #{now}"
@Update("update owner_loan_account set funding_account_balance = funding_account_balance + #{account.fundingAccountBalance}" +
",funding_usable_balance = funding_usable_balance + #{account.fundingUsableBalance},funding_frozen_balance = funding_frozen_balance + #{account.fundingFrozenBalance}" +
",virtually_account_balance = virtually_account_balance + #{account.virtuallyAccountBalance},virtually_usable_balance = virtually_usable_balance + #{account.virtuallyUsableBalance}" +
",virtually_frozen_balance = virtually_frozen_balance + #{account.virtuallyFrozenBalance}" +
",modified_time=#{now}"
+ "where id = #{account.id} and modified_time = #{account.modifiedTime}"
)
Integer addAccount(@Param("account") OwnerLoanAccount account, @Param("now") String nowStr);
......
......@@ -152,7 +152,7 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService {
ownerLoanRecord.setLoanType(param.getLoanType());
if (OwnerLoanRecordEnum.LoanType.FUND.getCode().equals(param.getLoanType())) {
//资金 TODO 调宁波银企直连的产品,从诚联信账户中给鑫祥和执行转账
//资金
BankTrade bankTrade = new BankTrade();
if (OwnerLoanRecordEnum.PayChannel.ORDER_DIRECT_PAY.getCode().equals(param.getPayChannel())) {
// 订单支付
......@@ -192,23 +192,26 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService {
} else {
// 虚拟币 直接增加 更改状态审批通过
ownerLoanRecord.setStatus(OwnerLoanRecordEnum.Status.APPROVE_PASS.getCode());
}
while (true) {
OwnerLoanAccount ownerLoanAccount = ownerLoanAccountDao.getOneByField(OwnerLoanAccount::getOwnerUserNo,
ownerLoanRecord.getOwnerUserNo()).get();
OwnerLoanAccount entity = new OwnerLoanAccount();
entity.setId(ownerLoanAccount.getId());
/* entity.setVirtuallyAmount(ownerLoanRecord.getLoanBalance());
entity.setFundingAmount(BigDecimal.ZERO);*/
entity.setModifiedTime(ownerLoanAccount.getModifiedTime());
Integer flag = ownerLoanAccountDao.updateAccountCAS(entity, LocalDateTime.now(), true);
if (flag == 1) {
//生成借款流水
initOwnerLoanRunningWaterRecord(ownerLoanRecord);
//生成还款记录
initOwnerRepayment(ownerLoanRecord);
break;
while (true) {
OwnerLoanAccount ownerLoanAccount = ownerLoanAccountDao.getOneByField(OwnerLoanAccount::getOwnerUserNo,
ownerLoanRecord.getOwnerUserNo()).get();
OwnerLoanAccount entity = new OwnerLoanAccount();
entity.setId(ownerLoanAccount.getId());
entity.setFundingAccountBalance(BigDecimal.ZERO);
entity.setFundingFrozenBalance(BigDecimal.ZERO);
entity.setFundingUsableBalance(BigDecimal.ZERO);
entity.setVirtuallyAccountBalance(ownerLoanRecord.getLoanBalance());
entity.setVirtuallyFrozenBalance(BigDecimal.ZERO);
entity.setVirtuallyUsableBalance(ownerLoanRecord.getLoanBalance());
entity.setModifiedTime(ownerLoanAccount.getModifiedTime());
Integer flag = ownerLoanAccountDao.updateAccountCAS(entity, LocalDateTime.now(), true);
if (flag == 1) {
//生成借款流水
initOwnerLoanRunningWaterRecord(ownerLoanRecord);
//生成还款记录
initOwnerRepayment(ownerLoanRecord);
break;
}
}
}
......
......@@ -78,7 +78,7 @@ public class NbBankServiceImpl implements NbBankService {
@Override
public NbBankOrderPayResultVO orderDirectPay(Long loanNo, Integer amount,
String payAcctOpenBankId, String payAcctNo, String payAcctNm) {
String merSeqNo = idGenerateSnowFlake.nextIdToString(3L);
String merSeqNo = String.valueOf(loanNo);
String merDtTm = LocalDateTimeUtils.formatTime();
String closeDtTm = LocalDateTimeUtils.formatTime(LocalDateTimeUtils.parseTime(merDtTm).plusDays(30));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论