From 04ce420613f90f8414e87e8fe68484fc32485349 Mon Sep 17 00:00:00 2001
From: huliguo <2023611923@qq.com>
Date: 星期二, 24 六月 2025 18:49:06 +0800
Subject: [PATCH] 部署

---
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java |  475 ++++++++++++++++++++++++----------------------------------
 1 files changed, 196 insertions(+), 279 deletions(-)

diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
index 49ea0f8..90d1020 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -1,6 +1,7 @@
 package com.ruoyi.account.controller;
 
 
+import cn.hutool.http.HttpResponse;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -8,6 +9,8 @@
 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.*;
 import com.ruoyi.account.util.ObsUploadUtil;
@@ -17,7 +20,9 @@
 import com.ruoyi.common.core.constant.CacheConstants;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
 import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.page.PageInfo;
 import com.ruoyi.common.redis.service.RedisService;
 import com.ruoyi.common.security.service.TokenService;
 import com.ruoyi.order.feignClient.OrderClient;
@@ -25,17 +30,21 @@
 import com.ruoyi.order.model.Order;
 import com.ruoyi.other.api.domain.Shop;
 import com.ruoyi.other.api.feignClient.ShopClient;
+import com.ruoyi.system.api.domain.SysConfig;
 import com.ruoyi.system.api.domain.SysUser;
+import com.ruoyi.system.api.feignClient.SysConfigClient;
 import com.ruoyi.system.api.feignClient.SysUserClient;
 import com.ruoyi.system.api.model.LoginUser;
 import io.swagger.annotations.*;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
@@ -52,7 +61,7 @@
  * @author luodangjia
  * @since 2024-11-21
  */
-@Api(tags = {"登录注册-小程序"})
+@Api(tags = {"用户端-小程序"})
 @RestController
 @RequestMapping("/app-user")
 @Slf4j
@@ -72,6 +81,10 @@
     private SysUserClient sysUserClient;
     @Resource
     private OrderClient orderClient;
+    @Resource
+    private SysConfigClient sysConfigClient;
+    @Resource
+    private AppUserShopService appUserShopService;
     
     @Resource
     private UserCancellationLogService userCancellationLogService;
@@ -90,6 +103,21 @@
     @ApiOperation(value = "手机号登录")
     public R<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin) {
         return appUserService.mobileLogin(mobileLogin);
+    }
+
+    @ResponseBody
+    @PostMapping("/registerAccount")
+    @ApiOperation(value = "注册新账号")
+    public R<LoginVo> registerAccount(@RequestBody RegisterAccount registerAccount) {
+        return appUserService.registerAccount(registerAccount);
+    }
+
+    @GetMapping("/logout")
+    @ApiOperation(value = "登出")
+    public R logout() {
+        Long userId = tokenService.getLoginUserApplet().getUserid();
+        loginout(userId);
+        return R.ok();
     }
 
 
@@ -140,44 +168,6 @@
     }
 
 
-  /*  @ResponseBody
-    @PostMapping("/registerAccount")
-    @ApiOperation(value = "注册新账号")
-    public R<LoginVo> registerAccount(@RequestBody RegisterAccount registerAccount) {
-        return appUserService.registerAccount(registerAccount);
-    }*/
-
-
-   /* @ResponseBody
-    @GetMapping("/getReferrer/{id}")
-    @ApiOperation(value = "获取推荐人信息")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "推荐人id", required = true, dataType = "long")
-    })
-    public R<String> getReferrer(@PathVariable("id") Long id) {
-        AppUser appUser = appUserService.getById(id);
-        String phone = appUser.getPhone();
-        phone = phone.substring(0, 3) + "****" + phone.substring(7);
-        return R.ok(appUser.getName() + "-" + phone);
-    }
-
-*/
-
-    @ResponseBody
-    @PostMapping("/info")
-    @ApiOperation(value = "我的资料", tags = {"小程序-个人中心首页-我的资料"})
-    public R<AppUser> info() {
-        Long userId = tokenService.getLoginUserApplet().getUserid();
-        AppUser user = appUserService.getById(userId);
-        if(StringUtils.isEmpty(user.getQrCode())){
-            //获取微信推广二维码
-            String fileName = UUID.randomUUID() + ".jpg";
-            String getwxacodeunlimit = weChatUtil.getwxacodeunlimit("pages/start/start", "id=" + user.getId(), EnvVersion.RELEASE, filePath + fileName);
-            user.setQrCode(getwxacodeunlimit);
-            appUserService.updateById(user);
-        }
-        return R.ok(user);
-    }
 
 
 
