Commit c990b5c6 authored by shiyu's avatar shiyu

兼容多个小程序配置2

parent 89191dca
......@@ -7,7 +7,6 @@ import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.OkHttpUtil;
import com.wwdz.ch.core.util.RedisUtils;
import com.wwdz.ch.db.dto.request.UserRequestDto;
import com.wwdz.ch.db.dto.request.qiandao.QdUserRequestDto;
import com.xxdxxs.utils.JsonUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -52,7 +51,7 @@ public class QdWxLoginManager {
private static final String GET_LINK_URL = "https://api.weixin.qq.com/wxa/genwxashortlink?access_token=%s";
@Resource(name = "qdWxMaService")
private WxMaService wxMaService;
private WxMaService qdWxMaService;
@Autowired
RedisUtils redisUtils;
......@@ -67,7 +66,7 @@ public class QdWxLoginManager {
WxMaJscode2SessionResult result = null;
try {
logger.info(">>>>>>>>> 获取微信openid, 参数loginCode:{}", loginCode);
result = this.wxMaService.getUserService().getSessionInfo(loginCode);
result = this.qdWxMaService.getUserService().getSessionInfo(loginCode);
//实际获取的是unionid,为了和公众号订阅用户关联
logger.info("获取WxMaJscode2SessionResult :{}", result);
logger.info("loginCode:{},获取openId成功 unionid :{}, openid:{}", loginCode, result.getUnionid(), result.getOpenid());
......@@ -109,7 +108,7 @@ public class QdWxLoginManager {
logger.info("开始获取sessionKey-----------------------");
String sessionKey = "";
try {
WxMaJscode2SessionResult result = this.wxMaService.getUserService().getSessionInfo(dto.getLoginCode());
WxMaJscode2SessionResult result = this.qdWxMaService.getUserService().getSessionInfo(dto.getLoginCode());
sessionKey = result.getSessionKey();
logger.info("获取sessionKey结果:" + JSON.toJSONString(result));
} catch (Exception e) {
......@@ -123,7 +122,7 @@ public class QdWxLoginManager {
logger.info("解析手机号加密信息-----------------------");
try {
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = this.wxMaService.getUserService().getPhoneNoInfo(sessionKey, dto.getEncryptedData(), dto.getIv());
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = this.qdWxMaService.getUserService().getPhoneNoInfo(sessionKey, dto.getEncryptedData(), dto.getIv());
logger.info("解析手机号加密信息结果:" + JSON.toJSONString(wxMaPhoneNumberInfo));
phone = wxMaPhoneNumberInfo.getPhoneNumber();
} catch (Exception e) {
......
......@@ -12,14 +12,16 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
@Configuration
public class QdWxConfig {
@Autowired
private QdWxProperties qdWxProperties;
@Bean(name = "qdWxMaConfig")
@Qualifier()
@Bean
@Qualifier("qdWxMaConfig")
public WxMaConfig qdWxMaConfig() {
WxMaInMemoryConfig config = new WxMaInMemoryConfig();
config.setAppid(qdWxProperties.getQdAppId());
......@@ -27,8 +29,9 @@ public class QdWxConfig {
return config;
}
@Bean(name = "qdWxMaService")
public WxMaService qdWxMaService(WxMaConfig qdWxMaConfig) {
@Bean
@Qualifier("qdWxMaService")
public WxMaService qdWxMaService(@Qualifier("qdWxMaConfig") WxMaConfig qdWxMaConfig) {
WxMaService service = new WxMaServiceImpl();
service.setWxMaConfig(qdWxMaConfig);
return service;
......
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