You've already forked FrameTour-BE
添加订单统计方法
This commit is contained in:
@@ -486,5 +486,44 @@
|
||||
) order_data ON order_data.date_key = date_series.DATE_KEY
|
||||
ORDER BY date_series.date_value
|
||||
</select>
|
||||
<select id="getOrderStatistics" resultType="com.ycwl.basic.model.pc.statistics.resp.OrderStatisticsResp">
|
||||
SELECT
|
||||
COALESCE(order_stats.total_count, 0) AS totalOrderCount,
|
||||
COALESCE(order_stats.total_amount, 0) AS totalOrderAmount,
|
||||
COALESCE(stats_data.push_count, 0) AS pushOrderCount,
|
||||
COALESCE(stats_data.scene_count, 0) AS sceneOrderCount
|
||||
FROM (
|
||||
SELECT
|
||||
COUNT(1) AS total_count,
|
||||
SUM(pay_price) AS total_amount
|
||||
FROM `order`
|
||||
WHERE (status = 1 OR status = 2)
|
||||
<if test="scenicId != null">
|
||||
AND scenic_id = #{scenicId}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND create_at >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND create_at <= #{endTime}
|
||||
</if>
|
||||
) order_stats
|
||||
CROSS JOIN (
|
||||
SELECT
|
||||
SUM(CASE WHEN type = 3 THEN 1 ELSE 0 END) AS push_count,
|
||||
SUM(CASE WHEN type = 4 THEN 1 ELSE 0 END) AS scene_count
|
||||
FROM statistics
|
||||
WHERE type IN (3, 4)
|
||||
<if test="scenicId != null">
|
||||
AND scenic_id = #{scenicId}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND create_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND create_time <= #{endTime}
|
||||
</if>
|
||||
) stats_data
|
||||
</select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user