Commit 99bddebf by 程裕兵

feat:ali

parent 0036c556
......@@ -108,16 +108,19 @@ public class PayServiceImpl implements PayService {
@Resource(name = "financeThreadPool")
private Executor executor;
private final Map<String, DefaultAlipayClient> aliClientMap = new HashMap<>();
// private final Map<String, DefaultAlipayClient> aliClientMap = new HashMap<>();
@PostConstruct
public void init() {
GlobalConfig config = globalConfigRpService.getById(GlobalConfigEnums.CASHIER_ALI_INFO.getCode())
.orElse(new GlobalConfig());
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"));
// GlobalConfig config = globalConfigRpService.getById(GlobalConfigEnums.CASHIER_ALI_INFO.getCode())
// .orElse(null);
// if (config == null) {
// return;
// }
// 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
......@@ -126,15 +129,15 @@ public class PayServiceImpl implements PayService {
case WX:
return Optional.ofNullable(weChatAuthService.getBaseAuthInfo(null, appId, authCode))
.map(BaseAuthInfoVO::getOpenId).orElse(null);
case ALI:
try {
AlipaySystemOauthTokenResponse response = aliClientMap.get(appId)
.execute(PayConvert.convertAlipaySystemOauthTokenRequest(authCode));
log.info("get ali openId response {}, {}, {}", appId, authCode, JSON.toJSONString(response));
return response.getOpenId();
} catch (AlipayApiException e) {
throw new BizException(e.getErrCode(), e.getMessage());
}
// case ALI:
// try {
// AlipaySystemOauthTokenResponse response = aliClientMap.get(appId)
// .execute(PayConvert.convertAlipaySystemOauthTokenRequest(authCode));
// log.info("get ali openId response {}, {}, {}", appId, authCode, JSON.toJSONString(response));
// return response.getOpenId();
// } catch (AlipayApiException e) {
// throw new BizException(e.getErrCode(), e.getMessage());
// }
default:
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