@@ -187,133 +177,66 @@
     public R unregis() {
         Long userId = tokenService.getLoginUserApplet().getUserid();
         AppUser user = appUserService.getById(userId);
-
         //添加注销记录
         UserCancellationLog userCancellationLog = new UserCancellationLog();
         userCancellationLog.setAppUserId(user.getId());
-        userCancellationLog.setVipId(user.getVipId());
         userCancellationLogService.save(userCancellationLog);
         user.setStatus(3);
         appUserService.updateById(user);
-
-        List<AppUser> subUserList = appUserService.list(new LambdaQueryWrapper<AppUser>()
-                .eq(AppUser::getInviteUserId, userId));
-        for (AppUser appUser : subUserList) {
-            Long inviteUserId = user.getInviteUserId();
-            appUser.setInviteUserId(inviteUserId);
-        }
-        appUserService.updateBatchById(subUserList);
         return R.ok();
     }
 
-
     @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("/getServicePhone")
+    @ApiOperation(value = "获取客服电话", tags = {"小程序-个人中心首页-客服"})
+    public R getServicePhone() {
+        SysConfig data = sysConfigClient.getInfo(7L).getData();
+        List<String> phoneList = null;
+        if (data != null) {
+            phoneList = Arrays.stream(data.getConfigValue().split(";"))
+                    .map(String::trim)  // 去除每个号码前后的空格
+                    .filter(s -> !s.isEmpty())  // 过滤空字符串
+                    .collect(Collectors.toList());
+        }
+        return R.ok(phoneList);
     }
+
+
+
+
 
 
 
     @GetMapping("/index")
-    @ApiOperation(value = "个人中心首页", tags = {"小程序-个人中心首页"})
+    @ApiOperation(value = "个人信息", tags = {"小程序-个人中心首页"})
     public R<AppUser> index() {
-        Long userId = tokenService.getLoginUserApplet().getUserid();
-        //当前用户信息
-        AppUser user = appUserService.getById(userId);
-        if(StringUtils.isEmpty(user.getQrCode())){
-            //获取微信推广二维码
-            String fileName = UUID.randomUUID() + ".jpg";
-            String getwxacodeunlimit = weChatUtil.getwxacodeunlimit("pages/start/start", "id=" + user.getId(), EnvVersion.RELEASE, filePath + fileName);
-            user.setQrCode(getwxacodeunlimit);
-            appUserService.updateById(user);
-        }
-        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);
-        }
-    }
 
 
 
-    @GetMapping("/index/change")
+    @PostMapping("/index/change")
     @ApiOperation(value = "修改个人资料", tags = {"小程序-个人中心首页"})
