| | |
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService;
|
| | | import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserLevelUpgradedNotifyService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
|
| | |
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | |
|
| | | @Service
|
| | | public class UserVIPPreInfoServiceImpl implements UserVIPPreInfoService {
|
| | |
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Resource
|
| | | private TeamUserLevelStatisticService teamUserLevelStatisticService;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addUserVIPPreInfo(UserVIPPreInfo info) throws UserVIPPreInfoException {
|
| | | if (info == null || info.getUid() == null || info.getProcess() == null)
|
| | | if (info == null || info.getUid() == null || info.getProcess() == null || info.getSourceType() == null)
|
| | | throw new UserVIPPreInfoException(1, "信息不完整");
|
| | | for (Long fuid : Constant.NO_UPGRADE_UIDS) {// 禁止不能升级的用户升级
|
| | | if (info.getUid().longValue() == fuid)
|
| | | throw new UserVIPPreInfoException(100, "禁止升级");
|
| | | }
|
| | |
|
| | | UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(info.getUid(), info.getProcess());
|
| | | if (oldInfo != null)
|
| | | throw new UserVIPPreInfoException(2, "进度已存在");
|
| | | if (info.getCreateTime() == null)
|
| | | info.setCreateTime(new Date());
|
| | |
|
| | | UserVIPPreInfo old = getLatestProcessInfo(info.getUid());
|
| | |
|
| | | userVIPPreInfoMapper.insertSelective(info);
|
| | | // 设置统计数据
|
| | | teamUserLevelStatisticService.setUserLevel(info.getUid(), UserLevelUtil.getByLevel(info.getProcess()));
|
| | |
|
| | | // 发送等级变化消息
|
| | | if (!Constant.IS_TEST) {
|
| | | UserLevelEnum oldLevel = null;
|
| | | if (old == null)
|
| | | oldLevel = UserLevelEnum.daRen;
|
| | | else {
|
| | | oldLevel = UserLevelUtil.getByLevel(old.getProcess());
|
| | | }
|
| | |
|
| | | if (oldLevel == UserLevelEnum.normalVIP)
|
| | | oldLevel = UserLevelEnum.daRen;
|
| | |
|
| | | UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(info.getUid(), oldLevel,
|
| | | UserLevelUtil.getByLevel(info.getProcess()), new Date());
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg);
|
| | | producer.send(message);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | // 验证是否满足升级高级会员
|
| | | if (doneZiGou >= limitZiGou7) {
|
| | | try {
|
| | | twoProcess(uid, limitZiGou7, null);
|
| | | twoProcess(uid, limitZiGou7, null, false);
|
| | | } catch (UserVIPPreInfoException e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void upgradeVipByTeamNum(Long uid) {
|
| | | vipTeamVerify(uid);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @RequestSerializableByKeyService(key = "#tid")
|
| | |
| | | vipTeamVerify(boss.getId());
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 验证用户是否满足升级队员条件
|
| | | * @param uid
|
| | |
| | |
|
| | | long limitFirst7 = 0;
|
| | | String first7 = userVipConfigService.getValueByKey("vip_pre_7_first_level_team_count");
|
| | | if (Constant.IS_TEST)
|
| | | first7 = "30";
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(first7)) {
|
| | | limitFirst7 = Long.parseLong(first7);
|
| | | }
|
| | |
|
| | | long limitSecond7 = 0;
|
| | | String second7 = userVipConfigService.getValueByKey("vip_pre_7_second_level_team_count");
|
| | | if (Constant.IS_TEST)
|
| | | second7 = "30";
|
| | | if (!StringUtil.isNullOrEmpty(second7)) {
|
| | | limitSecond7 = Long.parseLong(second7);
|
| | | }
|
| | |
| | | // 验证是否满足升级高级会员
|
| | | if (doneFirst >= limitFirst7 && doneSecond >= limitSecond7) {
|
| | | try {
|
| | | twoProcess(uid, limitFirst7, limitSecond7);
|
| | | twoProcess(uid, limitFirst7, limitSecond7, true);
|
| | | } catch (UserVIPPreInfoException e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 二阶段
|
| | | *
|
| | |
| | | * @param secondTeam
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private void twoProcess(Long uid, long limit1, Long limit2) throws UserVIPPreInfoException {
|
| | | private void twoProcess(Long uid, long limit1, Long limit2, boolean teamPass) throws UserVIPPreInfoException {
|
| | | String item = null;
|
| | | if (limit2 == null) {
|
| | | item = "返利+分享订单";
|
| | | } else {
|
| | | if (teamPass) {
|
| | | item = "直接+间接粉丝";
|
| | | } else {
|
| | | item = "返利+分享订单";
|
| | | }
|
| | |
|
| | | Date upgradeTime = new Date();
|
| | |
| | | info.setProcess(UserVIPPreInfo.PROCESS_2);
|
| | | info.setCreateTime(upgradeTime);
|
| | | info.setUpdateTime(upgradeTime);
|
| | | if (teamPass)
|
| | | info.setSourceType(UserVIPPreInfo.SOURCE_TYPE_TEAM);
|
| | | else
|
| | | info.setSourceType(UserVIPPreInfo.SOURCE_TYPE_ORDER);
|
| | |
|
| | | addUserVIPPreInfo(info);
|
| | |
|
| | | // 升级弹框提示
|
| | |
| | | registerTime = userInfoRegister.getCreateTime();
|
| | | }
|
| | | int daysBetween = TimeUtil.getDayDifferenceCount(registerTime, upgradeTime);
|
| | | userAccountMsgNotificationService.vipPreUpgrade(uid, "快省达人", "高级会员", daysBetween, limit1, limit2);
|
| | | userAccountMsgNotificationService.vipPreUpgrade(uid, "快省达人", "高级会员", daysBetween, limit1, limit2, teamPass);
|
| | |
|
| | | // 直接粉丝升级提醒
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | |
| | | LogHelper.error(e);
|
| | | }
|
| | |
|
| | | if (!Constant.IS_TEST) {
|
| | | UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(uid, UserLevelEnum.daRen, UserLevelEnum.highVIP,
|
| | | new Date());
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg);
|
| | | producer.send(message);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | userVIPPreInfoMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<UserVIPPreInfo> listByProcess(int process, Date minTime, Date maxTime, int page, int pageSize) {
|
| | | return userVIPPreInfoMapper.listByProcess(process, minTime, maxTime, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByProcess(int process, Date minTime, Date maxTime) {
|
| | | return userVIPPreInfoMapper.countByProcess(process, minTime, maxTime);
|
| | | }
|
| | |
|
| | | }
|