Commit 99bddebf by 程裕兵

feat:ali

parent 0036c556
...@@ -108,16 +108,19 @@ public class PayServiceImpl implements PayService { ...@@ -108,16 +108,19 @@ public class PayServiceImpl implements PayService {
@Resource(name = "financeThreadPool") @Resource(name = "financeThreadPool")
private Executor executor; private Executor executor;
private final Map<String, DefaultAlipayClient> aliClientMap = new HashMap<>(); // private final Map<String, DefaultAlipayClient> aliClientMap = new HashMap<>();
@PostConstruct @PostConstruct
public void init() { public void init() {
GlobalConfig config = globalConfigRpService.getById(GlobalConfigEnums.CASHIER_ALI_INFO.getCode()) // GlobalConfig config = globalConfigRpService.getById(GlobalConfigEnums.CASHIER_ALI_INFO.getCode())
.orElse(new GlobalConfig()); // .orElse(null);
AliInfo info = JSON.parseObject(config.getConfigValue(), AliInfo.class); // if (config == null) {
aliClientMap.put(info.getAppId(), // return;
new DefaultAlipayClient(info.getBaseUrl(), info.getAppId(), info.getMerchantPrivateKey(), "json", // }
"utf-8", info.getAlipayPublicKey(), "RSA2")); // AliInfo info = JSON.parseObject(config.getConfigValue(), AliInfo.class);
// aliClientMap.put(info.getAppId(),
// new DefaultAlipayClient(info.getBaseUrl(), info.getAppId(), info.getMerchantPrivateKey(), "json",
// "utf-8", info.getAlipayPublicKey(), "RSA2"));
} }
@Override @Override
...@@ -126,15 +129,15 @@ public class PayServiceImpl implements PayService { ...@@ -126,15 +129,15 @@ public class PayServiceImpl implements PayService {
case WX: case WX:
return Optional.ofNullable(weChatAuthService.getBaseAuthInfo(null, appId, authCode)) return Optional.ofNullable(weChatAuthService.getBaseAuthInfo(null, appId, authCode))
.map(BaseAuthInfoVO::getOpenId).orElse(null); .map(BaseAuthInfoVO::getOpenId).orElse(null);
case ALI: // case ALI:
try { // try {
AlipaySystemOauthTokenResponse response = aliClientMap.get(appId) // AlipaySystemOauthTokenResponse response = aliClientMap.get(appId)
.execute(PayConvert.convertAlipaySystemOauthTokenRequest(authCode)); // .execute(PayConvert.convertAlipaySystemOauthTokenRequest(authCode));
log.info("get ali openId response {}, {}, {}", appId, authCode, JSON.toJSONString(response)); // log.info("get ali openId response {}, {}, {}", appId, authCode, JSON.toJSONString(response));
return response.getOpenId(); // return response.getOpenId();
} catch (AlipayApiException e) { // } catch (AlipayApiException e) {
throw new BizException(e.getErrCode(), e.getMessage()); // throw new BizException(e.getErrCode(), e.getMessage());
} // }
default: default:
throw new BizException(FinanceErrorEnums.NOT_SUPPORT_TYPE); throw new BizException(FinanceErrorEnums.NOT_SUPPORT_TYPE);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment