mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
多商户配置
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.jsowell.adapay.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* adapay配置类
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class AbstractAdapayConfig implements InitializingBean {
|
||||
|
||||
private boolean debugFlag;
|
||||
|
||||
private boolean prodMode;
|
||||
|
||||
private String apiKey;
|
||||
|
||||
private String mockApiKey;
|
||||
|
||||
private String rsaPrivateKey;
|
||||
|
||||
private String adapayAppId;
|
||||
|
||||
private String wechatAppId;
|
||||
|
||||
}
|
||||
@@ -15,21 +15,21 @@ public class AdapayConfig implements CommandLineRunner {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(AdapayConfig.class);
|
||||
|
||||
@Value("${adapay.apiKey}")
|
||||
private String API_KEY;
|
||||
|
||||
@Value("${adapay.mockApiKey}")
|
||||
private String MOCK_API_KEY;
|
||||
|
||||
@Value("${adapay.rsaPrivateKey}")
|
||||
private String RSA_PRIVATE_KEY;
|
||||
|
||||
@Value("${adapay.debugFlag}")
|
||||
private boolean DEBUG_FLAG;
|
||||
|
||||
@Value("${adapay.prodMode}")
|
||||
private boolean PROD_MODE;
|
||||
|
||||
@Value("${adapay.jsowell.apiKey}")
|
||||
private String JSOWELL_API_KEY;
|
||||
|
||||
@Value("${adapay.jsowell.mockApiKey}")
|
||||
private String JSOWELL_MOCK_API_KEY;
|
||||
|
||||
@Value("${adapay.jsowell.rsaPrivateKey}")
|
||||
private String JSOWELL_RSA_PRIVATE_KEY;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
/**
|
||||
@@ -48,15 +48,15 @@ public class AdapayConfig implements CommandLineRunner {
|
||||
* mockApiKey为mock模式的API KEY
|
||||
* rsaPrivateKey为商户发起请求时,用于请求参数加签所需要的RSA私钥
|
||||
*/
|
||||
String apiKey = API_KEY;
|
||||
String mockApiKey = MOCK_API_KEY;
|
||||
String rsaPrivateKey = RSA_PRIVATE_KEY;
|
||||
String apiKey = JSOWELL_API_KEY;
|
||||
String mockApiKey = JSOWELL_MOCK_API_KEY;
|
||||
String rsaPrivateKey = JSOWELL_RSA_PRIVATE_KEY;
|
||||
MerConfig merConfig = new MerConfig();
|
||||
merConfig.setApiKey(apiKey);
|
||||
merConfig.setApiMockKey(mockApiKey);
|
||||
merConfig.setRSAPrivateKey(rsaPrivateKey);
|
||||
Adapay.initWithMerConfig(merConfig);
|
||||
logger.info("汇付配置初始化成功,debug:{}, prodMode:{}, apiKey:{}, mockApiKey:{}, rsaPrivateKey:{}"
|
||||
, DEBUG_FLAG, PROD_MODE, API_KEY, MOCK_API_KEY, RSA_PRIVATE_KEY);
|
||||
, DEBUG_FLAG, PROD_MODE, JSOWELL_API_KEY, JSOWELL_MOCK_API_KEY, JSOWELL_RSA_PRIVATE_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.jsowell.adapay.config;
|
||||
|
||||
import com.jsowell.adapay.factory.AdapayConfigFactory;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 万车充adapay配置类
|
||||
*/
|
||||
@Component
|
||||
@Getter
|
||||
@Setter
|
||||
public class JsowellAdapayConfig extends AbstractAdapayConfig{
|
||||
@Value("${adapay.debugFlag}")
|
||||
private boolean debugFlag;
|
||||
|
||||
@Value("${adapay.prodMode}")
|
||||
private boolean prodMode;
|
||||
|
||||
@Value("${adapay.jsowell.apiKey}")
|
||||
private String apiKey;
|
||||
|
||||
@Value("${adapay.jsowell.mockApiKey}")
|
||||
private String mockApiKey;
|
||||
|
||||
@Value("${adapay.jsowell.rsaPrivateKey}")
|
||||
private String rsaPrivateKey;
|
||||
|
||||
@Value("${adapay.jsowell.appId}")
|
||||
private String adapayAppId;
|
||||
|
||||
@Value("${adapay.jsowell.wechatAppId}")
|
||||
private String wechatAppId;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// key为微信小程序id
|
||||
AdapayConfigFactory.register(wechatAppId, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.jsowell.adapay.config;
|
||||
|
||||
import com.jsowell.adapay.factory.AdapayConfigFactory;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 希晓充电adapay配置
|
||||
*/
|
||||
@Component
|
||||
@Getter
|
||||
@Setter
|
||||
public class XixiaoAdapayConfig extends AbstractAdapayConfig{
|
||||
|
||||
@Value("${adapay.debugFlag}")
|
||||
private boolean debugFlag;
|
||||
|
||||
@Value("${adapay.prodMode}")
|
||||
private boolean prodMode;
|
||||
|
||||
@Value("${adapay.xixiao.apiKey}")
|
||||
private String apiKey;
|
||||
|
||||
@Value("${adapay.xixiao.mockApiKey}")
|
||||
private String mockApiKey;
|
||||
|
||||
@Value("${adapay.xixiao.rsaPrivateKey}")
|
||||
private String rsaPrivateKey;
|
||||
|
||||
@Value("${adapay.xixiao.appId}")
|
||||
private String adapayAppId;
|
||||
|
||||
@Value("${adapay.xixiao.wechatAppId}")
|
||||
private String wechatAppId;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// key为微信小程序id
|
||||
AdapayConfigFactory.register(wechatAppId, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.jsowell.adapay.factory;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.adapay.config.AbstractAdapayConfig;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* adapay配置工厂类
|
||||
*/
|
||||
public class AdapayConfigFactory {
|
||||
private static Map<String, AbstractAdapayConfig> configMap = Maps.newHashMap();
|
||||
|
||||
/**
|
||||
* 注册
|
||||
* @param str
|
||||
* @param handler
|
||||
*/
|
||||
public static void register(String str, AbstractAdapayConfig handler) {
|
||||
if (StringUtils.isBlank(str) || Objects.isNull(handler)) {
|
||||
return;
|
||||
}
|
||||
configMap.put(str, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static AbstractAdapayConfig getConfig(String name) {
|
||||
return configMap.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部
|
||||
*/
|
||||
public static List<AbstractAdapayConfig> getAllConfig() {
|
||||
return Lists.newArrayList(configMap.values());
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class AdapayMemberService {
|
||||
|
||||
@Value("${adapay.appId}")
|
||||
@Value("${adapay.jsowell.appId}")
|
||||
private String ADAPAY_APP_ID;
|
||||
|
||||
// private final String CALLBACK_URL = "https://api.jsowellcloud.com/uniapp/pay/callbackAdapay";
|
||||
|
||||
Reference in New Issue
Block a user