-    public R<AppUser> indexchange(String avatar, String name) {
+    public R<AppUser> indexchange(@RequestBody ChangeAppUserInfo changeAppInfo) {
         Long userId = tokenService.getLoginUserApplet().getUserid();
         //当前用户信息
         AppUser user = appUserService.getById(userId);
-        user.setName(name);
-        user.setAvatar(avatar);
+        if (null != changeAppInfo.getName()){
+            user.setName(changeAppInfo.getName());
+        }
+        if (null != changeAppInfo.getAvatar()){
+            user.setAvatar(changeAppInfo.getAvatar());
+        }
         appUserService.updateById(user);
         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();
-    }
 
 
     /**
@@ -377,8 +300,8 @@
             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());
         }
@@ -399,31 +322,10 @@
     public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum,
                                                @ApiParam("每一页数据大小") Integer pageSize,
                                                AppUser appUser){
-
-        Long userid = tokenService.getLoginUser().getUserid();
-        SysUser sysUser = sysUserClient.getSysUser(userid).getData();
         Integer shopId = null;
         Set<Long> userId = null;
-        if(sysUser.getRoleType() == 2){
-            shopId = sysUser.getObjectId();
-            userId = orderClient.getAppUserByShoppingShop(shopId).getData();
-        }
-        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());
-                record.setShopId(shop1.getId());
-            }
-            record.setTotalPoint(record.getUserTotalPoint());
-        }
+
         return R.ok(appuserPage);
     }
 
@@ -445,26 +347,26 @@
         }
         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){
                     record.setShopName(shopById.getData().getName());
                 }
             }
-            record.setTotalPoint(record.getUserTotalPoint());
+
         }
         return R.ok(appuserPage);
     }
 
 
     @GetMapping("/shop/getAppuserPage")
-    @ApiOperation(value = "用户列表", tags = {"门店后台"})
+    @ApiOperation(value = "用户列表-在门店下过单的", tags = {"门店后台"})
     public R<IPage<AppUser>> shopGetAppuserPage(@ApiParam("页码") @RequestParam Integer pageCurr,
                                                 @ApiParam("每一页数据大小") Integer pageSize,
                                                 AppUser appUser) {
@@ -481,8 +383,8 @@
             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);
@@ -532,80 +434,23 @@
 
     @GetMapping("/detail")
     @ApiOperation(value = "用户列表-详情", tags = {"管理后台"})
-    public R<AppUser> detail(Long id, Integer shopId) {
-        Long userid = tokenService.getLoginUser().getUserid();
-        SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+    public R<AppUser> detail(Long id) {
         AppUser byId = appUserService.getById(id);
-        Shop shop1 = shopClient.getServiceProvider(byId.getId()).getData();
-        if(null != shop1){
-            byId.setShopName(shop1.getName());
-            byId.setShopId(shop1.getId());
+        //获取店铺名称
+        List<String> shopNames=shopClient.getServiceProvider(byId.getId()).getData();
+        if(null != shopNames){
+            byId.setShopNames(shopNames);
         }
-        R<List<Shop>> shopByUserId = shopClient.getShopByUserId(id);
-        if (shopByUserId.getData() != null) {
-            List<String> shopName = new ArrayList<>();
-            for (Shop datum : shopByUserId.getData()) {
-                shopName.add(datum.getName());
-            }
-            byId.setShopNames(shopName);
-        }
-        //推广人
-        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);
         //消费总金额
-        if(null == shopId || 1 == sysUser.getRoleType()){
-            shopId = -1;
-        }
-        if(null == shopId && 2 == sysUser.getRoleType()){
-            shopId = sysUser.getObjectId();
-        }
-        R<List<Order>> orderR = remoteOrderGoodsClient.byUserId(id, shopId);
-        List<Order> orderList = orderR.getData();
-        if (!CollectionUtils.isEmpty(orderList)){
-            BigDecimal paymentAmount = orderList.stream().map(Order::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
-            byId.setShopAmount(paymentAmount);
-        }else {
-            byId.setShopAmount(BigDecimal.ZERO);
-        }
+        Integer customPoint =(byId.getExchangePoint()==null?0:byId.getExchangePoint())+
+                (byId.getTransferableOutPoint()==null?0:byId.getTransferableOutPoint())-
+                (byId.getCancelPoint()==null?0:byId.getCancelPoint());
+        byId.setCustomPoint(customPoint);
+
         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 = {"管理后台"})
@@ -659,63 +504,83 @@
     }
 
 
-    /**
-     * 设置指定用户的下级用户绑定门店
-     */
-    @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();
-    }
 
 
     /**
-     * 用户统计
+     * 工作台-顶部
      */
     @GetMapping("/statistics")
-    @ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"})
+    @ApiOperation(value = "统计", tags = {"后台-工作台-顶部"})
     public R<UserStatistics> statistics() {
-        Long userId = tokenService.getLoginUser().getUserid();
-        SysUser data = sysUserClient.getSysUser(userId).getData();
-
         QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>();
-        if (data.getRoleType() == 2) {
-            Integer shopId = data.getObjectId();
-            List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData();
-            List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList());
-            queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds); // userIds 不为空时,查询 id 在 userIds 中
-        }
         queryWrapper.eq("del_flag", 0);
