Browse Source

微信第三方平台-访问微信URL修改

dev_shibei_match
zxc 5 years ago
parent
commit
aa871545d1
  1. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  2. 6
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java

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

@ -7,6 +7,7 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.constant.ModuleConstant;
import com.epmet.constant.ThirdRedisKeyConstant;
import com.epmet.constant.ThirdRunTimeInfoConstant;
import com.epmet.dao.*;
import com.epmet.dto.form.*;
@ -328,7 +329,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
//第三方平台AppId
jsonObject.put(ModuleConstant.COMPONENT_APPID,componentAppId);
jsonObject.put(ModuleConstant.AUTHORIZER_REFRESH_TOKEN,willOverDueDTO.getAuthorizerRefreshToken());
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_AUTHORIZER_TOKEN_URL, JSON.toJSONString(jsonObject)).getData();
String componentAccessToken = redisThird.getComponentAccessToken();
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_AUTHORIZER_TOKEN_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData();
Map map = JSON.parseObject(data, HashMap.class);
//authorizer_access_token
String authorizerAccessToken = map.get(ModuleConstant.AUTHORIZER_ACCESS_TOKEN).toString();
@ -499,12 +501,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
log.info("开始创建开放平台账号并绑定");
Integer authCount = customerMpDao.selectAuthCount(customerId);
String openPlatformId = null;
String authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType);
if (authCount==NumConstant.ZERO){
log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定");
//没有任何一个小程序/公众号授权,【先创建,再绑定】
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.APP_ID,authAppId);
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN, JSON.toJSONString(jsonObject)).getData();
// 此处的 access_token 为 【authorizer_access_token】
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerRefreshToken, JSON.toJSONString(jsonObject)).getData();
Map<String,String> map = JSON.parseObject(data, Map.class);
CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE)));
@ -533,7 +537,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID,componentAppId);
jsonObject.put(ModuleConstant.OPEN_APP_ID,openAppId);
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN, JSON.toJSONString(jsonObject)).getData();
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerRefreshToken, JSON.toJSONString(jsonObject)).getData();
Map<String,String> map = JSON.parseObject(data, Map.class);
CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE)));

6
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java

@ -23,7 +23,7 @@ public interface WxMaCodeConstant {
*/
String API_COMPONENT_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_component_token";
String API_AUTHORIZER_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token";
String API_AUTHORIZER_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token=";
/**
* 授权回调url
@ -48,12 +48,12 @@ public interface WxMaCodeConstant {
/**
* 创建开放平台帐号并绑定公众号/小程序
*/
String API_CREATE_OPEN = "https://api.weixin.qq.com/cgi-bin/open/create";
String API_CREATE_OPEN = "https://api.weixin.qq.com/cgi-bin/open/create?access_token=";
/**
* 公众号/小程序绑定到开放平台帐号下
*/
String API_BIND_OPEN = "https://api.weixin.qq.com/cgi-bin/open/bind?";
String API_BIND_OPEN = "https://api.weixin.qq.com/cgi-bin/open/bind?access_token=";
/**
* 获取授权方的帐号基本信息

Loading…
Cancel
Save