<?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.VipGroupDao">

    <resultMap type="com.ym.mec.biz.dal.entity.VipGroup" id="VipGroup">
        <result column="id_" property="id"/>
        <result column="name_" property="name"/>
        <result column="user_id_" property="userId"/>
        <result column="username_" property="userName"/>
        <result column="single_class_minutes_" property="singleClassMinutes"/>
        <result column="payment_expire_date_" property="paymentExpireDate"/>
        <result column="courses_expire_date_" property="coursesExpireDate"/>
        <result column="registration_start_time_" property="registrationStartTime"/>
        <result column="create_time_" property="createTime"/>
        <result column="update_time_" property="updateTime"/>
        <result column="teacher_school_id_" property="teacherSchoolId"/>
        <result column="online_classes_num_" property="onlineClassesNum"/>
        <result column="offline_classes_num_" property="offlineClassesNum"/>
        <result column="audit_status_" property="auditStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="organ_id_list_" property="organIdList"/>
        <result column="vip_group_activity_id_" property="vipGroupActivityId"/>
        <result column="vip_group_activity_name_" property="vipGroupActivityName"/>
        <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="online_classes_unit_price_" property="onlineClassesUnitPrice"/>
        <result column="offline_classes_unit_price_" property="offlineClassesUnitPrice"/>
        <result column="total_price_" property="totalPrice"/>
        <result column="student_num_" property="studentNum"/>
        <result column="total_class_times_" property="totalClassTimes"/>
        <result column="current_class_times_" property="currentClassTimes"/>
        <result column="vip_group_category_id_" property="vipGroupCategoryId"/>
        <result column="give_teach_mode_" property="giveTeachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="organ_id_" property="organId"/>
        <result column="schoole_id_" property="schoolId"/>
    </resultMap>

    <resultMap id="studentManageVipGroup" type="com.ym.mec.biz.dal.dto.StudentManageVipGroupDto" extends="VipGroup">
        <result property="vipGroupCategory" column="vip_group_category_"/>
    </resultMap>

    <resultMap id="vipGroupManageDetailDto" type="com.ym.mec.biz.dal.dto.VipGroupManageDetailDto" extends="VipGroup">
        <result property="studentNum" column="student_num_"/>
        <result property="subjectIdList" column="subject_id_list_"/>
        <result property="categoryName" column="category_name_"/>
        <result column="teacher_school_name_" property="teacherSchoolName"/>
        <!--<collection property="students" ofType="com.ym.mec.auth.api.entity.SysUser" column="student_id_">-->
            <!--<result property="id" column="student_id_"/>-->
            <!--<result property="username" column="username_"/>-->
        <!--</collection>-->
    </resultMap>

    <resultMap id="studentVipGroupDetailDto" type="com.ym.mec.biz.dal.dto.StudentVipGroupDetailDto" extends="studentVipGroup">
        <result column="total_class_times_" property="totalClassTimes"/>
        <result column="address_" property="address"/>
        <collection property="courseSchedules" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleDao.CourseSchedule" column="cs.id_"/>
    </resultMap>

    <resultMap type="com.ym.mec.biz.dal.dto.StudentVipGroupShowListDto" id="studentVipGroup">
        <result column="id_" property="vipGroupId"/>
        <result column="name_" property="vipGroupName"/>
        <result column="single_class_minutes_" property="singleClassMinutes"/>
        <result column="payment_expire_date_" property="paymentExpireDate"/>
        <result column="online_classes_num_" property="onlineClassesNum"/>
        <result column="offline_classes_num_" property="offlineClassesNum"/>
        <result column="total_price_" property="totalPrice"/>
        <result column="expect_student_num_" property="expectStudentNum"/>
        <result column="student_num_" property="studentNum"/>
        <result column="user_id_" property="teacherId"/>
        <result column="teacher_name_" property="teacherName"/>
        <result column="introduction_" property="introduction"/>
        <result column="avatar_" property="avatar"/>
        <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="attribute1_" property="attribute1" />
        <result column="category_name_" property="categoryName"/>
    </resultMap>

    <!-- 根据主键查询一条记录 -->
    <select id="get" resultMap="VipGroup">
		SELECT * FROM vip_group WHERE id_ = #{id} 
	</select>

    <select id="findStudentVipGroups" resultMap="studentManageVipGroup">
        SELECT
            vg.*,
            vgc.name_ vip_group_category_
        FROM
            class_group_student_mapper cgsm
            LEFT JOIN vip_group_class_group_mapper vgcgm ON cgsm.class_group_id_=vgcgm.class_group_id_
            LEFT JOIN vip_group vg ON vgcgm.vip_group_id_=vg.id_
            LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
        WHERE cgsm.class_group_id_=vgcgm.class_group_id_ AND cgsm.user_id_=#{userId}
    </select>

    <!-- 全查询 -->
    <select id="findAll" resultMap="VipGroup">
		SELECT * FROM vip_group ORDER BY id_
	</select>

    <sql id="vipGroupQueryCondition">
        <where>
            <if test="search!=null and search!=''">
                vg.name LIKE CONCAT('%',#{search},'%')
            </if>
            <if test="organId!=null">
                AND FIND_IN_SET(#{organId},vg.organ_id_list_)
            </if>
        </where>
    </sql>

    <select id="findAllByOrgan" resultMap="VipGroup">
		SELECT
            vg.*,
            vga.name_ vip_group_activity_name_,
            su.username_,
            cg.student_num_,
            cg.total_class_times_,
            cg.current_class_times_
        FROM
            vip_group vg
            LEFT JOIN sys_user su ON vg.user_id_=su.id_
            LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
            LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
            LEFT JOIN vip_group_activity vga ON vg.vip_group_activity_id_=vga.id_
        <include refid="vipGroupQueryCondition"/>
        ORDER BY vg.id_
        <include refid="global.limit"/>
	</select>

    <select id="countVipGroupByOrgan" resultType="int">
        SELECT
        count(*)
        FROM
        vip_group vg
        <include refid="vipGroupQueryCondition"/>
    </select>

    <!-- 向数据库增加一条记录 -->
    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.VipGroup" useGeneratedKeys="true" keyColumn="id"
            keyProperty="id">
        <!--
        <selectKey resultClass="int" keyProperty="id" >
        SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
        </selectKey>
        -->
        INSERT INTO vip_group
        (id_,user_id_,single_class_minutes_,payment_expire_date_,courses_expire_date_,create_time_,update_time_,teacher_school_id_,online_classes_num_,offline_classes_num_,registration_start_time_,name_,organ_id_list_,vip_group_activity_id_,status_,online_classes_unit_price_,offline_classes_unit_price_,total_price_,give_teach_mode_,vip_group_category_id_,schoole_id_,organ_id_)
        VALUES(#{id},#{userId},#{singleClassMinutes},#{paymentExpireDate},#{coursesExpireDate},now(),now(),#{teacherSchoolId},#{onlineClassesNum},#{offlineClassesNum},#{registrationStartTime},#{name},#{organIdList},#{vipGroupActivityId},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{onlineClassesUnitPrice},#{offlineClassesUnitPrice},#{totalPrice},#{giveTeachMode},#{vipGroupCategoryId},#{schoolId},#{organId})
    </insert>

    <!-- 根据主键查询一条记录 -->
    <update id="update" parameterType="com.ym.mec.biz.dal.entity.VipGroup">
        UPDATE vip_group
        <set>
            <if test="paymentExpireDate != null">
                payment_expire_date_ = #{paymentExpireDate},
            </if>
            <if test="userId != null">
                user_id_ = #{userId},
            </if>
            <if test="offlineClassesNum != null">
                offline_classes_num_ = #{offlineClassesNum},
            </if>
            <if test="onlineClassesNum != null">
                online_classes_num_ = #{onlineClassesNum},
            </if>
            <if test="updateTime != null">
                update_time_ = #{updateTime},
            </if>
            <if test="singleClassMinutes != null">
                single_class_minutes_ = #{singleClassMinutes},
            </if>
            <if test="teacherSchoolId != null">
                teacher_school_id_ = #{teacherSchoolId},
            </if>
            <if test="coursesExpireDate != null">
                courses_expire_date_ = #{coursesExpireDate},
            </if>
            <if test="registrationStartTime != null">
                registration_start_time_ = #{registrationStartTime},
            </if>
            <if test="organIdList!=null">
                organ_id_list_=#{organIdList},
            </if>
            <if test="auditStatus != null">
                audit_status_ = #{auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
            </if>
            <if test="organIdList != null">
                organ_id_list_ = #{organIdList},
            </if>
            <if test="vipGroupActivityId != null">
                vip_group_activity_id_ = #{vipGroupActivityId},
            </if>
            <if test="status != null">
                status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
            </if>
            <if test="onlineClassesUnitPrice != null">
                online_classes_unit_price_ = #{onlineClassesUnitPrice},
            </if>
            <if test="offlineClassesUnitPrice != null">
                offline_classes_unit_price_ = #{offlineClassesUnitPrice},
            </if>
            <if test="totalPrice != null">
                total_price_ = #{totalPrice},
            </if>
            <if test="giveTeachMode!=null">
                give_teach_mode_=#{giveTeachMode}
            </if>
            <if test="organId!=null">
                organ_id_=#{organId}
            </if>
            <if test="schoolId!=null">
                schoole_id_=#{schoolId}
            </if>
        </set>
        WHERE id_ = #{id}
    </update>

    <!-- 根据主键删除一条记录 -->
    <delete id="delete">
		DELETE FROM vip_group WHERE id_ = #{id} 
	</delete>

    <!-- 分页查询 -->
    <select id="queryPage" resultMap="VipGroup" parameterType="map">
        SELECT * FROM vip_group ORDER BY id_
        <include refid="global.limit"/>
    </select>

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

    <sql id="studentVipGroupQueryCondition">
        <where>
            vg.status_!=3
            <if test="subjectId!=null">
               AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
            </if>
            <if test="classType!=null and classType.toString()=='0'.toString()">
                AND vg.offline_classes_num_>0
            </if>
            <if test="classType!=null and classType.toString()=='1'.toString()">
                AND vg.online_classes_num_>0
            </if>
            <if test="search!=null">
                AND vg.name_ like concat('%',#{search},'%')
            </if>
        </where>
    </sql>

    <select id="findVipGroups" resultMap="studentVipGroup">
       SELECT
            vg.id_,
            vg.name_,
            vg.single_class_minutes_,
            vg.payment_expire_date_,
            vg.courses_expire_date_,
            vg.online_classes_num_,
            vg.offline_classes_num_,
            vg.total_price_,
            cg.expect_student_num_,
            cg.student_num_,
            su.username_ teacher_name_,
            su.avatar_,
            t.introduction_,
            vga.type_,
            vga.attribute1_,
            vgc.name_ category_name_
        FROM
            vip_group vg
            LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
            LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
            LEFT JOIN teacher t ON vg.user_id_=t.id_
            LEFT JOIN sys_user su ON vg.user_id_=su.id_
            LEFT JOIN vip_group_activity vga ON vg.vip_group_activity_id_=vga.id_
            LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
            <include refid="studentVipGroupQueryCondition"/>
        ORDER BY vg.id_ DESC
        <include refid="global.limit"/>
    </select>
    <select id="countVipGorups" resultType="int">
        SELECT
            count(*)
        FROM
            vip_group vg
        LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
        LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
        <include refid="studentVipGroupQueryCondition"/>
    </select>
    <select id="getVipGroupBaseInfo" resultMap="vipGroupManageDetailDto">
        SELECT
            vg.*,
            vga.name_ vip_group_activity_name_,
            su.username_,
            cg.student_num_,
            cg.subject_id_list_,
            cg.total_class_times_,
            cg.current_class_times_,
            vgc.name_ category_name_,
            s.name_ teacher_school_name_
        FROM
            vip_group vg
            LEFT JOIN sys_user su ON vg.user_id_=su.id_
            LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
            LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
            LEFT JOIN vip_group_activity vga ON vg.vip_group_activity_id_=vga.id_
            LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
            LEFT JOIN school s ON vg.teacher_school_id_=s.id_
        WHERE vg.id_=#{vipGroupId}
    </select>

    <sql id="vipGroupAttendanceQueryCondition">
        <where>
            <if test="vipGroupId!=null">
                and vg.id_=#{vipGroupId}
            </if>
            <if test="startTime != null">
                and CONCAT(cs.class_date_,' ',cs.end_class_time_) &gt; #{startTime}
            </if>
            <if test="endTime != null">
                and CONCAT(cs.class_date_,' ',cs.end_class_time_) &lt; #{endTime}
            </if>
            <if test="status != null">
                and cs.status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
            </if>
            <if test="complaintStatus != null">
                and cs.complaint_status_ = #{complaintStatus}
            </if>
        </where>
    </sql>
    <select id="findVipGroupAttendances" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleDao.CourseSchedule">
        SELECT
            cs.*
        FROM
            vip_group vg
            LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
            LEFT JOIN teacher_attendance ta ON vgcgm.class_group_id_=ta.class_group_id_
            LEFT JOIN course_schedule cs ON ta.course_schedule_id_=cs.id_
        <include refid="vipGroupAttendanceQueryCondition"/>
        ORDER BY ta.id_
        <include refid="global.limit"/>
    </select>
    <select id="countVipGroupAttendance" resultType="int">
        SELECT
        count(*)
        FROM
        vip_group vg
        LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
        LEFT JOIN teacher_attendance ta ON vgcgm.class_group_id_=ta.class_group_id_
        LEFT JOIN course_schedule cs ON ta.course_schedule_id_=cs.id_
        <include refid="vipGroupAttendanceQueryCondition"/>
        ORDER BY ta.id_
    </select>

    <select id="getVipGroupDetail" resultMap="studentVipGroupDetailDto">
        SELECT
            vg.*,
            cg.total_class_times_,
            cg.expect_student_num_,
            cg.student_num_,
            su.username_ teacher_name_,
            su.avatar_,
            t.introduction_,
            s.name_ address_,
            cs.id_ course_id_,
            cs.class_group_id_,
            cs.status_,
            cs.subsidy_,
            cs.class_date_,
            CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
            CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
            cs.teacher_id_,
            cs.actual_teacher_id_,
            cs.create_time_,
            cs.update_time_,
            cs.teach_mode_,
            cs.type_,
            cs.name_
        FROM
            vip_group vg
            LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
            LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
            LEFT JOIN course_schedule cs ON vgcgm.class_group_id_=cs.class_group_id_
	        LEFT JOIN school s ON vg.teacher_school_id_=s.id_
            LEFT JOIN teacher t ON vg.user_id_=t.id_
          LEFT JOIN sys_user su ON vg.user_id_=su.id_
        WHERE vg.id_=#{vipGroupId}
    </select>
    <select id="countSurplusClassTimes" resultType="java.util.Map">
        SELECT
            cs.teach_mode_ as 'key',
            COUNT(cs.id_) as 'value'
        FROM
            vip_group_class_group_mapper vgcgm
            LEFT JOIN course_schedule cs ON vgcgm.class_group_id_=cs.class_group_id_
            WHERE cs.status_="NOT_START" AND cs.type_="VIP" AND vgcgm.vip_group_id_=#{vipGroupId}
            GROUP BY cs.teach_mode_
    </select>

    <resultMap id="vipGroupStudentDto" type="com.ym.mec.biz.dal.dto.VipGroupStudentDto">
        <result column="id_" property="id"/>
        <result column="username_" property="userName"/>
        <result column="total_class_times_" property="totalClassTimes"/>
        <result column="current_class_times_" property="currentClassTimes"/>
    </resultMap>

    <select id="findVipGroupStudents" resultMap="vipGroupStudentDto">
        SELECT
            su.id_,
            su.username_,
            cg.total_class_times_,
            cg.current_class_times_
        FROM
            vip_group_class_group_mapper vgcgm
            LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
            LEFT JOIN class_group_student_mapper cgsm ON vgcgm.class_group_id_=cgsm.class_group_id_
            LEFT JOIN sys_user su ON cgsm.user_id_=su.id_
        WHERE vgcgm.id_=#{vipGroupId}
        ORDER BY su.id_
        <include refid="global.limit"/>
    </select>

    <select id="countVipGroupStudents" resultType="int">
        SELECT
        count(*)
        FROM
        vip_group_class_group_mapper vgcgm
        LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
        LEFT JOIN class_group_student_mapper cgsm ON vgcgm.class_group_id_=cgsm.class_group_id_
        WHERE vgcgm.id_=#{vipGroupId}
    </select>

    <resultMap id="teachingRecord" type="com.ym.mec.biz.dal.dto.VipGroupCourseSchduleRecordDto">
        <result column="id_" property="id"/>
        <result column="start_class_time_" property="startClassTime"/>
        <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="give_teach_mode_" property="giveTeachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="is_salary_" property="isSalary" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="student_num_" property="attendanceNum"/>
    </resultMap>

    <sql id="teachingRecordQueryCondition">
        <where>
            vgcgm.vip_group_id_=#{vipGroupId}
            <if test="startTime!=null and endTime!=null">
                AND (cs.class_date_ BETWEEN #{startTime} AND #{endTime})
            </if>
            <if test="teachMode!=null and teachMode!=''">
                AND cs.teach_mode_=#{teachMode}
            </if>
            <if test="status!=null and status!=''">
                AND cs.status_=#{status}
            </if>
        </where>
    </sql>

    <select id="findTeachingRecord" resultMap="teachingRecord">
        SELECT
            cs.id_,
            CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
            cs.status_,
            cs.teach_mode_,
            cs.student_num_,
            csts.actual_salary_ IS NOT NULL is_salary_
        FROM
            vip_group_class_group_mapper vgcgm
            LEFT JOIN course_schedule cs ON vgcgm.class_group_id_=cs.class_group_id_
            LEFT JOIN course_schedule_teacher_salary csts ON cs.id_=csts.course_schedule_id_
        <include refid="teachingRecordQueryCondition"/>
        ORDER BY cs.id_
        <include refid="global.limit"/>
    </select>
    <select id="countTeachingRecord" resultType="int">
        SELECT
        COUNT(*)
        FROM
        vip_group_class_group_mapper vgcgm
        LEFT JOIN course_schedule cs ON vgcgm.class_group_id_=cs.class_group_id_
        <include refid="teachingRecordQueryCondition"/>
    </select>

    <select id="getClassTimes" resultType="com.ym.mec.biz.dal.dto.TeachingRecordBaseInfo">
        SELECT
            cg.total_class_times_ totalClassTimes,
            cg.current_class_times_ currentClassTimes
        FROM
            vip_group_class_group_mapper vgcgm
            LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
        WHERE vgcgm.vip_group_id_=#{vipGroupId}
    </select>
    <select id="countIsSalaryNum" resultType="int">
        SELECT
            COUNT(*)
        FROM
            vip_group_class_group_mapper vgcgm
            LEFT JOIN course_schedule cs ON vgcgm.class_group_id_=cs.class_group_id_
            LEFT JOIN course_schedule_teacher_salary csts ON cs.id_=csts.course_schedule_id_
        WHERE vgcgm.vip_group_id_=#{vipGroupId} AND csts.settlement_time_ IS NOT NULL
    </select>
    <select id="countComplaintsNum" resultType="java.lang.Integer">
        SELECT
            COUNT(*)
        FROM
            vip_group_class_group_mapper vgcgm
            LEFT JOIN course_schedule cs ON vgcgm.class_group_id_=cs.class_group_id_
            LEFT JOIN course_schedule_complaints csc ON cs.id_=csc.course_schedule_id_
        WHERE vgcgm.vip_group_id_=#{vipGroupId} AND csc.course_schedule_id_ IS NOT NULL

    </select>
    <select id="getVipGroupSalaryInfo" resultType="com.ym.mec.biz.dal.dto.VipGroupSalaryBaseInfo">
        SELECT
             SUM(csts.expect_salary_) expectTotalSalary,
             SUM(csts.actual_salary_) totalSalary
        FROM
            vip_group vg
            LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
            LEFT JOIN course_schedule cs ON vgcgm.class_group_id_=cs.class_group_id_
            LEFT JOIN course_schedule_teacher_salary csts ON cs.id_=csts.course_schedule_id_
        WHERE vg.id_=#{vipGroupId} AND cs.id_!=NULL AND csts.settlement_time_!=NULL
    </select>
    <select id="countVipGroupDeductionNum" resultType="int">
        SELECT
             COUNT(csts.id_)
        FROM
            vip_group vg
            LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
            LEFT JOIN course_schedule cs ON vgcgm.class_group_id_=cs.class_group_id_
            LEFT JOIN course_schedule_teacher_salary csts ON cs.id_=csts.course_schedule_id_
        WHERE vg.id_=#{vipGroupId} AND cs.id_!=NULL AND csts.settlement_time_!=NULL AND csts.actual_salary_&lt;csts.expect_salary_
    </select>

    <select id="countSurplusCourseFee" resultType="java.math.BigDecimal">
        SELECT
            cssp.user_id_ as 'key',
            SUM(cssp.expect_price_) as 'value'
        FROM
            vip_group vg
            LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_ = vgcgm.vip_group_id_
            LEFT JOIN course_schedule cs ON vgcgm.class_group_id_=cs.class_group_id_
            LEFT JOIN course_schedule_student_payment cssp ON cs.id_=cssp.course_schedule_id_
            WHERE vg.id_=#{vipGroupId} AND cs.status_!='OVER'
        GROUP BY cssp.user_id_
    </select>
    <select id="countTeacherVipGroups" resultType="int">
        SELECT
            COUNT( * )
        FROM
            vip_group
        WHERE user_id_=#{teacherId} AND status_!=3
    </select>
</mapper>
