<?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.ruoyi.system.mapper.PosOrderPromotionMapper">

    <resultMap type="PosOrderPromotion" id="PosOrderPromotionResult">
        <result property="id"             column="id" />
        <result property="orderId"        column="order_id" />
        <result property="promoType"      column="promo_type" />
        <result property="promoSubType"   column="promo_sub_type" />
        <result property="promoId"        column="promo_id" />
        <result property="userCouponId"   column="user_coupon_id" />
        <result property="promoName"      column="promo_name" />
        <result property="promoDetail"    column="promo_detail" />
        <result property="reduceAmount"   column="reduce_amount" />
        <result property="pathSummary"    column="path_summary" />
        <result property="createTime"     column="create_time" />
    </resultMap>

    <sql id="selectPosOrderPromotionVo">
        select id, order_id, promo_type, promo_sub_type, promo_id, user_coupon_id,
               promo_name, promo_detail, reduce_amount, path_summary, create_time
        from pos_order_promotion
    </sql>

    <select id="selectByOrderId" parameterType="Long" resultMap="PosOrderPromotionResult">
        <include refid="selectPosOrderPromotionVo"/>
        where order_id = #{orderId}
        order by id asc
    </select>

    <insert id="insertBatch" parameterType="java.util.List">
        insert into pos_order_promotion (order_id, promo_type, promo_sub_type, promo_id,
            user_coupon_id, promo_name, promo_detail, reduce_amount, path_summary)
        values
        <foreach item="item" collection="list" separator=",">
            (#{item.orderId}, #{item.promoType}, #{item.promoSubType}, #{item.promoId},
             #{item.userCouponId}, #{item.promoName}, #{item.promoDetail}, #{item.reduceAmount},
             #{item.pathSummary})
        </foreach>
    </insert>

</mapper>
