| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public UserInfoExtra updateUserRankByUid(Long uid) throws UserInfoExtraException{
|
| | | public void updateUserRankByUid(Long uid) throws UserInfoExtraException{
|
| | | if (uid == null || uid == 0) {
|
| | | return;
|
| | | }
|
| | |
|
| | | boolean isupdateRank = true;
|
| | |
|
| | |
| | | if (isupdateRank) {
|
| | | updateRank(userInfoExtra);
|
| | | }
|
| | | |
| | | return userInfoExtra;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | return isNew;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public UserRank gerUserRank(Long uid) {
|
| | | if(uid == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | | UserInfoExtra userInfoExtra = userInfoExtraMapper.gerUserRank(uid);
|
| | | if (userInfoExtra == null) {
|
| | | return null;
|
| | | }
|
| | | return userInfoExtra.getUserRank();
|
| | | }
|
| | | |
| | | |
| | | |
| | | @Override
|
| | | public UserInfo getUserByInviteCode(String inviteCode) throws UserInfoExtraException{
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | throw new UserInfoExtraException(1, "邀请码不能为空");
|
| | | }
|
| | | // 邀请人信息
|
| | | UserInfo inviter = userInfoService.getInfoByPhoneOrInviteCode(inviteCode, inviteCode);
|
| | | if (inviter == null) {
|
| | | throw new UserInfoExtraException(1, "上级邀请码不存在");
|
| | | }
|
| | | return inviter;
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public UserInfo getInviterInfo(Long uid, String code) throws UserInfoExtraException{
|
| | | if (code == null) {
|
| | | throw new UserInfoExtraException(1, "code信息不完整");
|
| | | }
|
| | | |
| | | // 用户信息
|
| | | UserInfo invitee = userInfoService.selectByPKey(uid);
|
| | | if (invitee == null) {
|
| | | throw new UserInfoExtraException(1, "用户不存在");
|
| | | }
|
| | | |
| | | // 用户额外信息
|
| | | UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | if (extra != null) {
|
| | | String inviteCodeHas = extra.getInviteCode();
|
| | | if (inviteCodeHas != null && inviteCodeHas.trim().length() > 0) {
|
| | | throw new UserInfoExtraException(1, "已经激活, 无需再次激活");
|
| | | }
|
| | | }
|
| | | |
| | | // 获取微信信息
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code);
|
| | | if (weiXinUser == null) {
|
| | | throw new UserInfoExtraException(1, "微信授权失败");
|
| | | }
|
| | | String wxUnionId = weiXinUser.getUnionid();
|
| | | if (wxUnionId == null || wxUnionId.trim().length() == 0) {
|
| | | throw new UserInfoExtraException(1, "微信授权失败");
|
| | | }
|
| | | |
| | | // 验证数据
|
| | | String wxUnionIdExist = invitee.getWxUnionId();
|
| | | if (StringUtil.isNullOrEmpty(wxUnionIdExist)) {
|
| | | UserInfo newUser = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid());
|
| | | if (newUser != null) {
|
| | | throw new UserInfoExtraException(1, "此微信已被其他帐号绑定");
|
| | | }
|
| | | } else if (!wxUnionId.equals(wxUnionIdExist)){
|
| | | throw new UserInfoExtraException(1, "绑定微信与激活微信不一致");
|
| | | }
|
| | | |
| | | // 邀请人ID
|
| | | Long inviterId = userInviteRecordService.getNewestInviterId(wxUnionId);
|
| | | if (inviterId == null) {
|
| | | throw new UserInfoExtraException(1, "没有对应的邀请关系");
|
| | | }
|
| | | |
| | | UserInfo inviter = userInfoService.selectByPKey(inviterId);
|
| | | if (inviter == null) {
|
| | | throw new UserInfoExtraException(1, "对应的邀请关系不存在");
|
| | | }
|
| | | return inviter;
|
| | | }
|
| | | }
|