| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.*; |
| | | import com.ruoyi.account.dto.ApplyForAdmissionDTO; |
| | | import com.ruoyi.account.dto.ChangeAppUserInfo; |
| | | import com.ruoyi.account.mapper.AppUserMapper; |
| | | import com.ruoyi.account.service.*; |
| | |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/recommend") |
| | | @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) |
| | | public R<AppUser> recommend() { |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | //获取绑定门店 |
| | | AppUser user = appUserService.getById(userId); |
| | | return R.ok(user); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/index") |
| | | @ApiOperation(value = "个人中心首页", tags = {"小程序-个人中心首页"}) |
| | | @ApiOperation(value = "个人信息", tags = {"小程序-个人中心首页"}) |
| | | public R<AppUser> index() { |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | //当前用户信息 |
| | | AppUser user = appUserService.getById(userId); |
| | | return R.ok(user); |
| | | return R.ok(appUserService.index()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取门店作为服务商的所有用户 |
| | | * @param shopId |
| | | * @return |
| | | */ |
| | | public Set<Long> getShopServerUser(Integer shopId){ |
| | | Shop shop = shopClient.getShopById(shopId).getData(); |
| | | List<Shop> shopList = shopClient.getAllShop().getData(); |
| | | List<Long> appUserIds = shopList.stream().map(Shop::getAppUserId).collect(Collectors.toList()); |
| | | Long appUserId = shop.getAppUserId(); |
| | | //所有未开店的用户 |
| | | List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0) |
| | | .ne(AppUser::getStatus, 3).notIn(AppUser::getId, appUserIds)); |
| | | Set<Long> ids = new HashSet<>(); |
| | | getShopServerUser(appUserId, list, ids); |
| | | return ids; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public void getShopServerUser(Long appUserId, List<AppUser> appUserList, Set<Long> ids){ |
| | | List<AppUser> collect = appUserList.stream().filter(s->s.getInviteUserId().equals(appUserId)).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return; |
| | | } |
| | | Set<Long> appUserSet = collect.stream().map(AppUser::getId).collect(Collectors.toSet()); |
| | | if(ids.containsAll(appUserSet)){ |
| | | return; |
| | | } |
| | | ids.addAll(appUserSet); |
| | | for (AppUser appUser : collect) { |
| | | getShopServerUser(appUser.getId(), appUserList, ids); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户的祖籍列表 |
| | | */ |
| | | @GetMapping("/getUserAncestorList") |
| | | public R<List<AppUser>> getUserAncestorList(Long id) { |
| | | List<AppUser> list = appUserService.getUserAncestorList(id, null); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户的直帮上级用户 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getSuperiorLeader") |
| | | @ApiOperation(value = "获取用户的直帮上级用户") |
| | | public R<AppUser> getSuperiorLeader(@RequestParam("id") Long id) { |
| | | AppUser superiorLeader = appUserService.getSuperiorLeader(id); |
| | | return R.ok(superiorLeader); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/onlineRecord") |
| | | @ApiOperation(value = "10分钟定时任务调用,记录用户在线时长", tags = {"小程序-个人中心首页"}) |
| | | public R onlineRecord() { |
| | | appUserService.onlineRecord(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData(); |
| | | List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList()); |
| | | //门店作为服务商的用户 |
| | | Set<Long> shopServerUser = getShopServerUser(shopId); |
| | | userIds.addAll(shopServerUser); |
| | | /* Set<Long> shopServerUser = getShopServerUser(shopId); |
| | | userIds.addAll(shopServerUser);*/ |
| | | queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds) |
| | | .like(StringUtils.isNotEmpty( appUser.getName()),"name", appUser.getName()); |
| | | } |
| | |
| | | appUser.setExcludeStatus(3); |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); |
| | | for (AppUser record : appuserPage.getRecords()) { |
| | | if (record.getInviteUserId() != null) { |
| | | AppUser byId1 = appUserService.getById(record.getInviteUserId()); |
| | | if (byId1!=null) { |
| | | record.setInviteUserName(byId1.getName()); |
| | | } |
| | | } |
| | | Shop shop1 = shopClient.getServiceProvider(record.getId()).getData(); |
| | | if(null != shop1){ |
| | | record.setShopName(shop1.getName()); |
| | |
| | | } |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); |
| | | for (AppUser record : appuserPage.getRecords()) { |
| | | if (record.getInviteUserId() != null) { |
| | | /* if (record.getInviteUserId() != null) { |
| | | AppUser byId1 = appUserService.getById(record.getInviteUserId()); |
| | | if (byId1!=null) { |
| | | record.setInviteUserName(byId1.getName()); |
| | | } |
| | | } |
| | | }*/ |
| | | if (record.getShopId()!=null){ |
| | | R<Shop> shopById = shopClient.getShopById(record.getShopId()); |
| | | if (shopById.getData()!=null){ |
| | |
| | | for (Order datum : listR.getData()) { |
| | | userIds.add(datum.getAppUserId()); |
| | | } |
| | | Set<Long> shopServerUser = getShopServerUser(objectId); |
| | | userIds.addAll(shopServerUser); |
| | | /* Set<Long> shopServerUser = getShopServerUser(objectId); |
| | | userIds.addAll(shopServerUser);*/ |
| | | } |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageCurr, pageSize, appUser, userIds); |
| | | return R.ok(appuserPage); |
| | |
| | | byId.setShopNames(shopName); |
| | | } |
| | | //推广人 |
| | | if (byId.getInviteUserId() != null) { |
| | | /*if (byId.getInviteUserId() != null) { |
| | | AppUser appUser = appUserService.getById(byId.getInviteUserId()); |
| | | if(null != appUser){ |
| | | byId.setInviteUserName(appUser.getName()); |
| | | } |
| | | } |
| | | }*/ |
| | | //最后下单时间 |
| | | R<Order> lastOrder = remoteOrderGoodsClient.getLastOrder(id); |
| | | if (lastOrder.getData() != null) { |
| | | byId.setLastOrderTime(lastOrder.getData().getCreateTime()); |
| | | } |
| | | List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list(); |
| | | byId.setBottomUsers(list); |
| | | /*List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list(); |
| | | byId.setBottomUsers(list);*/ |
| | | //消费总金额 |
| | | if(null == shopId || 1 == sysUser.getRoleType()){ |
| | | shopId = -1; |
| | |
| | | return R.ok(byId); |
| | | } |
| | | |
| | | /** |
| | | * 获取指定用户的下级用户 |
| | | */ |
| | | @GetMapping("/bottom/list") |
| | | @ApiOperation(value = "用户列表-下级用户", tags = {"管理后台"}) |
| | | public R<Page<AppUser>> bottom(Integer pageNum, Integer pageSize, Long userId){ |
| | | Page<AppUser> page = appUserService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getInviteUserId, userId)); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/bottom") |
| | | @ApiOperation(value = "用户列表-绑定下级列表", tags = {"管理后台"}) |
| | | public R<Page<AppUser>> bottom(Long id, Integer pageNum, Integer pageSize) { |
| | | //绑定下级 |
| | | Page<AppUser> page = appUserService.lambdaQuery() |
| | | .eq(AppUser::getInviteUserId, id) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .eq(AppUser::getStatus, 1) |
| | | .page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | |
| | | } |
| | | |
| | | @GetMapping("/orders") |
| | | @ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"}) |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置指定用户的下级用户绑定门店 |
| | | */ |
| | | @PostMapping("/setLowerUserShop") |
| | | public R<Void> setLowerUserShop(@RequestParam("userId") Long userId,@RequestParam("shopId") Integer shopId) { |
| | | appUserService.update(new LambdaUpdateWrapper<AppUser>() |
| | | .set(AppUser::getShopId,shopId) |
| | | .eq(AppUser::getInviteUserId, userId)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | shopId = data.getObjectId(); |
| | | if(null == userId){ |
| | | userIds = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | Set<Long> shopServerUser = getShopServerUser(shopId); |
| | | userIds.addAll(shopServerUser); |
| | | /* Set<Long> shopServerUser = getShopServerUser(shopId); |
| | | userIds.addAll(shopServerUser);*/ |
| | | }else{ |
| | | userIds = new HashSet<>(); |
| | | userIds.add(userId); |