-        queryWrapper.ne("status", 3);
-        List<AppUser> appUserList = appUserService.list(queryWrapper);
+        queryWrapper.ne("status", 3);//没有注销的
 
-        Map<Integer, Long> vipIdCountMap = appUserList.stream()
-                .collect(Collectors.groupingBy(AppUser::getVipId, Collectors.counting()));
+        List<AppUser> appUserList = appUserService.list(queryWrapper);
+        long consumerUser = appUserList.stream()
+                .filter(user -> user.getLastShopTime() != null)
+                .count();//消费者总数
 
         UserStatistics userStatistics = new UserStatistics();
-        userStatistics.setTotalUser(appUserList.size());
-        userStatistics.setConsumerUser(vipIdCountMap.getOrDefault(0, 0L).intValue() +
-                vipIdCountMap.getOrDefault(1, 0L).intValue() +
-                vipIdCountMap.getOrDefault(2, 0L).intValue() +
-                vipIdCountMap.getOrDefault(3, 0L).intValue());
-        userStatistics.setCommonUser(vipIdCountMap.getOrDefault(1, 0L).intValue());
-        userStatistics.setGoldUser(vipIdCountMap.getOrDefault(2, 0L).intValue());
-        userStatistics.setDiamondUser(vipIdCountMap.getOrDefault(3, 0L).intValue());
-        userStatistics.setEntrepreneurUser(vipIdCountMap.getOrDefault(4, 0L).intValue() +
-                vipIdCountMap.getOrDefault(5, 0L).intValue() +
-                vipIdCountMap.getOrDefault(6, 0L).intValue() +
-                vipIdCountMap.getOrDefault(7, 0L).intValue());
-        userStatistics.setProxyUser(vipIdCountMap.getOrDefault(4, 0L).intValue());
-        userStatistics.setAgentUser(vipIdCountMap.getOrDefault(5, 0L).intValue());
-        userStatistics.setTotalAgentUser(vipIdCountMap.getOrDefault(6, 0L).intValue());
-        userStatistics.setPartnerUser(vipIdCountMap.getOrDefault(7, 0L).intValue());
+        userStatistics.setTotalUser(appUserList.size());//总用户数
+        userStatistics.setConsumerUser((int) consumerUser);//消费过的用户
 
-        long shopUserCount = appUserList.stream()
-                .filter(appUser -> appUser.getUserType() == 2)
-                .count();
-        userStatistics.setShopUser((int) shopUserCount);
+        //拥有店铺用户数
+        Integer shopUserCount = appUserShopService.getHaveShopUserNum();
+
+        userStatistics.setShopUser(shopUserCount);
+
+        //门店总数
+        long shopNum = shopClient.getAllShop().getData().size();
+        userStatistics.setShopNum((int) shopNum);
+        return R.ok(userStatistics);
+    }
+
+    /**
+     * 工作台-用户分析
+     */
+    @GetMapping("/homeStatistics/userAnalysis")
+    @ApiOperation(value = "用户分析", tags = {"后台-工作台-用户分析"})
+    public R<UserStatisticsDetail> userAnalysis(@ApiParam(value = "用户id") @RequestParam(value = "userId",required = false) Long userId) {
+        UserStatisticsDetail userStatistics = new UserStatisticsDetail();
+
+        QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>();
+        // 条件构造  统计充值积分
+        queryWrapper.select("SUM(recharge_point) as total_points");
+        queryWrapper.eq("del_flag", 0);//未删除的
+        queryWrapper.ne("status", 3);//未注销的
+        if (userId != null) {
+            queryWrapper.eq("id", userId);
+        }
+        //统计充值积分
+        Map<String, Object> result = appUserService.getMap(queryWrapper);
+        if (result == null || result.get("total_points") == null) {
+            userStatistics.setTotalScore(0L);
+        }else {
+            userStatistics.setTotalScore(((BigDecimal) result.get("total_points")).longValue());
+        }
+        //条件构造  消费积分现金支付金额
+        queryWrapper.clear();
+        QueryWrapper<AppUser> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.select("sum(exchange_point + transferable_out_point - cancel_point) as total_points");
+        queryWrapper1.select("sum(shop_amount) as payment_amounts ");
+        queryWrapper1.eq("del_flag", 0);//未删除的
+        queryWrapper1.ne("status", 3);//未注销的
+        if (userId != null) {
+            queryWrapper1.eq("id", userId);
+        }
+        Map<String, Object> data  = appUserShopService.getPointAndPayAmount(userId);
+        if (data == null || data.get("total_points") == null) {
+            userStatistics.setConsumeScore(0L);
+        }else {
+            userStatistics.setConsumeScore(Long.valueOf(data.get("total_points").toString()) );
+        }
+
+        if (data == null || data.get("payment_amounts") == null) {
+            userStatistics.setShopAmount(BigDecimal.ZERO);
+        }else {
+            userStatistics.setShopAmount(new BigDecimal(data.get("payment_amounts").toString()));
+        }
 
         return R.ok(userStatistics);
     }
