<?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.yonge.cooleshow.biz.dal.mapper.DiscountCardRecordMapper">

	 
    
    <!-- 表字段 -->
    <sql id="baseColumns">
         t.id_ AS id
        , t.user_id_ AS userId
        , t.vip_card_id_ AS vipCardId
        , t.order_no_ AS orderNo
        , t.source_type_ AS sourceType
        , t.client_type_ AS clientType
        , t.sub_order_no_ AS subOrderNo
        , t.start_time_ AS startTime
        , t.end_time_ AS endTime
        , t.create_time_ AS createTime
        , t.create_by_ AS createBy
        , t.update_time_ AS updateTime
        , t.type_ AS type
        , t.times_ AS times
        , t.msg_status_ AS msgStatus
        , t.reason_ AS reason
        , t.vip_type_ AS vipType
        , t.status_ AS status
        , t.display_flag_ AS displayFlag
        , t.ref_id_ AS refId
        , t.efficient_flag_ AS efficientFlag
        , t.send_msg_ AS sendMsg
        </sql>

    <select id="detail" resultType="com.yonge.cooleshow.biz.dal.entity.MemberPriceSettings">
        SELECT
            s.*
        FROM user_order_detail a
        LEFT JOIN discount_card_record t ON a.order_no_ = t.order_no_ AND a.sub_order_no_ = t.sub_order_no_ AND t.display_flag_ = 1
        LEFT JOIN member_price_settings s ON t.vip_card_id_ = s.id_
        where a.id_ = #{orderDetilId}
        <if test="userId != null">
            and t.user_id_ = #{userId}
        </if>
    </select>
</mapper>