VipGroupMapper.xml 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.VipGroupDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.VipGroup" id="VipGroup">
  9. <result column="id_" property="id"/>
  10. <result column="name_" property="name"/>
  11. <result column="user_id_" property="userId"/>
  12. <result column="username_" property="userName"/>
  13. <result column="single_class_minutes_" property="singleClassMinutes"/>
  14. <result column="payment_expire_date_" property="paymentExpireDate"/>
  15. <result column="courses_expire_date_" property="coursesExpireDate"/>
  16. <result column="registration_start_time_" property="registrationStartTime"/>
  17. <result column="create_time_" property="createTime"/>
  18. <result column="update_time_" property="updateTime"/>
  19. <result column="teacher_school_id_" property="teacherSchoolId"/>
  20. <result column="online_classes_num_" property="onlineClassesNum"/>
  21. <result column="offline_classes_num_" property="offlineClassesNum"/>
  22. <result column="audit_status_" property="auditStatus"
  23. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  24. <result column="organ_id_list_" property="organIdList"/>
  25. <result column="vip_group_activity_id_" property="vipGroupActivityId"/>
  26. <result column="vip_group_activity_name_" property="vipGroupActivityName"/>
  27. <result column="group_status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  28. <result column="online_classes_unit_price_" property="onlineClassesUnitPrice"/>
  29. <result column="offline_classes_unit_price_" property="offlineClassesUnitPrice"/>
  30. <result column="total_price_" property="totalPrice"/>
  31. <result column="student_num_" property="studentNum"/>
  32. <result column="total_class_times_" property="totalClassTimes"/>
  33. <result column="current_class_times_" property="currentClassTimes"/>
  34. <result column="vip_group_category_id_" property="vipGroupCategoryId"/>
  35. <result column="give_teach_mode_" property="giveTeachMode"
  36. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  37. <result column="organ_id_" property="organId"/>
  38. <result column="stop_reason_" property="stopReason"/>
  39. <result column="memo_" property="memo"/>
  40. <result column="courses_start_date" property="courseStartDate"/>
  41. <result column="course_schedules_json_" property="courseSchedulesJson"/>
  42. <result column="student_id_list_" property="studentIdList"/>
  43. <result column="organ_name_" property="organName"/>
  44. <result column="school_name_" property="schoolName"/>
  45. <result column="subject_name_" property="subjectName"/>
  46. <result column="educational_teacher_id_" property="educationalTeacherId"/>
  47. <result column="vip_group_category_name_" property="vipGroupCategoryName"/>
  48. <result column="educational_teacher_name_" property="educationalTeacherName" />
  49. <result column="live_config_json_" property="liveConfigJson" />
  50. <result column="tenant_id_" property="tenantId" />
  51. </resultMap>
  52. <resultMap type="com.ym.mec.biz.dal.entity.School" id="School">
  53. <result column="id_" property="id"/>
  54. <result column="user_id_" property="userId"/>
  55. <result column="name_" property="name"/>
  56. <result column="organ_id_" property="organId"/>
  57. <result column="address_" property="address"/>
  58. <result column="contact_phone_" property="contactPhone"/>
  59. <result column="create_time_" property="createTime"/>
  60. <result column="update_time_" property="updateTime"/>
  61. <result column="del_flag_" property="delFlag"/>
  62. <result column="contact_name_" property="contactName"/>
  63. <result column="longitude_latitude_" property="longitudeLatitude"/>
  64. <result column="subsidy_" property="subsidy"/>
  65. <result column="cooperation_organ_id_" property="cooperationOrganId"/>
  66. <result column="remark_" property="remark"/>
  67. </resultMap>
  68. <resultMap id="studentManageVipGroup" type="com.ym.mec.biz.dal.dto.StudentManageVipGroupDto">
  69. <result property="teachMode" column="teach_mode_"/>
  70. <result property="realName" column="real_name_"/>
  71. <result property="studentNum" column="student_num_"/>
  72. <result property="totalClassTimes" column="total_class_times_"/>
  73. <result property="currentClassTimes" column="current_class_times_"/>
  74. <result property="courseDate" column="course_date_"/>
  75. <result property="classGroupName" column="class_group_name_"/>
  76. <result property="courseStatus" column="course_status_"/>
  77. </resultMap>
  78. <resultMap id="vipCourseStudentInfoDto" type="com.ym.mec.biz.dal.dto.VipCourseStudentInfoDto">
  79. <result property="totalAmount" column="total_amount_"/>
  80. <result property="studentNum" column="student_num_"/>
  81. <result property="musicGroupId" column="music_group_id_"/>
  82. <result property="totalCourseTimes" column="total_times_"/>
  83. </resultMap>
  84. <resultMap id="vipGroupManageDetailDto" type="com.ym.mec.biz.dal.dto.VipGroupManageDetailDto" extends="VipGroup">
  85. <result property="studentNum" column="student_num_"/>
  86. <result property="subjectIdList" column="subject_id_list_"/>
  87. <result property="categoryName" column="category_name_"/>
  88. <result column="teacher_school_name_" property="teacherSchoolName"/>
  89. <result column="music_theory_" property="musicTheory"/>
  90. <!--<collection property="students" ofType="com.ym.mec.auth.api.entity.SysUser" column="student_id_">-->
  91. <!--<result property="id" column="student_id_"/>-->
  92. <!--<result property="username" column="username_"/>-->
  93. <!--</collection>-->
  94. </resultMap>
  95. <resultMap id="studentVipGroupDetailDto" type="com.ym.mec.biz.dal.dto.StudentVipGroupDetailDto"
  96. extends="studentVipGroup">
  97. <result column="total_class_times_" property="totalClassTimes"/>
  98. <result column="address_" property="address"/>
  99. <collection property="courseSchedules" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleDao.CourseSchedule"
  100. column="cs.id_"/>
  101. </resultMap>
  102. <resultMap type="com.ym.mec.biz.dal.dto.StudentVipGroupShowListDto" id="studentVipGroup">
  103. <result column="id_" property="vipGroupId"/>
  104. <result column="name_" property="vipGroupName"/>
  105. <result column="single_class_minutes_" property="singleClassMinutes"/>
  106. <result column="payment_expire_date_" property="paymentExpireDate"/>
  107. <result column="online_classes_num_" property="onlineClassesNum"/>
  108. <result column="offline_classes_num_" property="offlineClassesNum"/>
  109. <result column="total_price_" property="totalPrice"/>
  110. <result column="expect_student_num_" property="expectStudentNum"/>
  111. <result column="student_num_" property="studentNum"/>
  112. <result column="user_id_" property="teacherId"/>
  113. <result column="teacher_name_" property="teacherName"/>
  114. <result column="introduction_" property="introduction"/>
  115. <result column="avatar_" property="avatar"/>
  116. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  117. <result column="attribute1_" property="attribute1"/>
  118. <result column="category_name_" property="categoryName"/>
  119. <result property="courseStartDate" column="courses_start_date"/>
  120. <result property="createTime" column="create_time_"/>
  121. <result property="groupType" column="group_type_"/>
  122. </resultMap>
  123. <!-- 根据主键查询一条记录 -->
  124. <select id="get" resultMap="VipGroup">
  125. SELECT *
  126. FROM vip_group
  127. WHERE id_ = #{id}
  128. </select>
  129. <select id="findStudentVipGroups" resultMap="studentManageVipGroup">
  130. SELECT CONCAT(cs.class_date_," ",cs.start_class_time_) course_date_,cs.teach_mode_,
  131. cs.status_ course_status_,cs.name_ class_group_name_
  132. FROM course_schedule_student_payment cssp
  133. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  134. WHERE cssp.group_type_ = 'VIP' and cssp.tenant_id_ = #{tenantId}
  135. <if test="vipGroupId != null">
  136. AND cssp.music_group_id_ = #{vipGroupId}
  137. </if>
  138. <if test="studentId != null">
  139. AND cssp.user_id_ = #{studentId}
  140. </if>
  141. <if test="classGroupName != null">
  142. AND cs.name_ LIKE CONCAT('%',#{classGroupName},'%')
  143. </if>
  144. ORDER BY course_date_
  145. <include refid="global.limit"/>
  146. </select>
  147. <select id="countStudentVipGroups" resultType="java.lang.Integer">
  148. SELECT COUNT(cssp.id_)
  149. FROM course_schedule_student_payment cssp
  150. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  151. WHERE cssp.group_type_ = 'VIP' and cssp.tenant_id_ = #{tenantId}
  152. <if test="vipGroupId != null">
  153. AND cssp.music_group_id_ = #{vipGroupId}
  154. </if>
  155. <if test="studentId != null">
  156. AND cssp.user_id_ = #{studentId}
  157. </if>
  158. <if test="classGroupName != null">
  159. AND cs.name_ LIKE CONCAT('%',#{classGroupName},'%')
  160. </if>
  161. </select>
  162. <!-- 全查询 -->
  163. <select id="findAll" resultMap="VipGroup">
  164. SELECT *
  165. FROM vip_group where tenant_id_ = #{tenantId}
  166. ORDER BY id_
  167. </select>
  168. <sql id="vipGroupQueryCondition">
  169. <where>
  170. vg.audit_status_='PASS' AND vg.group_status_ != 7 and vg.tenant_id_ = #{tenantId}
  171. <if test="search!=null and search!=''">
  172. AND (vg.name_ LIKE CONCAT('%',#{search},'%') OR vg.id_= #{search})
  173. </if>
  174. <if test="hasEducationalTeacherId != null and hasEducationalTeacherId == true">
  175. AND vg.educational_teacher_id_ IS NOT NULL
  176. </if>
  177. <if test="hasEducationalTeacherId != null and hasEducationalTeacherId == false">
  178. AND vg.educational_teacher_id_ IS NULL
  179. </if>
  180. <if test="teacherId!=null">
  181. AND vg.user_id_=#{teacherId}
  182. </if>
  183. <if test="status != null">
  184. AND vg.group_status_ = #{status}
  185. </if>
  186. <if test="activityId!=null">
  187. AND vg.vip_group_activity_id_=#{activityId}
  188. </if>
  189. <if test="organId != null and organId != ''">
  190. AND FIND_IN_SET(vg.organ_id_,#{organId})
  191. </if>
  192. <if test="liveOrganId != null and liveOrganId != ''">
  193. AND INTE_ARRAY(vg.organ_id_list_,#{liveOrganId})
  194. </if>
  195. <if test="educationalTeacherId!=null">
  196. AND vg.educational_teacher_id_=#{educationalTeacherId}
  197. </if>
  198. <if test="groupType != null and groupType != ''">
  199. AND vg.group_type_ = #{groupType}
  200. </if>
  201. </where>
  202. </sql>
  203. <select id="findAllByOrgan" resultMap="VipGroup">
  204. SELECT
  205. vg.*,
  206. vga.name_ vip_group_activity_name_,
  207. su.real_name_ username_,
  208. vgc.name_ vip_group_category_name_
  209. FROM
  210. vip_group vg
  211. LEFT JOIN sys_user su ON vg.user_id_=su.id_
  212. LEFT JOIN vip_group_activity vga ON vg.vip_group_activity_id_=vga.id_
  213. LEFT JOIN vip_group_category vgc ON vgc.id_=vg.vip_group_category_id_
  214. <include refid="vipGroupQueryCondition"/>
  215. ORDER BY vg.id_ DESC
  216. <include refid="global.limit"/>
  217. </select>
  218. <select id="countVipGroupByOrgan" resultType="int">
  219. SELECT
  220. count(id_)
  221. FROM
  222. vip_group vg
  223. <include refid="vipGroupQueryCondition"/>
  224. </select>
  225. <!-- 向数据库增加一条记录 -->
  226. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.VipGroup" useGeneratedKeys="true" keyColumn="id"
  227. keyProperty="id">
  228. INSERT INTO vip_group
  229. (id_,user_id_,single_class_minutes_,payment_expire_date_,courses_expire_date_,create_time_,
  230. update_time_,teacher_school_id_,online_classes_num_,offline_classes_num_,registration_start_time_,
  231. name_,organ_id_list_,vip_group_activity_id_,group_status_,online_classes_unit_price_,offline_classes_unit_price_,
  232. total_price_,give_teach_mode_,vip_group_category_id_,organ_id_,stop_reason_,memo_,audit_status_,courses_start_date,
  233. course_schedules_json_,student_id_list_,tenant_id_, group_type_, live_config_json_)
  234. VALUES(#{id},#{userId},#{singleClassMinutes},#{paymentExpireDate},#{coursesExpireDate},now(),now(),#{teacherSchoolId},
  235. #{onlineClassesNum},#{offlineClassesNum},#{registrationStartTime},#{name},#{organIdList},#{vipGroupActivityId},
  236. #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{onlineClassesUnitPrice},#{offlineClassesUnitPrice},
  237. #{totalPrice},#{giveTeachMode},#{vipGroupCategoryId},#{organId},#{stopReason},#{memo},
  238. #{auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{courseStartDate},#{courseSchedulesJson},#{studentIdList},#{tenantId},
  239. #{groupType}, #{liveConfigJson})
  240. </insert>
  241. <!-- 根据主键查询一条记录 -->
  242. <update id="update" parameterType="com.ym.mec.biz.dal.entity.VipGroup">
  243. UPDATE vip_group
  244. <set>
  245. <if test="courseStartDate != null">
  246. courses_start_date = #{courseStartDate},
  247. </if>
  248. <if test="paymentExpireDate != null">
  249. payment_expire_date_ = #{paymentExpireDate},
  250. </if>
  251. <if test="userId != null">
  252. user_id_ = #{userId},
  253. </if>
  254. <if test="offlineClassesNum != null">
  255. offline_classes_num_ = #{offlineClassesNum},
  256. </if>
  257. <if test="onlineClassesNum != null">
  258. online_classes_num_ = #{onlineClassesNum},
  259. </if>
  260. update_time_ = NOW(),
  261. <if test="singleClassMinutes != null">
  262. single_class_minutes_ = #{singleClassMinutes},
  263. </if>
  264. <if test="teacherSchoolId != null">
  265. teacher_school_id_ = #{teacherSchoolId},
  266. </if>
  267. <if test="coursesExpireDate != null">
  268. courses_expire_date_ = #{coursesExpireDate},
  269. </if>
  270. <if test="registrationStartTime != null">
  271. registration_start_time_ = #{registrationStartTime},
  272. </if>
  273. <if test="organIdList!=null">
  274. organ_id_list_=#{organIdList},
  275. </if>
  276. <if test="auditStatus != null">
  277. audit_status_ = #{auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  278. </if>
  279. <if test="vipGroupActivityId != null">
  280. vip_group_activity_id_ = #{vipGroupActivityId},
  281. </if>
  282. <if test="status != null">
  283. group_status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  284. </if>
  285. <if test="onlineClassesUnitPrice != null">
  286. online_classes_unit_price_ = #{onlineClassesUnitPrice},
  287. </if>
  288. <if test="offlineClassesUnitPrice != null">
  289. offline_classes_unit_price_ = #{offlineClassesUnitPrice},
  290. </if>
  291. <if test="totalPrice != null">
  292. total_price_ = #{totalPrice},
  293. </if>
  294. <if test="giveTeachMode!=null">
  295. give_teach_mode_=#{giveTeachMode},
  296. </if>
  297. <if test="organId!=null">
  298. organ_id_=#{organId},
  299. </if>
  300. <if test="stopReason!=null">
  301. stop_reason_=#{stopReason},
  302. </if>
  303. <if test="memo!=null">
  304. memo_=#{memo},
  305. </if>
  306. <if test="courseSchedulesJson!=null">
  307. course_schedules_json_=#{courseSchedulesJson},
  308. </if>
  309. <if test="studentIdList!=null">
  310. student_id_list_=#{studentIdList},
  311. </if>
  312. <if test="educationalTeacherId!=null">
  313. educational_teacher_id_=#{educationalTeacherId},
  314. </if>
  315. </set>
  316. WHERE id_ = #{id} and tenant_id_ = #{tenantId}
  317. </update>
  318. <!-- 根据主键删除一条记录 -->
  319. <delete id="delete">
  320. DELETE
  321. FROM vip_group
  322. WHERE id_ = #{id}
  323. </delete>
  324. <!-- 分页查询 -->
  325. <select id="queryPage" resultMap="VipGroup" parameterType="map">
  326. SELECT * FROM vip_group where tenant_id_ = #{tenantId} ORDER BY id_
  327. <include refid="global.limit"/>
  328. </select>
  329. <!-- 查询当前表的总记录数 -->
  330. <select id="queryCount" resultType="int">
  331. SELECT COUNT(*)
  332. FROM vip_group where tenant_id_ = #{tenantId}
  333. </select>
  334. <select id="getLockVipGroup" resultMap="VipGroup">
  335. SELECT *
  336. FROM vip_group
  337. WHERE id_ = #{vipGroupId} FOR
  338. UPDATE
  339. </select>
  340. <sql id="studentVipGroupQueryCondition">
  341. <where>
  342. vg.audit_status_='PASS'
  343. AND vg.group_status_ = 1
  344. AND vg.courses_expire_date_ &gt;= DATE_FORMAT(NOW(),'%Y%m%d')
  345. AND vg.registration_start_time_ &lt;= NOW()
  346. AND vg.courses_start_date &gt; NOW()
  347. AND (select count(1) as num from student_payment_order where vg.id_ = music_group_id_ AND user_id_=#{userId}
  348. AND status_='SUCCESS') = 0
  349. AND IF(vg.student_id_list_ IS NULL, vg.organ_id_ = #{organId}, FIND_IN_SET(#{userId},
  350. vg.student_id_list_))
  351. <if test="expireFlag != null and expireFlag == true">
  352. AND vg.payment_expire_date_ >= NOW()
  353. </if>
  354. <if test="subjectId!=null">
  355. AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
  356. </if>
  357. <if test="subjectId!=null">
  358. AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
  359. </if>
  360. <if test="categoryId!=null">
  361. AND FIND_IN_SET(vg.vip_group_category_id_,#{categoryId})
  362. </if>
  363. <if test="classType!=null and classType.toString()=='0'.toString()">
  364. AND vg.offline_classes_num_>0
  365. </if>
  366. <if test="classType!=null and classType.toString()=='1'.toString()">
  367. AND vg.online_classes_num_>0
  368. </if>
  369. <if test="search != null and search != ''">
  370. AND vg.name_ like concat('%',#{search},'%')
  371. </if>
  372. <if test="groupType != null and groupType != ''">
  373. AND vg.group_type_ = #{groupType}
  374. </if>
  375. </where>
  376. </sql>
  377. <sql id="studentLiveGroupQueryCondition">
  378. <where>
  379. vg.audit_status_='PASS'
  380. AND vg.group_status_ = 1
  381. AND vg.courses_expire_date_ &gt;= DATE_FORMAT(NOW(),'%Y%m%d')
  382. AND vg.registration_start_time_ &lt;= NOW()
  383. AND vg.courses_start_date &gt; NOW()
  384. 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'
  385. AND status_='SUCCESS') = 0
  386. <if test="expireFlag != null and expireFlag == true">
  387. AND vg.payment_expire_date_ >= NOW()
  388. </if>
  389. <if test="organId != null">
  390. AND FIND_IN_SET(#{organId},vg.organ_id_list_)
  391. </if>
  392. <if test="subjectId!=null">
  393. AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
  394. </if>
  395. <if test="subjectId!=null">
  396. AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
  397. </if>
  398. <if test="categoryId!=null">
  399. AND FIND_IN_SET(vg.vip_group_category_id_,#{categoryId})
  400. </if>
  401. <if test="classType!=null and classType.toString()=='0'.toString()">
  402. AND vg.offline_classes_num_>0
  403. </if>
  404. <if test="classType!=null and classType.toString()=='1'.toString()">
  405. AND vg.online_classes_num_>0
  406. </if>
  407. <if test="search != null and search != ''">
  408. AND vg.name_ like concat('%',#{search},'%')
  409. </if>
  410. <if test="groupType != null and groupType != ''">
  411. AND vg.group_type_ = #{groupType}
  412. </if>
  413. </where>
  414. </sql>
  415. <select id="findVipGroups" resultMap="studentVipGroup">
  416. SELECT
  417. vg.id_,
  418. vg.name_,
  419. vg.single_class_minutes_,
  420. vg.payment_expire_date_,
  421. vg.courses_expire_date_,
  422. vg.courses_start_date,
  423. vg.online_classes_num_,
  424. vg.offline_classes_num_,
  425. vg.total_price_,
  426. cg.expect_student_num_,
  427. cg.student_num_,
  428. su.real_name_ teacher_name_,
  429. su.avatar_,
  430. t.introduction_,
  431. vga.type_,
  432. vgc.name_ category_name_,vg.create_time_,
  433. vg.group_type_
  434. FROM
  435. vip_group vg
  436. LEFT JOIN class_group cg ON vg.id_=cg.music_group_id_ AND cg.group_type_ = vg.group_type_
  437. LEFT JOIN teacher t ON vg.user_id_=t.id_
  438. LEFT JOIN sys_user su ON vg.user_id_=su.id_
  439. LEFT JOIN vip_group_activity vga ON vg.vip_group_activity_id_=vga.id_
  440. LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
  441. <include refid="studentVipGroupQueryCondition"/>
  442. ORDER BY vg.id_ DESC
  443. <include refid="global.limit"/>
  444. </select>
  445. <select id="findLiveGroups" resultMap="studentVipGroup">
  446. SELECT
  447. vg.id_,
  448. vg.name_,
  449. vg.single_class_minutes_,
  450. vg.payment_expire_date_,
  451. vg.courses_expire_date_,
  452. vg.courses_start_date,
  453. vg.online_classes_num_,
  454. vg.offline_classes_num_,
  455. vg.total_price_,
  456. cg.expect_student_num_,
  457. cg.student_num_,
  458. su.real_name_ teacher_name_,
  459. su.avatar_,
  460. t.introduction_,
  461. vgc.name_ category_name_,vg.create_time_,
  462. vg.group_type_
  463. FROM
  464. vip_group vg
  465. LEFT JOIN class_group cg ON vg.id_=cg.music_group_id_ AND cg.group_type_ = vg.group_type_
  466. LEFT JOIN teacher t ON vg.user_id_=t.id_
  467. LEFT JOIN sys_user su ON vg.user_id_=su.id_
  468. LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
  469. <include refid="studentLiveGroupQueryCondition"/>
  470. ORDER BY vg.id_ DESC
  471. <include refid="global.limit"/>
  472. </select>
  473. <select id="countVipGorups" resultType="int">
  474. SELECT
  475. count(*)
  476. FROM
  477. vip_group vg
  478. LEFT JOIN class_group cg ON vg.id_=cg.music_group_id_ AND cg.group_type_ = 'VIP'
  479. LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
  480. <include refid="studentVipGroupQueryCondition"/>
  481. </select>
  482. <select id="getVipGroupBaseInfo" resultMap="vipGroupManageDetailDto">
  483. SELECT vg.*,
  484. vga.name_ vip_group_activity_name_,
  485. su.real_name_ username_,
  486. cg.student_num_,
  487. cg.subject_id_list_,
  488. cg.total_class_times_,
  489. cg.current_class_times_,
  490. vgc.name_ category_name_,
  491. s.name_ teacher_school_name_,
  492. vgc.music_theory_
  493. FROM vip_group vg
  494. LEFT JOIN sys_user su ON vg.user_id_ = su.id_
  495. LEFT JOIN class_group cg ON vg.id_ = cg.music_group_id_ AND cg.group_type_ = 'VIP'
  496. LEFT JOIN vip_group_activity vga ON vg.vip_group_activity_id_ = vga.id_
  497. LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_ = vgc.id_
  498. LEFT JOIN school s ON vg.teacher_school_id_ = s.id_
  499. WHERE vg.id_ = #{vipGroupId}
  500. </select>
  501. <sql id="vipGroupAttendanceQueryCondition">
  502. <where>
  503. vg.tenant_id_ = #{tenantId}
  504. <if test="vipGroupId!=null">
  505. and vg.id_=#{vipGroupId}
  506. </if>
  507. <if test="startTime != null">
  508. and CONCAT(cs.class_date_,' ',cs.end_class_time_) &gt; #{startTime}
  509. </if>
  510. <if test="endTime != null">
  511. and CONCAT(cs.class_date_,' ',cs.end_class_time_) &lt; #{endTime}
  512. </if>
  513. <if test="status != null">
  514. and cs.status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  515. </if>
  516. <if test="complaintStatus != null">
  517. and cs.complaint_status_ = #{complaintStatus}
  518. </if>
  519. </where>
  520. </sql>
  521. <select id="findVipGroupAttendances" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleDao.CourseSchedule">
  522. SELECT
  523. cs.*
  524. FROM
  525. vip_group vg
  526. LEFT JOIN teacher_attendance ta ON vg.id_=ta.music_group_id_ AND ta.group_type_ = 'VIP'
  527. LEFT JOIN course_schedule cs ON ta.course_schedule_id_=cs.id_
  528. <include refid="vipGroupAttendanceQueryCondition"/>
  529. ORDER BY ta.id_
  530. <include refid="global.limit"/>
  531. </select>
  532. <select id="countVipGroupAttendance" resultType="int">
  533. SELECT
  534. count(*)
  535. FROM
  536. vip_group vg
  537. LEFT JOIN teacher_attendance ta ON vg.id_=ta.music_group_id_ AND ta.group_type_ = 'VIP'
  538. LEFT JOIN course_schedule cs ON ta.course_schedule_id_=cs.id_
  539. <include refid="vipGroupAttendanceQueryCondition"/>
  540. ORDER BY ta.id_
  541. </select>
  542. <select id="getVipGroupDetail" resultMap="studentVipGroupDetailDto">
  543. SELECT vg.*,
  544. cg.total_class_times_,
  545. cg.expect_student_num_,
  546. cg.student_num_,
  547. su.real_name_ teacher_name_,
  548. su.avatar_,
  549. t.introduction_,
  550. s.name_ address_,
  551. cs.id_ course_id_,
  552. cs.class_group_id_,
  553. cs.status_,
  554. cs.subsidy_,
  555. cs.class_date_,
  556. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  557. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  558. cs.teacher_id_,
  559. cs.actual_teacher_id_,
  560. cs.create_time_,
  561. cs.update_time_,
  562. cs.teach_mode_,
  563. cs.type_,
  564. cs.name_
  565. FROM vip_group vg
  566. LEFT JOIN class_group cg ON vg.id_ = cg.music_group_id_ AND cg.group_type_ = 'VIP'
  567. LEFT JOIN course_schedule cs ON cg.id_ = cs.class_group_id_
  568. LEFT JOIN school s ON vg.teacher_school_id_ = s.id_
  569. LEFT JOIN teacher t ON vg.user_id_ = t.id_
  570. LEFT JOIN sys_user su ON vg.user_id_ = su.id_
  571. WHERE vg.id_ = #{vipGroupId}
  572. ORDER BY start_class_time_
  573. </select>
  574. <select id="countSurplusClassTimes" resultType="java.util.Map">
  575. SELECT cs.teach_mode_ as 'key',
  576. COUNT(cs.id_) as 'value'
  577. FROM course_schedule cs
  578. WHERE cs.status_ = "NOT_START"
  579. AND cs.type_ = 'VIP'
  580. AND cs.music_group_id_ = #{vipGroupId}
  581. AND cs.group_type_ = 'VIP'
  582. GROUP BY cs.teach_mode_
  583. </select>
  584. <resultMap id="vipGroupStudentDto" type="com.ym.mec.biz.dal.dto.VipGroupStudentDto">
  585. <result column="id_" property="id"/>
  586. <result column="username_" property="userName"/>
  587. <result column="phone_" property="phone"/>
  588. <result column="total_class_times_" property="totalClassTimes"/>
  589. <result column="current_class_times_" property="currentClassTimes"/>
  590. <result column="course_balance_" property="courseSalary"/>
  591. <result column="create_time_" property="applyDate"/>
  592. <result column="update_time_" property="refundDate"/>
  593. <result column="student_status_" property="studentStatus"/>
  594. </resultMap>
  595. <select id="findVipGroupStudents" resultMap="vipGroupStudentDto">
  596. SELECT
  597. su.id_,
  598. su.username_,
  599. su.phone_,
  600. cg.total_class_times_,
  601. cg.current_class_times_,
  602. suaa.course_balance_,
  603. cgsm.create_time_,
  604. cgsm.update_time_,
  605. CASE cgsm.status_
  606. WHEN 'QUIT' THEN 1
  607. WHEN 'QUIT_SCHOOL' THEN 3
  608. ELSE 0
  609. END student_status_
  610. FROM
  611. class_group cg
  612. LEFT JOIN class_group_student_mapper cgsm ON cg.id_=cgsm.class_group_id_
  613. LEFT JOIN sys_user su ON cgsm.user_id_=su.id_
  614. LEFT JOIN sys_user_cash_account suaa ON cgsm.user_id_=suaa.user_id_
  615. WHERE cg.music_group_id_=#{vipGroupId}
  616. <if test="groupType != null">
  617. AND cg.group_type_= #{groupType}
  618. </if>
  619. AND cgsm.user_id_ IS NOT NULL
  620. ORDER BY su.id_
  621. <include refid="global.limit"/>
  622. </select>
  623. <select id="findHaveCourseBalanceStudents" resultMap="vipGroupStudentDto">
  624. SELECT
  625. su.id_,
  626. su.username_,
  627. su.phone_,
  628. suca.course_balance_,
  629. suca.balance_ balance,
  630. (suca.course_balance_+suca.balance_) allBalance
  631. FROM
  632. sys_user_cash_account suca
  633. LEFT JOIN sys_user su ON suca.user_id_=su.id_
  634. WHERE
  635. suca.tenant_id_ = #{tenantId}
  636. AND su.user_type_ LIKE '%STUDENT%'
  637. # suca.course_balance_ >0
  638. <if test="search!=null and search!=''">
  639. AND (su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  640. </if>
  641. <if test="organIds!=null and organIds.size()>0">
  642. AND su.organ_id_ IN
  643. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  644. #{organId}
  645. </foreach>
  646. </if>
  647. ORDER BY suca.course_balance_ DESC
  648. <include refid="global.limit"/>
  649. </select>
  650. <select id="countHaveCourseBalanceStudentNum" resultType="int">
  651. SELECT
  652. COUNT(1)
  653. FROM
  654. sys_user_cash_account suca
  655. LEFT JOIN sys_user su ON suca.user_id_=su.id_
  656. WHERE suca.tenant_id_ = #{tenantId}
  657. AND su.user_type_ LIKE '%STUDENT%'
  658. # suca.course_balance_ > 0
  659. <if test="search!=null and search!=''">
  660. AND (su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  661. </if>
  662. <if test="organIds!=null and organIds.size()>0">
  663. AND su.organ_id_ IN
  664. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  665. #{organId}
  666. </foreach>
  667. </if>
  668. </select>
  669. <select id="countVipGroupStudents" resultType="int">
  670. SELECT count(*)
  671. FROM class_group cg
  672. LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
  673. WHERE cg.music_group_id_ = #{vipGroupId}
  674. AND cg.group_type_ = #{groupType}
  675. </select>
  676. <resultMap id="teachingRecord" type="com.ym.mec.biz.dal.dto.VipGroupCourseSchduleRecordDto">
  677. <result column="id_" property="id"/>
  678. <result column="start_class_time_" property="startClassTime"/>
  679. <result column="end_class_time_" property="endClassTime"/>
  680. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  681. <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  682. <result column="give_teach_mode_" property="giveTeachMode"
  683. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  684. <result column="is_salary_" property="isSalary" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  685. <result column="student_num_" property="attendanceNum"/>
  686. <result column="school_name_" property="schoolName"/>
  687. <result column="schoole_id_" property="schooleId"/>
  688. <result column="sign_in_status_" property="signInStatus"/>
  689. <result column="sign_out_status_" property="signOutStatus"/>
  690. <result column="sign_in_time_" property="signInTime"/>
  691. <result column="sign_out_time_" property="signOutTime"/>
  692. </resultMap>
  693. <sql id="teachingRecordQueryCondition">
  694. <where>
  695. cs.music_group_id_=#{vipGroupId}
  696. <if test="groupType != null and groupType != ''">
  697. AND cs.group_type_= #{groupType}
  698. </if>
  699. <if test="startTime!=null and endTime!=null">
  700. AND (cs.class_date_ BETWEEN #{startTime} AND #{endTime})
  701. </if>
  702. <if test="teachMode!=null and teachMode!=''">
  703. AND cs.teach_mode_=#{teachMode}
  704. </if>
  705. <if test="status!=null and status!=''">
  706. AND cs.status_=#{status}
  707. </if>
  708. </where>
  709. </sql>
  710. <select id="findTeachingRecord" resultMap="teachingRecord">
  711. SELECT
  712. cs.id_,
  713. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  714. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  715. cs.status_,
  716. cs.teach_mode_,
  717. s.name_ school_name_,
  718. csts.actual_salary_ IS NOT NULL is_salary_,
  719. cs.schoole_id_,
  720. IF(ta.sign_in_status_ IS NULL,3,ta.sign_in_status_) sign_in_status_,
  721. IF(ta.sign_out_status_ IS NULL,3,ta.sign_out_status_) sign_out_status_,
  722. ta.sign_in_time_,
  723. ta.sign_out_time_
  724. FROM
  725. course_schedule cs
  726. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_=csts.course_schedule_id_
  727. left join school s on cs.schoole_id_ = s.id_
  728. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_ AND ta.teacher_id_ = cs.actual_teacher_id_
  729. <include refid="teachingRecordQueryCondition"/>
  730. ORDER BY start_class_time_
  731. <include refid="global.limit"/>
  732. </select>
  733. <select id="countTeachingRecord" resultType="int">
  734. SELECT
  735. COUNT(*)
  736. FROM
  737. course_schedule cs
  738. <include refid="teachingRecordQueryCondition"/>
  739. </select>
  740. <select id="getClassTimes" resultType="com.ym.mec.biz.dal.dto.TeachingRecordBaseInfo">
  741. SELECT cg.total_class_times_ totalClassTimes,
  742. cg.current_class_times_ currentClassTimes
  743. FROM class_group cg
  744. WHERE cg.music_group_id_ = #{vipGroupId}
  745. </select>
  746. <select id="countIsSalaryNum" resultType="int">
  747. SELECT COUNT(*)
  748. FROM course_schedule cs
  749. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
  750. WHERE cs.music_group_id_ = #{vipGroupId}
  751. AND cs.group_type_ = 'VIP'
  752. AND csts.settlement_time_ IS NOT NULL
  753. </select>
  754. <select id="countComplaintsNum" resultType="java.lang.Integer">
  755. SELECT COUNT(*)
  756. FROM course_schedule cs
  757. LEFT JOIN course_schedule_complaints csc ON cs.id_ = csc.course_schedule_id_
  758. WHERE cs.music_group_id_ = #{vipGroupId}
  759. AND cs.group_type_ = 'VIP'
  760. AND csc.course_schedule_id_ IS NOT NULL
  761. AND csc.score_ &lt;= 2
  762. </select>
  763. <select id="getVipGroupSalaryInfo" resultType="com.ym.mec.biz.dal.dto.VipGroupSalaryBaseInfo">
  764. SELECT SUM(csts.expect_salary_) expectTotalSalary,
  765. SUM(csts.actual_salary_) totalSalary
  766. FROM vip_group vg
  767. LEFT JOIN course_schedule cs ON vg.id_ = cs.music_group_id_ AND cs.group_type_ = vg.group_type_
  768. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
  769. WHERE vg.id_ = #{vipGroupId}
  770. AND cs.id_ IS NOT NULL
  771. </select>
  772. <select id="countVipGroupDeductionNum" resultType="int">
  773. SELECT COUNT(csts.id_)
  774. FROM vip_group vg
  775. LEFT JOIN course_schedule cs ON vg.id_ = cs.music_group_id_ AND cs.group_type_ = vg.group_type_
  776. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
  777. WHERE vg.id_ = #{vipGroupId}
  778. AND cs.id_ != NULL
  779. AND csts.settlement_time_ != NULL
  780. AND csts.actual_salary_ &lt; csts.expect_salary_
  781. </select>
  782. <select id="countSurplusCourseFee" resultType="map">
  783. SELECT cssp.user_id_ as 'key',
  784. SUM(cssp.expect_price_) as 'value'
  785. FROM vip_group vg
  786. LEFT JOIN course_schedule cs ON vg.id_ = cs.music_group_id_ AND cs.group_type_ = vg.group_type_
  787. LEFT JOIN course_schedule_student_payment cssp ON cs.id_ = cssp.course_schedule_id_
  788. WHERE vg.id_ = #{vipGroupId}
  789. AND cs.status_ = 'NOT_START'
  790. GROUP BY cssp.user_id_
  791. </select>
  792. <select id="countTeacherVipGroups" resultType="int">
  793. SELECT COUNT(vg.id_)
  794. FROM vip_group vg
  795. WHERE vg.user_id_ = #{teacherId}
  796. AND vg.group_status_ != 3
  797. </select>
  798. <select id="countTeacherVipClass" resultType="java.lang.Integer">
  799. SELECT COUNT(DISTINCT vg.id_)
  800. FROM vip_group vg
  801. LEFT JOIN class_group cg ON cg.music_group_id_ = vg.id_ AND cg.group_type_ = vg.group_type_
  802. LEFT JOIN course_schedule cs ON cs.class_group_id_ = cg.id_
  803. WHERE cs.actual_teacher_id_ = #{teacherId}
  804. AND cs.type_ = 'VIP'
  805. AND cg.del_flag_ = 0
  806. </select>
  807. <resultMap type="com.ym.mec.biz.dal.dto.TeacherVipClassInfoDto" id="getTeacherVipClassMap">
  808. <result column="vip_group_id_" property="vipClassId"/>
  809. <result column="student_num_" property="studentNum"/>
  810. <result column="online_classes_unit_price_" property="onlineClassesUnitPrice"/>
  811. <result column="offline_classes_unit_price_" property="offlineClassesUnitPrice"/>
  812. <result column="class_group_id_" property="classGroupId"/>
  813. <result column="courses_expire_date_" property="coursesExpireDate"/>
  814. <result column="payment_expire_date_" property="paymentExpireDate"/>
  815. <result column="create_time_" property="createDate"/>
  816. <result column="current_class_times_" property="currentClassTimes"/>
  817. <result column="total_class_times_" property="totalClassTimes"/>
  818. <result column="vip_group_name_" property="vipClassName"/>
  819. <result column="audit_status_" property="auditStatus"
  820. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  821. <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  822. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  823. <result column="vip_group_activity_id_" property="activityId"/>
  824. </resultMap>
  825. <select id="getTeacherVipClass" resultMap="getTeacherVipClassMap">
  826. SELECT vg.id_ vip_group_id_,vg.name_ vip_group_name_,vg.group_status_,vg.audit_status_,vg.create_time_,
  827. vg.payment_expire_date_,vg.courses_expire_date_,vg.online_classes_unit_price_,vg.offline_classes_unit_price_,
  828. cg.total_class_times_,cg.current_class_times_,cg.id_ class_group_id_,cg.student_num_,vg.vip_group_activity_id_
  829. FROM vip_group vg
  830. LEFT JOIN class_group cg ON vg.id_ = cg.music_group_id_ AND cg.group_type_ = vg.group_type_
  831. LEFT JOIN course_schedule cs ON cs.class_group_id_ = cg.id_
  832. WHERE cs.actual_teacher_id_ = #{teacherId} AND cs.type_ = 'VIP' AND cg.del_flag_ = 0 GROUP BY vg.id_,cg.id_
  833. <include refid="global.limit"/>
  834. </select>
  835. <select id="querySchoolByUserId" resultMap="School">
  836. SELECT *
  837. from school
  838. where user_id_ = #{userId}
  839. or user_id_ is null
  840. </select>
  841. <select id="findByCourseSchedule" resultMap="VipGroup">
  842. SELECT vg.*
  843. FROM vip_group vg
  844. LEFT JOIN course_schedule cs ON vg.id_ = cs.music_group_id_ AND cs.group_type_ = vg.group_type_
  845. WHERE cs.id_ = #{courseScheduleId}
  846. </select>
  847. <select id="queryVipGroupNum" resultType="map">
  848. select count(*) total,sum(case when group_status_ = 2 then 1 else 0 end) applying_num_,sum(case when
  849. group_status_ = 4 then 1 else 0 end) finished_num_ from vip_group
  850. where organ_id_ not in (36,38) and tenant_id_ = #{tenantId}
  851. <if test="organId != null">
  852. and FIND_IN_SET(organ_id_,#{organId})
  853. </if>
  854. </select>
  855. <select id="queryCurrentMonthCoursesNum" resultType="int">
  856. select count(cs.id_) from course_schedule cs left join vip_group vg on cs.music_group_id_ = vg.id_ where
  857. cs.type_ in ('VIP')
  858. and DATE_FORMAT(cs.class_date_, '%Y%m' ) = DATE_FORMAT(CURDATE() , '%Y%m') and (cs.del_flag_ = 0 or cs.del_flag_
  859. is null) and vg.organ_id_ not in (36,38) and vg.tenant_id_ = #{tenantId}
  860. <if test="organId != null">
  861. AND FIND_IN_SET(vg.organ_id_,#{organId})
  862. </if>
  863. </select>
  864. <select id="findNoCreateSuccessVipGroup" resultMap="VipGroup">
  865. SELECT *
  866. FROM vip_group
  867. WHERE (payment_expire_date_ &lt; DATE_FORMAT(NOW(), '%Y-%m-%d')
  868. OR courses_start_date &lt; NOW())
  869. AND group_status_ = 1
  870. <if test="tenantId != null">
  871. and tenant_id_ = #{tenantId}
  872. </if>
  873. </select>
  874. <select id="countStudentPaymentNum" resultType="int">
  875. SELECT COUNT(*)
  876. FROM course_schedule_student_payment cssp
  877. WHERE cssp.settlement_time_ IS NOT NULL
  878. AND cssp.class_group_id_ = #{classGroupId}
  879. </select>
  880. <select id="countStudentPaymentFee" resultType="java.math.BigDecimal">
  881. SELECT SUM(actual_price_)
  882. FROM course_schedule_student_payment cssp
  883. WHERE cssp.settlement_time_ IS NOT NULL
  884. AND cssp.class_group_id_ = #{classGroupId}
  885. </select>
  886. <select id="queryByIds" resultMap="VipGroup" parameterType="string">
  887. select *
  888. from vip_group
  889. where FIND_IN_SET(id_, #{idList})
  890. </select>
  891. <resultMap id="VipBuyResult" type="com.ym.mec.biz.dal.dto.VipBuyResultDto">
  892. <result property="vipGroupId" column="id_"/>
  893. <result property="vipGroupName" column="name_"/>
  894. <result property="teacherName" column="username_"/>
  895. <result property="eduTeacherName" column="eduTeacherName"/>
  896. <result property="classTimes" column="total_class_times_"/>
  897. <result property="startClassTime" column="courses_start_date"/>
  898. <result property="endClassTime" column="courses_expire_date_"/>
  899. <result property="groupType" column="group_type_"/>
  900. </resultMap>
  901. <select id="getVipBuyResultInfo" resultMap="VipBuyResult">
  902. SELECT vg.id_,
  903. vg.name_,
  904. vg.courses_start_date,
  905. vg.courses_expire_date_,
  906. cg.total_class_times_,
  907. su.real_name_ username_,
  908. vg.group_type_
  909. FROM vip_group vg
  910. LEFT JOIN class_group cg ON vg.id_ = cg.music_group_id_ AND cg.group_type_ = vg.group_type_
  911. LEFT JOIN sys_user su ON vg.user_id_ = su.id_
  912. WHERE vg.id_ = #{vipGroupId}
  913. </select>
  914. <update id="batchUpdate" parameterType="java.util.List">
  915. <foreach collection="vipGroupList" item="item" index="index" open="" close="" separator=";">
  916. UPDATE vip_group
  917. <set>
  918. <if test="item.paymentExpireDate != null">
  919. payment_expire_date_ = #{item.paymentExpireDate},
  920. </if>
  921. <if test="item.userId != null">
  922. user_id_ = #{item.userId},
  923. </if>
  924. <if test="item.offlineClassesNum != null">
  925. offline_classes_num_ = #{item.offlineClassesNum},
  926. </if>
  927. <if test="item.onlineClassesNum != null">
  928. online_classes_num_ = #{item.onlineClassesNum},
  929. </if>
  930. <if test="item.updateTime != null">
  931. update_time_ = NOW(),
  932. </if>
  933. <if test="item.singleClassMinutes != null">
  934. single_class_minutes_ = #{item.singleClassMinutes},
  935. </if>
  936. <if test="item.teacherSchoolId != null">
  937. teacher_school_id_ = #{item.teacherSchoolId},
  938. </if>
  939. <if test="item.coursesExpireDate != null">
  940. courses_expire_date_ = #{item.coursesExpireDate},
  941. </if>
  942. <if test="item.registrationStartTime != null">
  943. registration_start_time_ = #{item.registrationStartTime},
  944. </if>
  945. <if test="item.organIdList!=null">
  946. organ_id_list_=#{item.organIdList},
  947. </if>
  948. <if test="item.auditStatus != null">
  949. audit_status_ = #{item.auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  950. </if>
  951. <if test="item.organIdList != null">
  952. organ_id_list_ = #{item.organIdList},
  953. </if>
  954. <if test="item.vipGroupActivityId != null">
  955. vip_group_activity_id_ = #{item.vipGroupActivityId},
  956. </if>
  957. <if test="item.status != null">
  958. group_status_ = #{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  959. </if>
  960. <if test="item.onlineClassesUnitPrice != null">
  961. online_classes_unit_price_ = #{item.onlineClassesUnitPrice},
  962. </if>
  963. <if test="item.offlineClassesUnitPrice != null">
  964. offline_classes_unit_price_ = #{item.offlineClassesUnitPrice},
  965. </if>
  966. <if test="item.totalPrice != null">
  967. total_price_ = #{item.totalPrice},
  968. </if>
  969. <if test="item.giveTeachMode!=null">
  970. give_teach_mode_=#{item.giveTeachMode},
  971. </if>
  972. <if test="item.organId!=null">
  973. organ_id_=#{item.organId},
  974. </if>
  975. <if test="item.stopReason!=null">
  976. stop_reason_=#{item.stopReason},
  977. </if>
  978. <if test="item.auditStatus!=null">
  979. audit_status_=#{item.auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  980. </if>
  981. <if test="item.courseSchedulesJson!=null">
  982. course_schedules_json_=#{item.courseSchedulesJson},
  983. </if>
  984. <if test="item.studentIdList!=null">
  985. student_id_list_=#{item.studentIdList},
  986. </if>
  987. </set>
  988. WHERE id_ = #{item.id} and tenant_id_ = #{item.tenantId}
  989. </foreach>
  990. </update>
  991. <select id="queryRequiredOverList" resultMap="VipGroup">
  992. SELECT
  993. vg.*
  994. FROM
  995. vip_group vg
  996. LEFT JOIN course_schedule cs ON cs.group_type_ = vg.group_type_ AND CONCAT(vg.id_, '') = cs.music_group_id_
  997. WHERE
  998. vg.group_status_ = 2
  999. GROUP BY
  1000. vg.id_
  1001. HAVING COUNT( CASE WHEN cs.status_ != 'OVER' THEN 1 ELSE NULL END )&lt;=0
  1002. </select>
  1003. <select id="queryNormalStatusList" resultMap="VipGroup">
  1004. SELECT *
  1005. FROM vip_group
  1006. WHERE group_status_ != 3
  1007. AND group_status_ != 4
  1008. </select>
  1009. <select id="findVipGroupInfo" resultMap="VipGroup">
  1010. SELECT vg.*, s.name_ subject_name_, s2.name_ school_name_,su.real_name_ educational_teacher_name_
  1011. FROM vip_group vg
  1012. LEFT JOIN class_group cg on vg.id_ = cg.music_group_id_
  1013. LEFT JOIN subject s on cg.subject_id_list_ = s.id_
  1014. LEFT JOIN school s2 on vg.teacher_school_id_ = s2.id_
  1015. LEFT JOIN sys_user su on vg.educational_teacher_id_ = su.id_
  1016. WHERE vg.id_ = #{id}
  1017. AND cg.id_ = #{classGroupId}
  1018. AND cg.group_type_ = 'VIP'
  1019. </select>
  1020. <select id="queryUserVipNames" resultType="java.util.Map">
  1021. SELECT cgsm.user_id_ 'key',GROUP_CONCAT(vg.name_)'value' FROM class_group_student_mapper cgsm
  1022. LEFT JOIN vip_group vg ON cgsm.music_group_id_ = vg.id_
  1023. WHERE vg.group_status_ IN (2,4,6) AND cgsm.group_type_='VIP' AND cgsm.user_id_ IN
  1024. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  1025. #{userId}
  1026. </foreach>
  1027. GROUP BY cgsm.user_id_
  1028. </select>
  1029. <select id="queryUserVipStatus" resultType="java.util.Map">
  1030. SELECT cgsm.user_id_ 'key',GROUP_CONCAT(CASE WHEN cgsm.status_ = 'NORMAL' THEN '在读'
  1031. WHEN cgsm.status_ = 'LEAVE' THEN '请假'
  1032. WHEN cgsm.status_ = 'QUIT' THEN '退班'
  1033. WHEN cgsm.status_ = 'QUIT_SCHOOL' THEN '休学' END) 'value'
  1034. FROM class_group_student_mapper cgsm
  1035. LEFT JOIN vip_group vg ON cgsm.music_group_id_ = vg.id_
  1036. WHERE vg.group_status_ IN (2,4,6) AND cgsm.group_type_='VIP' AND cgsm.user_id_ IN
  1037. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  1038. #{userId}
  1039. </foreach>
  1040. GROUP BY cgsm.user_id_
  1041. </select>
  1042. <select id="countUserRepeatVipGroupInCourseStartEndTime" resultType="int">
  1043. SELECT COUNT(id_)
  1044. FROM vip_group
  1045. WHERE user_id_ = #{userId}
  1046. AND courses_start_date = #{courseStartDate}
  1047. AND courses_expire_date_ = #{courseEndDate}
  1048. </select>
  1049. <select id="getGroupTeachers" resultMap="VipBuyResult">
  1050. SELECT vg.id_,t.real_name_ username_,et.real_name_ eduTeacherName FROM vip_group vg
  1051. LEFT JOIN sys_user t on vg.user_id_ = t.id_
  1052. LEFT JOIN sys_user et on vg.educational_teacher_id_ = et.id_
  1053. <where>
  1054. vg.tenant_id_ = #{tenantId}
  1055. <if test="groupIds != null">
  1056. AND vg.id_ IN
  1057. <foreach collection="groupIds" item="groupId" open="(" close=")" separator=",">
  1058. #{groupId}
  1059. </foreach>
  1060. </if>
  1061. </where>
  1062. </select>
  1063. <select id="getVipGroupByIds" resultMap="VipGroup">
  1064. SELECT * FROM vip_group WHERE id_ IN
  1065. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  1066. #{id}
  1067. </foreach>
  1068. </select>
  1069. <select id="queryEduNameMapByCourseId" resultType="java.util.Map">
  1070. SELECT cs.id_ 'key',su.real_name_ 'value' FROM course_schedule cs
  1071. LEFT JOIN vip_group vg ON vg.id_ = cs.music_group_id_
  1072. LEFT JOIN sys_user su ON su.id_ = vg.educational_teacher_id_
  1073. WHERE cs.id_ IN
  1074. <foreach collection="courseIds" item="item" open="(" close=")" separator=",">
  1075. #{item}
  1076. </foreach>
  1077. AND vg.educational_teacher_id_ IS NOT NULL
  1078. </select>
  1079. <select id="countStudentUserActivityNum" resultType="int">
  1080. SELECT COUNT(DISTINCT vg.id_)
  1081. FROM vip_group vg
  1082. LEFT JOIN class_group_student_mapper cgsm ON vg.id_=cgsm.music_group_id_ AND cgsm.group_type_='VIP'
  1083. WHERE vg.vip_group_activity_id_=#{vipGroupActivityId}
  1084. AND ((vg.group_status_ NOT IN (3, 7) AND FIND_IN_SET(#{studentId}, vg.student_id_list_)) OR cgsm.user_id_=#{studentId});
  1085. </select>
  1086. <select id="countStudentUseingActivityNum" resultType="int">
  1087. SELECT COUNT(DISTINCT vg.id_)
  1088. FROM vip_group vg
  1089. LEFT JOIN class_group_student_mapper cgsm ON vg.id_=cgsm.music_group_id_ AND cgsm.group_type_='VIP'
  1090. LEFT JOIN class_group cg ON cgsm.class_group_id_=cg.id_
  1091. WHERE vg.vip_group_activity_id_=#{vipGroupActivityId}
  1092. AND cg.del_flag_!=1
  1093. AND cgsm.user_id_=#{studentId}
  1094. </select>
  1095. <!--获取课程人数-->
  1096. <select id="getCourseStudentNumsByGroupId" resultType="java.lang.Integer">
  1097. 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}
  1098. </select>
  1099. <!--获取课程人数-->
  1100. </mapper>