【代码优化】PAY:移除 PayClient 缓存,减少复杂性,性能足够(非高频读取)
This commit is contained in:
@@ -23,9 +23,10 @@ public interface PayClientFactory {
|
||||
* @param channelId 渠道编号
|
||||
* @param channelCode 渠道编码
|
||||
* @param config 支付配置
|
||||
* @return 支付客户端
|
||||
*/
|
||||
<Config extends PayClientConfig> void createOrUpdatePayClient(Long channelId, String channelCode,
|
||||
Config config);
|
||||
<Config extends PayClientConfig> PayClient createOrUpdatePayClient(Long channelId, String channelCode,
|
||||
Config config);
|
||||
|
||||
/**
|
||||
* 注册支付客户端 Class,用于模块中实现的 PayClient
|
||||
|
||||
@@ -71,8 +71,8 @@ public class PayClientFactoryImpl implements PayClientFactory {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <Config extends PayClientConfig> void createOrUpdatePayClient(Long channelId, String channelCode,
|
||||
Config config) {
|
||||
public <Config extends PayClientConfig> PayClient createOrUpdatePayClient(Long channelId, String channelCode,
|
||||
Config config) {
|
||||
AbstractPayClient<Config> client = (AbstractPayClient<Config>) clients.get(channelId);
|
||||
if (client == null) {
|
||||
client = this.createPayClient(channelId, channelCode, config);
|
||||
@@ -81,6 +81,7 @@ public class PayClientFactoryImpl implements PayClientFactory {
|
||||
} else {
|
||||
client.refresh(config);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -34,7 +34,8 @@ public class WxNativePayClient extends AbstractWxPayClient {
|
||||
@Override
|
||||
protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException {
|
||||
// 构建 WxPayUnifiedOrderRequest 对象
|
||||
WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO);
|
||||
WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO)
|
||||
.setProductId(reqDTO.getOutTradeNo()); // V2 必须传递 productId,无需在微信配置。该参数在 V3 简化,无需传递!
|
||||
// 执行请求
|
||||
WxPayNativeOrderResult response = client.createOrder(request);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user