<?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.willalp.canteen.mapper.HsCanteenOrderDetailMapper">

    <resultMap type="HsCanteenOrderDetail" id="HsCanteenOrderDetailResult">
        <result property="detailId" column="detail_id"/>
        <result property="orderNumber" column="order_number"/>
        <result property="menuNumber" column="menu_number"/>
        <result property="cuisineNumber" column="cuisine_number"/>
        <result property="cuisineName" column="cuisine_name"/>
        <result property="amount" column="amount"/>
        <result property="price" column="price"/>
        <result property="total" column="total"/>
        <result property="jgid" column="jgid"/>
        <result property="isDelete" column="is_delete"/>
        <result property="patternId" column="pattern_id"/>
        <result property="cuisinePictrue" column="cuisine_pictrue"/>
    </resultMap>

    <sql id="selectHsCanteenOrderDetailVo">
        select a.detail_id, a.order_number, a.menu_number, a.cuisine_number, a.cuisine_name, a.amount, a.price, a.total, a.jgid, a.is_delete, b.pattern_id,c.cuisine_pictrue
        from hs_canteen_order_detail a
        left join hs_canteen_menu b on a.menu_number = b.menu_number
        left join hs_canteen_cuisine c on a.cuisine_number = c.cuisine_number
    </sql>

    <select id="selectHsCanteenOrderDetailList" parameterType="HsCanteenOrderDetail" resultMap="HsCanteenOrderDetailResult">
        <include refid="selectHsCanteenOrderDetailVo"/>
        <where>
            a.is_delete = 0
            <if test="orderNumber != null  and orderNumber != ''">and a.order_number like concat('%', #{orderNumber},'%')</if>
            <if test="menuNumber != null  and menuNumber != ''">and a.menu_number like concat('%', #{menuNumber}, '%')</if>
            <if test="cuisineNumber != null  and cuisineNumber != ''">and a.cuisine_number like concat('%',#{cuisineNumber}, '%')</if>
            <if test="cuisineName != null  and cuisineName != ''">and a.cuisine_name like concat('%', #{cuisineName},'%')</if>
            <if test="jgid != null and jgid != ''">and a.jgid = #{jgid}</if>
            <if test="patternId != null ">and b.pattern_id = #{patternId}</if>
        </where>
        order by a.menu_number
    </select>
</mapper>
