luodangjia
2025-02-06 4ea15c3e2a3f0434df79a1b49fe4e90f7337b025
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -1,6 +1,7 @@
package com.ruoyi.account.controller;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -744,7 +745,7 @@
    @GetMapping("/detail")
    @ApiOperation(value = "用户列表-详情", tags = {"管理后台"})
    public R<AppUser> detail(Long id, Integer shopId, Integer pageNum, Integer pageSize) {
    public R<AppUser> detail(Long id, Integer shopId) {
        Long userid = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserClient.getSysUser(userid).getData();
        AppUser byId = appUserService.getById(id);
@@ -774,8 +775,8 @@
        if (lastOrder.getData() != null) {
            byId.setLastOrderTime(lastOrder.getData().getCreateTime());
        }
        Page<AppUser> page = appUserService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<AppUser>().eq(AppUser::getInviteUserId, id));
        byId.setBottomUsersPage(page);
        List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list();
        byId.setBottomUsers(list);
        //消费总金额
        if(null == shopId || 1 == sysUser.getRoleType()){
            shopId = -1;
@@ -793,6 +794,20 @@
        }
        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);
    }
    
@@ -815,7 +830,6 @@
        byId.setVipId(vipId);
        appUserService.updateById(byId);
        return R.ok();
    }
    @GetMapping("/bottom")
@@ -829,7 +843,7 @@
    @GetMapping("/orders")
    @ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"})
    public R<List<Order>> orders(Long id) {
    public R<JSONObject> orders(Long id,Integer pageNum, Integer pageSize) {
        Long userid = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserClient.getSysUser(userid).getData();
        Integer shopId = -1;
@@ -837,8 +851,27 @@
            shopId = sysUser.getObjectId();
        }
        R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id,shopId);
        return R.ok(listR.getData());
        List<Order> data = listR.getData();
        Integer total = data.size();
        // 手动分页
        if (data != null && data.size() > 0) {
            if (pageNum == null || pageNum == 0) {
                pageNum = 1;
            }
            if (pageSize == null || pageSize == 0) {
                pageSize = 10;
            }
            data = data.stream()
                    .skip((pageNum - 1) * pageSize)
                    .limit(pageSize)
                    .collect(Collectors.toList());
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("records", data);
        jsonObject.put("total", total);
        jsonObject.put("size", pageSize);
        jsonObject.put("current", pageNum);
        return R.ok(jsonObject);
    }