From 47e7e97075e6948c6d2097930e80e498fa14c5a9 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Thu, 16 Oct 2025 09:55:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=90=A5=E5=85=BB=E5=88=86=E6=9E=90?= =?UTF-8?q?=E8=B6=8B=E5=8A=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../panel/PanelNutritionController.java | 22 ++++++++ .../hard/service/PanelNutritionService.java | 5 ++ .../impl/panel/PanelNutritionServiceImpl.java | 36 +++++++++++-- .../mapper/order/HardOrderMapper.xml | 50 +++++++++++++++++-- 4 files changed, 103 insertions(+), 10 deletions(-) diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/panel/PanelNutritionController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/panel/PanelNutritionController.java index c8c486862..34c1f68a5 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/panel/PanelNutritionController.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/panel/PanelNutritionController.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.time.LocalDateTime; import java.util.List; @RestController @@ -68,4 +69,25 @@ public class PanelNutritionController { return R.ok(panelNutritionService.nutritionTotal(dto)); } + @PostMapping(value = "/nutrition/trend") + @Operation(summary = "营养分析(趋势)") + public R nutritionTrend(@RequestBody PanelProductDto dto) { + dto.setTotalTimeList(new LocalDateTime[]{ + LocalDateTime.now().minusDays(8).withHour(0).withMinute(0).withSecond(0), + LocalDateTime.now().withHour(23).withMinute(59).withSecond(59) + }); + dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType())); + return R.ok(panelNutritionService.nutritionByTime(dto)); + } + + @PostMapping(value = "/repurchase") + @Operation(summary = "复购排行榜") + public R> repurchase(@RequestBody PanelProductDto dto) { + if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isEmpty(dto.getTotalTimeList())) { + dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType())); + } + dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType())); + return R.ok(panelNutritionService.repurchase(dto)); + } + } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/PanelNutritionService.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/PanelNutritionService.java index 85bbbd587..d93ed2508 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/PanelNutritionService.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/PanelNutritionService.java @@ -30,4 +30,9 @@ public interface PanelNutritionService { * 营养分析(总数统计) */ List nutritionTotal(PanelProductDto dto); + + /** + * 复购排行榜 + */ + List repurchase(PanelProductDto dto); } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/panel/PanelNutritionServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/panel/PanelNutritionServiceImpl.java index fb4ad50f3..bf81c1b69 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/panel/PanelNutritionServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/panel/PanelNutritionServiceImpl.java @@ -23,6 +23,8 @@ import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -179,12 +181,36 @@ public class PanelNutritionServiceImpl implements PanelNutritionService { return null; } + /** + * 复购排行榜 + */ + @Override + public List repurchase(PanelProductDto dto) { + PanelPorductVo panelPorductVo = hardOrderMapper.groupCount(dto); + return List.of(); + } + private List> nutritionSetting() { - return List.of( - Map.of("key", "hc", "name", "荤菜", "classify", new ArrayList(), "order", 0), - Map.of("key", "sc", "name", "素菜", "classify", new ArrayList(), "order", 1), - Map.of("key", "zs", "name", "主食", "classify", new ArrayList(), "order", 2) - ); + + Map hcMap = new HashMap<>(); + hcMap.put("key", "hc"); + hcMap.put("name", "荤菜"); + hcMap.put("classify", new ArrayList()); + hcMap.put("order", 0); + + Map scMap = new HashMap<>(); + scMap.put("key", "sc"); + scMap.put("name", "素菜"); + scMap.put("classify", new ArrayList()); + scMap.put("order", 1); + + Map zsMap = new HashMap<>(); + zsMap.put("key", "zs"); + zsMap.put("name", "主食"); + zsMap.put("classify", new ArrayList()); + zsMap.put("order", 2); + + return Arrays.asList(hcMap, scMap, zsMap); } } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml index 8940864d9..fb9d5dc12 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml @@ -554,7 +554,8 @@ select SUM(a.product_count) as buyProductCount, SUM(a.total_price) as totalPrice, count(distinct o.id) as buyCount, - count(distinct o.user_id) as personCount + count(distinct o.user_id) as personCount, + s.category_id as classifyId from hard_car a inner join hard_parent_car p on a.parent_car_id = p.id and p.del_flag = '0' inner join hard_order o on o.parent_car_id = p.id and o.del_flag = '0' and o.hour_type is not null and @@ -562,6 +563,7 @@ and o.hour_type is not null and o.hour_type not in ('-1', 'null') + left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id a.del_flag = '0' @@ -576,6 +578,12 @@ #{v} + + and s.category_id in + + #{v} + + @@ -586,13 +594,15 @@ SUM(a.product_count) as buyProductCount, SUM(a.total_price) as totalPrice, count(distinct o.id) as buyCount, - count(distinct o.user_id) as personCount + count(distinct o.user_id) as personCount, + s.category_id as classifyId from hard_car a inner join hard_parent_car p on a.parent_car_id = p.id and p.del_flag = '0' inner join hard_order o on o.parent_car_id = p.id and o.del_flag = '0' and o.hour_type is not null and o.hour_type not in ('-1', 'null') + left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id a.del_flag = '0' @@ -607,6 +617,12 @@ #{v} + + and s.category_id in + + #{v} + + group by date(o.create_time) order by date(o.create_time) desc @@ -622,13 +638,15 @@ SUM(a.product_count) as buyProductCount, SUM(a.total_price) as totalPrice, count(distinct o.id) as buyCount, - count(distinct o.user_id) as personCount + count(distinct o.user_id) as personCount, + s.category_id as classifyId from hard_car a inner join hard_parent_car p on a.parent_car_id = p.id and p.del_flag = '0' inner join hard_order o on o.parent_car_id = p.id and o.del_flag = '0' and o.hour_type is not null and o.hour_type not in ('-1', 'null') + left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id a.del_flag = '0' @@ -643,6 +661,12 @@ #{v} + + and s.category_id in + + #{v} + + group by date(o.create_time), o.hour_type order by date(o.create_time) desc @@ -658,13 +682,15 @@ SUM(a.product_count) as buyProductCount, SUM(a.total_price) as totalPrice, count(distinct o.id) as buyCount, - count(distinct o.user_id) as personCount + count(distinct o.user_id) as personCount, + s.category_id as classifyId from hard_car a inner join hard_parent_car p on a.parent_car_id = p.id and p.del_flag = '0' inner join hard_order o on o.parent_car_id = p.id and o.del_flag = '0' and o.hour_type is not null and o.hour_type not in ('-1', 'null') + left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id a.del_flag = '0' @@ -679,6 +705,12 @@ #{v} + + and s.category_id in + + #{v} + + group by date_format(o.create_time, '%Y-%m'), o.hour_type order by date_format(o.create_time, '%Y-%m') desc @@ -692,13 +724,15 @@ sum(a.product_count) as buyProductCount, SUM(a.total_price) as totalPrice, count(distinct o.id) as buyCount, - count(distinct o.user_id) as personCount + count(distinct o.user_id) as personCount, + s.category_id as classifyId from hard_car a inner join hard_parent_car p on a.parent_car_id = p.id and p.del_flag = '0' inner join hard_order o on o.parent_car_id = p.id and o.del_flag = '0' and o.hour_type is not null and o.hour_type not in ('-1', 'null') + left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id a.del_flag = '0' @@ -713,6 +747,12 @@ #{v} + + and s.category_id in + + #{v} + + group by o.merchant_id order by sum(a.product_count) desc