| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserInfoExtraMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserRankRecordMapper;
|
| | |
| | | }
|
| | |
|
| | | @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);
|
| | | }
|
| | | }
|
| | | |
| | | @Override
|
| | | public void createUserInfoExtra (Long uid) throws UserInfoExtraException{
|
| | | UserInfoExtra userInfoExtra = userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | if (userInfoExtra != null) {
|
| | | return;
|
| | | } |
| | |
|
| | | return userInfoExtra;
|
| | | userInfoExtra = new UserInfoExtra();
|
| | | userInfoExtra.setUserInfo(new UserInfo(uid));
|
| | | userInfoExtra.setFirstLoginTime(new Date());
|
| | | userInfoExtra.setCreateTime(new Date());
|
| | | userInfoExtra.setUpdateTime(new Date());
|
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public String activateInviteCode(Long uid, String inviteCode) throws UserInfoExtraException{
|
| | | public String activateInviteCode(Long uid, String inviteCode, String platform, String version) throws UserInfoExtraException{
|
| | | if (uid == null || inviteCode == null) {
|
| | | throw new UserInfoExtraException(1, "用户id、邀请码不能为空");
|
| | | }
|
| | |
| | |
|
| | | // 绑定关系
|
| | | try {
|
| | | threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter);
|
| | | threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter, platform, version);
|
| | | } catch (ThreeSaleException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public void activationInviteWX(Long uid, String code) throws UserInfoExtraException{
|
| | | public void activationInviteWX(Long uid, String code, String platform, String version) throws UserInfoExtraException{
|
| | | if (uid == null || code == null) {
|
| | | throw new UserInfoExtraException(1, "用户id、邀请码不能为空");
|
| | | throw new UserInfoExtraException(1, "激活信息不完整");
|
| | | }
|
| | |
|
| | | // 用户信息
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | // 获取微信信息
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinWYUser(code);
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code);
|
| | | if (weiXinUser == null) {
|
| | | throw new UserInfoExtraException(1, "微信授权失败");
|
| | | }
|
| | |
| | | throw new UserInfoExtraException(1, "微信授权失败");
|
| | | }
|
| | |
|
| | | |
| | | // 自动绑定微信
|
| | | UserInfo updateUserInfo = new UserInfo(uid);
|
| | | updateUserInfo.setWxName(weiXinUser.getNickname());
|
| | | updateUserInfo.setWxOpenId(weiXinUser.getOpenid());
|
| | | updateUserInfo.setWxPic(weiXinUser.getHeadimgurl());
|
| | | updateUserInfo.setWxUnionId(weiXinUser.getUnionid());
|
| | | updateUserInfo.setNickName(weiXinUser.getNickname());
|
| | | updateUserInfo.setPortrait(weiXinUser.getHeadimgurl());
|
| | | if (StringUtil.isNullOrEmpty(weiXinUser.getNickname())) {
|
| | | updateUserInfo.setNickName(Constant.systemCommonConfig.getDefaultNickName());
|
| | | // 验证数据
|
| | | String wxUnionIdExist = invitee.getWxUnionId();
|
| | | if (StringUtil.isNullOrEmpty(wxUnionIdExist)) {
|
| | | UserInfo newUser = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid());
|
| | | if (newUser != null) {
|
| | | throw new UserInfoExtraException(1, "此微信已被其他帐号绑定");
|
| | | }
|
| | | |
| | | // 自动绑定微信
|
| | | UserInfo updateUserInfo = new UserInfo(uid);
|
| | | updateUserInfo.setWxOpenId(weiXinUser.getOpenid());
|
| | | updateUserInfo.setWxUnionId(weiXinUser.getUnionid());
|
| | | if (!StringUtil.isNullOrEmpty(weiXinUser.getNickname())) {
|
| | | updateUserInfo.setWxName(weiXinUser.getNickname());
|
| | | updateUserInfo.setNickName(weiXinUser.getNickname());
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(weiXinUser.getHeadimgurl())) {
|
| | | updateUserInfo.setWxPic(weiXinUser.getHeadimgurl());
|
| | | updateUserInfo.setPortrait(weiXinUser.getHeadimgurl());
|
| | | }
|
| | | userInfoService.updateByPrimaryKeySelective(updateUserInfo);
|
| | | |
| | | } else if (!wxUnionId.equals(wxUnionIdExist)){
|
| | | throw new UserInfoExtraException(1, "绑定微信与激活微信不一致");
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(weiXinUser.getHeadimgurl())) {
|
| | | updateUserInfo.setPortrait(Constant.systemCommonConfig.getDefaultPortrait());
|
| | | }
|
| | | userInfoService.updateByPrimaryKeySelective(updateUserInfo);
|
| | |
|
| | |
|
| | |
|
| | | // 邀请人ID -1.5.3新版
|
| | |
| | |
|
| | | // 没有被邀请过
|
| | | if (inviterId == null && threeSale == null) {
|
| | | throw new UserInfoExtraException(1, "微信激活失败");
|
| | | throw new UserInfoExtraException(1, "没有对应的邀请关系");
|
| | | }
|
| | |
|
| | | // 绑定关系
|
| | | try {
|
| | | threeSaleSerivce.bindRelationshipByWX(invitee, inviterId, threeSale);
|
| | | threeSaleSerivce.bindRelationshipByWX(invitee, inviterId, threeSale, platform, version);
|
| | | } catch (ThreeSaleException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | throw new UserInfoExtraException(1, "激活失败");
|
| | | throw new UserInfoExtraException(1, "关系绑定时失败");
|
| | | }
|
| | |
|
| | |
|
| | |
| | | return userInfoExtraMapper.countByRankId(rankId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean isNewUser(Long uid) {
|
| | | boolean isNew = false;
|
| | | if (uid == null) {
|
| | | return isNew;
|
| | | }
|
| | | |
| | | UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | if (extra != null && extra.getFirstLoginTime() != null) {
|
| | | try {
|
| | | int day = DateUtil.daysBetween(extra.getFirstLoginTime(), new Date());
|
| | | if (day <= 15) {
|
| | | isNew = true;
|
| | | }
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | 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();
|
| | | }
|
| | | |
| | | |
| | | }
|