feat:本周外部就餐情况(合作商家)营养分析
This commit is contained in:
1 parent
200cb8390e
commit
cb181564e5
7 files changed
+217
-154
No files matched your search
+7
@@ -25,6 +25,13 @@ public class PanelProductDto {
|
||||
|
||||
private List<Long> excludeClassifyIds;
|
||||
|
||||
private List<String> orderStatus;
|
||||
|
||||
/**
|
||||
* 排除当天在食堂吃饭的数据
|
||||
*/
|
||||
private String excludeCanteenPay;
|
||||
|
||||
private String hourTypeIsNull;
|
||||
|
||||
private String hourType;
|
||||
|
||||
+20
@@ -3,8 +3,10 @@ package com.bsd.pjcloud.hard.controller.panel;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.DateRangeTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.DateRangeTool;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.panel.PanelProductDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.hard.PanelPorductVo;
|
||||
import com.bsd.pjcloud.hard.service.PanelNutritionService;
|
||||
@@ -37,6 +39,7 @@ public class PanelNutritionController {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType()));
|
||||
dto.setOrderStatus(HardOrderStatusEnum.getPayPrice());
|
||||
return R.ok(panelNutritionService.classCount(dto));
|
||||
}
|
||||
|
||||
@@ -47,6 +50,7 @@ public class PanelNutritionController {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType()));
|
||||
dto.setOrderStatus(HardOrderStatusEnum.getPayPrice());
|
||||
return R.ok(panelNutritionService.cuisineTop(dto));
|
||||
}
|
||||
|
||||
@@ -57,6 +61,7 @@ public class PanelNutritionController {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType()));
|
||||
dto.setOrderStatus(HardOrderStatusEnum.getPayPrice());
|
||||
return R.ok(panelNutritionService.nutritionByTime(dto));
|
||||
}
|
||||
|
||||
@@ -67,6 +72,7 @@ public class PanelNutritionController {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType()));
|
||||
dto.setOrderStatus(HardOrderStatusEnum.getPayPrice());
|
||||
return R.ok(panelNutritionService.nutritionTotal(dto));
|
||||
}
|
||||
|
||||
@@ -78,6 +84,7 @@ public class PanelNutritionController {
|
||||
LocalDateTime.now().withHour(23).withMinute(59).withSecond(59)
|
||||
});
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType()));
|
||||
dto.setOrderStatus(HardOrderStatusEnum.getPayPrice());
|
||||
return R.ok(panelNutritionService.nutritionByTime(dto));
|
||||
}
|
||||
|
||||
@@ -89,8 +96,21 @@ public class PanelNutritionController {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType()));
|
||||
dto.setOrderStatus(HardOrderStatusEnum.getPayPrice());
|
||||
dto.setLimit(5L);
|
||||
return R.ok(panelNutritionService.repurchase(dto));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/external")
|
||||
@Operation(summary = "外部就餐情况(合作商家)")
|
||||
public R<PanelPorductVo.HourTypeVo> external(@RequestBody PanelProductDto dto) {
|
||||
if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isEmpty(dto.getTotalTimeList())) {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.SUPERMARKET.getType()));
|
||||
dto.setOrderStatus(HardOrderStatusEnum.getPayPrice());
|
||||
dto.setExcludeCanteenPay(YesNoEnum.YES.getCode());
|
||||
return R.ok(panelNutritionService.external(dto));
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -120,6 +120,7 @@ public class PanelShopController {
|
||||
@PostMapping(value = "/mch-pay-count-top")
|
||||
@Operation(summary = "排行榜")
|
||||
public R<List<PanelPorductVo>> mchPayCountTop(@RequestBody PanelProductDto dto) {
|
||||
dto.setDateRangeType(DateRangeTypeEnum.TODAY);
|
||||
if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isEmpty(dto.getTotalTimeList())) {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
|
||||
+8
@@ -158,4 +158,12 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
|
||||
* 复购排行榜
|
||||
*/
|
||||
List<PanelPorductVo> repurchase(@Param("dto") PanelProductDto dto);
|
||||
|
||||
/**
|
||||
* 超市数据统计(根据时间段和日期分类统计)
|
||||
* 订单表位主表,商品表为从表
|
||||
*/
|
||||
List<PanelPorductVo> shopGroupByMonthAndHourType(@Param("dto") PanelProductDto dto);
|
||||
|
||||
List<PanelPorductVo> shopGroupByTimeAndHourType(@Param("dto") PanelProductDto dto);
|
||||
}
|
||||
+5
@@ -35,4 +35,9 @@ public interface PanelNutritionService {
|
||||
* 复购排行榜
|
||||
*/
|
||||
List<PanelPorductVo> repurchase(PanelProductDto dto);
|
||||
|
||||
/**
|
||||
* 外部就餐情况(合作商家)
|
||||
*/
|
||||
PanelPorductVo.HourTypeVo external(PanelProductDto dto);
|
||||
}
|
||||
+51
@@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.canteen.api.feign.RemoteCanteenCategoryService;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenCategoryEntity;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.DateRangeTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardHourTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductByClassifyDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductLikeTopDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.panel.PanelProductDto;
|
||||
@@ -207,6 +209,55 @@ public class PanelNutritionServiceImpl implements PanelNutritionService {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部就餐情况(合作商家)
|
||||
*/
|
||||
@Override
|
||||
public PanelPorductVo.HourTypeVo external(PanelProductDto dto) {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
List<PanelPorductVo> dateList = PanelPorductVo.generatePanelCanteenList(dto.getTotalTimeList(), dto.getDateRangeType());
|
||||
PanelPorductVo.HourTypeVo result = new PanelPorductVo.HourTypeVo();
|
||||
|
||||
List<HardHourTypeEnum> hourTypeList = List.of(HardHourTypeEnum.MORNING, HardHourTypeEnum.NOONING, HardHourTypeEnum.NIGHT);
|
||||
for (CompletableFuture<Void> voidCompletableFuture : hourTypeList.stream().map(hourType -> CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
PanelProductDto queryDto = BeanUtil.toBean(dto, PanelProductDto.class);
|
||||
List<PanelPorductVo> sqlList = new ArrayList<>();
|
||||
if (ObjectUtil.equals(dto.getDateRangeType(), DateRangeTypeEnum.THIS_YEAR)) {
|
||||
sqlList = hardOrderMapper.shopGroupByMonthAndHourType(queryDto);
|
||||
} else {
|
||||
sqlList = hardOrderMapper.shopGroupByTimeAndHourType(queryDto);
|
||||
}
|
||||
// 处理查询出来的数据
|
||||
List<PanelPorductVo> resultList = BeanUtil.copyToList(dateList, PanelPorductVo.class);
|
||||
for (PanelPorductVo v : resultList) {
|
||||
sqlList.stream().filter(item -> ObjectUtil.equals(item.getTime(), v.getTime())).forEach(target -> {
|
||||
v.setHourType(target.getHourType());
|
||||
v.setPersonCount(target.getPersonCount());
|
||||
v.setBuyCount(target.getBuyCount());
|
||||
v.setBuyProductCount(target.getBuyProductCount());
|
||||
v.setTotalPrice(target.getTotalPrice());
|
||||
});
|
||||
}
|
||||
// 组装数据
|
||||
PanelPorductVo.ProductTypeItemVo vo = PanelPorductVo.ProductTypeItemVo.builder().list(resultList).type(hourType.getType()).typeStr(hourType.getDescription()).build();
|
||||
switch (hourType) {
|
||||
case MORNING:
|
||||
result.setMorning(vo);
|
||||
break;
|
||||
case NOONING:
|
||||
result.setNoon(vo);
|
||||
break;
|
||||
case NIGHT:
|
||||
result.setEvening(vo);
|
||||
break;
|
||||
}
|
||||
})).toList()) {
|
||||
voidCompletableFuture.join();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void disposeRepurchaseList(List<PanelPorductVo> list, PanelProductDto dto) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
// 处理菜品分类
|
||||
|
||||
+125
-154
@@ -592,40 +592,56 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<sql id="groupWhereByPanelProductDto">
|
||||
c.del_flag = '0'
|
||||
<if test="dto.totalTimeList != null and dto.totalTimeList.length == 2">
|
||||
and o.create_time between #{dto.totalTimeList[0]} and #{dto.totalTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
|
||||
and o.merchant_type in
|
||||
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.classifyIds != null and dto.classifyIds.size() != 0">
|
||||
and s.category_id in
|
||||
<foreach collection="dto.classifyIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.excludeClassifyIds != null and dto.excludeClassifyIds.size() != 0">
|
||||
and s.category_id not in
|
||||
<foreach collection="dto.excludeClassifyIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.orderStatus != null and dto.orderStatus.size() != 0">
|
||||
and o.order_status in
|
||||
<foreach collection="dto.orderStatus" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="groupCount" resultType="com.bsd.pjcloud.hard.api.vo.hard.PanelPorductVo">
|
||||
select SUM(a.product_count) as buyProductCount,
|
||||
SUM(a.total_price) as totalPrice,
|
||||
select 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,
|
||||
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'
|
||||
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' and o.hour_type is not null and
|
||||
o.hour_type not in ('-1', 'null')
|
||||
<if test="dto.hourTypeIsNull == null">
|
||||
and o.hour_type is not null and o.hour_type not in ('-1', 'null')
|
||||
</if>
|
||||
left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id
|
||||
left join pjcloudx_canteen.canteen_spu s on c.product_id = s.id
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
<if test="dto.totalTimeList != null and dto.totalTimeList.length == 2">
|
||||
and o.create_time between #{dto.totalTimeList[0]} and #{dto.totalTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
|
||||
and o.merchant_type in
|
||||
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.classifyIds != null and dto.classifyIds.size() != 0">
|
||||
and s.category_id in
|
||||
<foreach collection="dto.classifyIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="groupWhereByPanelProductDto"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@@ -633,38 +649,20 @@
|
||||
select
|
||||
date(o.create_time) as time,
|
||||
o.hour_type as hourType,
|
||||
SUM(a.product_count) as buyProductCount,
|
||||
SUM(a.total_price) as totalPrice,
|
||||
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,
|
||||
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'
|
||||
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'
|
||||
<if test="dto.hourTypeIsNull == null">
|
||||
and o.hour_type is not null and o.hour_type not in ('-1', 'null')
|
||||
</if>
|
||||
left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id
|
||||
left join pjcloudx_canteen.canteen_spu s on c.product_id = s.id
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
<if test="dto.totalTimeList != null and dto.totalTimeList.length == 2">
|
||||
and o.create_time between #{dto.totalTimeList[0]} and #{dto.totalTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
|
||||
and o.merchant_type in
|
||||
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.classifyIds != null and dto.classifyIds.size() != 0">
|
||||
and s.category_id in
|
||||
<foreach collection="dto.classifyIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="groupWhereByPanelProductDto"/>
|
||||
</where>
|
||||
group by date(o.create_time)
|
||||
order by date(o.create_time) desc
|
||||
@@ -677,38 +675,20 @@
|
||||
select
|
||||
date(o.create_time) as time,
|
||||
o.hour_type as hourType,
|
||||
SUM(a.product_count) as buyProductCount,
|
||||
SUM(a.total_price) as totalPrice,
|
||||
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,
|
||||
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'
|
||||
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'
|
||||
<if test="dto.hourTypeIsNull == null">
|
||||
and o.hour_type is not null and o.hour_type not in ('-1', 'null')
|
||||
</if>
|
||||
left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id
|
||||
left join pjcloudx_canteen.canteen_spu s on c.product_id = s.id
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
<if test="dto.totalTimeList != null and dto.totalTimeList.length == 2">
|
||||
and o.create_time between #{dto.totalTimeList[0]} and #{dto.totalTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
|
||||
and o.merchant_type in
|
||||
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.classifyIds != null and dto.classifyIds.size() != 0">
|
||||
and s.category_id in
|
||||
<foreach collection="dto.classifyIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="groupWhereByPanelProductDto"/>
|
||||
</where>
|
||||
group by date(o.create_time), o.hour_type
|
||||
order by date(o.create_time) desc
|
||||
@@ -721,38 +701,20 @@
|
||||
select
|
||||
date(o.create_time) as time,
|
||||
o.hour_type as hourType,
|
||||
SUM(a.product_count) as buyProductCount,
|
||||
SUM(a.total_price) as totalPrice,
|
||||
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,
|
||||
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'
|
||||
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'
|
||||
<if test="dto.hourTypeIsNull == null">
|
||||
and o.hour_type is not null and o.hour_type not in ('-1', 'null')
|
||||
</if>
|
||||
left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id
|
||||
left join pjcloudx_canteen.canteen_spu s on c.product_id = s.id
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
<if test="dto.totalTimeList != null and dto.totalTimeList.length == 2">
|
||||
and o.create_time between #{dto.totalTimeList[0]} and #{dto.totalTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
|
||||
and o.merchant_type in
|
||||
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.classifyIds != null and dto.classifyIds.size() != 0">
|
||||
and s.category_id in
|
||||
<foreach collection="dto.classifyIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="groupWhereByPanelProductDto"/>
|
||||
</where>
|
||||
group by date_format(o.create_time, '%Y-%m'), o.hour_type
|
||||
order by date_format(o.create_time, '%Y-%m') desc
|
||||
@@ -763,41 +725,23 @@
|
||||
|
||||
<select id="groupByMch" resultType="com.bsd.pjcloud.hard.api.vo.hard.PanelPorductVo">
|
||||
select o.merchant_id as mchId,
|
||||
sum(a.product_count) as buyProductCount,
|
||||
SUM(a.total_price) as totalPrice,
|
||||
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,
|
||||
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'
|
||||
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'
|
||||
<if test="dto.hourTypeIsNull == null">
|
||||
and o.hour_type is not null and o.hour_type not in ('-1', 'null')
|
||||
</if>
|
||||
left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id
|
||||
left join pjcloudx_canteen.canteen_spu s on c.product_id = s.id
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
<if test="dto.totalTimeList != null and dto.totalTimeList.length == 2">
|
||||
and o.create_time between #{dto.totalTimeList[0]} and #{dto.totalTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
|
||||
and o.merchant_type in
|
||||
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.classifyIds != null and dto.classifyIds.size() != 0">
|
||||
and s.category_id in
|
||||
<foreach collection="dto.classifyIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="groupWhereByPanelProductDto"/>
|
||||
</where>
|
||||
group by o.merchant_id
|
||||
order by sum(a.product_count) desc
|
||||
order by sum(c.product_count) desc
|
||||
<if test="dto.limit != null">
|
||||
limit #{dto.limit}
|
||||
</if>
|
||||
@@ -805,52 +749,79 @@
|
||||
|
||||
<select id="repurchase" resultType="com.bsd.pjcloud.hard.api.vo.hard.PanelPorductVo">
|
||||
select o.merchant_id as mchId,
|
||||
a.product_name as productName,
|
||||
sum(a.product_count) as buyProductCount,
|
||||
SUM(a.total_price) as totalPrice,
|
||||
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,
|
||||
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'
|
||||
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'
|
||||
<if test="dto.hourTypeIsNull == null">
|
||||
and o.hour_type is not null and o.hour_type not in ('-1', 'null')
|
||||
</if>
|
||||
left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id
|
||||
left join pjcloudx_canteen.canteen_spu s on c.product_id = s.id
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
<if test="dto.totalTimeList != null and dto.totalTimeList.length == 2">
|
||||
and o.create_time between #{dto.totalTimeList[0]} and #{dto.totalTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
|
||||
and o.merchant_type in
|
||||
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.classifyIds != null and dto.classifyIds.size() != 0">
|
||||
and s.category_id in
|
||||
<foreach collection="dto.classifyIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.excludeClassifyIds != null and dto.excludeClassifyIds.size() != 0">
|
||||
and s.category_id not in
|
||||
<foreach collection="dto.excludeClassifyIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="groupWhereByPanelProductDto"/>
|
||||
</where>
|
||||
GROUP BY a.product_id, o.user_id, o.hour_type
|
||||
GROUP BY c.product_id, o.user_id, o.hour_type
|
||||
having COUNT(DISTINCT o.id) >= 2
|
||||
order by sum(a.product_count) desc
|
||||
order by sum(c.product_count) desc
|
||||
<if test="dto.limit != null">
|
||||
limit #{dto.limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="shopGroupByMonthAndHourType" resultType="com.bsd.pjcloud.hard.api.vo.hard.PanelPorductVo">
|
||||
select o.merchant_id as mchId,
|
||||
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_order o
|
||||
left join hard_parent_car p on p.id = o.parent_car_id
|
||||
left join hard_car c on c.parent_car_id = p.id
|
||||
<where>
|
||||
<include refid="groupWhereByPanelProductDto"/>
|
||||
<if test="dto.excludeCanteenPay != null and dto.excludeCanteenPay = '1' ">
|
||||
and o.id not in (select o.id
|
||||
from hard_order a
|
||||
where a.del_flag = 0
|
||||
and a.merchant_type in ('1')
|
||||
and a.order_status in ('5', '20', '10')
|
||||
and o.create_time between a.create_time - interval 1 hour and a.create_time + interval 1 hour
|
||||
group by a.user_id)
|
||||
</if>
|
||||
</where>
|
||||
group by date_format(o.create_time, '%Y-%m'), o.merchant_id
|
||||
order by date_format(o.create_time, '%Y-%m'), sum(c.product_count) desc
|
||||
</select>
|
||||
|
||||
<select id="shopGroupByTimeAndHourType" resultType="com.bsd.pjcloud.hard.api.vo.hard.PanelPorductVo">
|
||||
select o.merchant_id as mchId,
|
||||
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_order o
|
||||
left join hard_parent_car p on p.id = o.parent_car_id
|
||||
left join hard_car c on c.parent_car_id = p.id
|
||||
<where>
|
||||
<include refid="groupWhereByPanelProductDto"/>
|
||||
<if test="dto.excludeCanteenPay != null and dto.excludeCanteenPay = '1' ">
|
||||
and o.id not in (select o.id
|
||||
from hard_order a
|
||||
where a.del_flag = 0
|
||||
and a.merchant_type in ('1')
|
||||
and a.order_status in ('5', '20', '10')
|
||||
and o.create_time between a.create_time - interval 1 hour and a.create_time + interval 1 hour
|
||||
group by a.user_id)
|
||||
</if>
|
||||
</where>
|
||||
group by date(o.create_time), o.merchant_id
|
||||
order by date(o.create_time), sum(c.product_count) desc
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user