|
|
@@ -41,6 +41,7 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -119,6 +120,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
// 创建支付记录
|
|
|
var walletDetail = new WalletDetail()
|
|
|
.setType(WalletDetail.TYPE_充值)
|
|
|
+ .setStatus(WalletDetail.STATUS_待确认)
|
|
|
.setUserId(userId)
|
|
|
.setAmount(rechargeAmount)
|
|
|
.setOrderNo(outTradeNo);
|
|
|
@@ -216,10 +218,15 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
// 资金流水
|
|
|
var walletDetail = walletDetailService.getWalletDetailByOrderNo(transaction.getOutTradeNo());
|
|
|
if (walletDetail != null) {
|
|
|
- walletDetail.setType(1); // 充值
|
|
|
- walletDetail.setStatus(1); //已确认
|
|
|
+ walletDetail.setStatus(WalletDetail.STATUS_已确认); //已确认
|
|
|
walletDetail.setCurrency(transaction.getAmount().getCurrency());
|
|
|
walletDetail.setAmount(transaction.getAmount().getTotal());
|
|
|
+ walletDetail.setTransactionTime(LocalDateTime.parse(transaction.getSuccessTime()));
|
|
|
+ walletDetailService.updateById(walletDetail);
|
|
|
+
|
|
|
+ // 更新余额
|
|
|
+ accountService.lambdaUpdate().setSql("balance = (balance+%d)".formatted(transaction.getAmount().getTotal()))
|
|
|
+ .eq(Account::getUserId, walletDetail.getUserId()).update();
|
|
|
|
|
|
// 支付记录
|
|
|
var payLog = new PayLog();
|
|
|
@@ -229,7 +236,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
payLog.setMchId(transaction.getMchid());
|
|
|
payLog.setOutTradeNo(transaction.getOutTradeNo());
|
|
|
payLog.setTransactionId(transaction.getTransactionId());
|
|
|
- payLog.setSuccessTime(transaction.getSuccessTime());
|
|
|
+ payLog.setSuccessTime(LocalDateTime.parse(transaction.getSuccessTime()));
|
|
|
payLog.setTradeType(transaction.getTradeType().name());
|
|
|
payLog.setTradeState(transaction.getTradeState().name());
|
|
|
payLog.setAttach(transaction.getAttach());
|
|
|
@@ -239,9 +246,6 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
payLog.setPayerCurrency(transaction.getAmount().getPayerCurrency());
|
|
|
payLogService.save(payLog);
|
|
|
LOGGER.info("微信支付回调{}:业务处理结束", no);
|
|
|
- // 更新余额
|
|
|
- accountService.lambdaUpdate().setSql("balance = (balance+%d)".formatted(transaction.getAmount().getTotal()))
|
|
|
- .eq(Account::getUserId, walletDetail.getUserId()).update();
|
|
|
|
|
|
} else {
|
|
|
LOGGER.error("微信支付通知处理异常,资金流水为空,回调信息:{}", transaction);
|