Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b98853e82b
9 files changed
+108
-4
No files matched your search
+2
@@ -23,6 +23,8 @@ public class PanelProductDto {
|
||||
|
||||
private List<Long> classifyIds;
|
||||
|
||||
private List<Long> excludeClassifyIds;
|
||||
|
||||
private String hourTypeIsNull;
|
||||
|
||||
private String hourType;
|
||||
|
||||
+5
@@ -39,6 +39,11 @@ public class HardPanelSettingShare {
|
||||
*/
|
||||
private List<Long> zsCategoryIds;
|
||||
|
||||
/**
|
||||
* 复购排行需要排除的菜品分类
|
||||
*/
|
||||
private List<Long> repurchaseTopExcludeCategoryIds;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -73,6 +73,7 @@ public class PanelCanteenController {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType()));
|
||||
dto.setLimit(5L);
|
||||
return R.ok(panelCanteenService.mchPayPersonCount(dto));
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -1,6 +1,7 @@
|
||||
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.util.DateRangeTool;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
@@ -83,10 +84,12 @@ public class PanelNutritionController {
|
||||
@PostMapping(value = "/repurchase")
|
||||
@Operation(summary = "复购排行榜")
|
||||
public R<List<PanelPorductVo>> repurchase(@RequestBody PanelProductDto dto) {
|
||||
dto.setDateRangeType(DateRangeTypeEnum.THIS_YEAR);
|
||||
if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isEmpty(dto.getTotalTimeList())) {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType()));
|
||||
dto.setLimit(5L);
|
||||
return R.ok(panelNutritionService.repurchase(dto));
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -153,4 +153,9 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
|
||||
* 用餐数据统计(根据商户统计)
|
||||
*/
|
||||
List<PanelPorductVo> groupByMch(@Param("dto") PanelProductDto dto);
|
||||
|
||||
/**
|
||||
* 复购排行榜
|
||||
*/
|
||||
List<PanelPorductVo> repurchase(@Param("dto") PanelProductDto dto);
|
||||
}
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
PanelProductDto queryDto = BeanUtil.toBean(dto, PanelProductDto.class);
|
||||
queryDto.setHourType(hourType.getType());
|
||||
List<PanelPorductVo> sqlList = new ArrayList<>();
|
||||
if (ObjectUtil.equals(dto.getDateRangeType(), DateRangeTypeEnum.THIS_YEAR.getType())) {
|
||||
if (ObjectUtil.equals(dto.getDateRangeType(), DateRangeTypeEnum.THIS_YEAR)) {
|
||||
sqlList = hardOrderMapper.groupByMonthAndHourType(queryDto);
|
||||
} else {
|
||||
sqlList = hardOrderMapper.groupByTimeAndHourType(queryDto);
|
||||
|
||||
+39
-2
@@ -2,6 +2,8 @@ package com.bsd.pjcloud.hard.service.impl.panel;
|
||||
|
||||
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.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;
|
||||
@@ -28,6 +30,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Validated
|
||||
@Slf4j
|
||||
@@ -41,6 +44,7 @@ public class PanelNutritionServiceImpl implements PanelNutritionService {
|
||||
private final HardPanelSettingService panelSettingService;
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
private final RemoteCanteenCategoryService canteenCategoryService;
|
||||
|
||||
/**
|
||||
* 食堂用餐分类统计
|
||||
@@ -83,6 +87,8 @@ public class PanelNutritionServiceImpl implements PanelNutritionService {
|
||||
PanelPorductVo entity = new PanelPorductVo();
|
||||
entity.setProductName(item.getProductName());
|
||||
entity.setProductId(item.getProductId());
|
||||
entity.setClassifyId(item.getClassifyId());
|
||||
entity.setClassifyName(item.getClassifyName());
|
||||
entity.setBuyProductCount(item.getPayCount());
|
||||
return entity;
|
||||
}).toList();
|
||||
@@ -186,8 +192,39 @@ public class PanelNutritionServiceImpl implements PanelNutritionService {
|
||||
*/
|
||||
@Override
|
||||
public List<PanelPorductVo> repurchase(PanelProductDto dto) {
|
||||
PanelPorductVo panelPorductVo = hardOrderMapper.groupCount(dto);
|
||||
return List.of();
|
||||
// 查询配置
|
||||
HardPanelSettingEntity setting = panelSettingService.getSetting();
|
||||
if (ObjectUtil.isNotEmpty(setting) && ObjectUtil.isNotEmpty(setting.getNutritionSetting())) {
|
||||
HardPanelSettingShare.NutritionSetting nutritionSetting = setting.getNutritionSetting();
|
||||
if (ObjectUtil.isNotEmpty(nutritionSetting.getRepurchaseTopExcludeCategoryIds())) {
|
||||
dto.setExcludeClassifyIds(nutritionSetting.getRepurchaseTopExcludeCategoryIds());
|
||||
}
|
||||
}
|
||||
|
||||
List<PanelPorductVo> list = hardOrderMapper.repurchase(dto);
|
||||
// 处理查询出来的数据
|
||||
disposeRepurchaseList(list, dto);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void disposeRepurchaseList(List<PanelPorductVo> list, PanelProductDto dto) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
// 处理菜品分类
|
||||
List<Long> classifyList = list.stream().map(PanelPorductVo::getClassifyId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(classifyList)) {
|
||||
List<CanteenCategoryEntity> categoryList = canteenCategoryService.getAllSimple(null, null).getData();
|
||||
if (ObjectUtil.isNotEmpty(categoryList)) {
|
||||
Map<Long, CanteenCategoryEntity> categoryMap = categoryList.stream().collect(Collectors.toMap(CanteenCategoryEntity::getId, v -> v));
|
||||
if (ObjectUtil.isNotEmpty(categoryMap)) {
|
||||
for (PanelPorductVo i : list) {
|
||||
CanteenCategoryEntity category = categoryMap.get(i.getClassifyId());
|
||||
if (ObjectUtil.isNotEmpty(category)) {
|
||||
i.setClassifyName(category.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> nutritionSetting() {
|
||||
|
||||
+1
-1
@@ -318,7 +318,7 @@
|
||||
</if>
|
||||
</where>
|
||||
group by s.category_id
|
||||
order by s.category_id
|
||||
order by SUM(a.product_count) desc
|
||||
limit 5
|
||||
</select>
|
||||
|
||||
|
||||
+51
@@ -802,4 +802,55 @@
|
||||
limit #{dto.limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<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,
|
||||
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'
|
||||
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
|
||||
<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>
|
||||
</where>
|
||||
GROUP BY a.product_id, o.user_id, o.hour_type
|
||||
having COUNT(DISTINCT o.id) >= 2
|
||||
order by sum(a.product_count) desc
|
||||
<if test="dto.limit != null">
|
||||
limit #{dto.limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user