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)); } ruoyi-system/src/main/java/com/ruoyi/system/mapper/TOrderMealMapper.java
@@ -5,9 +5,7 @@ import com.ruoyi.system.domain.TOrderMeal; import com.ruoyi.system.query.TDataStatisticsQuery; import com.ruoyi.system.query.TOrderMealQuery; import com.ruoyi.system.vo.AmountSumVO; import com.ruoyi.system.vo.SalesVolumeVO; import com.ruoyi.system.vo.TOrderMealVO; import com.ruoyi.system.vo.*; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -51,4 +49,19 @@ * @return */ List<TOrderMealVO> exportOrderMeal(@Param("query")TOrderMealQuery query); /** * 查询下单趋势 * @param query * @return */ List<OrderTrendsVO> orderingTrends(@Param("query")TDataStatisticsQuery query); /** * 查询接待人数统计 * @param query * @return */ List<PersonnelStatisticsVO> personnelStatistics(@Param("query")TDataStatisticsQuery query); } ruoyi-system/src/main/java/com/ruoyi/system/mapper/TOrderSaleMapper.java
@@ -7,6 +7,7 @@ import com.ruoyi.system.query.TOrderMealQuery; import com.ruoyi.system.query.TOrderSaleQuery; import com.ruoyi.system.vo.AmountSumVO; import com.ruoyi.system.vo.OrderTrendsVO; import com.ruoyi.system.vo.SalesVolumeVO; import com.ruoyi.system.vo.TOrderSaleVO; import org.apache.ibatis.annotations.Param; @@ -51,4 +52,11 @@ * @return */ List<TOrderSaleVO> exportOrderSale(@Param("query")TOrderMealQuery query); /** * 查询销售订单趋势 * @param query * @return */ List<OrderTrendsVO> orderingTrends(@Param("query")TDataStatisticsQuery query); } ruoyi-system/src/main/java/com/ruoyi/system/service/TOrderMealService.java
@@ -9,10 +9,7 @@ import com.ruoyi.system.dto.TOrderMealDTO; import com.ruoyi.system.query.TDataStatisticsQuery; import com.ruoyi.system.query.TOrderMealQuery; import com.ruoyi.system.vo.AmountSumVO; import com.ruoyi.system.vo.SalesRankingVO; import com.ruoyi.system.vo.SalesVolumeVO; import com.ruoyi.system.vo.TOrderMealVO; import com.ruoyi.system.vo.*; import java.util.List; @@ -79,4 +76,18 @@ * @return */ List<TOrderMealVO> exportOrderMeal(TOrderMealQuery query); /** * 下单趋势 * @param query * @return */ List<OrderTrendsVO> orderingTrends(TDataStatisticsQuery query); /** * 接待人数统计 * @param query * @return */ List<PersonnelStatisticsVO> personnelStatistics(TDataStatisticsQuery query); } ruoyi-system/src/main/java/com/ruoyi/system/service/TOrderSaleService.java
@@ -61,4 +61,11 @@ * @return */ List<TOrderSaleVO> exportOrderSale(TOrderMealQuery query); /** * 下单趋势 * @param query * @return */ List<OrderTrendsVO> orderingTrends(TDataStatisticsQuery query); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOrderMealServiceImpl.java
@@ -285,4 +285,14 @@ return list; } @Override public List<OrderTrendsVO> orderingTrends(TDataStatisticsQuery query) { return this.baseMapper.orderingTrends(query); } @Override public List<PersonnelStatisticsVO> personnelStatistics(TDataStatisticsQuery query) { return this.baseMapper.personnelStatistics(query); } } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOrderSaleServiceImpl.java
@@ -180,4 +180,9 @@ } return list; } @Override public List<OrderTrendsVO> orderingTrends(TDataStatisticsQuery query) { return this.baseMapper.orderingTrends(query); } } ruoyi-system/src/main/java/com/ruoyi/system/vo/OrderTrendsVO.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.system.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; @Data @ApiModel(value = "下单趋势VO") public class OrderTrendsVO implements Serializable { @ApiModelProperty(value = "日期") private String dayTime; @ApiModelProperty(value = "单数") private Integer orderCount; } ruoyi-system/src/main/java/com/ruoyi/system/vo/PersonnelStatisticsVO.java
New file @@ -0,0 +1,21 @@ package com.ruoyi.system.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; @Data @ApiModel(value = "接待人数统计VO") public class PersonnelStatisticsVO implements Serializable { @ApiModelProperty(value = "桌号") private String boardName; @ApiModelProperty(value = "接待人数") private Integer personCount; @ApiModelProperty(value = "人均消费金额") private BigDecimal avgAmount; } ruoyi-system/src/main/resources/mapper/system/TOrderMealMapper.xml
@@ -134,5 +134,35 @@ </where> ORDER BY tom.createTime DESC </select> <select id="orderingTrends" resultType="com.ruoyi.system.vo.OrderTrendsVO"> select DATE_FORMAT(createTime, '%Y-%m-%d') AS dayTime, COUNT(id) AS orderCount from t_order_meal <where> <if test="query.shopId != null"> AND shopId = #{query.shopId} </if> <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> AND (createTime BETWEEN #{query.startTime} AND #{query.endTime}) </if> AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where> </select> <select id="personnelStatistics" resultType="com.ruoyi.system.vo.PersonnelStatisticsVO"> select tb.boardName,tom.mealPerson, (tom.payMoney/tom.mealPerson) AS avgAmount from t_order_meal tom left join t_board tb on tb.id = tom.boardId <where> <if test="query.shopId != null"> AND tom.shopId = #{query.shopId} </if> <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> AND (tom.createTime BETWEEN #{query.startTime} AND #{query.endTime}) </if> AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where> </select> </mapper> ruoyi-system/src/main/resources/mapper/system/TOrderSaleMapper.xml
@@ -113,5 +113,20 @@ </where> ORDER BY orderTime DESC </select> <select id="orderingTrends" resultType="com.ruoyi.system.vo.OrderTrendsVO"> select DATE_FORMAT(orderTime, '%Y-%m-%d') AS dayTime, COUNT(id) AS orderCount from t_order_sale <where> <if test="query.shopId != null"> AND shopId = #{query.shopId} </if> <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> AND (createTime BETWEEN #{query.startTime} AND #{query.endTime}) </if> AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where> </select> </mapper>