<?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.ym.mec.biz.dal.dao.ChildrenDayDegreeInfoDao">
    <resultMap id="ChildrenDayDegreeInfo" type="com.ym.mec.biz.dal.entity.ChildrenDayDegreeInfo">
        <!--@mbg.generated-->
        <!--@Table children_day_degree_info-->
        <id column="id_" property="id"/>
        <result column="reserve_id_" property="reserveId"/>
        <result column="user_id_" property="userId"/>
        <result column="subject_id_" property="subjectId"/>
        <result column="grade_level_" property="gradeLevel"/>
        <result column="grade_price_" property="gradePrice"/>
        <result column="theory_level_" property="theoryLevel"/>
        <result column="theory_price_" property="theoryPrice"/>
        <result column="vip_1v1_price_" property="vip1v1Price"/>
        <result column="vip_1v2_price_" property="vip1v2Price"/>
        <result column="theory_course_price_" property="theoryCoursePrice"/>
        <result column="total_amount_" property="totalAmount"/>
        <result column="order_id_" property="orderId"/>
        <result column="create_time_" property="createTime"/>
        <result column="update_time_" property="updateTime"/>
    </resultMap>

    <select id="get" parameterType="java.lang.Integer" resultMap="ChildrenDayDegreeInfo">
        <!--@mbg.generated-->
        select *
        from children_day_degree_info
        where id_ = #{id}
    </select>

    <delete id="delete" parameterType="java.lang.Integer">
        <!--@mbg.generated-->
        delete from children_day_degree_info
        where id_ = #{id}
    </delete>

    <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.ChildrenDayDegreeInfo"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into children_day_degree_info (reserve_id_, user_id_, subject_id_, grade_level_, grade_price_,
        theory_level_,theory_price_, vip_1v1_price_, vip_1v2_price_, theory_course_price_, total_amount_,order_id_,
        create_time_, update_time_)
        values (#{reserveId}, #{userId}, #{subjectId}, #{gradeLevel}, #{gradePrice}, #{theoryLevel},
        #{theoryPrice}, #{vip1v1Price}, #{vip1v2Price}, #{theoryCoursePrice}, #{totalAmount},#{orderId},
        NOW(), NOW())
    </insert>

    <update id="update" parameterType="com.ym.mec.biz.dal.entity.ChildrenDayDegreeInfo">
        <!--@mbg.generated-->
        update children_day_degree_info
        <set>
            <if test="reserveId != null">
                reserve_id_ = #{reserveId},
            </if>
            <if test="userId != null">
                user_id_ = #{userId},
            </if>
            <if test="subjectId != null">
                subject_id_ = #{subjectId},
            </if>
            <if test="gradeLevel != null">
                grade_level_ = #{gradeLevel},
            </if>
            <if test="gradePrice != null">
                grade_price_ = #{gradePrice},
            </if>
            <if test="theoryLevel != null">
                theory_level_ = #{theoryLevel},
            </if>
            <if test="theoryPrice != null">
                theory_price_ = #{theoryPrice},
            </if>
            <if test="vip1v1Price != null">
                vip_1v1_price_ = #{vip1v1Price},
            </if>
            <if test="vip1v2Price != null">
                vip_1v2_price_ = #{vip1v2Price},
            </if>
            <if test="theoryCoursePrice != null">
                theory_course_price_ = #{theoryCoursePrice},
            </if>
            <if test="totalAmount != null">
                total_amount_ = #{totalAmount},
            </if>
            <if test="orderId != null">
                order_id_ = #{orderId},
            </if>
            <if test="createTime != null">
                create_time_ = #{createTime},
            </if>
            <if test="updateTime != null">
                update_time_ = NOW(),
            </if>
        </set>
        where id_ = #{id}
    </update>

    <!-- 分页查询 -->
    <select id="queryPage" resultMap="ChildrenDayDegreeInfo" parameterType="map">
        SELECT * FROM children_day_degree_info
        <include refid="global.limit"/>
    </select>

    <!-- 查询当前表的总记录数 -->
    <select id="queryCount" resultType="int">
        SELECT COUNT(*)
        FROM children_day_degree_info
    </select>

    <select id="getPayedUser" resultType="java.lang.Integer">
        SELECT * FROM children_day_degree_info WHERE user_id_ IN
        <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
            #{userId}
        </foreach>
    </select>
</mapper>
