<?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.HsGiftOrderDetailMapper">

    <resultMap type="HsGiftOrderDetail" 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="giftNumber" column="gift_number"/>
        <result property="giftName" column="gift_name"/>
        <result property="cuisineName" column="cuisine_name"/>
        <result property="eventId" column="event_id"/>
        <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.gift_number,
               a.cuisine_name,
               a.event_id,
               a.gift_name,
               a.amount,
               a.price,
               a.total,
               a.jgid,
               a.is_delete
        from hs_gift_order_detail a
    </sql>

    <select id="selectHsCanteenOrderDetailList" resultType="OrderResp">
        select
        a.order_number,
        a.gift_name name,
        a.amount,
        a.total price,
        he.event_name,
        he.event_time,
        hg.gift_pictrue pictrue
        from hs_gift_order_detail a
        LEFT JOIN hs_gift hg ON hg.gift_number = a.gift_number
        LEFT JOIN hs_event he ON a.event_id = he.id
        <where>
            a.is_delete = 0 and a.order_number = #{orderNumber}
            <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>
        </where>
        order by a.menu_number
    </select>
</mapper>
