数据统计

This commit is contained in:
Tankaikai
2025-03-12 11:26:16 +08:00
parent c3bf44d1d6
commit 0782824143
11 changed files with 76 additions and 61 deletions

View File

@@ -30,12 +30,12 @@
max(update_time) as update_time
from tb_shop_order_statistic
where shop_id = #{shopId}
<if test="beginTime != null">
and create_day >= str_to_date(#{beginTime}, '%Y-%m-%d')
<if test="beginDate != null and endDate != ''">
and create_day >= str_to_date(#{beginDate}, '%Y-%m-%d')
</if>
<if test="endTime != null">
<if test="endDate != null and endDate != ''">
<![CDATA[
and create_day <= str_to_date(#{endTime}, '%Y-%m-%d')
and create_day <= str_to_date(#{endDate}, '%Y-%m-%d')
]]>
</if>
group by shop_id

View File

@@ -26,4 +26,26 @@
a.table_id
order by a.id desc
</select>
<select id="findSummaryList" resultType="com.czg.order.vo.TableSummaryInfoVo">
select
t1.table_id,
ifnull(t3.name,'N/A') as area_name,
ifnull(t2.name,'N/A') as table_name,
sum(t1.order_count) as order_count,
sum(t1.order_amount) as order_amount,
ifnull(sum(t1.refund_count),0) as refund_count,
ifnull(sum(t1.refund_amount),0) as refund_amount
from tb_shop_table_order_statistic t1
left join tb_shop_table t2 on t1.table_id = t2.id
left join tb_shop_table_area t3 on t2.area_id = t3.id
where t1.shop_id = #{shopId}
<if test="beginDate != null and beginDate != ''">
AND t1.create_day >= str_to_date(#{beginDate}, '%Y-%m-%d')
</if>
<if test="endDate != null and endDate != ''">
and t2.create_day &lt;= str_to_date(#{endDate}, '%Y-%m-%d')
</if>
group by t1.table_id
order by sum(t1.order_count) desc,max(t1.id) desc
</select>
</mapper>