| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | 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; |
| | |
| | | * @author luodangjia |
| | | * @since 2024-11-21 |
| | | */ |
| | | @Api(tags = {"登录注册-小程序"}) |
| | | @Api(tags = {"用户端-小程序"}) |
| | | @RestController |
| | | @RequestMapping("/app-user") |
| | | @Slf4j |
| | |
| | | private OrderClient orderClient; |
| | | @Resource |
| | | private SysConfigClient sysConfigClient; |
| | | @Resource |
| | | private AppUserShopService appUserShopService; |
| | | |
| | | @Resource |
| | | private UserCancellationLogService userCancellationLogService; |
| | |
| | | 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()) { |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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) { |
| | |
| | | |
| | | |
| | | |
| | | /* |
| | | |
| | | @GetMapping("/detail") |
| | | @ApiOperation(value = "用户列表-详情", tags = {"管理后台"}) |
| | |
| | | } |
| | | 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; |
| | |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | */ |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * 用户统计 |
| | | * 工作台-顶部 |
| | | */ |
| | | @GetMapping("/statistics") |
| | | @ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"}) |
| | | @GetMapping("/homeStatistics/statistics") |
| | | @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); |
| | | |
| | | //门店总数 |
| | | 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("user_id", userId); |
| | | } |
| | | //统计充值积分 |
| | | Map<String, Object> result = appUserService.getMap(queryWrapper); |
| | | if (result == null || result.get("total_points") == null) { |
| | | userStatistics.setTotalScore(0L); |
| | | }else { |
| | | userStatistics.setTotalScore((Long) result.get("total_points")); |
| | | } |
| | | |
| | | //统计消费积分和现金支付数 |
| | | Map<String, Object> data = orderClient.getConsumeScoreAndPayAmount(userId).getData(); |
| | | |
| | | 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); |
| | | } |
| | |
| | | * @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); |
| | | } |
| | | |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | @PostMapping("/saveOrUpdateAppUser") |
| | | Long saveOrUpdateAppUser(@RequestBody AppUser appuser){ |
| | | if (appuser.getId() == null) { |
| | | //保存用户 |
| | | appUserService.save(appuser); |
| | | }else { |
| | | appUserService.updateById(appuser); |
| | | } |
| | | return appuser.getId(); |
| | | |
| | | } |
| | | |
| | | } |
| | | |