Commit cc2e664d authored by 技术部—现金贷—曾丽宾's avatar 技术部—现金贷—曾丽宾

Merge branch 'baitiao_channel'

# Conflicts:
#	src/main/java/cn/quantgroup/xyqb/controller/external/user/WeChatController.java
parents 47e4eb2b 36975cc9
...@@ -79,6 +79,10 @@ public class WeChatController implements IBaseController { ...@@ -79,6 +79,10 @@ public class WeChatController implements IBaseController {
@Autowired @Autowired
private IHttpService httpService; private IHttpService httpService;
//加https地址
@Value("${xyqb-user.ui-s}")
private String userUIAddrS;
/** /**
* 开发者资质认证,有必要吗? * 开发者资质认证,有必要吗?
* *
...@@ -177,6 +181,8 @@ public class WeChatController implements IBaseController { ...@@ -177,6 +181,8 @@ public class WeChatController implements IBaseController {
extData = ""; extData = "";
} }
String protocol="http";
LOGGER.info("从微信extdata版本接口进入:{}, extData:{}", schema, extData); LOGGER.info("从微信extdata版本接口进入:{}, extData:{}", schema, extData);
if (StringUtils.isEmpty(extData)) { if (StringUtils.isEmpty(extData)) {
// 从code获取token // 从code获取token
...@@ -185,7 +191,7 @@ public class WeChatController implements IBaseController { ...@@ -185,7 +191,7 @@ public class WeChatController implements IBaseController {
AccessTokenResponse token = wechatService.getToken(code); AccessTokenResponse token = wechatService.getToken(code);
if (token == null) { if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url // 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT); redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return; return;
} }
WechatUserInfo userInfo = WechatUserInfo userInfo =
...@@ -193,7 +199,7 @@ public class WeChatController implements IBaseController { ...@@ -193,7 +199,7 @@ public class WeChatController implements IBaseController {
token.getOpenId()); token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) { if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url // 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT); redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return; return;
} }
WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId()); WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
...@@ -206,19 +212,19 @@ public class WeChatController implements IBaseController { ...@@ -206,19 +212,19 @@ public class WeChatController implements IBaseController {
} }
userInfo = wechatService.saveWechatUserInfo(userInfo); userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo,
Constants.Channel.WECHAT); Constants.Channel.WECHAT,protocol);
return; return;
} }
if (userInfoInDb.getUserId() == null) { if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面 // 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT); Constants.Channel.WECHAT,protocol);
return; return;
} }
User user = userService.findById(userInfoInDb.getUserId()); User user = userService.findById(userInfoInDb.getUserId());
if (user == null) { if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT); Constants.Channel.WECHAT,protocol);
return; return;
} }
// 已经关联了用户 // 已经关联了用户
...@@ -241,7 +247,7 @@ public class WeChatController implements IBaseController { ...@@ -241,7 +247,7 @@ public class WeChatController implements IBaseController {
AccessTokenResponse token = wechatService.getToken(code); AccessTokenResponse token = wechatService.getToken(code);
if (token == null) { if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url // 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT); redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return; return;
} }
WechatUserInfo userInfo = WechatUserInfo userInfo =
...@@ -249,7 +255,7 @@ public class WeChatController implements IBaseController { ...@@ -249,7 +255,7 @@ public class WeChatController implements IBaseController {
token.getOpenId()); token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) { if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url // 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT); redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return; return;
} }
WechatUserInfo userInfoInDb = WechatUserInfo userInfoInDb =
...@@ -263,19 +269,19 @@ public class WeChatController implements IBaseController { ...@@ -263,19 +269,19 @@ public class WeChatController implements IBaseController {
} }
userInfo = wechatService.saveWechatUserInfo(userInfo); userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo,
Constants.Channel.WECHAT); Constants.Channel.WECHAT,protocol);
return; return;
} }
if (userInfoInDb.getUserId() == null) { if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面 // 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT); Constants.Channel.WECHAT,protocol);
return; return;
} }
User user = userService.findById(userInfoInDb.getUserId()); User user = userService.findById(userInfoInDb.getUserId());
if (user == null) { if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT); Constants.Channel.WECHAT,protocol);
return; return;
} }
// 已经关联了用户 // 已经关联了用户
...@@ -286,6 +292,9 @@ public class WeChatController implements IBaseController { ...@@ -286,6 +292,9 @@ public class WeChatController implements IBaseController {
response.setStatus(301); response.setStatus(301);
return; return;
} }
protocol = extDataObj.getOrDefault("protocol", "http").toString();
LOGGER.info("从微信登录extData中获得协议信息,protocol:{}", protocol);
Long registerFrom = Long.valueOf(extDataObj.getOrDefault("registerFrom", "1").toString()); Long registerFrom = Long.valueOf(extDataObj.getOrDefault("registerFrom", "1").toString());
String redirect = (String) extDataObj.getOrDefault("redirect", "redirect"); String redirect = (String) extDataObj.getOrDefault("redirect", "redirect");
LOGGER.info("从微信登录,registerFrom:{}, redirect:{}", registerFrom, redirect); LOGGER.info("从微信登录,registerFrom:{}, redirect:{}", registerFrom, redirect);
...@@ -293,7 +302,7 @@ public class WeChatController implements IBaseController { ...@@ -293,7 +302,7 @@ public class WeChatController implements IBaseController {
AccessTokenResponse token = wechatService.getToken(code); AccessTokenResponse token = wechatService.getToken(code);
if (token == null) { if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url // 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, registerFrom); redirectNormalUrl(response, merchant, registerFrom,protocol);
return; return;
} }
WechatUserInfo userInfo = WechatUserInfo userInfo =
...@@ -301,7 +310,7 @@ public class WeChatController implements IBaseController { ...@@ -301,7 +310,7 @@ public class WeChatController implements IBaseController {
token.getOpenId()); token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) { if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url // 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, registerFrom); redirectNormalUrl(response, merchant, registerFrom,protocol);
return; return;
} }
WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId()); WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
...@@ -313,17 +322,17 @@ public class WeChatController implements IBaseController { ...@@ -313,17 +322,17 @@ public class WeChatController implements IBaseController {
userInfo.setNickName(nickName); userInfo.setNickName(nickName);
} }
userInfo = wechatService.saveWechatUserInfo(userInfo); userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, registerFrom); redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, registerFrom,protocol);
return; return;
} }
if (userInfoInDb.getUserId() == null) { if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面 // 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom); redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom,protocol);
return; return;
} }
User user = userService.findById(userInfoInDb.getUserId()); User user = userService.findById(userInfoInDb.getUserId());
if (user == null) { if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom); redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom,protocol);
return; return;
} }
// 已经关联了用户 // 已经关联了用户
...@@ -348,6 +357,7 @@ public class WeChatController implements IBaseController { ...@@ -348,6 +357,7 @@ public class WeChatController implements IBaseController {
@RequestMapping("/receiveCode/{key}") @RequestMapping("/receiveCode/{key}")
public void receiveCodeNoRedirect(String code, @PathVariable(value = "key") String systemKey, HttpServletRequest request, HttpServletResponse response) { public void receiveCodeNoRedirect(String code, @PathVariable(value = "key") String systemKey, HttpServletRequest request, HttpServletResponse response) {
String schema = request.getScheme(); String schema = request.getScheme();
String protocol="http";
LOGGER.info("HTTP协议no redirect:" + schema); LOGGER.info("HTTP协议no redirect:" + schema);
// 从code获取token // 从code获取token
Merchant merchant = merchantService.findMerchantByName(systemKey); Merchant merchant = merchantService.findMerchantByName(systemKey);
...@@ -355,13 +365,13 @@ public class WeChatController implements IBaseController { ...@@ -355,13 +365,13 @@ public class WeChatController implements IBaseController {
AccessTokenResponse token = wechatService.getToken(code); AccessTokenResponse token = wechatService.getToken(code);
if (token == null) { if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url // 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT); redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return; return;
} }
WechatUserInfo userInfo = wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(), token.getOpenId()); WechatUserInfo userInfo = wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(), token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) { if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url // 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT); redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return; return;
} }
WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId()); WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
...@@ -373,17 +383,17 @@ public class WeChatController implements IBaseController { ...@@ -373,17 +383,17 @@ public class WeChatController implements IBaseController {
userInfo.setNickName(nickName); userInfo.setNickName(nickName);
} }
userInfo = wechatService.saveWechatUserInfo(userInfo); userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, Constants.Channel.WECHAT); redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, Constants.Channel.WECHAT,protocol);
return; return;
} }
if (userInfoInDb.getUserId() == null) { if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面 // 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, Constants.Channel.WECHAT); redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, Constants.Channel.WECHAT,protocol);
return; return;
} }
User user = userService.findById(userInfoInDb.getUserId()); User user = userService.findById(userInfoInDb.getUserId());
if (user == null) { if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, Constants.Channel.WECHAT); redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, Constants.Channel.WECHAT,protocol);
return; return;
} }
// 已经关联了用户 // 已经关联了用户
...@@ -428,37 +438,58 @@ public class WeChatController implements IBaseController { ...@@ -428,37 +438,58 @@ public class WeChatController implements IBaseController {
return url + "/landing?token=" + authBean.getToken() + "&registerFrom=" + registerFrom + "&channelId=" + channelId + "&key=" + merchant.getName() + "&target=" + target; return url + "/landing?token=" + authBean.getToken() + "&registerFrom=" + registerFrom + "&channelId=" + channelId + "&key=" + merchant.getName() + "&target=" + target;
} }
private void redirectWechatLoginUrlWithoutLogin(HttpServletResponse response, Merchant merchant, WechatUserInfo userInfo, Long registerFrom) { private void redirectWechatLoginUrlWithoutLogin(HttpServletResponse response, Merchant merchant, WechatUserInfo userInfo, Long registerFrom,String protocol) {
String redirectUrl = assembleWechatRedirectUrl(merchant, userInfo, registerFrom); String redirectUrl = assembleWechatRedirectUrl(merchant, userInfo, registerFrom,protocol);
LOGGER.info("redirectWechatLoginUrlWithoutLogin redirectUrl:[{}]",redirectUrl); LOGGER.info("redirectWechatLoginUrlWithoutLogin redirectUrl:[{}]",redirectUrl);
response.setHeader("Location", redirectUrl); response.setHeader("Location", redirectUrl);
response.setStatus(301); response.setStatus(301);
} }
private void redirectNormalUrl(HttpServletResponse response, Merchant merchant, Long registerFrom) { private void redirectNormalUrl(HttpServletResponse response, Merchant merchant, Long registerFrom,String protocol) {
String redirectUrl = assembleNormalRedirectUrl(merchant, registerFrom); String redirectUrl = assembleNormalRedirectUrl(merchant, registerFrom,protocol);
LOGGER.info("redirectNormalUrl redirectUrl:[{}]",redirectUrl); LOGGER.info("redirectNormalUrl redirectUrl:[{}]",redirectUrl);
response.setHeader("Location", redirectUrl); response.setHeader("Location", redirectUrl);
response.setStatus(301); response.setStatus(301);
} }
private String assembleNormalRedirectUrl(Merchant merchant, Long registerFrom) { private String assembleNormalRedirectUrl(Merchant merchant, Long registerFrom,String protocol) {
String domains=userUIAddr;
if(protocol!=null&&protocol.equals("https")){
domains=userUIAddrS;
}
if ("baitiao".equals(merchant.getName())) { if ("baitiao".equals(merchant.getName())) {
return userUIAddr + "/landing?key=baitiao&target=cashTarget5&channelId=222&registerFrom=198"; if(registerFrom==58l||registerFrom==198l){
return domains + "/landing?key=baitiao&target=cashTarget5&channelId=222&registerFrom="+registerFrom;
}else{
return domains + "/landing?key=baitiao&target=cashTarget5&channelId=222&registerFrom=198";
}
} else if ("wechat-pay".equals(merchant.getName())) { } else if ("wechat-pay".equals(merchant.getName())) {
return userUIAddr + "/landing?key=wechat-pay&target=cashTarget5&channelId=1&page=landing/4&registerFrom" + registerFrom; return domains + "/landing?key=wechat-pay&target=cashTarget5&channelId=1&page=landing/4&registerFrom" + registerFrom;
} else { } else {
return userUIAddr + "/landing?key=xyqb&target=cashTarget4&channelId=1&registerFrom=" + registerFrom; return domains + "/landing?key=xyqb&target=cashTarget4&channelId=1&registerFrom=" + registerFrom;
} }
} }
private String assembleWechatRedirectUrl(Merchant merchant, WechatUserInfo userInfo, Long registerFrom) { private String assembleWechatRedirectUrl(Merchant merchant, WechatUserInfo userInfo, Long registerFrom,String protocol) {
String domains=userUIAddr;
if(protocol!=null&&protocol.equals("https")){
domains=userUIAddrS;
}
if ("baitiao".equals(merchant.getName())) { if ("baitiao".equals(merchant.getName())) {
return userUIAddr + "/landing?key=baitiao&target=cashTarget5&registerFrom=198&channelId=222&isWechat=true&openId=" + userInfo.getOpenId(); if(registerFrom==58l||registerFrom==198l){
return domains + "/landing?key=baitiao&target=cashTarget5&registerFrom=" + registerFrom + "&channelId=222&isWechat=true&openId=" + userInfo.getOpenId();
}else{
return domains + "/landing?key=baitiao&target=cashTarget5&registerFrom=198&channelId=222&isWechat=true&openId=" + userInfo.getOpenId();
}
} else if ("wechat-pay".equals(merchant.getName())) { } else if ("wechat-pay".equals(merchant.getName())) {
return userUIAddr + "/landing?key=wechat-pay&target=cashTarget5&page=landing/4&registerFrom= " + registerFrom + "&channelId=1&isWechat=true&openId=" + userInfo.getOpenId(); return domains + "/landing?key=wechat-pay&target=cashTarget5&page=landing/4&registerFrom= " + registerFrom + "&channelId=1&isWechat=true&openId=" + userInfo.getOpenId();
} else { } else {
return userUIAddr + "/landing?key=xyqb&target=cashTarget4&registerFrom= " + registerFrom + "&channelId=1&isWechat=true&openId=" + userInfo.getOpenId(); return domains + "/landing?key=xyqb&target=cashTarget4&registerFrom= " + registerFrom + "&channelId=1&isWechat=true&openId=" + userInfo.getOpenId();
} }
} }
......
...@@ -71,6 +71,7 @@ xyqb.auth.url=http://192.168.192.206:9001 ...@@ -71,6 +71,7 @@ xyqb.auth.url=http://192.168.192.206:9001
usersys.url=http://localhost:9001 usersys.url=http://localhost:9001
xyqb-user.ui=http://192.168.100.36:7043 xyqb-user.ui=http://192.168.100.36:7043
xyqb-user.ui-s=https://192.168.100.36:7043
wechat.appid=wxcdf6077af8127559 wechat.appid=wxcdf6077af8127559
wechat.secret=16eaec16084d0d9c52d4114f359cc72c wechat.secret=16eaec16084d0d9c52d4114f359cc72c
......
...@@ -36,6 +36,7 @@ jr58.notify.userinfo=http://dk.58.com/customer/quantgroup_user_info ...@@ -36,6 +36,7 @@ jr58.notify.userinfo=http://dk.58.com/customer/quantgroup_user_info
model.quantgroup.url=http://model.quantgroup.cn model.quantgroup.url=http://model.quantgroup.cn
xyqb.auth.url=http://auth.xyqb.com xyqb.auth.url=http://auth.xyqb.com
xyqb-user.ui=http://passport.xyqb.com xyqb-user.ui=http://passport.xyqb.com
xyqb-user.ui-s=https://passport.xyqb.com
#motan protocol #motan protocol
protocol.name=motan protocol.name=motan
protocol.contentLength=1048576 protocol.contentLength=1048576
......
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