<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper">
    <select id="countPending" resultType="cn.ysk.cashier.vo.PendingCountVO">
        select
            a.id orderId,b.pending_at pendingAt, sum(b.total_amount) totalAmount,
               count(b.id) totalCount, sum(b.total_number) totalNumber, a.remark
        from tb_order_info a
        JOIN tb_cashier_cart b on a.id=b.order_id
        where a.shop_id=#{shopId} and a.`status`='pending'
          and a.trade_day=#{day} and a.use_type=#{useType}
        <if test="tableId != null and tableId != ''">
            and a.table_id=#{tableId}
        </if>
        GROUP BY a.id ORDER BY a.id desc

    </select>
</mapper>
