<?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.zhongzheng.modules.order.mapper.OrderCouponMapper">

    <resultMap type="com.zhongzheng.modules.order.domain.OrderCoupon" id="OrderCouponResult">
        <result property="id" column="id"/>
        <result property="orderSn" column="order_sn"/>
        <result property="couponId" column="coupon_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="activityName" column="activity_name"/>
        <result property="price" column="price"/>
        <result property="couponType" column="coupon_type"/>
    </resultMap>

    <select id="queryOrderCouponList" resultMap="OrderCouponResult">
        SELECT
        ac.activity_name,
        c.price,
        c.coupon_type
        FROM
        order_coupon oc
        LEFT JOIN coupon c ON oc.coupon_id = c.coupon_id
        LEFT JOIN activity_configuration ac ON c.configuration_id = ac.id
        <if test="orderSn != null and orderSn != ''" >
            WHERE
            oc.order_sn = #{orderSn}
        </if>
    </select>


</mapper>
