12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154 |
- <?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="group_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="stop_reason_" property="stopReason"/>
- <result column="memo_" property="memo"/>
- <result column="courses_start_date" property="courseStartDate"/>
- <result column="course_schedules_json_" property="courseSchedulesJson"/>
- <result column="student_id_list_" property="studentIdList"/>
- <result column="organ_name_" property="organName"/>
- <result column="school_name_" property="schoolName"/>
- <result column="subject_name_" property="subjectName"/>
- <result column="educational_teacher_id_" property="educationalTeacherId"/>
- <result column="vip_group_category_name_" property="vipGroupCategoryName"/>
- <result column="educational_teacher_name_" property="educationalTeacherName" />
- <result column="live_config_json_" property="liveConfigJson" />
- <result column="tenant_id_" property="tenantId" />
- </resultMap>
- <resultMap type="com.ym.mec.biz.dal.entity.School" id="School">
- <result column="id_" property="id"/>
- <result column="user_id_" property="userId"/>
- <result column="name_" property="name"/>
- <result column="organ_id_" property="organId"/>
- <result column="address_" property="address"/>
- <result column="contact_phone_" property="contactPhone"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="del_flag_" property="delFlag"/>
- <result column="contact_name_" property="contactName"/>
- <result column="longitude_latitude_" property="longitudeLatitude"/>
- <result column="subsidy_" property="subsidy"/>
- <result column="cooperation_organ_id_" property="cooperationOrganId"/>
- <result column="remark_" property="remark"/>
- </resultMap>
- <resultMap id="studentManageVipGroup" type="com.ym.mec.biz.dal.dto.StudentManageVipGroupDto">
- <result property="teachMode" column="teach_mode_"/>
- <result property="realName" column="real_name_"/>
- <result property="studentNum" column="student_num_"/>
- <result property="totalClassTimes" column="total_class_times_"/>
- <result property="currentClassTimes" column="current_class_times_"/>
- <result property="courseDate" column="course_date_"/>
- <result property="classGroupName" column="class_group_name_"/>
- <result property="courseStatus" column="course_status_"/>
- </resultMap>
- <resultMap id="vipCourseStudentInfoDto" type="com.ym.mec.biz.dal.dto.VipCourseStudentInfoDto">
- <result property="totalAmount" column="total_amount_"/>
- <result property="studentNum" column="student_num_"/>
- <result property="musicGroupId" column="music_group_id_"/>
- <result property="totalCourseTimes" column="total_times_"/>
- </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"/>
- <result column="music_theory_" property="musicTheory"/>
- <!--<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"/>
- <result property="courseStartDate" column="courses_start_date"/>
- <result property="createTime" column="create_time_"/>
- <result property="groupType" column="group_type_"/>
- </resultMap>
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="VipGroup">
- SELECT *
- FROM vip_group
- WHERE id_ = #{id}
- </select>
- <select id="findStudentVipGroups" resultMap="studentManageVipGroup">
- SELECT CONCAT(cs.class_date_," ",cs.start_class_time_) course_date_,cs.teach_mode_,
- cs.status_ course_status_,cs.name_ class_group_name_
- FROM course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
- WHERE cssp.group_type_ = 'VIP' and cssp.tenant_id_ = #{tenantId}
- <if test="vipGroupId != null">
- AND cssp.music_group_id_ = #{vipGroupId}
- </if>
- <if test="studentId != null">
- AND cssp.user_id_ = #{studentId}
- </if>
- <if test="classGroupName != null">
- AND cs.name_ LIKE CONCAT('%',#{classGroupName},'%')
- </if>
- ORDER BY course_date_
- <include refid="global.limit"/>
- </select>
- <select id="countStudentVipGroups" resultType="java.lang.Integer">
- SELECT COUNT(cssp.id_)
- FROM course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
- WHERE cssp.group_type_ = 'VIP' and cssp.tenant_id_ = #{tenantId}
- <if test="vipGroupId != null">
- AND cssp.music_group_id_ = #{vipGroupId}
- </if>
- <if test="studentId != null">
- AND cssp.user_id_ = #{studentId}
- </if>
- <if test="classGroupName != null">
- AND cs.name_ LIKE CONCAT('%',#{classGroupName},'%')
- </if>
- </select>
- <!-- 全查询 -->
- <select id="findAll" resultMap="VipGroup">
- SELECT *
- FROM vip_group where tenant_id_ = #{tenantId}
- ORDER BY id_
- </select>
- <sql id="vipGroupQueryCondition">
- <where>
- vg.audit_status_='PASS' AND vg.group_status_ != 7 and vg.tenant_id_ = #{tenantId}
- <if test="search!=null and search!=''">
- AND (vg.name_ LIKE CONCAT('%',#{search},'%') OR vg.id_= #{search})
- </if>
- <if test="hasEducationalTeacherId != null and hasEducationalTeacherId == true">
- AND vg.educational_teacher_id_ IS NOT NULL
- </if>
- <if test="hasEducationalTeacherId != null and hasEducationalTeacherId == false">
- AND vg.educational_teacher_id_ IS NULL
- </if>
- <if test="teacherId!=null">
- AND vg.user_id_=#{teacherId}
- </if>
- <if test="status != null">
- AND vg.group_status_ = #{status}
- </if>
- <if test="activityId!=null">
- AND vg.vip_group_activity_id_=#{activityId}
- </if>
- <if test="organId != null and organId != ''">
- AND FIND_IN_SET(vg.organ_id_,#{organId})
- </if>
- <if test="liveOrganId != null and liveOrganId != ''">
- AND INTE_ARRAY(vg.organ_id_list_,#{liveOrganId})
- </if>
- <if test="educationalTeacherId!=null">
- AND vg.educational_teacher_id_=#{educationalTeacherId}
- </if>
- <if test="groupType != null and groupType != ''">
- AND vg.group_type_ = #{groupType}
- </if>
- </where>
- </sql>
- <select id="findAllByOrgan" resultMap="VipGroup">
- SELECT
- vg.*,
- vga.name_ vip_group_activity_name_,
- su.real_name_ username_,
- vgc.name_ vip_group_category_name_
- FROM
- vip_group vg
- 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 vgc.id_=vg.vip_group_category_id_
- <include refid="vipGroupQueryCondition"/>
- ORDER BY vg.id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="countVipGroupByOrgan" resultType="int">
- SELECT
- count(id_)
- 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">
- 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_,group_status_,online_classes_unit_price_,offline_classes_unit_price_,
- total_price_,give_teach_mode_,vip_group_category_id_,organ_id_,stop_reason_,memo_,audit_status_,courses_start_date,
- course_schedules_json_,student_id_list_,tenant_id_, group_type_, live_config_json_)
- 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},#{organId},#{stopReason},#{memo},
- #{auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{courseStartDate},#{courseSchedulesJson},#{studentIdList},#{tenantId},
- #{groupType}, #{liveConfigJson})
- </insert>
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.VipGroup">
- UPDATE vip_group
- <set>
- <if test="courseStartDate != null">
- courses_start_date = #{courseStartDate},
- </if>
- <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>
- update_time_ = NOW(),
- <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="vipGroupActivityId != null">
- vip_group_activity_id_ = #{vipGroupActivityId},
- </if>
- <if test="status != null">
- group_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="stopReason!=null">
- stop_reason_=#{stopReason},
- </if>
- <if test="memo!=null">
- memo_=#{memo},
- </if>
- <if test="courseSchedulesJson!=null">
- course_schedules_json_=#{courseSchedulesJson},
- </if>
- <if test="studentIdList!=null">
- student_id_list_=#{studentIdList},
- </if>
- <if test="educationalTeacherId!=null">
- educational_teacher_id_=#{educationalTeacherId},
- </if>
- </set>
- WHERE id_ = #{id} and tenant_id_ = #{tenantId}
- </update>
- <!-- 根据主键删除一条记录 -->
- <delete id="delete">
- DELETE
- FROM vip_group
- WHERE id_ = #{id}
- </delete>
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="VipGroup" parameterType="map">
- SELECT * FROM vip_group where tenant_id_ = #{tenantId} ORDER BY id_
- <include refid="global.limit"/>
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*)
- FROM vip_group where tenant_id_ = #{tenantId}
- </select>
- <select id="getLockVipGroup" resultMap="VipGroup">
- SELECT *
- FROM vip_group
- WHERE id_ = #{vipGroupId} FOR
- UPDATE
- </select>
- <sql id="studentVipGroupQueryCondition">
- <where>
- vg.audit_status_='PASS'
- AND vg.group_status_ = 1
- AND vg.courses_expire_date_ >= DATE_FORMAT(NOW(),'%Y%m%d')
- AND vg.registration_start_time_ <= NOW()
- AND vg.courses_start_date > NOW()
- AND (select count(1) as num from student_payment_order where vg.id_ = music_group_id_ AND user_id_=#{userId}
- AND status_='SUCCESS') = 0
- AND IF(vg.student_id_list_ IS NULL, vg.organ_id_ = #{organId}, FIND_IN_SET(#{userId},
- vg.student_id_list_))
- <if test="expireFlag != null and expireFlag == true">
- AND vg.payment_expire_date_ >= NOW()
- </if>
- <if test="subjectId!=null">
- AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
- </if>
- <if test="subjectId!=null">
- AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
- </if>
- <if test="categoryId!=null">
- AND FIND_IN_SET(vg.vip_group_category_id_,#{categoryId})
- </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 search != ''">
- AND vg.name_ like concat('%',#{search},'%')
- </if>
- <if test="groupType != null and groupType != ''">
- AND vg.group_type_ = #{groupType}
- </if>
- </where>
- </sql>
- <sql id="studentLiveGroupQueryCondition">
- <where>
- vg.audit_status_='PASS'
- AND vg.group_status_ = 1
- AND vg.courses_expire_date_ >= DATE_FORMAT(NOW(),'%Y%m%d')
- AND vg.registration_start_time_ <= NOW()
- AND vg.courses_start_date > NOW()
- AND (select count(1) as num from student_payment_order where vg.id_ = music_group_id_ AND user_id_ = #{userId} AND type_ = 'LIVE_GROUP_BUY'
- AND status_='SUCCESS') = 0
- <if test="expireFlag != null and expireFlag == true">
- AND vg.payment_expire_date_ >= NOW()
- </if>
- <if test="organId != null">
- AND FIND_IN_SET(#{organId},vg.organ_id_list_)
- </if>
- <if test="subjectId!=null">
- AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
- </if>
- <if test="subjectId!=null">
- AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
- </if>
- <if test="categoryId!=null">
- AND FIND_IN_SET(vg.vip_group_category_id_,#{categoryId})
- </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 search != ''">
- AND vg.name_ like concat('%',#{search},'%')
- </if>
- <if test="groupType != null and groupType != ''">
- AND vg.group_type_ = #{groupType}
- </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.courses_start_date,
- vg.online_classes_num_,
- vg.offline_classes_num_,
- vg.total_price_,
- cg.expect_student_num_,
- cg.student_num_,
- su.real_name_ teacher_name_,
- su.avatar_,
- t.introduction_,
- vga.type_,
- vgc.name_ category_name_,vg.create_time_,
- vg.group_type_
- FROM
- vip_group vg
- LEFT JOIN class_group cg ON vg.id_=cg.music_group_id_ AND cg.group_type_ = vg.group_type_
- 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="findLiveGroups" resultMap="studentVipGroup">
- SELECT
- vg.id_,
- vg.name_,
- vg.single_class_minutes_,
- vg.payment_expire_date_,
- vg.courses_expire_date_,
- vg.courses_start_date,
- vg.online_classes_num_,
- vg.offline_classes_num_,
- vg.total_price_,
- cg.expect_student_num_,
- cg.student_num_,
- su.real_name_ teacher_name_,
- su.avatar_,
- t.introduction_,
- vgc.name_ category_name_,vg.create_time_,
- vg.group_type_
- FROM
- vip_group vg
- LEFT JOIN class_group cg ON vg.id_=cg.music_group_id_ AND cg.group_type_ = vg.group_type_
- 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_category vgc ON vg.vip_group_category_id_=vgc.id_
- <include refid="studentLiveGroupQueryCondition"/>
- ORDER BY vg.id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="countVipGorups" resultType="int">
- SELECT
- count(*)
- FROM
- vip_group vg
- LEFT JOIN class_group cg ON vg.id_=cg.music_group_id_ AND cg.group_type_ = 'VIP'
- LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
- <include refid="studentVipGroupQueryCondition"/>
- </select>
- <select id="getVipGroupBaseInfo" resultMap="vipGroupManageDetailDto">
- SELECT vg.*,
- vga.name_ vip_group_activity_name_,
- su.real_name_ 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_,
- vgc.music_theory_
- FROM vip_group vg
- LEFT JOIN sys_user su ON vg.user_id_ = su.id_
- LEFT JOIN class_group cg ON vg.id_ = cg.music_group_id_ AND cg.group_type_ = 'VIP'
- 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>
- vg.tenant_id_ = #{tenantId}
- <if test="vipGroupId!=null">
- and vg.id_=#{vipGroupId}
- </if>
- <if test="startTime != null">
- and CONCAT(cs.class_date_,' ',cs.end_class_time_) > #{startTime}
- </if>
- <if test="endTime != null">
- and CONCAT(cs.class_date_,' ',cs.end_class_time_) < #{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 teacher_attendance ta ON vg.id_=ta.music_group_id_ AND ta.group_type_ = 'VIP'
- 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 teacher_attendance ta ON vg.id_=ta.music_group_id_ AND ta.group_type_ = 'VIP'
- 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.real_name_ 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 class_group cg ON vg.id_ = cg.music_group_id_ AND cg.group_type_ = 'VIP'
- LEFT JOIN course_schedule cs ON cg.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}
- ORDER BY start_class_time_
- </select>
- <select id="countSurplusClassTimes" resultType="java.util.Map">
- SELECT cs.teach_mode_ as 'key',
- COUNT(cs.id_) as 'value'
- FROM course_schedule cs
- WHERE cs.status_ = "NOT_START"
- AND cs.type_ = 'VIP'
- AND cs.music_group_id_ = #{vipGroupId}
- AND cs.group_type_ = 'VIP'
- 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="phone_" property="phone"/>
- <result column="total_class_times_" property="totalClassTimes"/>
- <result column="current_class_times_" property="currentClassTimes"/>
- <result column="course_balance_" property="courseSalary"/>
- <result column="create_time_" property="applyDate"/>
- <result column="update_time_" property="refundDate"/>
- <result column="student_status_" property="studentStatus"/>
- </resultMap>
- <select id="findVipGroupStudents" resultMap="vipGroupStudentDto">
- SELECT
- su.id_,
- su.username_,
- su.phone_,
- cg.total_class_times_,
- cg.current_class_times_,
- suaa.course_balance_,
- cgsm.create_time_,
- cgsm.update_time_,
- CASE cgsm.status_
- WHEN 'QUIT' THEN 1
- WHEN 'QUIT_SCHOOL' THEN 3
- ELSE 0
- END student_status_
- FROM
- class_group cg
- LEFT JOIN class_group_student_mapper cgsm ON cg.id_=cgsm.class_group_id_
- LEFT JOIN sys_user su ON cgsm.user_id_=su.id_
- LEFT JOIN sys_user_cash_account suaa ON cgsm.user_id_=suaa.user_id_
- WHERE cg.music_group_id_=#{vipGroupId}
- <if test="groupType != null">
- AND cg.group_type_= #{groupType}
- </if>
- AND cgsm.user_id_ IS NOT NULL
- ORDER BY su.id_
- <include refid="global.limit"/>
- </select>
- <select id="findHaveCourseBalanceStudents" resultMap="vipGroupStudentDto">
- SELECT
- su.id_,
- su.username_,
- su.phone_,
- suca.course_balance_,
- suca.balance_ balance,
- (suca.course_balance_+suca.balance_) allBalance
- FROM
- sys_user_cash_account suca
- LEFT JOIN sys_user su ON suca.user_id_=su.id_
- WHERE
- suca.tenant_id_ = #{tenantId}
- AND su.user_type_ LIKE '%STUDENT%'
- # suca.course_balance_ >0
- <if test="search!=null and search!=''">
- AND (su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
- </if>
- <if test="organIds!=null and organIds.size()>0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- ORDER BY suca.course_balance_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="countHaveCourseBalanceStudentNum" resultType="int">
- SELECT
- COUNT(1)
- FROM
- sys_user_cash_account suca
- LEFT JOIN sys_user su ON suca.user_id_=su.id_
- WHERE suca.tenant_id_ = #{tenantId}
- AND su.user_type_ LIKE '%STUDENT%'
- # suca.course_balance_ > 0
- <if test="search!=null and search!=''">
- AND (su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
- </if>
- <if test="organIds!=null and organIds.size()>0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- </select>
- <select id="countVipGroupStudents" resultType="int">
- SELECT count(*)
- FROM class_group cg
- LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
- WHERE cg.music_group_id_ = #{vipGroupId}
- AND cg.group_type_ = #{groupType}
- </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="end_class_time_" property="endClassTime"/>
- <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"/>
- <result column="school_name_" property="schoolName"/>
- <result column="schoole_id_" property="schooleId"/>
- <result column="sign_in_status_" property="signInStatus"/>
- <result column="sign_out_status_" property="signOutStatus"/>
- <result column="sign_in_time_" property="signInTime"/>
- <result column="sign_out_time_" property="signOutTime"/>
- </resultMap>
- <sql id="teachingRecordQueryCondition">
- <where>
- cs.music_group_id_=#{vipGroupId}
- <if test="groupType != null and groupType != ''">
- AND cs.group_type_= #{groupType}
- </if>
- <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_,
- CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
- cs.status_,
- cs.teach_mode_,
- s.name_ school_name_,
- csts.actual_salary_ IS NOT NULL is_salary_,
- cs.schoole_id_,
- IF(ta.sign_in_status_ IS NULL,3,ta.sign_in_status_) sign_in_status_,
- IF(ta.sign_out_status_ IS NULL,3,ta.sign_out_status_) sign_out_status_,
- ta.sign_in_time_,
- ta.sign_out_time_
- FROM
- course_schedule cs
- LEFT JOIN course_schedule_teacher_salary csts ON cs.id_=csts.course_schedule_id_
- left join school s on cs.schoole_id_ = s.id_
- LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_ AND ta.teacher_id_ = cs.actual_teacher_id_
- <include refid="teachingRecordQueryCondition"/>
- ORDER BY start_class_time_
- <include refid="global.limit"/>
- </select>
- <select id="countTeachingRecord" resultType="int">
- SELECT
- COUNT(*)
- FROM
- course_schedule cs
- <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 class_group cg
- WHERE cg.music_group_id_ = #{vipGroupId}
- </select>
- <select id="countIsSalaryNum" resultType="int">
- SELECT COUNT(*)
- FROM course_schedule cs
- LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
- WHERE cs.music_group_id_ = #{vipGroupId}
- AND cs.group_type_ = 'VIP'
- AND csts.settlement_time_ IS NOT NULL
- </select>
- <select id="countComplaintsNum" resultType="java.lang.Integer">
- SELECT COUNT(*)
- FROM course_schedule cs
- LEFT JOIN course_schedule_complaints csc ON cs.id_ = csc.course_schedule_id_
- WHERE cs.music_group_id_ = #{vipGroupId}
- AND cs.group_type_ = 'VIP'
- AND csc.course_schedule_id_ IS NOT NULL
- AND csc.score_ <= 2
- </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 course_schedule cs ON vg.id_ = cs.music_group_id_ AND cs.group_type_ = vg.group_type_
- LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
- WHERE vg.id_ = #{vipGroupId}
- AND cs.id_ IS NOT NULL
- </select>
- <select id="countVipGroupDeductionNum" resultType="int">
- SELECT COUNT(csts.id_)
- FROM vip_group vg
- LEFT JOIN course_schedule cs ON vg.id_ = cs.music_group_id_ AND cs.group_type_ = vg.group_type_
- 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_ < csts.expect_salary_
- </select>
- <select id="countSurplusCourseFee" resultType="map">
- SELECT cssp.user_id_ as 'key',
- SUM(cssp.expect_price_) as 'value'
- FROM vip_group vg
- LEFT JOIN course_schedule cs ON vg.id_ = cs.music_group_id_ AND cs.group_type_ = vg.group_type_
- LEFT JOIN course_schedule_student_payment cssp ON cs.id_ = cssp.course_schedule_id_
- WHERE vg.id_ = #{vipGroupId}
- AND cs.status_ = 'NOT_START'
- GROUP BY cssp.user_id_
- </select>
- <select id="countTeacherVipGroups" resultType="int">
- SELECT COUNT(vg.id_)
- FROM vip_group vg
- WHERE vg.user_id_ = #{teacherId}
- AND vg.group_status_ != 3
- </select>
- <select id="countTeacherVipClass" resultType="java.lang.Integer">
- SELECT COUNT(DISTINCT vg.id_)
- FROM vip_group vg
- LEFT JOIN class_group cg ON cg.music_group_id_ = vg.id_ AND cg.group_type_ = vg.group_type_
- LEFT JOIN course_schedule cs ON cs.class_group_id_ = cg.id_
- WHERE cs.actual_teacher_id_ = #{teacherId}
- AND cs.type_ = 'VIP'
- AND cg.del_flag_ = 0
- </select>
- <resultMap type="com.ym.mec.biz.dal.dto.TeacherVipClassInfoDto" id="getTeacherVipClassMap">
- <result column="vip_group_id_" property="vipClassId"/>
- <result column="student_num_" property="studentNum"/>
- <result column="online_classes_unit_price_" property="onlineClassesUnitPrice"/>
- <result column="offline_classes_unit_price_" property="offlineClassesUnitPrice"/>
- <result column="class_group_id_" property="classGroupId"/>
- <result column="courses_expire_date_" property="coursesExpireDate"/>
- <result column="payment_expire_date_" property="paymentExpireDate"/>
- <result column="create_time_" property="createDate"/>
- <result column="current_class_times_" property="currentClassTimes"/>
- <result column="total_class_times_" property="totalClassTimes"/>
- <result column="vip_group_name_" property="vipClassName"/>
- <result column="audit_status_" property="auditStatus"
- typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="vip_group_activity_id_" property="activityId"/>
- </resultMap>
- <select id="getTeacherVipClass" resultMap="getTeacherVipClassMap">
- SELECT vg.id_ vip_group_id_,vg.name_ vip_group_name_,vg.group_status_,vg.audit_status_,vg.create_time_,
- vg.payment_expire_date_,vg.courses_expire_date_,vg.online_classes_unit_price_,vg.offline_classes_unit_price_,
- cg.total_class_times_,cg.current_class_times_,cg.id_ class_group_id_,cg.student_num_,vg.vip_group_activity_id_
- FROM vip_group vg
- LEFT JOIN class_group cg ON vg.id_ = cg.music_group_id_ AND cg.group_type_ = vg.group_type_
- LEFT JOIN course_schedule cs ON cs.class_group_id_ = cg.id_
- WHERE cs.actual_teacher_id_ = #{teacherId} AND cs.type_ = 'VIP' AND cg.del_flag_ = 0 GROUP BY vg.id_,cg.id_
- <include refid="global.limit"/>
- </select>
- <select id="querySchoolByUserId" resultMap="School">
- SELECT *
- from school
- where user_id_ = #{userId}
- or user_id_ is null
- </select>
- <select id="findByCourseSchedule" resultMap="VipGroup">
- SELECT vg.*
- FROM vip_group vg
- LEFT JOIN course_schedule cs ON vg.id_ = cs.music_group_id_ AND cs.group_type_ = vg.group_type_
- WHERE cs.id_ = #{courseScheduleId}
- </select>
- <select id="queryVipGroupNum" resultType="map">
- select count(*) total,sum(case when group_status_ = 2 then 1 else 0 end) applying_num_,sum(case when
- group_status_ = 4 then 1 else 0 end) finished_num_ from vip_group
- where organ_id_ not in (36,38) and tenant_id_ = #{tenantId}
- <if test="organId != null">
- and FIND_IN_SET(organ_id_,#{organId})
- </if>
- </select>
- <select id="queryCurrentMonthCoursesNum" resultType="int">
- select count(cs.id_) from course_schedule cs left join vip_group vg on cs.music_group_id_ = vg.id_ where
- cs.type_ in ('VIP')
- and DATE_FORMAT(cs.class_date_, '%Y%m' ) = DATE_FORMAT(CURDATE() , '%Y%m') and (cs.del_flag_ = 0 or cs.del_flag_
- is null) and vg.organ_id_ not in (36,38) and vg.tenant_id_ = #{tenantId}
- <if test="organId != null">
- AND FIND_IN_SET(vg.organ_id_,#{organId})
- </if>
- </select>
- <select id="findNoCreateSuccessVipGroup" resultMap="VipGroup">
- SELECT *
- FROM vip_group
- WHERE (payment_expire_date_ < DATE_FORMAT(NOW(), '%Y-%m-%d')
- OR courses_start_date < NOW())
- AND group_status_ = 1
- <if test="tenantId != null">
- and tenant_id_ = #{tenantId}
- </if>
- </select>
- <select id="countStudentPaymentNum" resultType="int">
- SELECT COUNT(*)
- FROM course_schedule_student_payment cssp
- WHERE cssp.settlement_time_ IS NOT NULL
- AND cssp.class_group_id_ = #{classGroupId}
- </select>
- <select id="countStudentPaymentFee" resultType="java.math.BigDecimal">
- SELECT SUM(actual_price_)
- FROM course_schedule_student_payment cssp
- WHERE cssp.settlement_time_ IS NOT NULL
- AND cssp.class_group_id_ = #{classGroupId}
- </select>
- <select id="queryByIds" resultMap="VipGroup" parameterType="string">
- select *
- from vip_group
- where FIND_IN_SET(id_, #{idList})
- </select>
- <resultMap id="VipBuyResult" type="com.ym.mec.biz.dal.dto.VipBuyResultDto">
- <result property="vipGroupId" column="id_"/>
- <result property="vipGroupName" column="name_"/>
- <result property="teacherName" column="username_"/>
- <result property="eduTeacherName" column="eduTeacherName"/>
- <result property="classTimes" column="total_class_times_"/>
- <result property="startClassTime" column="courses_start_date"/>
- <result property="endClassTime" column="courses_expire_date_"/>
- <result property="groupType" column="group_type_"/>
- </resultMap>
- <select id="getVipBuyResultInfo" resultMap="VipBuyResult">
- SELECT vg.id_,
- vg.name_,
- vg.courses_start_date,
- vg.courses_expire_date_,
- cg.total_class_times_,
- su.real_name_ username_,
- vg.group_type_
- FROM vip_group vg
- LEFT JOIN class_group cg ON vg.id_ = cg.music_group_id_ AND cg.group_type_ = vg.group_type_
- LEFT JOIN sys_user su ON vg.user_id_ = su.id_
- WHERE vg.id_ = #{vipGroupId}
- </select>
- <update id="batchUpdate" parameterType="java.util.List">
- <foreach collection="vipGroupList" item="item" index="index" open="" close="" separator=";">
- UPDATE vip_group
- <set>
- <if test="item.paymentExpireDate != null">
- payment_expire_date_ = #{item.paymentExpireDate},
- </if>
- <if test="item.userId != null">
- user_id_ = #{item.userId},
- </if>
- <if test="item.offlineClassesNum != null">
- offline_classes_num_ = #{item.offlineClassesNum},
- </if>
- <if test="item.onlineClassesNum != null">
- online_classes_num_ = #{item.onlineClassesNum},
- </if>
- <if test="item.updateTime != null">
- update_time_ = NOW(),
- </if>
- <if test="item.singleClassMinutes != null">
- single_class_minutes_ = #{item.singleClassMinutes},
- </if>
- <if test="item.teacherSchoolId != null">
- teacher_school_id_ = #{item.teacherSchoolId},
- </if>
- <if test="item.coursesExpireDate != null">
- courses_expire_date_ = #{item.coursesExpireDate},
- </if>
- <if test="item.registrationStartTime != null">
- registration_start_time_ = #{item.registrationStartTime},
- </if>
- <if test="item.organIdList!=null">
- organ_id_list_=#{item.organIdList},
- </if>
- <if test="item.auditStatus != null">
- audit_status_ = #{item.auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="item.organIdList != null">
- organ_id_list_ = #{item.organIdList},
- </if>
- <if test="item.vipGroupActivityId != null">
- vip_group_activity_id_ = #{item.vipGroupActivityId},
- </if>
- <if test="item.status != null">
- group_status_ = #{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="item.onlineClassesUnitPrice != null">
- online_classes_unit_price_ = #{item.onlineClassesUnitPrice},
- </if>
- <if test="item.offlineClassesUnitPrice != null">
- offline_classes_unit_price_ = #{item.offlineClassesUnitPrice},
- </if>
- <if test="item.totalPrice != null">
- total_price_ = #{item.totalPrice},
- </if>
- <if test="item.giveTeachMode!=null">
- give_teach_mode_=#{item.giveTeachMode},
- </if>
- <if test="item.organId!=null">
- organ_id_=#{item.organId},
- </if>
- <if test="item.stopReason!=null">
- stop_reason_=#{item.stopReason},
- </if>
- <if test="item.auditStatus!=null">
- audit_status_=#{item.auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="item.courseSchedulesJson!=null">
- course_schedules_json_=#{item.courseSchedulesJson},
- </if>
- <if test="item.studentIdList!=null">
- student_id_list_=#{item.studentIdList},
- </if>
- </set>
- WHERE id_ = #{item.id} and tenant_id_ = #{item.tenantId}
- </foreach>
- </update>
- <select id="queryRequiredOverList" resultMap="VipGroup">
- SELECT
- vg.*
- FROM
- vip_group vg
- LEFT JOIN course_schedule cs ON cs.group_type_ = vg.group_type_ AND CONCAT(vg.id_, '') = cs.music_group_id_
- WHERE
- vg.group_status_ = 2
- GROUP BY
- vg.id_
- HAVING COUNT( CASE WHEN cs.status_ != 'OVER' THEN 1 ELSE NULL END )<=0
- </select>
- <select id="queryNormalStatusList" resultMap="VipGroup">
- SELECT *
- FROM vip_group
- WHERE group_status_ != 3
- AND group_status_ != 4
- </select>
- <select id="findVipGroupInfo" resultMap="VipGroup">
- SELECT vg.*, s.name_ subject_name_, s2.name_ school_name_,su.real_name_ educational_teacher_name_
- FROM vip_group vg
- LEFT JOIN class_group cg on vg.id_ = cg.music_group_id_
- LEFT JOIN subject s on cg.subject_id_list_ = s.id_
- LEFT JOIN school s2 on vg.teacher_school_id_ = s2.id_
- LEFT JOIN sys_user su on vg.educational_teacher_id_ = su.id_
- WHERE vg.id_ = #{id}
- AND cg.id_ = #{classGroupId}
- AND cg.group_type_ = 'VIP'
- </select>
- <select id="queryUserVipNames" resultType="java.util.Map">
- SELECT cgsm.user_id_ 'key',GROUP_CONCAT(vg.name_)'value' FROM class_group_student_mapper cgsm
- LEFT JOIN vip_group vg ON cgsm.music_group_id_ = vg.id_
- WHERE vg.group_status_ IN (2,4,6) AND cgsm.group_type_='VIP' AND cgsm.user_id_ IN
- <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- GROUP BY cgsm.user_id_
- </select>
- <select id="queryUserVipStatus" resultType="java.util.Map">
- SELECT cgsm.user_id_ 'key',GROUP_CONCAT(CASE WHEN cgsm.status_ = 'NORMAL' THEN '在读'
- WHEN cgsm.status_ = 'LEAVE' THEN '请假'
- WHEN cgsm.status_ = 'QUIT' THEN '退班'
- WHEN cgsm.status_ = 'QUIT_SCHOOL' THEN '休学' END) 'value'
- FROM class_group_student_mapper cgsm
- LEFT JOIN vip_group vg ON cgsm.music_group_id_ = vg.id_
- WHERE vg.group_status_ IN (2,4,6) AND cgsm.group_type_='VIP' AND cgsm.user_id_ IN
- <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- GROUP BY cgsm.user_id_
- </select>
- <select id="countUserRepeatVipGroupInCourseStartEndTime" resultType="int">
- SELECT COUNT(id_)
- FROM vip_group
- WHERE user_id_ = #{userId}
- AND courses_start_date = #{courseStartDate}
- AND courses_expire_date_ = #{courseEndDate}
- </select>
- <select id="getGroupTeachers" resultMap="VipBuyResult">
- SELECT vg.id_,t.real_name_ username_,et.real_name_ eduTeacherName FROM vip_group vg
- LEFT JOIN sys_user t on vg.user_id_ = t.id_
- LEFT JOIN sys_user et on vg.educational_teacher_id_ = et.id_
- <where>
- vg.tenant_id_ = #{tenantId}
- <if test="groupIds != null">
- AND vg.id_ IN
- <foreach collection="groupIds" item="groupId" open="(" close=")" separator=",">
- #{groupId}
- </foreach>
- </if>
- </where>
- </select>
- <select id="getVipGroupByIds" resultMap="VipGroup">
- SELECT * FROM vip_group WHERE id_ IN
- <foreach collection="ids" item="id" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </select>
- <select id="queryEduNameMapByCourseId" resultType="java.util.Map">
- SELECT cs.id_ 'key',su.real_name_ 'value' FROM course_schedule cs
- LEFT JOIN vip_group vg ON vg.id_ = cs.music_group_id_
- LEFT JOIN sys_user su ON su.id_ = vg.educational_teacher_id_
- WHERE cs.id_ IN
- <foreach collection="courseIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- AND vg.educational_teacher_id_ IS NOT NULL
- </select>
- <select id="countStudentUserActivityNum" resultType="int">
- SELECT COUNT(DISTINCT vg.id_)
- FROM vip_group vg
- LEFT JOIN class_group_student_mapper cgsm ON vg.id_=cgsm.music_group_id_ AND cgsm.group_type_='VIP'
- WHERE vg.vip_group_activity_id_=#{vipGroupActivityId}
- AND ((vg.group_status_ NOT IN (3, 7) AND FIND_IN_SET(#{studentId}, vg.student_id_list_)) OR cgsm.user_id_=#{studentId});
- </select>
- <select id="countStudentUseingActivityNum" resultType="int">
- SELECT COUNT(DISTINCT vg.id_)
- FROM vip_group vg
- LEFT JOIN class_group_student_mapper cgsm ON vg.id_=cgsm.music_group_id_ AND cgsm.group_type_='VIP'
- LEFT JOIN class_group cg ON cgsm.class_group_id_=cg.id_
- WHERE vg.vip_group_activity_id_=#{vipGroupActivityId}
- AND cg.del_flag_!=1
- AND cgsm.user_id_=#{studentId}
- </select>
- <!--获取课程人数-->
- <select id="getCourseStudentNumsByGroupId" resultType="java.lang.Integer">
- SELECT t2.student_num_ FROM vip_group t1 JOIN vip_group_category t2 ON (t1.vip_group_category_id_ = t2.id_) WHERE t1.id_ = #{groupId}
- </select>
- <!--获取课程人数-->
- </mapper>
|