| | |
| | | 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 org.yeshi.utils.DateUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserLevelUpgradedNotifyService userLevelUpgradedNotifyService;
|
| | | |
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | |
|
| | | @Override
|
| | | public void addUserVIPPreInfo(UserVIPPreInfo info) throws UserVIPPreInfoException {
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void upgradeVipByFanLiOrder(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.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, HongBaoV2.TYPE_ZIGOU);
|
| | | // 高级会员限制条件
|
| | | long limitZiGou7 = 0;
|
| | | String zigou7 = userVipConfigService.getValueByKey("vip_pre_7_zigou_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(zigou7)) {
|
| | | limitZiGou7 = Long.parseLong(zigou7);
|
| | | }
|
| | | |
| | | // 验证是否满足升级高级会员
|
| | | if (doneZiGou >= limitZiGou7) {
|
| | | twoProcess(uid, limitZiGou7, null, Constant.TYPE_REBATE);
|
| | | return;
|
| | | } |
| | | |
| | | // 已经成为普通会员
|
| | | if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_1) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 普通会员条件
|
| | | long limitZiGou3 = 0;
|
| | | String zigou3 = userVipConfigService.getValueByKey("vip_pre_3_zigou_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(zigou3)) {
|
| | | limitZiGou3 = Long.parseLong(zigou3);
|
| | | }
|
| | | if (doneZiGou >= limitZiGou3) {
|
| | | oneProcess(uid, limitZiGou3, null, Constant.TYPE_REBATE);
|
| | | } |
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void verifyVipPreInfo(Long uid, boolean inviteSuccess) {
|
| | | if (uid == null || uid <= 0)
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void upgradeVipByShareOrder(Long uid) {
|
| | | UserVIPPreInfo latest = getLatestProcessInfo(uid);
|
| | | if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_2) {
|
| | | return;
|
| | |
|
| | | verifyCondition(uid);
|
| | |
|
| | | // 验证上级
|
| | | if (inviteSuccess) {
|
| | | UserInfo boss = threeSaleSerivce.getBoss(uid);
|
| | | if (boss != null) {
|
| | | verifyVipPreInfoBoss(boss.getId());
|
| | | }
|
| | | |
| | | if (latest == null) {
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | return; //未激活邀请码
|
| | | }
|
| | | } |
| | | |
| | | // 分享订单已到账
|
| | | long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | HongBaoV2.TYPE_SHARE_GOODS);
|
| | | // 高级会员限制条件
|
| | | long limitShare7 = 0;
|
| | | String share7 = userVipConfigService.getValueByKey("vip_pre_7_share_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(share7)) {
|
| | | limitShare7 = Long.parseLong(share7);
|
| | | }
|
| | | |
| | | // 验证是否满足升级高级会员
|
| | | if (doneShare >= limitShare7) {
|
| | | twoProcess(uid, limitShare7, null, Constant.TYPE_SHAER);
|
| | | return;
|
| | | } |
| | | |
| | | // 已经成为普通会员
|
| | | if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_1) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 普通会员条件
|
| | | long limitShare3 = 0;
|
| | | String share3 = userVipConfigService.getValueByKey("vip_pre_3_share_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(share3)) {
|
| | | limitShare3 = Long.parseLong(share3);
|
| | | }
|
| | | if (doneShare >= limitShare3) {
|
| | | oneProcess(uid, limitShare3, null, Constant.TYPE_SHAER);
|
| | | } |
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @RequestSerializableByKeyService(key = "#tid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void upgradeVipByTeamNum(Long tid) {
|
| | | UserInfo boss = threeSaleSerivce.getBoss(tid);
|
| | | if (boss == null) {
|
| | | return;
|
| | | }
|
| | | Long bossId = boss.getId();
|
| | | |
| | | // 验证上上级 -间接粉丝是否满足
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | upgradeVipByTeamNum(bossId);
|
| | | }
|
| | | });
|
| | | |
| | | UserVIPPreInfo latest = getLatestProcessInfo(bossId);
|
| | | if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_2) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 有效粉丝
|
| | | int doneFirst = 0;
|
| | | int doneSecond = 0;
|
| | | UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(bossId);
|
| | | 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 (!StringUtil.isNullOrEmpty(first7)) {
|
| | | limitFirst7 = Long.parseLong(first7);
|
| | | }
|
| | | long limitSecond7 = 0;
|
| | | String second7 = userVipConfigService.getValueByKey("vip_pre_7_second_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(second7)) {
|
| | | limitSecond7 = Long.parseLong(second7);
|
| | | }
|
| | | |
| | | // 验证是否满足升级高级会员
|
| | | if (doneFirst >= limitFirst7 && doneSecond >= limitSecond7) {
|
| | | twoProcess(bossId, limitFirst7, limitSecond7, null);
|
| | | return;
|
| | | }
|
| | |
|
| | | // 已经成为普通会员
|
| | | if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_1) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 普通会员 条件
|
| | | long limitFirst3 = 0;
|
| | | String first = userVipConfigService.getValueByKey("vip_pre_3_first_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(first)) {
|
| | | limitFirst3 = Long.parseLong(first);
|
| | | }
|
| | | |
| | | long limitSecond3 = 0;
|
| | | String second = userVipConfigService.getValueByKey("vip_pre_3_second_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(second)) {
|
| | | limitSecond3 = Long.parseLong(second);
|
| | | }
|
| | | |
| | | if (doneFirst >= limitFirst3 && doneSecond >= limitSecond3) {
|
| | | oneProcess(bossId, limitFirst3, limitSecond3, null);
|
| | | }
|
| | | }
|
| | |
|
| | | // 上级验证
|
| | | private void verifyVipPreInfoBoss(Long uid) {
|
| | | if (uid == null || uid <= 0)
|
| | | 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);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | |
| | | |
| | | /**
|
| | | * 一阶段
|
| | | *
|
| | |
| | | * @param secondTeam
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private boolean oneProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) throws Exception{
|
| | | UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(uid, UserVIPPreInfo.PROCESS_1);
|
| | | if (oldInfo != null) {
|
| | | return true;
|
| | | }
|
| | | |
| | | 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);
|
| | | }
|
| | | |
| | | String item = "";
|
| | | Integer type = null;
|
| | | long targetNum1 = 0L;
|
| | | Long targetNum2 = 0L;
|
| | | boolean process = false;
|
| | | if (countZiGou >= limitZiGou) {
|
| | | process = true;
|
| | | type = Constant.TYPE_REBATE;
|
| | | targetNum1 = limitZiGou;
|
| | | item = "返利订单";
|
| | | } else if (countShare >= limitShare) {
|
| | | process = true;
|
| | | type = Constant.TYPE_SHAER;
|
| | | targetNum1 = limitShare;
|
| | | item = "分享订单";
|
| | | } else if (firstTeam >= limitFirst && secondTeam >= limitSecond) {
|
| | | process = true;
|
| | | targetNum1 = limitFirst;
|
| | | targetNum2 = limitSecond;
|
| | | item = "邀请粉丝";
|
| | | }
|
| | |
|
| | | if (process) {
|
| | | try {
|
| | | Date upgradeTime = new Date();
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | | info.setUid(uid);
|
| | | info.setProcess(UserVIPPreInfo.PROCESS_1);
|
| | | info.setCreateTime(upgradeTime);
|
| | | info.setUpdateTime(upgradeTime);
|
| | | addUserVIPPreInfo(info);
|
| | |
|
| | | // 升级消息
|
| | | Date registerTime = new Date(1577836800000L);
|
| | | UserInfoRegister userInfoRegister = userInfoRegisterService.selectByPrimaryKey(uid);
|
| | | if (userInfoRegister != null && userInfoRegister.getCreateTime() != null) {
|
| | | registerTime = userInfoRegister.getCreateTime();
|
| | | }
|
| | | int daysBetween = DateUtil.daysBetween(registerTime, new Date());
|
| | | userAccountMsgNotificationService.vipPreUpgrade(uid, "快省达人", "普通会员", daysBetween, targetNum1, targetNum2, type);
|
| | | |
| | | |
| | | // 升级弹框提示
|
| | | UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
|
| | | notify.setUid(uid);
|
| | | notify.setFromLevel(UserLevelEnum.daRen);
|
| | | notify.setToLevel(UserLevelEnum.normalVIP);
|
| | | notify.setValid(true);
|
| | | notify.setCreateTime(new Date());
|
| | | userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
|
| | | |
| | | // 赠送金币
|
| | | String goldcoin = userVipConfigService.getValueByKey("vip_pre_3_gift_goldcoin");
|
| | | if (!StringUtil.isNullOrEmpty(goldcoin)) {
|
| | | |
| | | int goldcoinNum = Integer.parseInt(goldcoin);
|
| | | // 添加金币明细
|
| | | IntegralDetail detail = new IntegralDetail();
|
| | | detail.setTitle("升级VIP福利");
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(Integer.parseInt(goldcoin));
|
| | | detail.setCreateTime(upgradeTime);
|
| | | detail.setUniqueKey("VIP-3-" + uid);
|
| | | integralDetailService.insertSelective(detail);
|
| | | |
| | | // 添加金币
|
| | | userInfoExtraService.addGoldCoinByUid(uid, Integer.parseInt(goldcoin));
|
| | | |
| | | // 消息
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | userOtherMsgNotificationService.goldCoinSystemGiveMsg(uid, goldcoinNum, userInfoExtra.getGoldCoin());
|
| | | }
|
| | | // 是否存在下级脱离期限 -更新不脱离
|
| | | userInviteSeparateService.updateInvalidByBossId(uid);
|
| | | |
| | | // 提醒上级
|
| | | remindBoss(uid, "普通会员", item, upgradeTime, true);
|
| | | |
| | | } catch (UserVIPPreInfoException e) {
|
| | | e.printStackTrace();
|
| | | private void oneProcess(Long uid, long limit1, Long limit2, Integer type) {
|
| | | try {
|
| | | String item = null;
|
| | | if (type == null) {
|
| | | item = "邀请粉丝";
|
| | | } else if (type == Constant.TYPE_REBATE) {
|
| | | item = "返利订单";
|
| | | } else {
|
| | | item = "分享订单";
|
| | | }
|
| | |
|
| | | Date upgradeTime = new Date();
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | | info.setUid(uid);
|
| | | info.setProcess(UserVIPPreInfo.PROCESS_1);
|
| | | info.setCreateTime(upgradeTime);
|
| | | info.setUpdateTime(upgradeTime);
|
| | | addUserVIPPreInfo(info);
|
| | |
|
| | | // 升级消息
|
| | | Date registerTime = new Date(1577836800000L);
|
| | | UserInfoRegister userInfoRegister = userInfoRegisterService.selectByPrimaryKey(uid);
|
| | | if (userInfoRegister != null && userInfoRegister.getCreateTime() != null) {
|
| | | registerTime = userInfoRegister.getCreateTime();
|
| | | }
|
| | | int daysBetween = DateUtil.daysBetween(registerTime, new Date());
|
| | | userAccountMsgNotificationService.vipPreUpgrade(uid, "快省达人", "普通会员", daysBetween, limit1, limit2, type);
|
| | | |
| | | // 升级弹框提示
|
| | | UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
|
| | | notify.setUid(uid);
|
| | | notify.setFromLevel(UserLevelEnum.daRen);
|
| | | notify.setToLevel(UserLevelEnum.normalVIP);
|
| | | notify.setValid(true);
|
| | | notify.setCreateTime(new Date());
|
| | | userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
|
| | | |
| | | // 金币奖励
|
| | | goldcoinReward(uid);
|
| | | |
| | | // 是否存在下级脱离期限 -更新不脱离
|
| | | userInviteSeparateService.updateInvalidByBossId(uid);
|
| | | // 提醒上级
|
| | | remindBoss(uid, "普通会员", item, upgradeTime, true);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return process;
|
| | | }
|
| | | |
| | |
|
| | |
|
| | | /**
|
| | |
| | | * @param secondTeam
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private boolean twoProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) {
|
| | | 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);
|
| | | }
|
| | | |
| | | Integer type = null;
|
| | | long targetNum1 = 0L;
|
| | | Long targetNum2 = 0L;
|
| | | String item = "";
|
| | | boolean process = false;
|
| | | if (countZiGou >= limitZiGou) {
|
| | | process = true;
|
| | | targetNum1 = limitZiGou;
|
| | | type = Constant.TYPE_REBATE;
|
| | | item = "返利订单";
|
| | | } else if (countShare >= limitShare) {
|
| | | process = true;
|
| | | targetNum1 = limitShare;
|
| | | type = Constant.TYPE_SHAER;
|
| | | item = "分享订单";
|
| | | } else if (firstTeam >= limitFirst && secondTeam >= limitSecond) {
|
| | | process = true;
|
| | | targetNum1 = limitFirst;
|
| | | targetNum2 = limitSecond;
|
| | | item = "邀请粉丝";
|
| | | }
|
| | |
|
| | | if (process) {
|
| | | try {
|
| | | Date upgradeTime = new Date();
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | | info.setUid(uid);
|
| | | info.setProcess(UserVIPPreInfo.PROCESS_2);
|
| | | info.setCreateTime(upgradeTime);
|
| | | info.setUpdateTime(upgradeTime);
|
| | | addUserVIPPreInfo(info);
|
| | | |
| | | // 升级弹框提示
|
| | | UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
|
| | | notify.setUid(uid);
|
| | | notify.setFromLevel(UserLevelEnum.normalVIP);
|
| | | notify.setToLevel(UserLevelEnum.highVIP);
|
| | | notify.setValid(true);
|
| | | notify.setCreateTime(new Date());
|
| | | userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
|
| | | |
| | | // 升级消息
|
| | | UserVIPPreInfo pre1 = userVIPPreInfoMapper.selectByUidAndProcess(uid, UserVIPPreInfo.PROCESS_1);
|
| | | int daysBetween = DateUtil.daysBetween(pre1.getCreateTime(), upgradeTime);
|
| | | userAccountMsgNotificationService.vipPreUpgrade(uid, "普通会员", "高级会员", daysBetween, targetNum1, targetNum2, type);
|
| | | |
| | | // 赠送奖励券
|
| | | 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()));
|
| | | userSystemCouponService.rewardCouponWin(uid, UserSystemCoupon.SOURCE_SYSTEM_PUSH, num, true, percent);
|
| | | }
|
| | | |
| | | // 提醒上级
|
| | | remindBoss(uid, "高级会员", item, upgradeTime, false);
|
| | | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.error(e);
|
| | | private void twoProcess(Long uid, long limit1, Long limit2, Integer type) {
|
| | | try {
|
| | | String item = null;
|
| | | if (type == null) {
|
| | | item = "邀请粉丝";
|
| | | } else if (type == Constant.TYPE_REBATE) {
|
| | | item = "返利订单";
|
| | | } else {
|
| | | item = "分享订单";
|
| | | }
|
| | |
|
| | | Date upgradeTime = new Date();
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | | info.setUid(uid);
|
| | | info.setProcess(UserVIPPreInfo.PROCESS_2);
|
| | | info.setCreateTime(upgradeTime);
|
| | | info.setUpdateTime(upgradeTime);
|
| | | addUserVIPPreInfo(info);
|
| | |
|
| | | // 升级弹框提示
|
| | | UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
|
| | | notify.setUid(uid);
|
| | | notify.setFromLevel(UserLevelEnum.normalVIP);
|
| | | notify.setToLevel(UserLevelEnum.highVIP);
|
| | | notify.setValid(true);
|
| | | notify.setCreateTime(new Date());
|
| | | userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
|
| | |
|
| | | // 升级福利-赠送奖励券
|
| | | 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()));
|
| | | userSystemCouponService.rewardCouponWin(uid, UserSystemCoupon.SOURCE_SYSTEM_PUSH, num, true, percent);
|
| | | }
|
| | | |
| | | // 升级消息
|
| | | int daysBetween = 0;
|
| | | boolean divorced = false;
|
| | | String beforeName = "快省达人";
|
| | | UserVIPPreInfo pre1 = userVIPPreInfoMapper.selectByUidAndProcess(uid, UserVIPPreInfo.PROCESS_1);
|
| | | if (pre1 != null) {
|
| | | beforeName = "普通会员";
|
| | | daysBetween = DateUtil.daysBetween(pre1.getCreateTime(), upgradeTime);
|
| | | } else {
|
| | | Date registerTime = new Date(1577836800000L);
|
| | | UserInfoRegister userInfoRegister = userInfoRegisterService.selectByPrimaryKey(uid);
|
| | | if (userInfoRegister != null && userInfoRegister.getCreateTime() != null) {
|
| | | registerTime = userInfoRegister.getCreateTime();
|
| | | }
|
| | | daysBetween = DateUtil.daysBetween(registerTime, upgradeTime);
|
| | | |
| | | // 金币奖励 (直接升级高级会员补齐一级奖励)
|
| | | goldcoinReward(uid);
|
| | | // 需要发送脱离信息
|
| | | divorced = true;
|
| | | }
|
| | | userAccountMsgNotificationService.vipPreUpgrade(uid, beforeName, "高级会员", daysBetween, limit1, limit2, type);
|
| | |
|
| | | // 提醒上级
|
| | | remindBoss(uid, "高级会员", item, upgradeTime, divorced);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.error(e);
|
| | | }
|
| | | return process;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 升级奖励金币
|
| | | * @param uid
|
| | | */
|
| | | private void goldcoinReward(Long uid) {
|
| | | String goldcoin = userVipConfigService.getValueByKey("vip_pre_3_gift_goldcoin");
|
| | | if (!StringUtil.isNullOrEmpty(goldcoin)) {
|
| | | int goldcoinNum = Integer.parseInt(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));
|
| | | // 消息
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | userOtherMsgNotificationService.goldCoinSystemGiveMsg(uid, goldcoinNum, userInfoExtra.getGoldCoin());
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void remindBoss(Long uid, String rankName, String item, Date time, boolean divorced) {
|
| | | // 是否存在上级
|
| | |
| | |
|
| | | @Override
|
| | | public UserVIPPreInfo selectByUidAndProcess(Long uid, int process) {
|
| | | UserVIPPreInfo info = userVIPPreInfoMapper.selectByUidAndProcess(uid, process);
|
| | | return info;
|
| | | return userVIPPreInfoMapper.selectByUidAndProcess(uid, process);
|
| | | }
|
| | |
|
| | | }
|