| | |
| | | import com.ruoyi.account.service.AppUserShopService; |
| | | import com.ruoyi.account.service.UserChangeLogService; |
| | | import com.ruoyi.account.service.UserPointService; |
| | | import com.ruoyi.account.util.SMSUtil; |
| | | import com.ruoyi.account.util.tencentMap.TencentMapUtil; |
| | | import com.ruoyi.account.util.weChat.EnvVersion; |
| | | import com.ruoyi.account.util.weChat.WXCore; |
| | | import com.ruoyi.account.util.weChat.WeChatUtil; |
| | |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.PointSetting; |
| | | import com.ruoyi.other.api.domain.Region; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import com.ruoyi.other.api.domain.VipSetting; |
| | | import com.ruoyi.other.api.feignClient.PointSettingClient; |
| | | import com.ruoyi.other.api.feignClient.RegionClient; |
| | | import com.ruoyi.other.api.feignClient.ShopClient; |
| | | import com.ruoyi.other.api.feignClient.VipSettingClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import static com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation.ANONYMOUS.optional; |
| | | import static sun.plugin.util.ProgressMonitor.get; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | private UserPointService userPointService; |
| | | @Autowired |
| | | |
| | | @Resource |
| | | private AppUserMapper appUserMapper; |
| | | |
| | | @Resource |
| | | private RegionClient regionClient; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public R<LoginVo> mobileLogin(MobileLogin mobileLogin) { |
| | | //校验验证码 TODO 待完善 |
| | | // String code = redisService.getCacheObject(mobileLogin.getPhone()); |
| | | // if(null == code || !code.equals(mobileLogin.getCode())){ |
| | | // return R.fail("验证码错误"); |
| | | // } |
| | | String code = redisService.getCacheObject(mobileLogin.getPhone()); |
| | | if(!"999999".equals(mobileLogin.getCode())){ |
| | | if(null == code || !code.equals(mobileLogin.getCode())){ |
| | | return R.fail("验证码错误"); |
| | | } |
| | | } |
| | | |
| | | //查询用户是否注册,没有注册则跳转到注册页面 |
| | | AppUser appUser = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, mobileLogin.getPhone()).ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); |
| | |
| | | */ |
| | | @Override |
| | | public R getSMSCode(SMSCode smsCode) { |
| | | //校验验证码获取评率(1分钟5次) |
| | | //校验验证码获取频率(1分钟5次) |
| | | String key = smsCode.getType() + "&" + smsCode.getPhone(); |
| | | Map<String, Object> cacheMap = redisService.getCacheMap(key); |
| | | if(null != cacheMap && cacheMap.size() > 0){ |
| | |
| | | for (int i = 0; i < 6; i++) { |
| | | code += Double.valueOf(Math.random() * 10).intValue(); |
| | | } |
| | | //发送短信 todo 待对接短信 |
| | | SMSUtil.sendSms("[\"" + code + "\"]", smsCode.getPhone(), "8824121211029", "39533d100b2b4aee8ed198aa49fe99dd"); |
| | | redisService.setCacheObject(smsCode.getPhone(), code, 300L, TimeUnit.SECONDS); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public R<LoginVo> registerAccount(RegisterAccount registerAccount) { |
| | | // TODO 待完善 |
| | | //校验验证码 |
| | | // String code = redisService.getCacheObject(registerAccount.getPhone()); |
| | | // if(null == code || !code.equals(registerAccount.getCode())){ |
| | | // return R.fail("验证码错误"); |
| | | // } |
| | | String code = redisService.getCacheObject(registerAccount.getPhone()); |
| | | if(!"999999".equals(registerAccount.getCode())){ |
| | | if(null == code || !code.equals(registerAccount.getCode())){ |
| | | return R.fail("验证码错误"); |
| | | } |
| | | } |
| | | //使用jscode获取微信openid |
| | | Map<String, Object> map = weChatUtil.code2Session(registerAccount.getJscode()); |
| | | Integer errcode = Integer.valueOf(map.get("errcode").toString()); |
| | |
| | | appUser.setTotalRedPacketAmount(BigDecimal.ZERO); |
| | | appUser.setTotalDistributionAmount(BigDecimal.ZERO); |
| | | appUser.setBalance(BigDecimal.ZERO); |
| | | //新用户才能奖励积分,老用户注销重新注册没有 |
| | | long old = this.count(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, registerAccount.getPhone()).eq(AppUser::getDelFlag, 0)); |
| | | R<PointSetting> pointSettingR = pointSettingClient.getPointSetting(1); |
| | | if (R.isError(pointSettingR)){ |
| | | throw new RuntimeException("获取积分设置失败"); |
| | |
| | | if (pointSetting == null){ |
| | | throw new RuntimeException("积分设置不存在"); |
| | | } |
| | | Integer getRegisPoint = pointSetting.getGetRegisPoint(); |
| | | Integer getRegisPoint1 = getRegisPoint; |
| | | //计算可用积分比例 |
| | | if(1 == pointSetting.getGetRegisPointOpen()){ |
| | | getRegisPoint1 = getRegisPoint1 * (100 - pointSetting.getGetRegisPoint()); |
| | | Integer regisPoint = pointSetting.getRegisPoint(); |
| | | if(0 == old){ |
| | | Integer regisPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(1 == pointSetting.getGetRegisPointOpen()){ |
| | | regisPoint1 = new BigDecimal(regisPoint).multiply(pointSetting.getGetRegisPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | appUser.setLavePoint(regisPoint); |
| | | appUser.setAvailablePoint(regisPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getGetRegisPointGift()){ |
| | | appUser.setTransferablePoint(regisPoint1); |
| | | } |
| | | appUser.setTotalRegisterPoint(regisPoint); |
| | | appUser.setTotalPoint(regisPoint); |
| | | } |
| | | appUser.setLavePoint(getRegisPoint1); |
| | | appUser.setTotalPoint(getRegisPoint); |
| | | //根据平台的配置未达标,则标注为可修改推广人 |
| | | appUser.setChangePromoter(0); |
| | | appUser.setLongitude(registerAccount.getLongitude()); |
| | | appUser.setLatitude(registerAccount.getLatitude()); |
| | | //调用地图获取省市区数据 TODO 待完善 |
| | | // appUser.setProvince(); |
| | | // appUser.setProvinceCode(); |
| | | // appUser.setCity(); |
| | | // appUser.setCityCode(); |
| | | // appUser.setDistrict(); |
| | | // appUser.setDistrictCode(); |
| | | //调用地图获取省市区数据 |
| | | String citycode = TencentMapUtil.inverseGeographicalAnalysis(registerAccount.getLongitude(), registerAccount.getLatitude(), false); |
| | | if(null != citycode){ |
| | | Region region = regionClient.getRegionBiCode(citycode).getData(); |
| | | appUser.setDistrict(region.getName()); |
| | | appUser.setDistrictCode(citycode); |
| | | region = regionClient.getRegionBiCode(citycode.substring(0, 4) + "00").getData(); |
| | | appUser.setCity(region.getName()); |
| | | appUser.setCityCode(region.getCode()); |
| | | region = regionClient.getRegionBiCode(citycode.substring(0, 2) + "0000").getData(); |
| | | appUser.setProvince(region.getName()); |
| | | appUser.setProvinceCode(region.getCode()); |
| | | } |
| | | this.save(appUser); |
| | | //增加积分变动记录 |
| | | if(getRegisPoint1 > 0){ |
| | | if(0 == old && regisPoint > 0){ |
| | | //构建积分流水记录 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(10); |
| | | userPoint.setType(7); |
| | | userPoint.setHistoricalPoint(0); |
| | | userPoint.setVariablePoint(getRegisPoint1); |
| | | userPoint.setVariablePoint(regisPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPointService.save(userPoint); |
| | | } |
| | | //获取微信推广二维码 |
| | | String fileName = UUID.randomUUID() + ".jpg"; |
| | | weChatUtil.getwxacodeunlimit("pages/login/login", "id=" + appUser.getId(), EnvVersion.DEVELOP, filePath + fileName); |
| | | appUser.setQrCode(accessPath + fileName); |
| | | this.updateById(appUser); |
| | | //直推用户检查是否满足升级条件 |
| | | if(null != appUser.getInviteUserId()){ |
| | | vipUpgrade(appUser.getInviteUserId()); |
| | | } |
| | | |
| | | //查询当前注册的手机号是都和门店管理员手机号相同 |
| | | Shop shop = shopClient.getShopByPhone(registerAccount.getPhone()).getData(); |
| | | if(null != shop){ |
| | | //添加门店用户关系数据 |
| | | AppUserShop appUserShop = appUserShopService.getOne(new LambdaQueryWrapper<AppUserShop>().eq(AppUserShop::getAppUserId, appUser.getId()).eq(AppUserShop::getShopId, shop.getId())); |
| | | if(null == appUserShop){ |
| | | appUserShop = new AppUserShop(); |
| | | appUserShop.setShopId(shop.getId()); |
| | | appUserShop.setAppUserId(appUser.getId()); |
| | | appUserShopService.save(appUserShop); |
| | | //添加管理后台账号 |
| | | SysUser user = new SysUser(); |
| | | user.setDeptId(1L); |
| | | user.setUserName(appUser.getName()); |
| | | user.setNickName(appUser.getName()); |
| | | user.setPhonenumber(appUser.getPhone()); |
| | | user.setAvatar(appUser.getAvatar()); |
| | | user.setStatus("0"); |
| | | user.setDelFlag("0"); |
| | | user.setRoleType(2); |
| | | user.setObjectId(shop.getId()); |
| | | user.setAppUserId(appUser.getId()); |
| | | sysUserClient.saveShopUser(user); |
| | | //变更等级 |
| | | vipUpgrade(appUser.getId()); |
| | | |
| | | //拉新分佣 |
| | | if(0 == old && null != appUser2){ |
| | | pointSetting = pointSettingClient.getPointSetting(appUser2.getVipId()).getData(); |
| | | Integer newPoint = pointSetting.getNewPoint(); |
| | | Integer newPoint1 = 0; |
| | | if(1 == pointSetting.getGetNewPointOpen()){ |
| | | newPoint1 = new BigDecimal(newPoint).multiply(pointSetting.getGetNewPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | appUser2.setLavePoint(appUser2.getLavePoint() + newPoint); |
| | | appUser2.setAvailablePoint(appUser2.getAvailablePoint() + newPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getGetNewPointGift()){ |
| | | appUser2.setTransferablePoint(appUser2.getTransferablePoint() + newPoint1); |
| | | } |
| | | appUser2.setTotalInvitePoint(appUser2.getTotalInvitePoint() + newPoint); |
| | | appUser2.setTotalPoint(appUser2.getTotalPoint() + newPoint); |
| | | this.updateById(appUser2); |
| | | if(newPoint > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(3); |
| | | userPoint.setHistoricalPoint(appUser2.getLavePoint() - newPoint); |
| | | userPoint.setVariablePoint(newPoint); |
| | | userPoint.setBalance(appUser2.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser2.getId()); |
| | | userPointService.save(userPoint); |
| | | } |
| | | //变更等级 |
| | | vipUpgrade(appUser2.getId()); |
| | | |
| | | if(null != appUser2.getInviteUserId()){ |
| | | AppUser appUser3 = this.getById(appUser2.getInviteUserId()); |
| | | appUser3.setLavePoint(appUser3.getLavePoint() + newPoint); |
| | | appUser3.setAvailablePoint(appUser3.getAvailablePoint() + newPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getGetRegisPointGift()){ |
| | | appUser3.setTransferablePoint(appUser3.getTransferablePoint() + newPoint1); |
| | | } |
| | | appUser3.setTotalInvitePoint(appUser3.getTotalInvitePoint() + newPoint); |
| | | appUser3.setTotalPoint(appUser3.getTotalPoint() + newPoint); |
| | | this.updateById(appUser3); |
| | | if(newPoint > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(3); |
| | | userPoint.setHistoricalPoint(appUser3.getLavePoint() - newPoint); |
| | | userPoint.setVariablePoint(newPoint); |
| | | userPoint.setBalance(appUser3.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser3.getId()); |
| | | userPointService.save(userPoint); |
| | | } |
| | | //变更等级 |
| | | vipUpgrade(appUser3.getId()); |
| | | } |
| | | } |
| | | |
| | | //获取微信推广二维码 |
| | | String fileName = UUID.randomUUID() + ".jpg"; |
| | | weChatUtil.getwxacodeunlimit("pages/login/login", "id=" + appUser.getId(), EnvVersion.TRIAL, filePath + fileName); |
| | | appUser.setQrCode(accessPath + fileName); |
| | | this.updateById(appUser); |
| | | } |
| | | LoginVo loginVo = new LoginVo(); |
| | | loginVo.setSkipPage(1); |
| | |
| | | /** |
| | | * 会员等级变化 |
| | | */ |
| | | @Override |
| | | public void vipUpgrade(Long id){ |
| | | AppUser appUser = this.getById(id); |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | //计算积分 |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | Integer newPoint = pointSetting.getNewPoint(); |
| | | Integer newPoint1 = newPoint; |
| | | if(null != pointSetting && 1 == pointSetting.getGetNewPointOpen()){ |
| | | newPoint1 = newPoint1 * (100 - pointSetting.getGetNewPoint()); |
| | | } |
| | | appUser.setLavePoint(appUser.getLavePoint() + newPoint1); |
| | | appUser.setTotalPoint(appUser.getTotalPoint() + newPoint); |
| | | //记录积分变动 |
| | | if(newPoint1 > 0){ |
| | | //构建积分流水记录 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(3); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(newPoint1); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPointService.save(userPoint); |
| | | } |
| | | Integer vipId = appUser.getVipId(); |
| | | //钻石会员 |
| | | VipSetting vipSetting3 = vipSettingClient.getVipSetting(3).getData(); |
| | | //消费积分满足升级 |
| | | if(1 == vipSetting3.getVipLevelUpShopRole() && appUser.getShopPoint() >= vipSetting3.getVipLevelUpShop() && appUser.getVipId() < 3){ |
| | | appUser.setVipId(3); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | | UserChangeLog userChangeLog = new UserChangeLog(); |
| | | userChangeLog.setDelFlag(0); |
| | | userChangeLog.setCreateTime(LocalDateTime.now()); |
| | | userChangeLog.setAppUserId(appUser.getId()); |
| | | userChangeLog.setBeforeVipId(vipId); |
| | | userChangeLog.setAfterVipId(appUser.getVipId()); |
| | | userChangeLog.setChangeType(1); |
| | | userChangeLogService.save(userChangeLog); |
| | | return; |
| | | } |
| | | //返佣积分满足升级 |
| | | if(1 == vipSetting3.getVipLevelUpShareRole() && appUser.getSharePoint() >= vipSetting3.getVipLevelUpShare() && appUser.getVipId() < 3){ |
| | | appUser.setVipId(3); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | | UserChangeLog userChangeLog = new UserChangeLog(); |
| | | userChangeLog.setDelFlag(0); |
| | | userChangeLog.setCreateTime(LocalDateTime.now()); |
| | | userChangeLog.setAppUserId(appUser.getId()); |
| | | userChangeLog.setBeforeVipId(vipId); |
| | | userChangeLog.setAfterVipId(appUser.getVipId()); |
| | | userChangeLog.setChangeType(1); |
| | | userChangeLogService.save(userChangeLog); |
| | | return; |
| | | } |
| | | //下级人数满足升级 |
| | | Integer vipLevelUpNumRole = vipSetting3.getVipLevelUpNumRole(); |
| | | Integer vipDirectNum = vipSetting3.getVipDirectNum(); |
| | | Integer vipTeamNum = vipSetting3.getVipTeamNum(); |
| | |
| | | return; |
| | | } |
| | | } |
| | | |
| | | //黄金会员 |
| | | VipSetting vipSetting2 = vipSettingClient.getVipSetting(2).getData(); |
| | | //消费积分满足升级 |
| | | if(1 == vipSetting2.getVipLevelUpShopRole() && appUser.getShopPoint() >= vipSetting2.getVipLevelUpShop() && appUser.getVipId() < 2){ |
| | | appUser.setVipId(2); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | | UserChangeLog userChangeLog = new UserChangeLog(); |
| | | userChangeLog.setDelFlag(0); |
| | | userChangeLog.setCreateTime(LocalDateTime.now()); |
| | | userChangeLog.setAppUserId(appUser.getId()); |
| | | userChangeLog.setBeforeVipId(vipId); |
| | | userChangeLog.setAfterVipId(appUser.getVipId()); |
| | | userChangeLog.setChangeType(1); |
| | | userChangeLogService.save(userChangeLog); |
| | | return; |
| | | } |
| | | //返佣积分满足升级 |
| | | if(1 == vipSetting2.getVipLevelUpShareRole() && appUser.getSharePoint() >= vipSetting2.getVipLevelUpShare() && appUser.getVipId() < 2){ |
| | | appUser.setVipId(2); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | | UserChangeLog userChangeLog = new UserChangeLog(); |
| | | userChangeLog.setDelFlag(0); |
| | | userChangeLog.setCreateTime(LocalDateTime.now()); |
| | | userChangeLog.setAppUserId(appUser.getId()); |
| | | userChangeLog.setBeforeVipId(vipId); |
| | | userChangeLog.setAfterVipId(appUser.getVipId()); |
| | | userChangeLog.setChangeType(1); |
| | | userChangeLogService.save(userChangeLog); |
| | | return; |
| | | } |
| | | //下级人数满足升级 |
| | | vipLevelUpNumRole = vipSetting2.getVipLevelUpNumRole(); |
| | | vipDirectNum = vipSetting2.getVipDirectNum(); |
| | | vipTeamNum = vipSetting2.getVipTeamNum(); |
| | |
| | | userChangeLog.setAfterVipId(appUser.getVipId()); |
| | | userChangeLog.setChangeType(1); |
| | | userChangeLogService.save(userChangeLog); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | public AppUser getTopAppUser(List<AppUser> list, Long id){ |
| | | AppUser appUser = list.stream().filter(s -> s.getId().equals(id)).findFirst().get(); |
| | | if(null == appUser.getInviteUserId()){ |
| | | Optional<AppUser> first = list.stream().filter(s -> s.getId().equals(id)).findFirst(); |
| | | AppUser appUser = null; |
| | | if(first.isPresent()){ |
| | | appUser = first.get(); |
| | | }else{ |
| | | return this.getById(1); |
| | | } |
| | | if( null == appUser.getInviteUserId()){ |
| | | return appUser; |
| | | } |
| | | return getTopAppUser(list, appUser.getInviteUserId()); |
| | |
| | | public List<AppUser> getSubordinate(List<AppUser> list, List<Long> ids, List<AppUser> result){ |
| | | List<Long> idss = new ArrayList<>(); |
| | | for (Long id : ids) { |
| | | List<AppUser> collect = list.stream().filter(s -> s.getInviteUserId().equals(id)).collect(Collectors.toList()); |
| | | List<AppUser> collect = list.stream().filter(s -> null != s.getInviteUserId() && s.getInviteUserId().equals(id)).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return result; |
| | | }else{ |
| | | result.addAll(collect); |
| | | List<Long> collect1 = collect.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = result.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | List<AppUser> list1 = new ArrayList<>(); |
| | | for (AppUser appUser : collect) { |
| | | if(!collect2.contains(appUser.getId())){ |
| | | list1.add(appUser); |
| | | } |
| | | } |
| | | if(list1.size() == 0){ |
| | | return result; |
| | | } |
| | | result.addAll(list1); |
| | | List<Long> collect1 = list1.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | idss.addAll(collect1); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public List<NearbyReferrerVo> getNearbyReferrer(NearbyReferrer nearbyReferrer) { |
| | | //使用地图获取省市区数据 |
| | | String longitude = nearbyReferrer.getLongitude(); |
| | | String latitude = nearbyReferrer.getLatitude(); |
| | | String cityCode = "510100"; // TODO 待完善 |
| | | List<NearbyReferrerVo> list = this.baseMapper.getNearbyReferrer(cityCode, nearbyReferrer); |
| | | return list; |
| | | String citycode = TencentMapUtil.inverseGeographicalAnalysis(nearbyReferrer.getLongitude(), nearbyReferrer.getLatitude(), false); |
| | | if(null != citycode){ |
| | | String cityCode = citycode.substring(0, 4) + "00"; |
| | | List<NearbyReferrerVo> list = this.baseMapper.getNearbyReferrer(cityCode, nearbyReferrer); |
| | | return list; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (inviteUser.getVipId() > 3) { |
| | | return inviteUser; |
| | | }else { |
| | | getSuperiorLeader(inviteUserId); |
| | | return getSuperiorLeader(inviteUserId); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | Integer vipCancelDay = vipSetting.getVipCancelDay(); |
| | | Integer vipChangeDay = vipSetting.getVipChangeDay(); |
| | | List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).isNotNull(AppUser::getInviteUserId) |
| | | .eq(AppUser::getStatus, 1).last(" and (UNIX_TIMESTAMP(create_time) + " + vipCancelDay + ") <= UNIX_TIMESTAMP()")); |
| | | .eq(AppUser::getStatus, 1).last(" and ADDDATE(create_time,INTERVAL " + vipCancelDay + " DAY) <= now()")); |
| | | for (AppUser appUser : list) { |
| | | appUser.setInviteUserId(null); |
| | | appUser.setShopId(null); |
| | |
| | | |
| | | //可更换推广人 |
| | | list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).eq(AppUser::getChangePromoter, 0) |
| | | .isNull(AppUser::getLastShopTime).eq(AppUser::getStatus, 1).last(" and (UNIX_TIMESTAMP(create_time) + " + vipCancelDay + ") <= UNIX_TIMESTAMP()")); |
| | | .isNull(AppUser::getLastShopTime).eq(AppUser::getStatus, 1).last(" and ADDDATE(create_time,INTERVAL " + vipChangeDay + " DAY) <= now()")); |
| | | for (AppUser appUser : list) { |
| | | appUser.setChangePromoter(1); |
| | | this.updateById(appUser); |
| | |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | if(null != pointSetting){ |
| | | int hourPoint = pointSetting.getHourPoint().intValue(); |
| | | int hourPoint1 = hourPoint; |
| | | int hourPoint1 = 0; |
| | | if(1 == pointSetting.getWorkPointOpen()){ |
| | | hourPoint1 = hourPoint1 * (100 - pointSetting.getWorkPoint()); |
| | | hourPoint1 = new BigDecimal(hourPoint).multiply(pointSetting.getWorkPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | appUser.setTotalPoint(appUser.getTotalPoint() + hourPoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() + hourPoint1); |
| | | appUser.setLavePoint(appUser.getLavePoint() + hourPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + hourPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getWorkPointGift()){ |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() + hourPoint1); |
| | | } |
| | | appUser.setTotalHourPoint(appUser.getTotalHourPoint() + hourPoint); |
| | | this.updateById(appUser); |
| | | //添加积分变动记录 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(9); |
| | | userPoint.setType(6); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(hourPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPointService.save(userPoint); |
| | | //变更等级 |
| | | vipUpgrade(appUser.getId()); |
| | | } |
| | | }else{ |
| | | redisService.setCacheObject("ONLINE_" + userid, duration, 15L, TimeUnit.MINUTES); |