提交代码

master
胡锐 6 days ago
parent d7a62a2d09
commit 9fd569d446
  1. 7
      cweb/src/main/java/com/hfkj/controller/ClientController.java
  2. 7
      cweb/src/main/java/com/hfkj/controller/UserController.java
  3. 16
      service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java

@ -93,8 +93,8 @@ public class ClientController {
Long inviteUseId = body.getLong("inviteUseId"); Long inviteUseId = body.getLong("inviteUseId");
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("appid", "wxa075e8509802f826"); params.put("appid", "wxadc7c8cd025639c6");
params.put("secret", "0e606fc1378d35e359fcf3f15570b2c5"); params.put("secret", "3b11012a83de870c2a81fb52d6427fce");
params.put("code", body.getString("code")); params.put("code", body.getString("code"));
params.put("grant_type", "authorization_code"); params.put("grant_type", "authorization_code");
JSONObject accessToken = HttpsUtils.doGet("https://api.weixin.qq.com/sns/oauth2/access_token", params); JSONObject accessToken = HttpsUtils.doGet("https://api.weixin.qq.com/sns/oauth2/access_token", params);
@ -114,9 +114,8 @@ public class ClientController {
user.setName(userinfo.getString("nickname")); user.setName(userinfo.getString("nickname"));
user.setWechatOpenId(userinfo.getString("openid")); user.setWechatOpenId(userinfo.getString("openid"));
user.setWechatUnionid(userinfo.getString("unionid")); user.setWechatUnionid(userinfo.getString("unionid"));
userService.weChatAuth(user, new HashMap<>(), inviteUseId); return ResponseMsgUtil.success(userService.weChatAuth(user, new HashMap<>(), inviteUseId));
return ResponseMsgUtil.success(userinfo);
} catch (Exception e) { } catch (Exception e) {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }

@ -342,8 +342,8 @@ public class UserController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已绑定过微信"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已绑定过微信");
} }
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("appid", "wxa075e8509802f826"); params.put("appid", "wxadc7c8cd025639c6");
params.put("secret", "0e606fc1378d35e359fcf3f15570b2c5"); params.put("secret", "3b11012a83de870c2a81fb52d6427fce");
params.put("code", body.getString("code")); params.put("code", body.getString("code"));
params.put("grant_type", "authorization_code"); params.put("grant_type", "authorization_code");
JSONObject accessToken = HttpsUtils.doGet("https://api.weixin.qq.com/sns/oauth2/access_token", params); JSONObject accessToken = HttpsUtils.doGet("https://api.weixin.qq.com/sns/oauth2/access_token", params);
@ -358,6 +358,9 @@ public class UserController {
if (userinfo == null || StringUtils.isBlank(userinfo.getString("openid"))) { if (userinfo == null || StringUtils.isBlank(userinfo.getString("openid"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取用户信息失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取用户信息失败");
} }
if (userService.getUserByWechatOpenId(userinfo.getString("openid")) != null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "微信已被绑定,无法重复绑定");
}
BsUser user = userSession.getUser(); BsUser user = userSession.getUser();
user.setWechatOpenId(userinfo.getString("openid")); user.setWechatOpenId(userinfo.getString("openid"));
user.setWechatUnionid(userinfo.getString("unionid")); user.setWechatUnionid(userinfo.getString("unionid"));

@ -295,24 +295,24 @@ public class BsUserServiceImpl implements BsUserService {
bsUser.setWechatUnionid(user.getWechatUnionid()); bsUser.setWechatUnionid(user.getWechatUnionid());
bsUser.setGrade(UserGradeEnum.grade1.getCode()); bsUser.setGrade(UserGradeEnum.grade1.getCode());
bsUser.setStatus(UserStatusEnum.status1.getCode()); bsUser.setStatus(UserStatusEnum.status1.getCode());
editData(user); editData(bsUser);
// 创建账户余额 // 创建账户余额
userAccountService.create(user.getId()); userAccountService.create(bsUser.getId());
} else { } else {
bsUser.setHeadImg(user.getHeadImg()); bsUser.setHeadImg(user.getHeadImg());
bsUser.setName(user.getName()); bsUser.setName(user.getName());
user.setInviteUserId(inviteUseId); bsUser.setInviteUserId(inviteUseId);
user.setInviteTime(new Date()); bsUser.setInviteTime(new Date());
updateInfo(user); updateInfo(bsUser);
} }
// 缓存 // 缓存
UserSessionObject session = new UserSessionObject(); UserSessionObject session = new UserSessionObject();
session.setUser(user); session.setUser(bsUser);
SessionObject sessionObject = new SessionObject(userToken(user.getId()), session); SessionObject sessionObject = new SessionObject(userToken(bsUser.getId()), session);
userCenter.save(sessionObject); userCenter.save(sessionObject);
// 异步记录登录信息 // 异步记录登录信息
userLoginLogService.asyncCreateLog(UserLoginType.WECHAT_AUTH, user, (HttpServletRequest) RequestContextHolder.getRequestAttributes().resolveReference(RequestAttributes.REFERENCE_REQUEST)); userLoginLogService.asyncCreateLog(UserLoginType.WECHAT_AUTH, bsUser, (HttpServletRequest) RequestContextHolder.getRequestAttributes().resolveReference(RequestAttributes.REFERENCE_REQUEST));
return sessionObject; return sessionObject;
} }

Loading…
Cancel
Save