| | |
| | | */ |
| | | @Override |
| | | public ResultUtil addAppUser(AddAppUserVo addAppUserVo) throws Exception { |
| | | TAppUser tAppUser = this.baseMapper.selectOne(new QueryWrapper<TAppUser>().eq("phone", addAppUserVo.getPhone()).ne("state", 3)); |
| | | TAppUser tAppUser = this.baseMapper.selectOne(new QueryWrapper<TAppUser>() |
| | | .eq("phone", addAppUserVo.getPhone()) |
| | | .ne("state", 3)); |
| | | if(null != tAppUser){ |
| | | return ResultUtil.error("账号已存在"); |
| | | } |
| | |
| | | tAppUser.setIsVip(0); |
| | | tAppUser.setState(1); |
| | | tAppUser.setInsertTime(new Date()); |
| | | |
| | | |
| | | |
| | | // 介绍有礼 |
| | | if(addAppUserVo.getReferralUserId()!=null || ToolUtil.isNotEmpty(addAppUserVo.getInvitePhone())){ |
| | | if(ToolUtil.isEmpty(addAppUserVo.getLat()) || ToolUtil.isEmpty(addAppUserVo.getLon())){ |
| | | return ResultUtil.error("请先开启定位", ""); |
| | | } |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(addAppUserVo.getLon(), addAppUserVo.getLat()); |
| | | Integer num=0; |
| | | if(null != geocode){ |
| | | String province = geocode.get("province"); |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String city = geocode.get("city"); |
| | | String cityCode = geocode.get("cityCode"); |
| | | num = introduceRewardsClient.getGiftList(cityCode); |
| | | } |
| | | if(ToolUtil.isNotEmpty(addAppUserVo.getInvitePhone())){ |
| | | List<TAppUser> tAppUsers = this.baseMapper.selectList(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getPhone, addAppUserVo.getInvitePhone())); |
| | | if(tAppUsers.size()>0){ |
| | | addAppUserVo.setReferralUserId(tAppUsers.get(0).getId()); |
| | | // 注册用户 |
| | | int insert = this.baseMapper.insert(tAppUser); |
| | | // 介绍有礼 |
| | | if(addAppUserVo.getReferralUserId()!=null || ToolUtil.isNotEmpty(addAppUserVo.getInvitePhone())){ |
| | | if(ToolUtil.isEmpty(addAppUserVo.getLat()) || ToolUtil.isEmpty(addAppUserVo.getLon())){ |
| | | return ResultUtil.error("请先开启定位", ""); |
| | | } |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(addAppUserVo.getLon(), addAppUserVo.getLat()); |
| | | Integer num=0; |
| | | Integer activityId=null; |
| | | if(null != geocode){ |
| | | String province = geocode.get("province"); |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String city = geocode.get("city"); |
| | | String cityCode = geocode.get("cityCode"); |
| | | // 根据所在市code 查询是否有介绍有礼活动 |
| | | IntroduceRewards res = introduceRewardsClient.getGiftList(cityCode); |
| | | if (res!=null){ |
| | | num = res.getGiveClass(); |
| | | activityId = res.getId(); |
| | | if(ToolUtil.isNotEmpty(addAppUserVo.getInvitePhone())){ |
| | | List<TAppUser> tAppUsers = this.baseMapper.selectList(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getPhone, addAppUserVo.getInvitePhone())); |
| | | if(tAppUsers.size()>0){ |
| | | addAppUserVo.setReferralUserId(tAppUsers.get(0).getId()); |
| | | } |
| | | } |
| | | if (num!=0){ |
| | | TAppGift tAppGift = new TAppGift(); |
| | | TAppUser phone = appUserService.getOne(new QueryWrapper<TAppUser>() |
| | | .eq("phone", addAppUserVo.getInvitePhone())); |
| | | if (phone == null){ |
| | | return ResultUtil.error("推荐人手机号未注册玩湃会员!"); |
| | | }else{ |
| | | tAppGift.setUserName(phone.getName()); |
| | | tAppGift.setUserPhone(phone.getPhone()); |
| | | } |
| | | tAppGift.setUserId(addAppUserVo.getReferralUserId()); |
| | | tAppGift.setNum(num); |
| | | tAppGift.setShareUserId(tAppUser.getId()); |
| | | tAppGift.setShareUserName(tAppUser.getPhone()); |
| | | tAppGift.setShareUserPhone(tAppUser.getPhone()); |
| | | tAppGift.setActivityId(activityId); |
| | | tAppGift.setInsertTime(new Date()); |
| | | appGiftService.save(tAppGift); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | TAppGift one = appGiftService.getOne(new LambdaQueryWrapper<TAppGift>().eq(TAppGift::getUserId, addAppUserVo.getReferralUserId())); |
| | | if(one!=null){ |
| | | one.setNum(one.getNum()+num); |
| | | appGiftService.updateById(one); |
| | | }else { |
| | | TAppGift tAppGift = new TAppGift(); |
| | | tAppGift.setUserId(addAppUserVo.getReferralUserId()); |
| | | tAppGift.setNum(num); |
| | | appGiftService.save(tAppGift); |
| | | } |
| | | |
| | | } |
| | | this.baseMapper.insert(tAppUser); |
| | | |
| | | |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String city = geocode.get("city"); |
| | | String cityCode = geocode.get("cityCode"); |
| | | num = introduceRewardsClient.getGiftList(cityCode); |
| | | IntroduceRewards giftList = introduceRewardsClient.getGiftList(cityCode); |
| | | num = giftList.getGiveClass(); |
| | | } |
| | | Integer userId=null; |
| | | if(ToolUtil.isNotEmpty(dto.getInvitePhone())){ |