mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 03:55:17 +08:00
支付宝登录
This commit is contained in:
@@ -28,6 +28,9 @@ public class AliPayConfig implements CommandLineRunner {
|
||||
@Value("${alipay.notifyUrl}")
|
||||
private String notifyUrl;
|
||||
|
||||
@Value("${alipay.encryptKey}")
|
||||
private String encryptKey;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
log.info(">>>>>>>>>>>>>>>服务启动执行,执行加载数据等操作 AliPayConfig order 2 <<<<<<<<<<<<<");
|
||||
@@ -50,8 +53,9 @@ public class AliPayConfig implements CommandLineRunner {
|
||||
config.alipayPublicKey = alipayPublicKey;
|
||||
// 可设置异步通知接收服务地址(可选)
|
||||
// config.notifyUrl = "<-- 请填写您的支付类接口异步通知接收服务地址,例如:https://www.test.com/callback -->";
|
||||
|
||||
// 可设置AES密钥,调用AES加解密相关接口时需要(可选)
|
||||
// config.encryptKey = "<-- 请填写您的AES密钥,例如:aa4BtZ4tspm2wnXLb1ThQA== -->";
|
||||
config.encryptKey = encryptKey;
|
||||
Factory.setOptions(config);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,21 @@
|
||||
package com.jsowell.alipay.service;
|
||||
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.AlipayConfig;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.internal.util.AlipayEncrypt;
|
||||
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
||||
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
||||
import com.alipay.easysdk.base.oauth.models.AlipaySystemOauthTokenResponse;
|
||||
import com.alipay.easysdk.factory.Factory;
|
||||
import com.jsowell.alipay.config.AliPayConfig;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -22,36 +27,34 @@ import java.util.Map;
|
||||
/**
|
||||
* 支付宝小程序service
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AliAppletRemoteService {
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(AliAppletRemoteService.class);
|
||||
/**
|
||||
* 通过authCode获取手机号
|
||||
* @param code
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String getMobileNumberByCode(String code) throws Exception {
|
||||
AlipaySystemOauthTokenResponse token = Factory.Base.OAuth().getToken(code);
|
||||
log.info("AlipaySystemOauthTokenResponse:{}", JSON.toJSONString(token));
|
||||
|
||||
String accessToken = token.getAccessToken();
|
||||
|
||||
// Factory.Util.AES().decrypt();
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* (支付宝) 换取授权访问令牌
|
||||
* alipay.system.oauth.token(换取授权访问令牌)
|
||||
* 通过openIdCode获取openId
|
||||
* @param openIdCode
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("getInfo")
|
||||
public RestApiResponse<?> getInfo(String auth_code) throws AlipayApiException {
|
||||
RestApiResponse<?> restApiResponse;
|
||||
try {
|
||||
if(auth_code==null||auth_code.length()==0) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("userid", "");
|
||||
restApiResponse = new RestApiResponse<>(map);
|
||||
} catch (BusinessException e) {
|
||||
restApiResponse = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
restApiResponse = new RestApiResponse<>(ReturnCodeEnum.CODE_FAILED);
|
||||
}
|
||||
|
||||
return restApiResponse;
|
||||
public String getOpenId(String openIdCode) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user