台桌订单金额查询
This commit is contained in:
@@ -5,12 +5,25 @@
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopTableMapper">
|
||||
|
||||
<select id="pageInfo" resultType="com.czg.account.vo.ShopTableVO">
|
||||
select a.*, b.id orderId, b.user_id, b.origin_amount as orderAmount, b.seat_num as personNum, b.create_time as orderCreateTime, ar.name as areaName
|
||||
select
|
||||
a.*,
|
||||
MAX(b.id) as orderId,
|
||||
MAX(b.user_id) as user_id,
|
||||
-- 核心:真实金额 = 支付总额 - 退款总额
|
||||
IFNULL(SUM(d.pay_amount), 0) - IFNULL(SUM(d.return_amount), 0) as orderAmount,
|
||||
MAX(b.seat_num) as personNum,
|
||||
MAX(b.create_time) as orderCreateTime,
|
||||
MAX(ar.name) as areaName
|
||||
from tb_shop_table as a
|
||||
left join tb_order_info as b
|
||||
on a.table_code = b.table_code and b.`status` = 'unpaid' and b.table_code != '' and
|
||||
b.table_code is not null
|
||||
left join tb_shop_table_area as ar on a.area_id = ar.id
|
||||
on a.table_code = b.table_code
|
||||
and b.`status` = 'unpaid'
|
||||
and b.table_code != ''
|
||||
and b.table_code is not null
|
||||
left join tb_order_detail as d
|
||||
on b.id = d.order_id
|
||||
left join tb_shop_table_area as ar
|
||||
on a.area_id = ar.id
|
||||
where a.shop_id=#{shopId}
|
||||
<if test="areaId != null">
|
||||
and a.area_id=#{areaId}
|
||||
@@ -29,6 +42,5 @@
|
||||
</if>
|
||||
group by a.id
|
||||
ORDER BY a.area_id,a.id
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user