feat:完善统计接口订单趋势图数据
This commit is contained in:
@@ -2,6 +2,7 @@ package com.gxwebsoft.shop.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.gxwebsoft.shop.entity.Dashboard;
|
import com.gxwebsoft.shop.entity.Dashboard;
|
||||||
|
import com.gxwebsoft.shop.entity.Order;
|
||||||
import com.gxwebsoft.shop.entity.OrderPay;
|
import com.gxwebsoft.shop.entity.OrderPay;
|
||||||
import com.gxwebsoft.shop.param.DashBoardParam;
|
import com.gxwebsoft.shop.param.DashBoardParam;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@@ -10,11 +11,20 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface DashboardMapper extends BaseMapper<Dashboard> {
|
public interface DashboardMapper extends BaseMapper<Dashboard> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单统计
|
||||||
|
*
|
||||||
|
* @param param 查询参数
|
||||||
|
* @return List<Order>
|
||||||
|
*/
|
||||||
|
List<Order> selectOrderListRel(@Param("param") DashBoardParam param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销售额统计
|
* 销售额统计
|
||||||
*
|
*
|
||||||
* @param param 查询参数
|
* @param param 查询参数
|
||||||
* @return SalesAmountStatistics
|
* @return List<OrderPay>
|
||||||
*/
|
*/
|
||||||
List<OrderPay> selectOrderPayListRel(@Param("param") DashBoardParam param);
|
List<OrderPay> selectOrderPayListRel(@Param("param") DashBoardParam param);
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,26 @@
|
|||||||
|
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
<!-- 查询订单 -->
|
||||||
<!-- 分页查询 -->
|
<select id="selectOrderListRel" resultType="com.gxwebsoft.shop.entity.Order">
|
||||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.Dashboard">
|
SELECT a.*,DATE_FORMAT(a.create_time,'%Y-%m-%d') AS createTime
|
||||||
<include refid="selectSql"></include>
|
FROM shop_order a
|
||||||
|
<where>
|
||||||
|
AND is_renew = 0 AND is_freeze = 1 AND deleted = 0
|
||||||
|
<if test="param.goodsId != null">
|
||||||
|
AND a.merchant_code = #{param.goodsId}
|
||||||
|
</if>
|
||||||
|
<if test="param.shopId != null">
|
||||||
|
AND a.merchant_code = #{param.shopId}
|
||||||
|
</if>
|
||||||
|
<if test="param.createTimeStart != null">
|
||||||
|
AND a.create_time >= #{param.createTimeStart}
|
||||||
|
</if>
|
||||||
|
<if test="param.createTimeEnd != null">
|
||||||
|
AND a.create_time <= #{param.createTimeEnd}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY a.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询全部支付订单 -->
|
<!-- 查询全部支付订单 -->
|
||||||
|
|||||||
@@ -186,24 +186,28 @@ public class DashboardServiceImpl extends ServiceImpl<DashboardMapper, Dashboard
|
|||||||
return salesAmountStatisticsList;
|
return salesAmountStatisticsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单统计趋势图
|
||||||
|
*
|
||||||
|
* @param param 查询参数
|
||||||
|
* @return List<SalesAmountStatistics>
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Dashboard.OrderStatistics> orderStatisticsList(DashBoardParam param) {
|
public List<Dashboard.OrderStatistics> orderStatisticsList(DashBoardParam param) {
|
||||||
|
List<Order> orderList = baseMapper.selectOrderListRel(param);
|
||||||
|
Map<Date, List<Order>> orderPayListMap = orderList.stream().collect(Collectors.groupingBy(Order::getCreateTime));
|
||||||
|
|
||||||
//TODO 测试数据
|
|
||||||
List<Dashboard.OrderStatistics> orderStatisticsList = new ArrayList<>();
|
List<Dashboard.OrderStatistics> orderStatisticsList = new ArrayList<>();
|
||||||
List<Date> dateList = new ArrayList<>();
|
orderPayListMap.forEach((date, orderPays) -> {
|
||||||
dateList.add(DateUtil.parse("2024-08-15"));
|
Date statisticsDate = DateUtil.parseDate(DateUtil.formatDate(date));//将时间转化为
|
||||||
dateList.add(DateUtil.parse("2024-08-16"));
|
Dashboard.OrderStatistics statistics = new Dashboard.OrderStatistics();
|
||||||
dateList.add(DateUtil.parse("2024-08-17"));
|
statistics.setDailyNewOrders(orderPays.size());
|
||||||
dateList.add(DateUtil.parse("2024-08-18"));
|
statistics.setStartStatisticsDate(statisticsDate);
|
||||||
dateList.forEach(date -> {
|
statistics.setEndStatisticsDate(statisticsDate);
|
||||||
Dashboard.OrderStatistics orderStatistics=new Dashboard.OrderStatistics();
|
orderStatisticsList.add(statistics);
|
||||||
orderStatistics.setDailyNewOrders(10);
|
|
||||||
orderStatistics.setStartStatisticsDate(date);
|
|
||||||
orderStatistics.setEndStatisticsDate(date);
|
|
||||||
orderStatisticsList.add(orderStatistics);
|
|
||||||
});
|
});
|
||||||
|
//按照时间排序
|
||||||
|
Collections.sort(orderStatisticsList, Comparator.comparing(Dashboard.BaseStatistics::getStartStatisticsDate));
|
||||||
return orderStatisticsList;
|
return orderStatisticsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user