更新会员交易记录的冻结金额

This commit is contained in:
2023-08-28 10:20:25 +08:00
parent f7803b5ef2
commit a4f8be1bda
2 changed files with 24 additions and 6 deletions

View File

@@ -34,5 +34,7 @@ public interface MemberAdapayRecordService{
void updateRefundAmount(String paymentId, BigDecimal amount);
void updateSpendAmountAndRefundAmount(String paymentId, BigDecimal SpendAmount, BigDecimal RefundAmount);
void updateFreezeAmount(String paymentId, BigDecimal amount);
void updateSpendAmountAndRefundAmount(String paymentId, BigDecimal SpendAmount, BigDecimal RefundAmount, BigDecimal freezeAmount);
}

View File

@@ -88,7 +88,7 @@ public class MemberAdapayRecordServiceImpl implements MemberAdapayRecordService
*/
@Override
public void updateSpendAmount(String paymentId, BigDecimal amount) {
updateSpendAmountAndRefundAmount(paymentId, amount, null);
updateSpendAmountAndRefundAmount(paymentId, amount, null, null);
}
/**
@@ -99,7 +99,17 @@ public class MemberAdapayRecordServiceImpl implements MemberAdapayRecordService
*/
@Override
public void updateRefundAmount(String paymentId, BigDecimal amount) {
updateSpendAmountAndRefundAmount(paymentId, null, amount);
updateSpendAmountAndRefundAmount(paymentId, null, amount, null);
}
/**
* 更新冻结金额
* @param paymentId
* @param amount
*/
@Override
public void updateFreezeAmount(String paymentId, BigDecimal amount) {
updateSpendAmountAndRefundAmount(paymentId, null, null, amount);
}
/**
@@ -110,20 +120,26 @@ public class MemberAdapayRecordServiceImpl implements MemberAdapayRecordService
* @param RefundAmount 退款金额
*/
@Override
public void updateSpendAmountAndRefundAmount(String paymentId, BigDecimal SpendAmount, BigDecimal RefundAmount) {
public void updateSpendAmountAndRefundAmount(String paymentId, BigDecimal SpendAmount, BigDecimal RefundAmount, BigDecimal freezeAmount) {
MemberAdapayRecord record = selectByPaymentId(paymentId);
if (record == null) {
log.info("更新交易记录的消费金额和退款金额paymentId:{}, 查询为空", paymentId);
return;
}
if (RefundAmount != null) {
// 设置退款金额 = 历史退款金额 + 本次退款金额
record.setRefundAmt(record.getRefundAmt().add(RefundAmount));
}
if (SpendAmount != null) {
// 设置消费金额 = 历史消费金额 + 本次消费金额
record.setSpendAmt(record.getSpendAmt().add(SpendAmount));
}
// 更新此笔交易单的剩余金额 = 支付金额 - 累计退款金额 - 累计消费金额
record.setBalanceAmt(record.getPayAmt().subtract(record.getRefundAmt()).subtract(record.getSpendAmt()));
if (freezeAmount != null) {
// 设置冻结金额 = 历史冻结金额 + 本次冻结金额
record.setFreezeAmt(record.getFreezeAmt().add(freezeAmount));
}
// 更新此笔交易单的剩余金额 = 支付金额 - 累计退款金额 - 累计消费金额 - 累计冻结金额
record.setBalanceAmt(record.getPayAmt().subtract(record.getRefundAmt()).subtract(record.getSpendAmt()).subtract(record.getFreezeAmt()));
updateByPrimaryKeySelective(record);
// if (BigDecimal.ZERO.compareTo(record.getBalanceAmt()) != 0) {