Commit be1bec39 authored by jiaorz's avatar jiaorz

Merge branch 'master-auto-pay' into base-modify

parents 44321da8 4bc543cf
......@@ -93,7 +93,7 @@ public class AppUserAlipayBiz extends BaseBiz<AppUserAlipayMapper, AppUserAlipay
if (StringUtils.isNotBlank(result)) {
log.info("【支付宝】用户授权获取用户token, {}", result);
JSONObject jsonObject = JSONObject.parseObject(result);
if (jsonObject != null && jsonObject.getString("code") != null && jsonObject.getString("code").equals("10000")) {
if (jsonObject.getJSONObject("error_response") == null) {
String account = jsonObject.getString("userId");
if (account != null) {
appUserAlipay.setTxAlipay(account);
......@@ -108,7 +108,7 @@ public class AppUserAlipayBiz extends BaseBiz<AppUserAlipayMapper, AppUserAlipay
insertSelectiveRe(appUserAlipay);
return ObjectRestResponse.succ();
} else {
return ObjectRestResponse.createFailedResult(Integer.parseInt(jsonObject.getString("code")), jsonObject.getString("sub_msg"));
return ObjectRestResponse.createFailedResult(Integer.parseInt(jsonObject.getJSONObject("error_response").getString("code")), jsonObject.getJSONObject("error_response").getString("sub_msg"));
}
}
return ObjectRestResponse.createDefaultFail();
......
......@@ -16,6 +16,7 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.HTTPSUtils;
import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.UUIDUtils;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
......@@ -478,6 +479,48 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> implements In
}
public String generateAliPayInfo(String apiName, String appName) {
//apiname=com.alipay.account.auth&app_id=xxxxx&app_name=mc&auth_type=AUTHACCOUNT&biz_type=openservice&method=alipay.open.auth.sdk.code.get&pid=xxxxx&product_id=APP_FAST_LOGIN&scope=kuaijie&sign_type=RSA2&target_id=20141225xxxx&sign=fMcp4GtiM6rxSIeFnJCVePJKV43eXrUP86CQgiLhDHH2u%2FdN75eEvmywc2ulkm7qKRetkU9fbVZtJIqFdMJcJ9Yp%2BJI%2FF%2FpESafFR6rB2fRjiQQLGXvxmDGVMjPSxHxVtIqpZy5FDoKUSjQ2%2FILDKpu3%2F%2BtAtm2jRw1rUoMhgt0%3D
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("apiname=");
stringBuilder.append(apiName);
stringBuilder.append("&app_id=");
stringBuilder.append(SystemConfig.ALIPAY_APPID);
stringBuilder.append("&app_name=");
stringBuilder.append(appName);
stringBuilder.append("&auth_type=AUTHACCOUNT");
stringBuilder.append("&biz_type=openservice");
stringBuilder.append("&method=alipay.open.auth.sdk.code.get");
stringBuilder.append("&pid=");
stringBuilder.append(SystemConfig.ALIPAY_PID);
stringBuilder.append("&product_id=APP_FAST_LOGIN");
stringBuilder.append("&scope=kuaijie");
stringBuilder.append("&sign_type=RSA2");
stringBuilder.append("&target_id=");
stringBuilder.append(UUIDUtils.generateShortUuid());
stringBuilder.append("&sign=");
return stringBuilder.toString();
}
public String alipayUserAuth() throws AlipayApiException {
AlipayClient alipayClient = getAlipayClient();
AlipayUserInfoAuthRequest request = new AlipayUserInfoAuthRequest();
request.setBizContent("{" +
" \"scopes\":[" +
" \"auth_base\"" +
" ]," +
"\"state\":\"init\"," +
"\"is_mobile\":\"true\"" +
" }");
AlipayUserInfoAuthResponse response = alipayClient.execute(request);
if(response.isSuccess()){
System.out.println("调用成功");
} else {
System.out.println("调用失败");
}
return response.getBody();
}
//解冻预授权
public void fundAuthOrderUnFreeze(AlipayClient alipayClient) throws AlipayApiException {
......
......@@ -66,5 +66,16 @@ public class UserInfoController {
return ObjectRestResponse.createDefaultFail();
}
@GetMapping("/app/unauth/alipayUserAuth")
public ObjectRestResponse<String> alipayUserAuth() {
try {
JSONObject jsonObject = JSONObject.parseObject(orderPayBiz.alipayUserAuth());
return ObjectRestResponse.succ(jsonObject);
} catch (AlipayApiException e) {
e.printStackTrace();
}
return ObjectRestResponse.createDefaultFail();
}
}
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