Commit ed0e9e6b authored by 技术部-任文超's avatar 技术部-任文超

修复微信还款/代还的landing资源定位符

parent d23e6a5e
...@@ -270,52 +270,13 @@ public class WeChatController implements IBaseController { ...@@ -270,52 +270,13 @@ 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(); Long registerFrom = null;
String protocol="http:"; String redirect = null;
LOGGER.info("HTTP协议no redirect:" + schema); String schema = "http:";
// 从code获取token if(Objects.equals("https:", request.getScheme())){
Merchant merchant = merchantService.findMerchantByName(systemKey); schema = "https:";
AccessTokenResponse token = wechatService.getToken(code);
if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return;
}
WechatUserInfo userInfo = wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(), token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return;
}
WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
// welcome 首次登录
if (userInfoInDb == null) {
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if (StringUtils.isNotBlank(userInfo.getNickName())) {
String nickName = EmojiUtil.filter(userInfo.getNickName());
userInfo.setNickName(nickName);
}
userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, Constants.Channel.WECHAT,protocol);
return;
}
if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, Constants.Channel.WECHAT,protocol);
return;
}
User user = userService.findById(userInfoInDb.getUserId());
if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, Constants.Channel.WECHAT,protocol);
return;
} }
// 已经关联了用户 receiveCodeWithDefault(code, systemKey, schema, registerFrom, redirect, response);
// create session, 登进去,该怎么玩怎么玩。
String redirectUrl = createUserSession(user, merchant, "", schema, Constants.Channel.WECHAT);
LOGGER.info("Location=[{}]", redirectUrl);
response.setHeader("Location", redirectUrl);
response.setStatus(301);
} }
private String createUserSession(User user, Merchant merchant, String redirect, String domain, Long registerFrom) { private String createUserSession(User user, Merchant merchant, String redirect, String domain, Long registerFrom) {
......
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