| | |
| | | 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(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){ |
| | | if(null != cacheMap && cacheMap.size() > 0){ |
| | | Integer number = Integer.valueOf(cacheMap.get("number").toString()) + 1; |
| | | Long startTime = Long.valueOf(cacheMap.get("startTime").toString()); |
| | | if(number > 5 && (System.currentTimeMillis() - startTime) < 60000){ |
| | |
| | | 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(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.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){ |
| | |
| | | } |
| | | |
| | | 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{ |
| | |
| | | @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 |