| | |
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserRank;
|
| | | import com.yeshi.fanli.entity.bus.user.UserRankRecord;
|
| | | import com.yeshi.fanli.exception.ThreeSaleException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserRankService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.vo.user.UserInfoExtraVO;
|
| | |
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | | |
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | | |
| | |
|
| | | @Override
|
| | | public UserInfoExtraVO getRankInfo(Long uid) throws UserInfoExtraException, Exception {
|
| | |
| | | throw new UserInfoExtraException(1, "用户附加信息不存在");
|
| | | }
|
| | |
|
| | | // 等级列表
|
| | | List<UserRank> listRank = userRankService.getAllRank();
|
| | | if (listRank == null || listRank.size() == 0) {
|
| | | throw new UserInfoExtraException(1, "系统等级不存在");
|
| | | }
|
| | | extraVO.setListRank(listRank);
|
| | |
|
| | | // 等级对照表
|
| | | String contrast = configService.get("user_rank_contrast");
|
| | | extraVO.setRankContrast(contrast);
|
| | | // 特别提醒
|
| | | String rankTip = configService.get("user_rank_tip");
|
| | | extraVO.setRankTip(rankTip);
|
| | |
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | return userInfoExtra;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public String activateInviteCode(Long uid, String inviteCode) throws UserInfoExtraException{
|
| | | if (uid == null || inviteCode == null) {
|
| | | throw new UserInfoExtraException(1, "用户id、邀请码不能为空");
|
| | | }
|
| | | |
| | | // 被邀请人信息
|
| | | UserInfo invitee = userInfoService.selectByPKey(uid);
|
| | | if (invitee == null) {
|
| | | throw new UserInfoExtraException(1, "用户不存在");
|
| | | }
|
| | | |
| | | // 邀请人信息
|
| | | UserInfo inviter = userInfoService.getInfoByPhoneOrInviteCode(inviteCode, inviteCode);
|
| | | if (inviter == null) {
|
| | | throw new UserInfoExtraException(1, "请输入有效的邀请码");
|
| | | }
|
| | | |
| | | // 绑定关系
|
| | | try {
|
| | | threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter);
|
| | | } catch (ThreeSaleException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | throw new UserInfoExtraException(1, "激活失败");
|
| | | }
|
| | | |
| | | |
| | | // 邀请码有效、生成邀请码
|
| | | String code = UserUtil.getInviteCode(uid); |
| | | if (code == null || code.trim().length() == 0) {
|
| | | throw new UserInfoExtraException(1, "激活码生成失败");
|
| | | }
|
| | | |
| | | UserInfoExtra userInfoExtra = new UserInfoExtra();
|
| | | userInfoExtra.setUserInfo(invitee);
|
| | | userInfoExtra.setInviteCode(code);
|
| | | |
| | | // 保存额外信息
|
| | | saveUserInfoExtra(userInfoExtra);
|
| | | |
| | | |
| | | Long id = userInfoExtra.getId();
|
| | | if (id == null) {
|
| | | throw new UserInfoExtraException(1, "激活码生成失败");
|
| | | }
|
| | | |
| | | return code;
|
| | | }
|
| | | |
| | | @Override
|
| | | public UserInfoExtra getUserInfoExtra(Long uid) {
|
| | | return userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | }
|
| | | |
| | | @Override
|
| | | public String getUserInviteCode(Long uid) throws UserInfoExtraException {
|
| | | |
| | | UserInfoExtra userInfoExtra = userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | if (userInfoExtra == null) {
|
| | | userInfoExtra = new UserInfoExtra();
|
| | | }
|
| | | |
| | | // 邀请码
|
| | | String inviteCode = userInfoExtra.getInviteCode();
|
| | | |
| | | if (inviteCode == null || inviteCode.trim().length() == 0) {
|
| | | // 判断用户
|
| | | int relationshipNum = threeSaleSerivce.getSuccessRelationshipNum(uid);
|
| | | |
| | | if (relationshipNum > 0) {
|
| | | // 邀请码有效、生成邀请码
|
| | | inviteCode = UserUtil.getInviteCode(uid); |
| | | if (inviteCode == null || inviteCode.trim().length() == 0) {
|
| | | throw new UserInfoExtraException(1, "激活码生成失败");
|
| | | }
|
| | | |
| | | // 保存邀请码
|
| | | userInfoExtra.setUserInfo(new UserInfo(uid));
|
| | | userInfoExtra.setInviteCode(inviteCode);
|
| | | // 保存附加信息
|
| | | saveUserInfoExtra(userInfoExtra);
|
| | | }
|
| | | }
|
| | | |
| | | return inviteCode;
|
| | | }
|
| | | |
| | | }
|