<?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.dao.MemberPriceSettingsDao">
	<resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.MemberPriceSettings">
		<result column="id_" property="id" />
		<result column="period_" property="period" />
		<result column="sale_price_" property="salePrice" />
		<result column="original_price_" property="originalPrice" />
		<result column="create_time_" property="createTime" />
		<result column="update_time_" property="updateTime" />
		<result column="create_by_" property="createBy" />
		<result column="update_by_" property="updateBy" />
	</resultMap>

	<!-- 表字段 -->
	<sql id="baseColumns">
         t.id_ as id
        , t.period_ as period
        , t.sale_price_ as salePrice
        , t.original_price_ as originalPrice
        , t.create_time_ as createTime
        , t.update_time_ as updateTime
        , t.create_by_ as createBy
        , t.update_by_ as updateBy
        </sql>

	<select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.MemberPriceSettingsVo">
		SELECT
			<include refid="baseColumns"/>,
			ifnull(u.real_name_,u.username_) modifierName
		FROM member_price_settings t
		LEFT JOIN sys_user u on t.update_by_ = u.id_
		where t.id_ = #{id}
	</select>

	<sql id="selectSql">
		SELECT
			<include refid="baseColumns" />,
		ifnull(u.real_name_,u.username_) as modifierName
		FROM member_price_settings t
		LEFT JOIN sys_user u on t.update_by_ = u.id_
	</sql>

	<select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.MemberPriceSettingsVo">
		<include refid="selectSql"/>
	</select>

	<select id="selectList" resultType="com.yonge.cooleshow.biz.dal.vo.MemberPriceSettingsVo">
		<include refid="selectSql"/>
	</select>

    <select id="getMemberPriceByOrderDetilId"
            resultType="com.yonge.cooleshow.biz.dal.entity.MemberPriceSettings">
		SELECT
			<include refid="baseColumns"/>
		FROM user_order_detail d
		left join member_price_settings t on d.biz_id_ = t.id_
		where d.good_type_ = 'VIP' and  d.id_ = #{orderDetilId}
	</select>
</mapper>