| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserInviteSeparate;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
|
| | | import com.yeshi.fanli.entity.integral.IntegralDetail;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPInfoException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | |
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | |
|
| | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | |
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addUserVIPInfo(UserVIPInfo info) throws UserVIPInfoException {
|
| | | if (info.getId() == null) {
|
| | | throw new UserVIPInfoException(1, "信息不完整");
|
| | |
| | | // 下级的超级会员 不脱离
|
| | | userInviteSeparateService.updateInvalidByBossId(uid);
|
| | |
|
| | | // 赠送券
|
| | | // 额外信息
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid);
|
| | | if (userInfoExtra == null)
|
| | | throw new UserVIPInfoException(1, "用户信息不存在");
|
| | | |
| | | // 添加金币
|
| | | IntegralDetail detail = new IntegralDetail();
|
| | | detail.setTitle("升级VIP福利");
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(Constant.VIP_COLDCOIN_NUM);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUniqueKey("VIP-" + uid);
|
| | | integralDetailService.insertSelective(detail);
|
| | | userInfoExtraService.addGoldCoinByUid(uid, Constant.VIP_COLDCOIN_NUM);
|
| | | |
| | | try {
|
| | | BigDecimal percent = new BigDecimal(configService.get("exchange_rebate_percent"));
|
| | | // 奖励券
|
| | | BigDecimal percent = new BigDecimal(configService.get(ConfigKeyEnum.exchangeRebatePercent.getKey()));
|
| | | for (int i = 0; i < Constant.VIP_COUPON_REWARD_NUM; i++) {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_SYSTEM_PUSH, percent, false);
|
| | | }
|
| | |
|
| | | // 赠送免单券
|
| | | for (int i = 0; i < Constant.VIP_COUPON_GIVEFREE_NUM; i++) {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCouponGive.name(),
|
| | | UserSystemCoupon.SOURCE_SYSTEM_PUSH, null, false);
|
| | |
| | | msgOther.setContent1("恭喜你,已成为超级会员");
|
| | | msgOther.setContent2("满足升级条件");
|
| | | msgOther.setContent3(TimeUtil.formatDateDot(new Date()));
|
| | | userOtherMsgNotificationService.passVIPApplyMsg(uid, "返利奖励券和赠送免单券请到我的-福利中心中查看", msgOther);
|
| | | userOtherMsgNotificationService.passVIPApplyMsg(uid, "返利奖励券和、赠送免单券和金币请到我的-福利中心中查看", msgOther);
|
| | |
|
| | | // 通知上级
|
| | | callBoss(uid);
|
| | |
| | | userInviteSeparateService.updateStateByWorkerIdAndBossId(uid, bossId, UserInviteSeparate.STATE_INVALID);
|
| | |
|
| | | // 限制时间
|
| | | int limitDays = Integer.parseInt(configService.get("invite_separate_limit_days"));
|
| | | int limitDays = Integer.parseInt(configService.get(ConfigKeyEnum.inviteSeparateLimitDays.getKey()));
|
| | | UserInviteSeparate inviteSeparate = new UserInviteSeparate();
|
| | | inviteSeparate.setBossId(bossId);
|
| | | inviteSeparate.setWorkerId(uid);
|
| | |
| | | MsgOtherVIPDTO msgboss = new MsgOtherVIPDTO();
|
| | | msgboss.setContent1(userInfo.getNickName() +" "+ uid);
|
| | | msgboss.setContent2("于" + TimeUtil.formatDateDot(new Date()) + "成功升级成为超级会员");
|
| | | msgboss.setContent3("今日起"+limitDays+"天内,你未能成为超级会员将会与其以及其直接粉丝脱离邀请关系 ");
|
| | | msgboss.setContent3("今日起"+limitDays+"天内,你未能成为超级会员将会与其脱离邀请关系 ");
|
| | | userOtherMsgNotificationService.teamVIPCallBoss(bossId, "如有疑问请联系我的-人工客服", msgboss);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void rejectVIPApply(Long uid, String reason) throws UserVIPInfoException {
|
| | | UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | |
| | | userOtherMsgNotificationService.rejectVIPApply(uid, "如有疑问请联系我的-人工客服", msgOther);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void applyVIP(Long uid) throws UserVIPInfoException {
|
| | | UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userInfo == null) {
|
| | | throw new UserVIPInfoException(1, "用户信息不存在");
|
| | | userInfo = new UserVIPInfo();
|
| | | userInfo.setId(uid);
|
| | | addUserVIPInfo(userInfo);
|
| | | }
|
| | |
|
| | | if (userInfo.getState() != UserVIPInfo.STATE_INVALID) {
|
| | | if (userInfo.getState() != UserVIPInfo.STATE_INVALID)
|
| | | throw new UserVIPInfoException(2, "已经申请过");
|
| | | }
|
| | |
|
| | | UserVIPInfo info = new UserVIPInfo();
|
| | | info.setId(userInfo.getId());
|
| | |
| | | if (extra == null)
|
| | | return false;
|
| | |
|
| | | // 1、直接粉丝(从 2020 年 1 月 1 日起直接粉丝产生有效订单)
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | | long teamNum = hongBaoV2CountService.countValidOrderTeamUserByUid(uid, TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney);
|
| | | |
| | |
|
| | | // 区分老用户和新用户
|
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | | Date executeDate = null;
|
| | | try {
|
| | |
| | | if (executeDate == null)
|
| | | return false;
|
| | |
|
| | | // 1、直接粉丝(从 2020 年 1 月 1 日起直接粉丝产生有效订单)
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | | long teamNum = hongBaoV2CountService.countValidOrderTeamUserByUid(uid, executeDate.getTime(), payMoney);
|
| | | if (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime()) {
|
| | | long limitNum = Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user"));
|
| | | if (teamNum < limitNum)
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public void InviteSeparate(Long workerId, Long bossId) {
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void inviteSeparate(Long workerId, Long bossId) {
|
| | | if (workerId == null || bossId == null)
|
| | | return;
|
| | |
|
| | |
| | | // 脱离邀请关系
|
| | | threeSaleSerivce.inviteSeparate(workerId, bossId);
|
| | |
|
| | | int limitDays = Integer.parseInt(configService.get("invite_separate_limit_days"));
|
| | | int limitDays = Integer.parseInt(configService.get(ConfigKeyEnum.inviteSeparateLimitDays.getKey()));
|
| | | // 消息
|
| | | UserInfo userInfo = userInfoService.selectByPKey(workerId);
|
| | | MsgOtherVIPDTO msgboss = new MsgOtherVIPDTO();
|
| | | msgboss.setContent1(userInfo.getNickName() + workerId + "于" +TimeUtil.formatDateDot(userInviteSeparate.getCreateTime())+"成功升级成为超级会员 ");
|
| | | msgboss.setContent2("很遗憾,你未能在"+limitDays+"天升级为超级会员 ");
|
| | | msgboss.setContent3(" 已与其以及其直接粉丝脱离了邀请关系 ");
|
| | | msgboss.setContent3("已与其脱离邀请关系");
|
| | | userOtherMsgNotificationService.teamSplitCallBoss(bossId, "如有疑问请联系我的-人工客服", msgboss);
|
| | | }
|
| | | }
|