| | |
| | |
|
| | | @Resource
|
| | | private UserVIPInfoMapper userVIPInfoMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | | |
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private IntegralDetailService integralDetailService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private BanLiShopOrderService banLiShopOrderService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserOtherMsgNotificationService userOtherMsgNotificationService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInviteSeparateService userInviteSeparateService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | |
| | | if (userVIPInfo.getState() != UserVIPInfo.STATE_VERIFING) {
|
| | | throw new UserVIPInfoException(2, "申请未处于审核状态");
|
| | | }
|
| | | |
| | |
|
| | | if (!verifyConform(uid))
|
| | | throw new UserVIPInfoException(1, "系统验证:不满足升级条件");
|
| | | |
| | |
|
| | | UserVIPInfo info = new UserVIPInfo();
|
| | | info.setId(userVIPInfo.getId());
|
| | | info.setSuccessTime(new Date());
|
| | | info.setState(UserVIPInfo.STATE_SUCCESS);
|
| | | info.setUpdateTime(new Date());
|
| | | userVIPInfoMapper.updateByPrimaryKeySelective(info);
|
| | | |
| | |
|
| | | // 下级的超级会员 不脱离
|
| | | userInviteSeparateService.updateInvalidByBossId(uid);
|
| | | |
| | |
|
| | | // 额外信息
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid);
|
| | | if (userInfoExtra == null)
|
| | | throw new UserVIPInfoException(1, "用户信息不存在");
|
| | | |
| | |
|
| | | // 添加金币
|
| | | IntegralDetail detail = new IntegralDetail();
|
| | | detail.setTitle("升级VIP福利");
|
| | |
| | | detail.setUniqueKey("VIP-" + uid);
|
| | | integralDetailService.insertSelective(detail);
|
| | | userInfoExtraService.addGoldCoinByUid(uid, Constant.VIP_COLDCOIN_NUM);
|
| | | |
| | |
|
| | | try {
|
| | | // 奖励券
|
| | | 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(), |
| | | 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(), |
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCouponGive.name(),
|
| | | UserSystemCoupon.SOURCE_SYSTEM_PUSH, null, false);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | throw new UserVIPInfoException(1, "券赠送失败");
|
| | | }
|
| | | |
| | |
|
| | | // 消息
|
| | | MsgOtherVIPDTO msgOther = new MsgOtherVIPDTO();
|
| | | msgOther.setContent1("恭喜你,已成为超级会员");
|
| | | msgOther.setContent2("满足升级条件");
|
| | | msgOther.setContent3(TimeUtil.formatDateDot(new Date()));
|
| | | userOtherMsgNotificationService.passVIPApplyMsg(uid, "返利奖励券和、赠送免单券和金币请到我的-福利中心中查看", msgOther);
|
| | | |
| | |
|
| | | // 通知上级
|
| | | callBoss(uid);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通知上级脱离关系
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void callBoss(Long uid) {
|
| | | // 是否存在上级
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale == null) |
| | | if (threeSale == null)
|
| | | return;
|
| | | // 上级是否为会员
|
| | | Long bossId = threeSale.getBoss().getId();
|
| | | UserVIPInfo bossVIP = userVIPInfoMapper.selectByPrimaryKeyForUpdate(bossId);
|
| | | if (bossVIP != null && bossVIP.getState() != null && bossVIP.getState() == UserVIPInfo.STATE_SUCCESS)
|
| | | return;
|
| | | |
| | |
|
| | | // 之前插入记录失效
|
| | | userInviteSeparateService.updateStateByWorkerIdAndBossId(uid, bossId, UserInviteSeparate.STATE_INVALID);
|
| | | |
| | |
|
| | | // 限制时间
|
| | | int limitDays = Integer.parseInt(configService.get(ConfigKeyEnum.inviteSeparateLimitDays.getKey()));
|
| | | UserInviteSeparate inviteSeparate = new UserInviteSeparate();
|
| | |
| | | inviteSeparate.setCreateTime(new Date());
|
| | | inviteSeparate.setUpdateTime(new Date());
|
| | | userInviteSeparateService.insertSelective(inviteSeparate);
|
| | | |
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | // 消息
|
| | | MsgOtherVIPDTO msgboss = new MsgOtherVIPDTO();
|
| | | msgboss.setContent1(userInfo.getNickName() +" "+ uid);
|
| | | msgboss.setContent1(userInfo.getNickName() + " " + uid);
|
| | | msgboss.setContent2("于" + TimeUtil.formatDateDot(new Date()) + "成功升级成为超级会员");
|
| | | msgboss.setContent3("今日起"+limitDays+"天内,你未能成为超级会员将会与其脱离邀请关系 ");
|
| | | msgboss.setContent3("今日起" + limitDays + "天内,你未能成为超级会员将会与其脱离邀请关系 ");
|
| | | userOtherMsgNotificationService.teamVIPCallBoss(bossId, "如有疑问请联系我的-人工客服", msgboss);
|
| | | }
|
| | | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void rejectVIPApply(Long uid, String reason) throws UserVIPInfoException {
|
| | |
| | | info.setState(UserVIPInfo.STATE_INVALID);
|
| | | info.setUpdateTime(new Date());
|
| | | userVIPInfoMapper.updateByPrimaryKeySelective(info);
|
| | | |
| | |
|
| | | // 消息
|
| | | MsgOtherVIPDTO msgOther = new MsgOtherVIPDTO();
|
| | | msgOther.setContent1("很抱歉,未通过超级会员申请");
|
| | |
| | | return map;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public boolean verifyConform(Long uid) {
|
| | | if (uid == null || uid <= 0)
|
| | | return false;
|
| | | |
| | |
|
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (extra == null) |
| | | 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);
|
| | | |
| | | long teamNum = hongBaoV2CountService.countValidOrderTeamUserByUid(uid,
|
| | | TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney);
|
| | |
|
| | | // 区分老用户和新用户
|
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | |
| | | }
|
| | | if (executeDate == null)
|
| | | return false;
|
| | | |
| | |
|
| | | if (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime()) {
|
| | | long limitNum = Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user"));
|
| | | if (teamNum < limitNum)
|
| | |
| | | if (teamNum < limitNum)
|
| | | return false;
|
| | | }
|
| | | |
| | |
|
| | | // 2、累计自购返利≥100 元(从注册板栗快省起);
|
| | | BigDecimal fanMoney = new BigDecimal(userVipConfigService.getValueByKey("require_fan_money"));
|
| | | BigDecimal purchase = hongBaoV2CountService.getRewardMoneyBySelf(uid);
|
| | | if (purchase.compareTo(fanMoney) < 0)
|
| | | return false;
|
| | | |
| | |
|
| | | // 3、累计金币≥10000 枚(从注册板栗快省起);
|
| | | BigDecimal goldCoin = integralDetailService.getCumulativeMoney(uid);
|
| | | BigDecimal limitGoldCoin = new BigDecimal(userVipConfigService.getValueByKey("require_gold_coin"));
|
| | | if (goldCoin.compareTo(limitGoldCoin) < 0)
|
| | | return false;
|
| | | |
| | |
|
| | | // 4、使用红包≥1 次
|
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | |
| | | long limitHongBao = Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy"));
|
| | | if (useHongBao < limitHongBao)
|
| | | return false;
|
| | | |
| | |
|
| | | // 符合条件
|
| | | return true;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public List<UserVIPInfo> listQuery(int page, int count, String key, Integer state){
|
| | | return userVIPInfoMapper.listQuery((page-1) * count, count, key, state);
|
| | | public List<UserVIPInfo> listQuery(int page, int count, String key, Integer state) {
|
| | | return userVIPInfoMapper.listQuery((page - 1) * count, count, key, state);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public long countQuery(String key, Integer state){
|
| | | public long countQuery(String key, Integer state) {
|
| | | return userVIPInfoMapper.countQuery(key, state);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void inviteSeparate(Long workerId, Long bossId) {
|
| | | if (workerId == null || bossId == null)
|
| | | return;
|
| | | |
| | |
|
| | | // 查询记录
|
| | | UserInviteSeparate userInviteSeparate = userInviteSeparateService.selectByWorkerIdAndBossId(workerId, bossId);
|
| | | if (userInviteSeparate == null)
|
| | | return;
|
| | | |
| | |
|
| | | // 是否存在邀请关系
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(workerId);
|
| | | if (threeSale == null) |
| | | if (threeSale == null)
|
| | | return;
|
| | | Long bossIdExist = threeSale.getBoss().getId();
|
| | | if (bossIdExist == null || bossId.longValue() != bossIdExist.longValue())
|
| | | return;
|
| | | |
| | |
|
| | | // 上级会员情况
|
| | | boolean separate = false;
|
| | | UserVIPInfo userVIPInfo = userVIPInfoMapper.selectByPrimaryKey(bossId);
|
| | | if (userVIPInfo != null && userVIPInfo.getState() != null && userVIPInfo.getState() == UserVIPInfo.STATE_SUCCESS) {
|
| | | if (userVIPInfo != null && userVIPInfo.getState() != null
|
| | | && userVIPInfo.getState() == UserVIPInfo.STATE_SUCCESS) {
|
| | | if (userInviteSeparate.getEndTime().getTime() < userVIPInfo.getSuccessTime().getTime()) {
|
| | | separate = true; // 结束时间已经超过
|
| | | }
|
| | | } else {
|
| | | separate = true; // 上级非会员 |
| | | separate = true; // 上级非会员
|
| | | }
|
| | | |
| | |
|
| | | if (!separate) {
|
| | | // 未脱离
|
| | | userInviteSeparateService.updateStateByWorkerIdAndBossId(workerId, bossId, UserInviteSeparate.STATE_INVALID);
|
| | | userInviteSeparateService.updateStateByWorkerIdAndBossId(workerId, bossId,
|
| | | UserInviteSeparate.STATE_INVALID);
|
| | | } else {
|
| | | // 脱离关系
|
| | | userInviteSeparateService.updateStateByWorkerIdAndBossId(workerId, bossId, UserInviteSeparate.STATE_SUCCESS);
|
| | | |
| | | userInviteSeparateService.updateStateByWorkerIdAndBossId(workerId, bossId,
|
| | | UserInviteSeparate.STATE_SUCCESS);
|
| | |
|
| | | // 脱离邀请关系
|
| | | threeSaleSerivce.inviteSeparate(workerId, bossId);
|
| | | |
| | |
|
| | | 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.setContent1(userInfo.getNickName() + workerId + "于"
|
| | | + TimeUtil.formatDateDot(userInviteSeparate.getCreateTime()) + "成功升级成为超级会员 ");
|
| | | msgboss.setContent2("很遗憾,你未能在" + limitDays + "天升级为超级会员 ");
|
| | | msgboss.setContent3("已与其脱离邀请关系");
|
| | | userOtherMsgNotificationService.teamSplitCallBoss(bossId, "如有疑问请联系我的-人工客服", msgboss);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | }
|