<?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="com.czg.service.account.mapper.ShopTableMapper">

    <select id="pageInfo" resultType="com.czg.account.vo.ShopTableVO">
        select a.*, b.id orderId, b.user_id
        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
        where a.shop_id=#{shopId}
        <if test="areaId != null">
            and a.area_id=#{areaId}
        </if>
        <if test="tableCode != null and tableCode != ''">
            and a.table_code=#{tableCode}
        </if>
        <if test="status != null and status != ''">
            and a.status=#{status}
        </if>
        <if test="name != null and name != ''">
            and a.name like concat('%', #{name}, '%')
        </if>
        <if test="isBind != null">
            and a.table_code is not null
        </if>
        group by a.id
        ORDER BY a.create_time

    </select>
</mapper>