@@ -738,8 +603,8 @@
             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);
@@ -758,14 +623,14 @@
      * @return
      */
     @PostMapping("/upload")
-    public String upload(MultipartFile file){
+    public R upload(MultipartFile file){
         String s = null;
         try {
             s = ObsUploadUtil.obsUpload(file);
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
-        return s;
+        return R.ok(s);
     }
     
     
@@ -782,5 +647,57 @@
         return R.ok();
     }
 
+
+    /**
+     * 获取所有用户积分列表
+     */
+    @ResponseBody
+    @GetMapping("/getUserPointPageList")
+    @ApiOperation(value = "所有用户积分列表", tags = "后台-财务统计-用户积分统计")
+    public R<PageInfo<UserPointStatisticsVO>> getUserPointPageList(@RequestParam(value = "name",required = false) String name,
+                                                                   @ApiParam("当前页")@RequestParam("pageCurr") Integer pageCurr,
+                                                                   @ApiParam("分页大小")@RequestParam("pageSize") Integer pageSize) {
+        PageInfo<UserPointStatisticsVO> pageInfo=appUserService.getUserPointPageList(name,pageCurr,pageSize);
+
+        return R.ok(pageInfo);
+    }
+
+    /**
+     * 导出用户积分列表
+     */
+    @ResponseBody
+    @GetMapping("/exportUserPoint")
+    @ApiOperation(value = "导出用户积分列表", tags = "后台-财务统计-用户积分统计")
+    public void exportUserPoint(HttpServletResponse response, @RequestParam(value = "name",required = false) String name) {
+
+        List<UserPointStatisticsVO> exportList=appUserMapper.exportUserPoint(name);
+        ExcelUtil<UserPointStatisticsVO> util = new ExcelUtil<UserPointStatisticsVO>(UserPointStatisticsVO.class);
+        util.exportExcel(response, exportList, "用户积分汇总");
+    }
+
+
+    @PostMapping("/saveOrUpdateAppUser")
+    Long saveOrUpdateAppUser(@RequestBody AppUser appuser){
+        if (appuser.getId() == null) {
+            //保存用户
+            appUserService.save(appuser);
+        }else {
+            appUserService.updateById(appuser);
+        }
+        return appuser.getId();
+
+    }
+
+    @GetMapping("/getAllUser")
+    @ApiOperation(value = "获取所有用户")
+    public R<List<AppUser>> getAllUser() {
+        LambdaQueryWrapper<AppUser> queryWrapper=new LambdaQueryWrapper<>();
+        queryWrapper.select(AppUser::getId,AppUser::getName);
+        queryWrapper.eq(AppUser::getDelFlag,0);//未删除的
+        queryWrapper.ne(AppUser::getStatus, 3);//未注销的
+        List<AppUser> list = appUserService.list(queryWrapper);
+        return R.ok(list);
+    }
+
 }
 

--
Gitblit v1.7.1