mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
update 打印日志
This commit is contained in:
@@ -142,12 +142,12 @@ public class MemberAdapayRecordServiceImpl implements MemberAdapayRecordService
|
||||
* 更新交易记录的消费金额和退款金额
|
||||
*
|
||||
* @param paymentId 支付id
|
||||
* @param SpendAmount 消费金额
|
||||
* @param RefundAmount 退款金额
|
||||
* @param spendAmount 消费金额
|
||||
* @param refundAmount 退款金额
|
||||
* @param freezeAmount 冻结金额
|
||||
*/
|
||||
@Override
|
||||
public void commonUpdateAmountMethod(String paymentId, BigDecimal SpendAmount, BigDecimal RefundAmount, BigDecimal freezeAmount) {
|
||||
public void commonUpdateAmountMethod(String paymentId, BigDecimal spendAmount, BigDecimal refundAmount, BigDecimal freezeAmount) {
|
||||
MemberAdapayRecord record = selectByPaymentId(paymentId);
|
||||
if (record == null) {
|
||||
log.info("更新交易记录的消费金额和退款金额paymentId:{}, 查询为空", paymentId);
|
||||
@@ -159,41 +159,46 @@ public class MemberAdapayRecordServiceImpl implements MemberAdapayRecordService
|
||||
BigDecimal freezeAmt = record.getFreezeAmt();
|
||||
BigDecimal balanceAmt = record.getBalanceAmt();
|
||||
|
||||
if (freezeAmount != null) {
|
||||
if (BigDecimal.ZERO.compareTo(freezeAmount) > 0) {
|
||||
// 如果冻结金额传过来是负数,说明是解冻
|
||||
if (freezeAmount.negate().compareTo(freezeAmt) > 0) {
|
||||
throw new BusinessException("", "解冻金额大于冻结金额");
|
||||
try {
|
||||
if (freezeAmount != null) {
|
||||
if (BigDecimal.ZERO.compareTo(freezeAmount) > 0) {
|
||||
// 如果冻结金额传过来是负数,说明是解冻
|
||||
if (freezeAmount.negate().compareTo(freezeAmt) > 0) {
|
||||
throw new BusinessException("", "解冻金额大于冻结金额");
|
||||
}
|
||||
balanceAmt = balanceAmt.add(freezeAmount.negate()); // 剩余金额增加
|
||||
} else {
|
||||
if (freezeAmount.compareTo(balanceAmt) > 0) {
|
||||
throw new BusinessException("", "冻结金额大于剩余金额");
|
||||
}
|
||||
}
|
||||
balanceAmt = balanceAmt.add(freezeAmount.negate()); // 剩余金额增加
|
||||
} else {
|
||||
if (freezeAmount.compareTo(balanceAmt) > 0) {
|
||||
throw new BusinessException("", "冻结金额大于剩余金额");
|
||||
freezeAmt = freezeAmt.add(freezeAmount); // 冻结金额减少
|
||||
// 设置冻结金额 = 历史冻结金额 + 本次冻结金额
|
||||
record.setFreezeAmt(freezeAmt);
|
||||
}
|
||||
if (refundAmount != null) {
|
||||
if (refundAmount.compareTo(balanceAmt) > 0) {
|
||||
throw new BusinessException("", "退款金额大于剩余金额");
|
||||
}
|
||||
// 设置退款金额 = 历史退款金额 + 本次退款金额
|
||||
refundAmt = refundAmt.add(refundAmount);
|
||||
record.setRefundAmt(refundAmt);
|
||||
}
|
||||
freezeAmt = freezeAmt.add(freezeAmount); // 冻结金额减少
|
||||
// 设置冻结金额 = 历史冻结金额 + 本次冻结金额
|
||||
record.setFreezeAmt(freezeAmt);
|
||||
}
|
||||
if (RefundAmount != null) {
|
||||
if (RefundAmount.compareTo(balanceAmt) > 0) {
|
||||
throw new BusinessException("", "退款金额大于剩余金额");
|
||||
if (spendAmount != null) {
|
||||
if (spendAmount.compareTo(balanceAmt) > 0) {
|
||||
throw new BusinessException("", "消费金额大于剩余金额");
|
||||
}
|
||||
// 设置消费金额 = 历史消费金额 + 本次消费金额
|
||||
spendAmt = spendAmt.add(spendAmount);
|
||||
record.setSpendAmt(spendAmt);
|
||||
}
|
||||
// 设置退款金额 = 历史退款金额 + 本次退款金额
|
||||
refundAmt = refundAmt.add(RefundAmount);
|
||||
record.setRefundAmt(refundAmt);
|
||||
// 更新此笔交易单的剩余金额 = 支付金额 - 累计退款金额 - 累计消费金额 - 累计冻结金额
|
||||
balanceAmt = record.getPayAmt().subtract(refundAmt).subtract(spendAmt).subtract(freezeAmt);
|
||||
record.setBalanceAmt(balanceAmt);
|
||||
updateByPrimaryKeySelective(record);
|
||||
} catch (Exception e) {
|
||||
log.error("更新MemberAdapayRecord金额paymentId:{}, spendAmount:{}, refundAmount:{}, freezeAmount:{}", paymentId, spendAmount, refundAmount, freezeAmount);
|
||||
log.error("更新MemberAdapayRecord金额error", e);
|
||||
}
|
||||
if (SpendAmount != null) {
|
||||
if (SpendAmount.compareTo(balanceAmt) > 0) {
|
||||
throw new BusinessException("", "消费金额大于剩余金额");
|
||||
}
|
||||
// 设置消费金额 = 历史消费金额 + 本次消费金额
|
||||
spendAmt = spendAmt.add(SpendAmount);
|
||||
record.setSpendAmt(spendAmt);
|
||||
}
|
||||
// 更新此笔交易单的剩余金额 = 支付金额 - 累计退款金额 - 累计消费金额 - 累计冻结金额
|
||||
balanceAmt = record.getPayAmt().subtract(refundAmt).subtract(spendAmt).subtract(freezeAmt);
|
||||
record.setBalanceAmt(balanceAmt);
|
||||
updateByPrimaryKeySelective(record);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user