feat:热卖商品

This commit is contained in:
dzc committed 2025-10-28 11:06:47 +08:00
1 parent c81ea9ebe7
commit a5ff990b9e
7 files changed
+65 -1

No files matched your search

@@ -113,6 +113,20 @@ public class PanelPorductVo {
}
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class ProductListByTimeItemVo {
private String timeStr;
private LocalDateTime time;
private List<PanelPorductVo> list;
}
@Data
@Builder
@AllArgsConstructor
@@ -100,7 +100,7 @@ public class PanelNutritionController {
@PostMapping(value = "/repurchase")
@Operation(summary = "复购排行榜")
public R<List<PanelPorductVo>> repurchase(@RequestBody PanelProductDto dto) {
dto.setDateRangeType(DateRangeTypeEnum.THIS_YEAR);
dto.setDateRangeType(DateRangeTypeEnum.TODAY);
if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isEmpty(dto.getTotalTimeList())) {
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
}
@@ -146,4 +146,19 @@ public class PanelShopController {
return R.ok(panelShopService.todayTrend(dto));
}
@PostMapping(value = "/hot-product")
@Operation(summary = "热卖商品")
public R<List<PanelPorductVo>> hotProduct(@RequestBody PanelProductDto dto) {
dto.setDateRangeType(DateRangeTypeEnum.THIS_WEEK);
if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isEmpty(dto.getTotalTimeList())) {
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
}
dto.setMchTypeCodes(List.of(MerchantTypeEnum.SELF_SUPERMARKET.getType()));
dto.setOrderStatus(HardOrderStatusEnum.getPayPrice());
dto.setLimit(10L);
return R.ok(panelShopService.hotProduct(dto));
}
}
@@ -168,4 +168,6 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
List<PanelPorductVo> shopGroupByMonthAndHourType(@Param("dto") PanelProductDto dto);
List<PanelPorductVo> shopGroupByTimeAndHourType(@Param("dto") PanelProductDto dto);
List<PanelPorductVo> shopGroupByProduct(@Param("dto") PanelProductDto dto);
}
@@ -26,4 +26,9 @@ public interface PanelShopService {
* 当天超市购买次数趋势统计
*/
List<PanelPorductVo> todayTrend(PanelProductDto dto);
/**
* 热卖商品
*/
List<PanelPorductVo> hotProduct(PanelProductDto dto);
}
@@ -133,6 +133,14 @@ public class PanelShopServiceImpl implements PanelShopService {
return result.stream().sorted(Comparator.comparingInt(PanelPorductVo::getOrder)).toList();
}
/**
* 热卖商品
*/
@Override
public List<PanelPorductVo> hotProduct(PanelProductDto dto) {
return hardOrderMapper.shopGroupByProduct(dto);
}
private void disposePanelCanteenVoSetMchName(List<PanelPorductVo> list) {
if (ObjectUtil.isEmpty(list)) return;
// 商户名
@@ -846,4 +846,24 @@
group by date(o.create_time), o.merchant_id
order by date(o.create_time), sum(c.product_count) desc
</select>
<select id="shopGroupByProduct" resultType="com.bsd.pjcloud.hard.api.vo.hard.PanelPorductVo">
select c.product_id as productId,
c.product_name as productName,
SUM(c.product_count) as buyProductCount,
SUM(c.total_price) as totalPrice,
count(distinct o.id) as buyCount,
count(distinct o.user_id) as personCount
from hard_car c
inner join hard_parent_car p on c.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'
<where>
<include refid="groupWhereByPanelProductDto"/>
</where>
group by c.product_id
order by sum(c.product_count) desc
<if test="dto.limit!= null">
limit #{dto.limit}
</if>
</select>
</mapper>