| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.model.AppUserShop; |
| | |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.AppUserShopService; |
| | | import com.ruoyi.account.util.weChat.WXCore; |
| | | import com.ruoyi.account.util.weChat.WeChatUtil; |
| | | import com.ruoyi.account.vo.*; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | return R.fail(map.get("msg").toString()); |
| | | } |
| | | String openid = map.get("openid").toString(); |
| | | String sessionKey = map.get("sessionKey").toString(); |
| | | //查询用户是否注册,没有注册则跳转到注册页面 |
| | | AppUser appUser = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getWxOpenid, openid).ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); |
| | | if(null == appUser){ |
| | | String decrypt = WXCore.decrypt(appletLogin.getEncryptedData_phone(), sessionKey, appletLogin.getIv_phone()); |
| | | if (StringUtils.isEmpty(decrypt)) { |
| | | return R.fail("获取手机信息失败"); |
| | | } |
| | | JSONObject phone = JSON.parseObject(decrypt); |
| | | String purePhoneNumber = phone.getString("purePhoneNumber"); |
| | | LoginVo loginVo = new LoginVo(); |
| | | loginVo.setSkipPage(2); |
| | | loginVo.setPhone(purePhoneNumber); |
| | | return R.ok(loginVo); |
| | | } |
| | | //账户被冻结,给出提示 |
| | |
| | | if(null == appUser){ |
| | | LoginVo loginVo = new LoginVo(); |
| | | loginVo.setSkipPage(2); |
| | | loginVo.setPhone(mobileLogin.getPhone()); |
| | | return R.ok(loginVo); |
| | | } |
| | | //账户被冻结,给出提示 |
| | |
| | | // return R.fail("验证码错误"); |
| | | // } |
| | | //使用jscode获取微信openid |
| | | // Map<String, Object> map = weChatUtil.code2Session(registerAccount.getJscode()); |
| | | // Integer errcode = Integer.valueOf(map.get("errcode").toString()); |
| | | // if(0 != errcode){ |
| | | // return R.fail(map.get("msg").toString()); |
| | | // } |
| | | // String openid = map.get("openid").toString(); |
| | | // //查询用户是否注册 |
| | | // AppUser appUser = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getWxOpenid, openid).ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); |
| | | // if(null != appUser){ |
| | | // return R.fail("此微信号已注册,请直接登录!"); |
| | | // } |
| | | AppUser appUser = null; |
| | | Map<String, Object> map = weChatUtil.code2Session(registerAccount.getJscode()); |
| | | Integer errcode = Integer.valueOf(map.get("errcode").toString()); |
| | | if(0 != errcode){ |
| | | return R.fail(map.get("msg").toString()); |
| | | } |
| | | String openid = map.get("openid").toString(); |
| | | //查询用户是否注册 |
| | | AppUser appUser = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getWxOpenid, openid).ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); |
| | | if(null != appUser){ |
| | | return R.fail("此微信号已注册,请直接登录!"); |
| | | } |
| | | AppUser appUser1 = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, registerAccount.getPhone()).ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); |
| | | if(null != appUser1){ |
| | | return R.fail("手机号已注册,请直接登录!"); |
| | |
| | | appUser = new AppUser(); |
| | | appUser.setName(registerAccount.getName()); |
| | | appUser.setPhone(registerAccount.getPhone()); |
| | | // appUser.setWxOpenid(openid); |
| | | appUser.setWxOpenid(openid); |
| | | //注册默认为普通会员 |
| | | appUser.setVipId(1); |
| | | appUser.setStatus(1); |
| | |
| | | } |
| | | |
| | | public AppUser getTopAppUser(List<AppUser> list, Long id){ |
| | | AppUser appUser = list.stream().filter(s -> s.getInviteUserId().equals(id)).findFirst().get(); |
| | | AppUser appUser = list.stream().filter(s -> s.getId().equals(id)).findFirst().get(); |
| | | if(null == appUser.getInviteUserId()){ |
| | | return appUser; |
| | | } |
| | | return getTopAppUser(list, appUser.getId()); |
| | | return getTopAppUser(list, appUser.getInviteUserId()); |
| | | } |
| | | |
| | | |
| | |
| | | List<NearbyReferrerVo> list = this.baseMapper.getNearbyReferrer(cityCode, nearbyReferrer); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<AppUser> getUserAncestorList(Long id, List<AppUser> list) { |
| | | if (list == null) { |
| | | list = new ArrayList<>(); |
| | | } |
| | | |
| | | Set<Long> visitedIds = new HashSet<>(); |
| | | Long currentId = id; |
| | | |
| | | while (currentId != null && !visitedIds.contains(currentId)) { |
| | | AppUser appUser = getById(currentId); |
| | | if (appUser == null) { |
| | | break; // 如果用户不存在,终止循环 |
| | | } |
| | | |
| | | Long inviteUserId = appUser.getInviteUserId(); |
| | | if (inviteUserId != null) { |
| | | AppUser invitedUser = getById(inviteUserId); |
| | | if (invitedUser != null) { |
| | | list.add(invitedUser); |
| | | visitedIds.add(currentId); |
| | | currentId = inviteUserId; |
| | | } else { |
| | | break; // 如果邀请用户不存在,终止循环 |
| | | } |
| | | } else { |
| | | break; // 如果没有邀请用户,终止循环 |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | } |