台桌统计报表

This commit is contained in:
Tankaikai
2025-04-02 13:04:05 +08:00
parent 6df79916bd
commit d748680ee3
6 changed files with 136 additions and 9 deletions

View File

@@ -63,6 +63,8 @@
LEFT JOIN tb_shop_table_area t3 ON t2.area_id = t3.id
where t1.shop_id = #{shopId}
and t1.table_code is not null
and t2.table_code is not null
and t2.table_code != ''
and t2.name is not null
and t1.paid_time is not null
<if test="beginDate != null and beginDate != ''">
@@ -74,4 +76,50 @@
GROUP BY t1.table_code
order by count( t1.id ) desc,sum( t1.pay_amount ) desc
</select>
<select id="findSummaryExportList" resultType="com.czg.order.vo.TableSummaryExportVo">
SELECT
t.product_name,
date_format(t.create_time, '%Y-%m-%d') as create_date,
if(t.table_name = '11111111','银收客',t.table_name) as table_name,
concat(if(t.table_name = '11111111','银收客',t.table_name),'-',date_format(t.create_time, '%Y-%m-%d')) as tableConcatDate,
t.category_name,
t.unit_name,
group_concat(distinct t.sku_name SEPARATOR ';') as sku_name,
sum(t.num) as num,
avg(t.unit_price) as unit_price,
sum(t.num*t.unit_price) as amount,
sum(-t.refund_num) as refund_num,
sum(-t.refund_num*t.unit_price) as refund_amount
FROM
(
SELECT
t1.product_id,
t2.table_code,
IF(t2.table_code is null or t2.table_code = '' or t6.NAME is null, '11111111', t6.NAME) AS table_name,
t1.create_time,
t4.NAME AS category_name,
t3.name as product_name,
t5.NAME AS unit_name,
t1.sku_name,
t1.num,
t1.unit_price,
t1.refund_num as refund_num
FROM
tb_order_detail t1
LEFT JOIN tb_order_info t2 ON t1.order_id = t2.id
LEFT JOIN tb_product t3 ON t1.product_id = t3.id
LEFT JOIN tb_shop_prod_category t4 ON t3.category_id = t4.id
LEFT JOIN tb_shop_prod_unit t5 ON t3.unit_id = t5.id
LEFT JOIN tb_shop_table t6 ON t2.table_code = t6.table_code AND t1.shop_id = t6.shop_id and t6.table_code != '' and t6.table_code is not null
WHERE t1.shop_id = #{shopId}
<if test="beginDate != null and beginDate != ''">
AND t1.create_time >= str_to_date(#{beginDate}, '%Y-%m-%d %H:%i:%s')
</if>
<if test="endDate != null and endDate != ''">
and t1.create_time &lt;= str_to_date(#{endDate}, '%Y-%m-%d %H:%i:%s')
</if>
) t
group by t.product_id,date_format(t.create_time, '%Y-%m-%d'),t.table_name
order by t.table_name,t.table_code,date_format(t.create_time, '%Y-%m-%d'),t.category_name,t.product_id
</select>
</mapper>