提交 17ba1b8f authored 作者: liruixin's avatar liruixin

Merge remote-tracking branch 'origin/v5.7_break_contract_reverse_20231020' into…

Merge remote-tracking branch 'origin/v5.7_break_contract_reverse_20231020' into v5.7_break_contract_reverse_20231020
......@@ -655,6 +655,8 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
String ownerName = "";
BigDecimal frozenBalance = param.getFrozenBalance();
BigDecimal ensureBalance = param.getEnsureBalance();
boolean ensureBalanceZeroFlag = false;
boolean frozenBalanceZeroFlag = false;
Integer orderId = param.getOrderId();
String orderNo = param.getOrderNo();
LocalDateTime now = LocalDateTime.now();
......@@ -677,6 +679,10 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
if (ownerAccount.getUsableBalance().compareTo(ensureBalance) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货主保证金账户可用余额不够冻结");
}
if (ensureBalance.compareTo(BigDecimal.ZERO) == 0) {
flag += 1;
ensureBalanceZeroFlag = true;
} else {
//冻结金额
entity.setFrozenBalance(ensureBalance);
//可用余额
......@@ -686,10 +692,16 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
//updateList.add(entity);
flag += ownerAccountDao.updateAccountCAS(entity, now, false);
}
} else {
if (ownerAccount.getUsableBalance().compareTo(frozenBalance) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货主预付运费账户可用余额不够冻结");
}
if (frozenBalance.compareTo(BigDecimal.ZERO) == 0) {
flag += 1;
frozenBalanceZeroFlag = true;
} else {
//冻结金额
entity.setFrozenBalance(frozenBalance);
//可用余额
......@@ -700,6 +712,7 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
flag += ownerAccountDao.updateAccountCAS(entity, now, false);
}
}
}
if (flag == 2) {
log.info("冻结账户完毕");
log.info("插入保证金冻结流水");
......@@ -707,6 +720,10 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
for (OwnerAccount ownerAccount : accountList) {
if (ownerAccount.getAccountType().equals(OwnerAccountEnum.AccountTypeStatus.MARGIN_ACCOUNT.getCode())) {
log.info("插入保证金冻结流水");
if (ensureBalanceZeroFlag) {
log.info("保证金账户需冻结金额为0,不产生流水");
continue;
}
OwnerRunningWaterRecord marginAccount = new OwnerRunningWaterRecord();
marginAccount.setOwnerUserName(ownerName);
marginAccount.setMobile(mobile);
......@@ -728,6 +745,10 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
ownerRunningWaterRecordDao.saveEntity(marginAccount);
} else {
log.info("插入预付运费冻结流水");
if (frozenBalanceZeroFlag) {
log.info("保证金账户需冻结金额为0,不产生流水");
continue;
}
OwnerRunningWaterRecord prepaidFreight = new OwnerRunningWaterRecord();
prepaidFreight.setOwnerUserName(ownerName);
prepaidFreight.setMobile(mobile);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论