|
@@ -15,8 +15,8 @@ import com.kym.common.utils.LambadaTools;
|
|
|
import com.kym.common.utils.OrderUtils;
|
|
import com.kym.common.utils.OrderUtils;
|
|
|
import com.kym.entity.Account;
|
|
import com.kym.entity.Account;
|
|
|
import com.kym.entity.*;
|
|
import com.kym.entity.*;
|
|
|
-import com.kym.service.ActivityService;
|
|
|
|
|
import com.kym.service.*;
|
|
import com.kym.service.*;
|
|
|
|
|
+import com.kym.service.cache.KymCache;
|
|
|
import com.kym.service.wechat.WxPayService;
|
|
import com.kym.service.wechat.WxPayService;
|
|
|
import com.wechat.pay.java.core.Config;
|
|
import com.wechat.pay.java.core.Config;
|
|
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
|
@@ -88,6 +88,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
private final UserRechargeRightsService userRechargeRightsService;
|
|
private final UserRechargeRightsService userRechargeRightsService;
|
|
|
|
|
|
|
|
private final RechargeConfigService rechargeConfigService;
|
|
private final RechargeConfigService rechargeConfigService;
|
|
|
|
|
+ private final MerchantAccountService merchantAccountService;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -100,7 +101,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
PayLogService payLogService, AccountService accountService,
|
|
PayLogService payLogService, AccountService accountService,
|
|
|
RefundLogService refundLogService,
|
|
RefundLogService refundLogService,
|
|
|
ActivityService activityService, UserRechargeRightsService userRechargeRightsService,
|
|
ActivityService activityService, UserRechargeRightsService userRechargeRightsService,
|
|
|
- RechargeConfigService rechargeConfigService) {
|
|
|
|
|
|
|
+ RechargeConfigService rechargeConfigService, MerchantAccountService merchantAccountService) {
|
|
|
this.conf = conf;
|
|
this.conf = conf;
|
|
|
this.walletDetailService = walletDetailService;
|
|
this.walletDetailService = walletDetailService;
|
|
|
this.payLogService = payLogService;
|
|
this.payLogService = payLogService;
|
|
@@ -109,6 +110,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
this.activityService = activityService;
|
|
this.activityService = activityService;
|
|
|
this.userRechargeRightsService = userRechargeRightsService;
|
|
this.userRechargeRightsService = userRechargeRightsService;
|
|
|
this.rechargeConfigService = rechargeConfigService;
|
|
this.rechargeConfigService = rechargeConfigService;
|
|
|
|
|
+ this.merchantAccountService = merchantAccountService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -207,7 +209,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public PrepayWithRequestPaymentResponse wxPay(Long rechargeConfigId) {
|
|
|
|
|
|
|
+ public PrepayWithRequestPaymentResponse wxPay(Long rechargeConfigId, String stationId) {
|
|
|
// 充值配置
|
|
// 充值配置
|
|
|
var rechargeConfig = rechargeConfigService.getById(rechargeConfigId);
|
|
var rechargeConfig = rechargeConfigService.getById(rechargeConfigId);
|
|
|
|
|
|
|
@@ -240,6 +242,8 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
request.setDescription("超级进化车生活充值");
|
|
request.setDescription("超级进化车生活充值");
|
|
|
request.setNotifyUrl(conf.getNotifyUrl());
|
|
request.setNotifyUrl(conf.getNotifyUrl());
|
|
|
request.setOutTradeNo(outTradeNo);
|
|
request.setOutTradeNo(outTradeNo);
|
|
|
|
|
+ // 把stationId传给微信,微信回调时携带再取出,记录是充值到哪个站点
|
|
|
|
|
+ request.setAttach(stationId);
|
|
|
Payer payer = new Payer();
|
|
Payer payer = new Payer();
|
|
|
payer.setOpenid(openid);
|
|
payer.setOpenid(openid);
|
|
|
request.setPayer(payer);
|
|
request.setPayer(payer);
|
|
@@ -329,13 +333,22 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
payLog.setTradeType(transaction.getTradeType().name());
|
|
payLog.setTradeType(transaction.getTradeType().name());
|
|
|
payLog.setTradeState(transaction.getTradeState().name());
|
|
payLog.setTradeState(transaction.getTradeState().name());
|
|
|
payLog.setAttach(transaction.getAttach());
|
|
payLog.setAttach(transaction.getAttach());
|
|
|
- payLog.setTotal(transaction.getAmount().getTotal());
|
|
|
|
|
|
|
+ var totalAmount = transaction.getAmount().getTotal();
|
|
|
|
|
+ payLog.setTotal(totalAmount);
|
|
|
payLog.setCurrency(transaction.getAmount().getCurrency());
|
|
payLog.setCurrency(transaction.getAmount().getCurrency());
|
|
|
payLog.setPayerTotal(transaction.getAmount().getPayerTotal());
|
|
payLog.setPayerTotal(transaction.getAmount().getPayerTotal());
|
|
|
payLog.setPayerCurrency(transaction.getAmount().getPayerCurrency());
|
|
payLog.setPayerCurrency(transaction.getAmount().getPayerCurrency());
|
|
|
payLogService.save(payLog);
|
|
payLogService.save(payLog);
|
|
|
- LOGGER.info("微信支付回调{}:业务处理结束", notifyRes[2]);
|
|
|
|
|
|
|
|
|
|
|
|
+ // 用户(此时要知道用户归属的站点)充值的资金先进到洗车站商户账户的基本户和冻结户,然后在消费时再将冻结户金额进行分润
|
|
|
|
|
+ var stationId = transaction.getAttach();
|
|
|
|
|
+ // 70%进入站点商户基本户,30%进入站点商户冻结户
|
|
|
|
|
+ var stationBasicAmount = (int) (totalAmount * 0.7);
|
|
|
|
|
+ var stationFreezeAmount = totalAmount - stationBasicAmount;
|
|
|
|
|
+ merchantAccountService.lambdaUpdate().setSql("balance = (balance + %d), frozen_amount = (frozen_amount + %d)".formatted(stationBasicAmount, stationFreezeAmount))
|
|
|
|
|
+ .eq(MerchantAccount::getId, KymCache.INSTANCE.getMerchantIdByStationId(stationId)).update();
|
|
|
|
|
+
|
|
|
|
|
+ LOGGER.info("微信支付回调{}:业务处理结束", notifyRes[2]);
|
|
|
return ResponseEntity.status(HttpStatus.OK).build();
|
|
return ResponseEntity.status(HttpStatus.OK).build();
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|