Browse Source

微信第三方平台-授权回调

dev_shibei_match
zxc 5 years ago
parent
commit
04e70575e0
  1. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java
  2. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java

@ -34,7 +34,7 @@ public interface ThirdRedisKeyConstant {
/** /**
* 第三方 授权方交互使用的 * 第三方 授权方交互使用的
*/ */
String AUTHORIZER_REFRESH_TOKEN_REDIS_KEY = "epmet:wechartthird:authorizerrefreshtoken"; String AUTHORIZER_REFRESH_TOKEN_REDIS_KEY = "epmet:wechartthird:authorizerrefreshtoken:";
/** /**
* auth_code 授权码 * auth_code 授权码

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java

@ -501,13 +501,15 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
Integer authCount = customerMpDao.selectAuthCount(customerId); Integer authCount = customerMpDao.selectAuthCount(customerId);
String openPlatformId = null; String openPlatformId = null;
String authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); String authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType);
Map authRefresh = JSON.parseObject(authorizerRefreshToken, Map.class);
AuthorizationInfoResultDTO authorizationInfo = this.mapToEntity(authRefresh, AuthorizationInfoResultDTO.class);
if (authCount==NumConstant.ZERO){ if (authCount==NumConstant.ZERO){
log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定");
//没有任何一个小程序/公众号授权,【先创建,再绑定】 //没有任何一个小程序/公众号授权,【先创建,再绑定】
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.APP_ID,authAppId); jsonObject.put(ModuleConstant.APP_ID,authAppId);
// 此处的 access_token 为 【authorizer_access_token】 // 此处的 access_token 为 【authorizer_access_token】
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerRefreshToken, JSON.toJSONString(jsonObject)).getData(); String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizationInfo.getAuthorizer_access_token(), JSON.toJSONString(jsonObject)).getData();
Map<String,String> map = JSON.parseObject(data, Map.class); Map<String,String> map = JSON.parseObject(data, Map.class);
CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE))); createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE)));

Loading…
Cancel
Save