From e628c260ccff372849b4279c89a45d6b028a5484 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期二, 03 九月 2024 19:45:24 +0800 Subject: [PATCH] 统计数据分析 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java index 3bbf0a1..b736fed 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java @@ -6,6 +6,8 @@ import com.ruoyi.system.query.TDataStatisticsQuery; import com.ruoyi.system.service.TOrderMealService; import com.ruoyi.system.service.TOrderSaleService; +import com.ruoyi.system.vo.OrderTrendsVO; +import com.ruoyi.system.vo.PersonnelStatisticsVO; import com.ruoyi.system.vo.SalesRankingVO; import com.ruoyi.system.vo.SalesVolumeVO; import io.swagger.annotations.ApiOperation; @@ -129,7 +131,7 @@ @ApiOperation( value = "下单趋势") @PostMapping(value = "/orderingTrends") - public AjaxResult<List<SalesRankingVO>> orderingTrends(@RequestBody TDataStatisticsQuery query) { + public AjaxResult<List<OrderTrendsVO>> orderingTrends(@RequestBody TDataStatisticsQuery query) { Integer roleType = tokenService.getLoginUser().getRoleType(); Long objectId = tokenService.getLoginUser().getObjectId(); query.setShopId(objectId); @@ -162,13 +164,50 @@ } query.setStartTime(startTime); query.setEndTime(endTime); - List<SalesRankingVO> salesRankingVOS; + List<OrderTrendsVO> orderTrendsVOS; if(roleType == 2){ - salesRankingVOS = orderMealService.salesRanking(query); + orderTrendsVOS = orderMealService.orderingTrends(query); }else{ - salesRankingVOS = orderSaleService.salesRanking(query); + orderTrendsVOS = orderSaleService.orderingTrends(query); } - return AjaxResult.success(salesRankingVOS); + return AjaxResult.success(orderTrendsVOS); + } + + @ApiOperation( value = "接待人数统计") + @PostMapping(value = "/personnelStatistics") + public AjaxResult<List<PersonnelStatisticsVO>> personnelStatistics(@RequestBody TDataStatisticsQuery query) { + Long objectId = tokenService.getLoginUser().getObjectId(); + query.setShopId(objectId); + if(Objects.isNull(query.getTimeType())){ + query.setTimeType(1); + } + LocalDateTime startTime = null; + LocalDateTime endTime = null; + switch (query.getTimeType()){ + case 1: + // 今日 + startTime = LocalDateTime.MIN; + endTime = LocalDateTime.MAX; + break; + case 2: + // 昨日 + startTime = LocalDateTime.now().minusDays(1); + endTime = LocalDateTime.now().minusDays(1); + break; + case 3: + // 近7天 + startTime = LocalDateTime.now().minusDays(7); + endTime = LocalDateTime.now(); + break; + case 4: + // 近30天 + startTime = LocalDateTime.now().minusDays(30); + endTime = LocalDateTime.now(); + break; + } + query.setStartTime(startTime); + query.setEndTime(endTime); + return AjaxResult.success(orderMealService.personnelStatistics(query)); } -- Gitblit v1.7.1