| | |
| | | |
| | | @PostMapping("/getAppUserById") |
| | | public AppUser getAppUserById(@RequestParam("id") Long id) { |
| | | System.out.println("根据id获取用户:"+id); |
| | | return appUserService.getById(id); |
| | | } |
| | | |
| | |
| | | @GetMapping("/change") |
| | | @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) |
| | | public R<AppUser> change(@ApiParam("换绑用户手机号") String phone) { |
| | | |
| | | Long userId1 = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser byId = appUserService.getById(userId1); |
| | | List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getInviteUserId, userId1) |
| | | .eq(AppUser::getPhone, phone)); |
| | | if (!CollectionUtils.isEmpty(appUserList)){ |
| | | return R.fail("绑定关系已存在!"); |
| | | } |
| | | |
| | | |
| | | |
| | | // List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | // .eq(AppUser::getInviteUserId, userId1) |
| | | // .eq(AppUser::getPhone, phone)); |
| | | // if (!CollectionUtils.isEmpty(appUserList)){ |
| | | // return R.fail("绑定关系已存在!"); |
| | | // } |
| | | //获取绑定门店 |
| | | AppUser user = appUserService.lambdaQuery() |
| | | .eq(AppUser::getPhone, phone) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .eq(AppUser::getStatus, 1) |
| | | .one(); |
| | | |
| | | |
| | | // 获取当前用户的所有下级 |
| | | List<AppUser> allSubordinates = getAllSubordinates(byId.getId()); |
| | | long count = allSubordinates.stream().filter(appUser -> appUser.getId().equals(user.getId())).count(); |
| | | if (count > 0) { |
| | | return R.fail("绑定关系已存在!"); |
| | | } |
| | | |
| | | if (user == null) { |
| | | return R.fail("当前手机号未注册"); |
| | | } |
| | | |
| | | Long userId = user.getId(); |
| | | if (userId.equals(byId.getId())) { |
| | | return R.fail("不能选择自己为绑定人。"); |
| | | } |
| | | |
| | | byId.setInviteUserId(user.getId()); |
| | | appUserService.updateById(byId); |
| | | return R.ok(); |