| | |
| | | package com.yeshi.fanli.service.impl.user.vip;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Collections;
|
| | | import java.util.Comparator;
|
| | | import java.util.Date;
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.yeshi.fanli.dao.mybatis.user.vip.UserVIPPreInfoMapper;
|
| | | import com.yeshi.fanli.dto.msg.MsgAccountVipDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserLevelChangedMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoRegister;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteValidNum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelUpgradedNotify;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
|
| | | import com.yeshi.fanli.entity.integral.IntegralDetail;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPPreInfoException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInviteSeparateService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoRegisterService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | 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.MsgAccountDetailService;
|
| | | 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.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | 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 {
|
| | |
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private MsgAccountDetailService msgAccountDetailService;
|
| | | |
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInviteValidNumService userInviteValidNumService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | | @Resource
|
| | | private IntegralDetailService integralDetailService;
|
| | | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Lazy
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | | |
| | | @Resource
|
| | | private UserInviteSeparateService userInviteSeparateService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserOtherMsgNotificationService userOtherMsgNotificationService;
|
| | |
|
| | | @Resource
|
| | | private UserAccountMsgNotificationService userAccountMsgNotificationService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoRegisterService userInfoRegisterService;
|
| | |
|
| | | @Resource
|
| | | private UserInviteMsgNotificationService userInviteMsgNotificationService;
|
| | |
|
| | | @Resource
|
| | | private UserLevelUpgradedNotifyService userLevelUpgradedNotifyService;
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | @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
|
| | |
| | | return null;
|
| | |
|
| | | Comparator<UserVIPPreInfo> cm = new Comparator<UserVIPPreInfo>() {
|
| | |
|
| | | @Override
|
| | | public int compare(UserVIPPreInfo o1, UserVIPPreInfo o2) {
|
| | | return o2.getProcess() - o1.getProcess();
|
| | |
| | | Collections.sort(infoList, cm);
|
| | | return infoList.get(0);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public UserVIPPreInfo getVipByProcess(Long uid, int process){
|
| | | public UserVIPPreInfo getVipByProcess(Long uid, int process) {
|
| | | return userVIPPreInfoMapper.selectByUidAndProcess(uid, process);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public UserVIPPreInfo getProcessInfo(Long uid, Date time) {
|
| | |
| | | if (infoList == null || infoList.size() == 0)
|
| | | return null;
|
| | | Comparator<UserVIPPreInfo> cm = new Comparator<UserVIPPreInfo>() {
|
| | |
|
| | | @Override
|
| | | public int compare(UserVIPPreInfo o1, UserVIPPreInfo o2) {
|
| | | return o2.getProcess() - o1.getProcess();
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void upgradeVipByMyOrder(Long uid) {
|
| | | UserVIPPreInfo latest = getLatestProcessInfo(uid);
|
| | | if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_2) {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (latest == null) {
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | return; // 未激活邀请码
|
| | | }
|
| | | }
|
| | |
|
| | | // 自购+ 分享订单到账
|
| | | long doneZiGou = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY);
|
| | | // 高级会员限制条件
|
| | | long limitZiGou7 = 0;
|
| | | String zigou7 = userVipConfigService.getValueByKey("vip_pre_7_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(zigou7)) {
|
| | | limitZiGou7 = Long.parseLong(zigou7);
|
| | | }
|
| | | // 验证是否满足升级高级会员
|
| | | if (doneZiGou >= limitZiGou7) {
|
| | | try {
|
| | | twoProcess(uid, limitZiGou7, null, false);
|
| | | } catch (UserVIPPreInfoException e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void verifyVipPreInfo(Long uid, boolean inviteSuccess) {
|
| | | if (uid == null || uid <= 0)
|
| | | return;
|
| | |
|
| | | verifyCondition(uid);
|
| | |
|
| | | // 验证上级
|
| | | if (inviteSuccess) {
|
| | | UserInfo boss = threeSaleSerivce.getBoss(uid);
|
| | | if (boss != null) {
|
| | | verifyVipPreInfoBoss(boss.getId());
|
| | | }
|
| | | }
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void upgradeVipByTeamNum(Long uid) {
|
| | | vipTeamVerify(uid);
|
| | | }
|
| | |
|
| | | // 上级验证
|
| | | private void verifyVipPreInfoBoss(Long uid) {
|
| | | if (uid == null || uid <= 0)
|
| | | @Override
|
| | | @RequestSerializableByKeyService(key = "#tid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void upgradeBossVipByTeamNum(Long tid) {
|
| | | UserInfo boss = threeSaleSerivce.getBoss(tid);
|
| | | if (boss == null) {
|
| | | return;
|
| | |
|
| | | verifyCondition(uid);
|
| | | }
|
| | |
|
| | | private void verifyCondition(Long uid) {
|
| | | try {
|
| | | // 验证二阶段
|
| | | UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(uid, UserVIPPreInfo.PROCESS_2);
|
| | | if (oldInfo != null) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 自购订单
|
| | | long doneZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | HongBaoV2.TYPE_ZIGOU);
|
| | | // 分享订单
|
| | | long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | HongBaoV2.TYPE_SHARE_GOODS);
|
| | | |
| | | // 有效粉丝
|
| | | int doneFirst = 0;
|
| | | int doneSecond = 0;
|
| | | UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
|
| | | if (userInviteValidNum != null) {
|
| | | doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
|
| | | doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
|
| | | }
|
| | |
|
| | | // 一阶段
|
| | | boolean process1 = oneProcess(uid, doneZiGou, doneShare, doneFirst, doneSecond);
|
| | | if (!process1) {
|
| | | return;
|
| | | }
|
| | |
|
| | | // 二阶段
|
| | | twoProcess(uid, doneZiGou, doneShare, doneFirst, doneSecond);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | vipTeamVerify(boss.getId());
|
| | | }
|
| | |
|
| | | /**
|
| | | * 一阶段
|
| | | * |
| | | * 验证用户是否满足升级队员条件
|
| | | * @param uid
|
| | | * @param countZiGou
|
| | | * @param countShare
|
| | | * @param firstTeam
|
| | | * @param secondTeam
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private boolean oneProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) {
|
| | | boolean process = false;
|
| | | String msg = "";
|
| | | |
| | | long limitZiGou = 0;
|
| | | String zigou = userVipConfigService.getValueByKey("vip_pre_3_zigou_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(zigou)) {
|
| | | limitZiGou = Long.parseLong(zigou);
|
| | | }
|
| | | |
| | | long limitShare = 0;
|
| | | String share = userVipConfigService.getValueByKey("vip_pre_3_share_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(share)) {
|
| | | limitShare = Long.parseLong(share);
|
| | | }
|
| | | |
| | | long limitFirst = 0;
|
| | | String first = userVipConfigService.getValueByKey("vip_pre_3_first_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(first)) {
|
| | | limitFirst = Long.parseLong(first);
|
| | | }
|
| | | |
| | | long limitSecond = 0;
|
| | | String second = userVipConfigService.getValueByKey("vip_pre_3_second_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(second)) {
|
| | | limitSecond = Long.parseLong(second);
|
| | | }
|
| | | |
| | | if (countZiGou >= limitZiGou) {
|
| | | process = true;
|
| | | msg = "恭喜你!返利订单达到 " + limitZiGou + "笔";
|
| | | } else if (countShare >= limitShare) {
|
| | | process = true;
|
| | | msg = "恭喜你!分享订单达到 " + limitShare + "笔";
|
| | | } else if (firstTeam >= limitFirst && secondTeam >= limitSecond) {
|
| | | process = true;
|
| | | msg = "直接粉丝达到" + limitFirst + "人,间接粉丝达到 " + limitSecond + "人";
|
| | | private void vipTeamVerify(Long uid) {
|
| | | UserVIPPreInfo latest = getLatestProcessInfo(uid);
|
| | | if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_2) {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (process) {
|
| | | // 有效粉丝
|
| | | int doneFirst = 0;
|
| | | int doneSecond = 0;
|
| | | UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
|
| | | if (userInviteValidNum != null) {
|
| | | doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
|
| | | doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
|
| | | }
|
| | |
|
| | | 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 {
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | | info.setUid(uid);
|
| | | info.setProcess(UserVIPPreInfo.PROCESS_1);
|
| | | info.setCreateTime(new Date());
|
| | | info.setUpdateTime(new Date());
|
| | | addUserVIPPreInfo(info);
|
| | |
|
| | | // 消息
|
| | | MsgAccountVipDTO msgDto = new MsgAccountVipDTO();
|
| | | msgDto.setStatus("系统已将你的账户由快省达人升级为普通会员");
|
| | | msgDto.setEquity("从收到本消息起,你将获得全部普通会员权益");
|
| | | msgAccountDetailService.addMsgVIP(uid, msg, "如有疑问请联系我的-人工客服", msgDto);
|
| | | |
| | | |
| | | // 赠送金币
|
| | | String goldcoin = userVipConfigService.getValueByKey("vip_pre_3_gift_goldcoin");
|
| | | if (!StringUtil.isNullOrEmpty(goldcoin)) {
|
| | | // 添加金币明细
|
| | | IntegralDetail detail = new IntegralDetail();
|
| | | detail.setTitle("升级VIP福利");
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(Integer.parseInt(goldcoin));
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUniqueKey("VIP-3-" + uid);
|
| | | integralDetailService.insertSelective(detail);
|
| | | |
| | | // 添加金币
|
| | | userInfoExtraService.addGoldCoinByUid(uid, Integer.parseInt(goldcoin));
|
| | | |
| | | //TODO 消息
|
| | | }
|
| | | |
| | | // 是否存在下级脱离期限 -更新不脱离
|
| | | userInviteSeparateService.updateInvalidByBossId(uid);
|
| | | |
| | | // 上级脱离关系
|
| | | remindBoss(uid);
|
| | | |
| | | twoProcess(uid, limitFirst7, limitSecond7, true);
|
| | | } catch (UserVIPPreInfoException e) {
|
| | | e.printStackTrace();
|
| | |
|
| | | }
|
| | | }
|
| | | return process;
|
| | | }
|
| | |
|
| | | |
| | | private void remindBoss(Long uid) {
|
| | | // 是否存在上级
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale == null)
|
| | | return;
|
| | | |
| | | Long bossId = threeSale.getBoss().getId();
|
| | | // 验证上级是否已是会员
|
| | | UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(bossId, UserVIPPreInfo.PROCESS_1);
|
| | | if (oldInfo != null) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 添加脱离关系倒计时
|
| | | userInviteSeparateService.addPreSeparateRecord(uid, bossId);
|
| | | |
| | | // TODO 消息
|
| | | |
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 二阶段
|
| | | *
|
| | |
| | | * @param secondTeam
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private boolean twoProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) {
|
| | | boolean process = false;
|
| | | String msg = "";
|
| | | |
| | | long limitZiGou = 0;
|
| | | String zigou = userVipConfigService.getValueByKey("vip_pre_7_zigou_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(zigou)) {
|
| | | limitZiGou = Long.parseLong(zigou);
|
| | | }
|
| | | |
| | | long limitShare = 0;
|
| | | String share = userVipConfigService.getValueByKey("vip_pre_7_share_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(share)) {
|
| | | limitShare = Long.parseLong(share);
|
| | | }
|
| | | |
| | | long limitFirst = 0;
|
| | | String first = userVipConfigService.getValueByKey("vip_pre_7_first_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(first)) {
|
| | | limitFirst = Long.parseLong(first);
|
| | | }
|
| | | |
| | | long limitSecond = 0;
|
| | | String second = userVipConfigService.getValueByKey("vip_pre_7_second_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(second)) {
|
| | | limitSecond = Long.parseLong(second);
|
| | | }
|
| | | |
| | | if (countZiGou >= limitZiGou) {
|
| | | process = true;
|
| | | msg = "恭喜你!返利订单达到 " + limitZiGou + "笔";
|
| | | } else if (countShare >= limitShare) {
|
| | | process = true;
|
| | | msg = "恭喜你!分享订单达到 " + limitShare + "笔";
|
| | | } else if (firstTeam >= limitFirst && secondTeam >= limitSecond) {
|
| | | process = true;
|
| | | msg = "直接粉丝达到" + limitFirst + "人,间接粉丝达到 " + limitSecond + "人";
|
| | | private void twoProcess(Long uid, long limit1, Long limit2, boolean teamPass) throws UserVIPPreInfoException {
|
| | | String item = null;
|
| | | if (teamPass) {
|
| | | item = "直接+间接粉丝";
|
| | | } else {
|
| | | item = "返利+分享订单";
|
| | | }
|
| | |
|
| | | if (process) {
|
| | | try {
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | | info.setUid(uid);
|
| | | info.setProcess(UserVIPPreInfo.PROCESS_2);
|
| | | info.setCreateTime(new Date());
|
| | | info.setUpdateTime(new Date());
|
| | | addUserVIPPreInfo(info);
|
| | | Date upgradeTime = new Date();
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | | info.setUid(uid);
|
| | | 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);
|
| | |
|
| | | // 消息
|
| | | MsgAccountVipDTO msgDto = new MsgAccountVipDTO();
|
| | | msgDto.setStatus("系统已将你的账户由普通会员升级为高级会员");
|
| | | msgDto.setEquity("从收到本消息起,你将获得全部高级会员权益");
|
| | | msgAccountDetailService.addMsgVIP(uid, msg, "如有疑问请联系我的-人工客服", msgDto);
|
| | | |
| | | // 赠送奖励券
|
| | | String rewardCoupon = userVipConfigService.getValueByKey("vip_pre_7_gift_reward_coupon");
|
| | | if (!StringUtil.isNullOrEmpty(rewardCoupon)) {
|
| | | int num = Integer.parseInt(rewardCoupon);
|
| | | BigDecimal percent = new BigDecimal(configService.get(ConfigKeyEnum.exchangeRebatePercent.getKey()));
|
| | | for (int i = 0; i < num; i++) {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_SYSTEM_PUSH, percent, false);
|
| | | }
|
| | | }
|
| | | |
| | | // TODO 发券消息
|
| | | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.error(e);
|
| | | addUserVIPPreInfo(info);
|
| | |
|
| | | // 升级弹框提示
|
| | | UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
|
| | | notify.setUid(uid);
|
| | | notify.setFromLevel(UserLevelEnum.daRen);
|
| | | notify.setToLevel(UserLevelEnum.highVIP);
|
| | | notify.setValid(true);
|
| | | notify.setCreateTime(new Date());
|
| | | userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
|
| | |
|
| | | try {
|
| | | // 升级消息
|
| | | Date registerTime = new Date(1577836800000L);
|
| | | UserInfoRegister userInfoRegister = userInfoRegisterService.selectByPrimaryKey(uid);
|
| | | if (userInfoRegister != null && userInfoRegister.getCreateTime() != null) {
|
| | | registerTime = userInfoRegister.getCreateTime();
|
| | | }
|
| | | int daysBetween = TimeUtil.getDayDifferenceCount(registerTime, upgradeTime);
|
| | | userAccountMsgNotificationService.vipPreUpgrade(uid, "快省达人", "高级会员", daysBetween, limit1, limit2, teamPass);
|
| | |
|
| | | // 直接粉丝升级提醒
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null) {
|
| | | Long bossId = threeSale.getBoss().getId();
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | userInviteMsgNotificationService.fansUpgrade(bossId, "高级会员", userInfo.getNickName(), item, upgradeTime);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.error(e);
|
| | | }
|
| | | return process;
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserVIPPreInfo selectByUidAndProcess(Long uid, int process) {
|
| | | UserVIPPreInfo info = userVIPPreInfoMapper.selectByUidAndProcess(uid, process);
|
| | | return info;
|
| | | return userVIPPreInfoMapper.selectByUidAndProcess(uid, process);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteByPrimaryKey(Long id) {
|
| | | 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);
|
| | | }
|
| | |
|
| | | }
|