feat: 新增挂单支付

This commit is contained in:
张松 2024-11-27 15:38:44 +08:00
parent a7349f806b
commit cfc17d9533
1 changed files with 8 additions and 8 deletions

View File

@ -171,15 +171,15 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl<TbCreditBuyerOrde
// 账户余额
BigDecimal accountBalance = creditBuyer.getAccountBalance();
// 如果有余额的话从余额里面扣除没有余额的话从信用额度里面扣除余额和信用额度都为0则不允许挂账余额+信用额度刚好够支付这笔订单的话需要同时减余额减信用额度
if (NumberUtil.isGreaterOrEqual(accountBalance, orderInfo.getPayAmount())) {
if (NumberUtil.isGreaterOrEqual(accountBalance, orderInfo.getOrderAmount())) {
// 减余额
creditBuyer.setAccountBalance(NumberUtil.sub(accountBalance, orderInfo.getPayAmount()));
creditBuyer.setAccountBalance(NumberUtil.sub(accountBalance, orderInfo.getOrderAmount()));
tbCreditBuyerMapper.updateById(creditBuyer);
// 记录还款记录
TbCreditPaymentRecord record = new TbCreditPaymentRecord();
record.setCreditBuyerId(creditBuyerId);
record.setOrderId(orderId);
record.setRepaymentAmount(orderInfo.getPayAmount());
record.setRepaymentAmount(orderInfo.getOrderAmount());
record.setPaymentMethod("余额支付");
record.setPaymentTime(new Date());
record.setRemark("挂账时余额充足,直接从余额扣除");
@ -188,7 +188,7 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl<TbCreditBuyerOrde
TbCreditBuyerOrder entity = new TbCreditBuyerOrder();
entity.setCreditBuyerId(creditBuyerId);
entity.setOrderId(orderId);
entity.setPaidAmount(orderInfo.getPayAmount());
entity.setPaidAmount(orderInfo.getOrderAmount());
entity.setStatus("paid");
entity.setLastPaymentTime(new Date());
entity.setLastPaymentMethod(record.getPaymentMethod());
@ -219,14 +219,14 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl<TbCreditBuyerOrde
entity.setLastPaymentMethod(record.getPaymentMethod());
entity.setRemark(record.getRemark());
//super.save(entity);
orderInfo.setPayAmount(NumberUtil.sub(orderInfo.getPayAmount(), accountBalance));
orderInfo.setPayAmount(NumberUtil.sub(orderInfo.getOrderAmount(), accountBalance));
}
// 剩余挂账额度
BigDecimal remainingAmount = creditBuyer.getRemainingAmount();
// 验证挂账金额是否大于剩余额度
boolean greater = NumberUtil.isGreater(orderInfo.getPayAmount(), remainingAmount);
boolean greater = NumberUtil.isGreater(orderInfo.getOrderAmount(), remainingAmount);
if (greater) {
throw new BadRequestException(StrUtil.format("{}:¥{}不能大于剩余挂账额度({})", "挂账金额", orderInfo.getPayAmount(), remainingAmount));
throw new BadRequestException(StrUtil.format("{}:¥{}不能大于剩余挂账额度({})", "挂账金额", orderInfo.getOrderAmount(), remainingAmount));
}
if (entity == null) {
entity = new TbCreditBuyerOrder();