<?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.ics.admin.mapper.meeting.OrderMapper">
    
    <resultMap type="com.ics.admin.domain.meeting.Order" id="OrderResult">
        <result property="id"    column="id"    />
        <result property="roomContentId"    column="room_content_id"    />
        <result property="userId"    column="user_id"    />
        <result property="reservationId"    column="reservation_id"    />
        <result property="orderMoney"    column="order_money"    />
        <result property="orderStauts"    column="order_stauts"    />
        <result property="outTradeNo"    column="out_trade_no"    />
        <result property="isAfterSale"    column="is_after_sale"    />
        <result property="cancelTime"    column="cancel_time"    />
        <result property="cancelResaon"    column="cancel_resaon"    />
        <result property="afterNumber"    column="after_number"    />
        <result property="deleteFlag"    column="delete_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remake"    column="remake"    />
        <result property="mchid"    column="mchid"    />
        <result property="description"    column="description"    />
        <result property="prepayId"    column="prepay_id"    />
    </resultMap>

    <sql id="selectOrderVo">
        SELECT id, room_content_id, user_id, reservation_id, order_money, order_stauts, out_trade_no, is_after_sale, cancel_time, cancel_resaon, after_number, delete_flag, create_by, create_time, update_by, update_time, remake, mchid, description, prepay_id FROM tb_order
    </sql>

    <select id="selectOrderList" parameterType="Order" resultMap="OrderResult">
        <include refid="selectOrderVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectOrderById" parameterType="Long" resultMap="OrderResult">
        <include refid="selectOrderVo"/>
        WHERE id = #{id}
    </select>
        
    <insert id="insertOrder" parameterType="Order">
        INSERT INTO tb_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null ">id,</if>
            <if test="roomContentId != null ">room_content_id,</if>
            <if test="userId != null ">user_id,</if>
            <if test="reservationId != null ">reservation_id,</if>
            <if test="orderMoney != null  and orderMoney != ''">order_money,</if>
            <if test="orderStauts != null ">order_stauts,</if>
            <if test="outTradeNo != null ">out_trade_no,</if>
            <if test="isAfterSale != null  and isAfterSale != ''">is_after_sale,</if>
            <if test="cancelTime != null ">cancel_time,</if>
            <if test="cancelResaon != null  and cancelResaon != ''">cancel_resaon,</if>
            <if test="afterNumber != null  and afterNumber != ''">after_number,</if>
            <if test="deleteFlag != null ">delete_flag,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="updateBy != null  and updateBy != ''">update_by,</if>
            <if test="updateTime != null ">update_time,</if>
            <if test="remake != null  and remake != ''">remake,</if>
            <if test="mchid != null ">mchid,</if>
            <if test="description != null  and description != ''">description,</if>
            <if test="prepayId != null ">prepay_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null ">#{id},</if>
            <if test="roomContentId != null ">#{roomContentId},</if>
            <if test="userId != null ">#{userId},</if>
            <if test="reservationId != null ">#{reservationId},</if>
            <if test="orderMoney != null  and orderMoney != ''">#{orderMoney},</if>
            <if test="orderStauts != null ">#{orderStauts},</if>
            <if test="outTradeNo != null ">#{outTradeNo},</if>
            <if test="isAfterSale != null  and isAfterSale != ''">#{isAfterSale},</if>
            <if test="cancelTime != null ">#{cancelTime},</if>
            <if test="cancelResaon != null  and cancelResaon != ''">#{cancelResaon},</if>
            <if test="afterNumber != null  and afterNumber != ''">#{afterNumber},</if>
            <if test="deleteFlag != null ">#{deleteFlag},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="updateBy != null  and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null ">#{updateTime},</if>
            <if test="remake != null  and remake != ''">#{remake},</if>
            <if test="mchid != null ">#{mchid},</if>
            <if test="description != null  and description != ''">#{description},</if>
            <if test="prepayId != null ">#{prepayId},</if>
         </trim>
    </insert>

    <update id="updateOrder" parameterType="Order">
        UPDATE tb_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="roomContentId != null ">room_content_id = #{roomContentId},</if>
            <if test="userId != null ">user_id = #{userId},</if>
            <if test="reservationId != null ">reservation_id = #{reservationId},</if>
            <if test="orderMoney != null  and orderMoney != ''">order_money = #{orderMoney},</if>
            <if test="orderStauts != null ">order_stauts = #{orderStauts},</if>
            <if test="outTradeNo != null ">out_trade_no = #{outTradeNo},</if>
            <if test="isAfterSale != null  and isAfterSale != ''">is_after_sale = #{isAfterSale},</if>
            <if test="cancelTime != null ">cancel_time = #{cancelTime},</if>
            <if test="cancelResaon != null  and cancelResaon != ''">cancel_resaon = #{cancelResaon},</if>
            <if test="afterNumber != null  and afterNumber != ''">after_number = #{afterNumber},</if>
            <if test="deleteFlag != null ">delete_flag = #{deleteFlag},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null ">update_time = #{updateTime},</if>
            <if test="remake != null  and remake != ''">remake = #{remake},</if>
            <if test="mchid != null ">mchid = #{mchid},</if>
            <if test="description != null  and description != ''">description = #{description},</if>
            <if test="prepayId != null ">prepay_id = #{prepayId},</if>
        </trim>
        WHERE id = #{id}
    </update>

    <delete id="deleteOrderById" parameterType="Long">
        DELETE FROM tb_order WHERE id = #{id}
    </delete>

    <delete id="deleteOrderByIds" parameterType="String">
        DELETE FROM tb_order where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>