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