CourseScheduleEvaluateMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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. <mapper namespace="com.ym.mec.biz.dal.dao.CourseScheduleEvaluateDao">
  4. <resultMap id="CourseScheduleEvaluate" type="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate">
  5. <id column="id_" jdbcType="BIGINT" property="id"/>
  6. <result column="music_group_id_" jdbcType="VARCHAR" property="musicGroupId"/>
  7. <result column="class_group_id_" jdbcType="INTEGER" property="classGroupId"/>
  8. <result column="course_schedule_id_" jdbcType="BIGINT" property="courseScheduleId"/>
  9. <result column="teacher_id_" jdbcType="INTEGER" property="teacherId"/>
  10. <result column="item_" jdbcType="VARCHAR" property="item"/>
  11. <result column="comment_" jdbcType="LONGVARCHAR" property="comment"/>
  12. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  13. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  14. <result column="student_id_" jdbcType="INTEGER" property="studentId"/>
  15. <result column="student_avatar_" property="studentAvatar"/>
  16. <result column="subject_id_" jdbcType="INTEGER" property="subjectId"/>
  17. <result column="subject_name_" jdbcType="VARCHAR" property="subjectName"/>
  18. <result column="is_pushed_" jdbcType="INTEGER" property="isPushed"/>
  19. <result column="month_" jdbcType="VARCHAR" property="month"/>
  20. <result column="music_theory_" jdbcType="VARCHAR" property="musicTheory"/>
  21. <result column="song_" jdbcType="VARCHAR" property="song"/>
  22. <result column="teaching_material_" jdbcType="VARCHAR" property="teachingMaterial"/>
  23. <result column="times_" jdbcType="INTEGER" property="times"/>
  24. <result column="total_minutes_" jdbcType="INTEGER" property="totalMinutes"/>
  25. <result column="version_" jdbcType="INTEGER" property="version"/>
  26. <result column="student_id_list_" jdbcType="VARCHAR" property="studentIdList"/>
  27. <result column="group_name_" jdbcType="VARCHAR" property="groupName"/>
  28. <result column="status_" jdbcType="TINYINT" property="status"/>
  29. <result column="tenant_id_" property="tenantId" />
  30. </resultMap>
  31. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate" useGeneratedKeys="true"
  32. keyColumn="id" keyProperty="id">
  33. INSERT INTO course_schedule_evaluate (music_group_id_, class_group_id_, course_schedule_id_, music_theory_,
  34. song_, times_, total_minutes_,
  35. teaching_material_, teacher_id_, item_, comment_, create_time_,
  36. update_time_,
  37. student_id_list_, version_, status_, tenant_id_)
  38. values (#{musicGroupId,jdbcType=VARCHAR}, #{classGroupId,jdbcType=INTEGER}, #{courseScheduleId,jdbcType=BIGINT},
  39. #{musicTheory,jdbcType=VARCHAR}, #{song,jdbcType=VARCHAR}, #{times,jdbcType=INTEGER}, #{totalMinutes},
  40. #{teachingMaterial,jdbcType=VARCHAR},
  41. #{teacherId,jdbcType=INTEGER}, #{item,jdbcType=VARCHAR}, #{comment,jdbcType=LONGVARCHAR},
  42. #{createTime,jdbcType=TIMESTAMP},
  43. #{updateTime,jdbcType=TIMESTAMP}, #{studentIdList}, #{version,jdbcType=INTEGER},
  44. #{status,jdbcType=TINYINT},#{tenantId})
  45. </insert>
  46. <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate">
  47. update course_schedule_evaluate
  48. <set>
  49. <if test="musicGroupId != null">
  50. music_group_id_ = #{musicGroupId},
  51. </if>
  52. <if test="classGroupId != null">
  53. class_group_id_ = #{classGroupId},
  54. </if>
  55. <if test="courseScheduleId != null">
  56. course_schedule_id_ = #{courseScheduleId},
  57. </if>
  58. <if test="musicTheory != null">
  59. music_theory_ = #{musicTheory},
  60. </if>
  61. <if test="song != null">
  62. song_ = #{song},
  63. </if>
  64. <if test="teachingMaterial != null">
  65. teaching_material_ = #{teachingMaterial},
  66. </if>
  67. <if test="item != null">
  68. item_ = #{item},
  69. </if>
  70. <if test="comment != null">
  71. comment_ = #{comment},
  72. </if>
  73. <if test="classGroupId != null">
  74. class_group_id_ = #{classGroupId},
  75. </if>
  76. <if test="studentIdList != null">
  77. student_id_list_ = #{studentIdList},
  78. </if>
  79. <if test="teacherId != null">
  80. teacher_id_ = #{teacherId},
  81. </if>
  82. <if test="version != null != null">
  83. version_ = #{version},
  84. </if>
  85. <if test="status != null">
  86. status_ = #{status},
  87. </if>
  88. <if test="isPushed != null">
  89. is_pushed_ = #{isPushed},
  90. </if>
  91. <if test="updateTime != null">
  92. update_time_ = #{updateTime}
  93. </if>
  94. </set>
  95. WHERE id_ = #{id} and tenant_id_ = #{tenantId}
  96. </update>
  97. <select id="get" resultMap="CourseScheduleEvaluate">
  98. SELECT *
  99. FROM course_schedule_evaluate
  100. WHERE id_ = #{id}
  101. </select>
  102. <select id="findByClassGroupId" resultMap="CourseScheduleEvaluate">
  103. SELECT cse.*, s.name_ subject_name_, pg.student_id_
  104. FROM course_schedule_evaluate cse
  105. LEFT JOIN practice_group pg ON pg.id_ = cse.music_group_id_
  106. LEFT JOIN subject s on s.id_ = pg.subject_id_
  107. WHERE cse.class_group_id_ = #{classGroupId}
  108. AND status_ = 1
  109. AND version_ = 1
  110. ORDER BY create_time_ DESC
  111. LIMIT 1
  112. </select>
  113. <select id="findByClassGroupIds" resultMap="CourseScheduleEvaluate">
  114. SELECT * FROM course_schedule_evaluate WHERE class_group_id_ IN
  115. <foreach collection="classGroupIds" item="classGroupId" separator="," open="(" close=")">
  116. #{classGroupId}
  117. </foreach>
  118. AND status_=1
  119. ORDER BY create_time_ ASC
  120. </select>
  121. <resultMap id="PracticeGroupsOrgan" type="com.ym.mec.biz.dal.dto.PracticeGroupsDto">
  122. <result column="organ_id_" jdbcType="INTEGER" property="organId"/>
  123. <result column="total_nums_" jdbcType="INTEGER" property="totalNums"/>
  124. <result column="buy_nums_" jdbcType="INTEGER" property="buyNums"/>
  125. <result column="renew_nums_" jdbcType="INTEGER" property="renewNums"/>
  126. <result column="report_nums_" jdbcType="INTEGER" property="reportNums"/>
  127. <result column="total_money_" jdbcType="DECIMAL" property="totalMoney"/>
  128. </resultMap>
  129. <!-- 体验人数 -->
  130. <select id="getPracticeGroupsFree" resultMap="PracticeGroupsOrgan">
  131. SELECT organ_id_, count(distinct student_id_) total_nums_
  132. FROM practice_group
  133. WHERE group_status_ != 'LOCK'
  134. AND group_status_ != 'CANCEL'
  135. AND type_='FREE'
  136. and tenant_id_ = #{tenantId}
  137. GROUP BY organ_id_
  138. </select>
  139. <!-- 已购买人数 -->
  140. <select id="getPracticeGroupsBuy" resultMap="PracticeGroupsOrgan">
  141. SELECT organ_id_, count(distinct student_id_) buy_nums_
  142. FROM practice_group
  143. WHERE group_status_ != 'LOCK'
  144. AND group_status_ != 'CANCEL'
  145. AND buy_months_ >= 1
  146. and tenant_id_ = #{tenantId}
  147. GROUP BY organ_id_
  148. </select>
  149. <!-- 报告完成数 -->
  150. <select id="getHasReportNums" resultMap="PracticeGroupsOrgan">
  151. SELECT pg.organ_id_, count(*) report_nums_
  152. FROM course_schedule_evaluate cse
  153. LEFT JOIN practice_group pg on cse.music_group_id_ = pg.id_
  154. AND pg.type_='FREE'
  155. AND pg.group_status_ != 'LOCK'
  156. AND cse.status_ = 1
  157. and cse.tenant_id_ = #{tenantId}
  158. GROUP BY pg.organ_id_
  159. </select>
  160. <!-- 已完成课程数统计 -->
  161. <select id="getOrganPracticeGroups" resultMap="PracticeGroupsOrgan">
  162. SELECT COUNT(class_group_id_) buy_nums_, cg.total_class_times_ total_nums_, pg.organ_id_
  163. FROM course_schedule cs
  164. LEFT JOIN class_group cg on cg.id_ = cs.class_group_id_
  165. LEFT JOIN practice_group pg ON cs.music_group_id_ = pg.id_
  166. WHERE cs.group_type_ = 'PRACTICE'
  167. AND cs.status_ != 'NOT_START'
  168. AND cs.del_flag_ = 0
  169. AND pg.type_='FREE'
  170. AND pg.group_status_ != 'LOCK'
  171. and cs.tenant_id_ = #{tenantId}
  172. GROUP BY cs.class_group_id_, pg.organ_id_
  173. </select>
  174. <!-- 成交金额 -->
  175. <select id="getOrganMoney" resultMap="PracticeGroupsOrgan">
  176. SELECT SUM(actual_amount_) total_money_, organ_id_
  177. FROM student_payment_order
  178. WHERE group_type_ = 'PRACTICE'
  179. AND status_ = 'SUCCESS'
  180. and tenant_id_ = #{tenantId}
  181. GROUP BY organ_id_
  182. </select>
  183. <select id="findExpiredDateBeforeReport" resultMap="CourseScheduleEvaluate">
  184. SELECT *
  185. FROM course_schedule_evaluate
  186. WHERE status_ = 1
  187. AND create_time_ &lt;= #{expiredDate}
  188. AND (is_pushed_ = 0 OR is_pushed_ IS NULL)
  189. </select>
  190. <select id="findByGroupId" resultMap="CourseScheduleEvaluate">
  191. SELECT id_,status_,class_group_id_,version_,times_,total_minutes_, DATE_FORMAT(create_time_, '%Y年%m月') month_
  192. FROM course_schedule_evaluate
  193. WHERE music_group_id_ = #{groupId}
  194. <if test="status != null">
  195. AND status_ = #{status}
  196. </if>
  197. ORDER BY create_time_ ASC
  198. </select>
  199. <select id="findById" resultMap="CourseScheduleEvaluate">
  200. SELECT cse.*, s.name_ subject_name_, pg.student_id_
  201. FROM course_schedule_evaluate cse
  202. LEFT JOIN practice_group pg ON pg.id_ = cse.music_group_id_
  203. LEFT JOIN subject s on s.id_ = pg.subject_id_
  204. WHERE cse.id_ = #{id}
  205. </select>
  206. <select id="findByCourseAndTeacher" resultMap="CourseScheduleEvaluate">
  207. SELECT *
  208. FROM course_schedule_evaluate cse
  209. WHERE cse.teacher_id_ = #{teacherId}
  210. AND cse.course_schedule_id_ = #{courseScheduleId}
  211. </select>
  212. <select id="getNeedPostReports" resultMap="CourseScheduleEvaluate">
  213. SELECT cse.id_,cse.class_group_id_,DATE_FORMAT(cse.create_time_,'%Y年%m月') month_,pg.name_
  214. group_name_,cse.teacher_id_,pg.student_id_,su.avatar_ student_avatar_ FROM course_schedule_evaluate cse
  215. LEFT JOIN practice_group pg on cse.music_group_id_ = pg.id_
  216. LEFT JOIN sys_user su ON pg.student_id_=su.id_
  217. WHERE status_= 0 AND cse.tenant_id_ = #{tenantId}
  218. <if test="teacherId != null">
  219. AND cse.teacher_id_ = #{teacherId}
  220. </if>
  221. ORDER BY cse.create_time_ ASC
  222. </select>
  223. <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  224. INSERT INTO course_schedule_evaluate (music_group_id_, class_group_id_, course_schedule_id_, music_theory_,
  225. song_,teaching_material_, teacher_id_, item_, comment_, create_time_,update_time_,student_id_list_, version_,
  226. status_,
  227. times_,total_minutes_,tenant_id_)
  228. VALUE
  229. <foreach collection="list" item="evaluate" separator=",">
  230. (#{evaluate.musicGroupId,jdbcType=VARCHAR}, #{evaluate.classGroupId,jdbcType=INTEGER},
  231. #{evaluate.courseScheduleId,jdbcType=BIGINT},
  232. #{evaluate.musicTheory,jdbcType=VARCHAR}, #{evaluate.song,jdbcType=VARCHAR},
  233. #{evaluate.teachingMaterial,jdbcType=VARCHAR},
  234. #{evaluate.teacherId,jdbcType=INTEGER}, #{evaluate.item,jdbcType=VARCHAR},
  235. #{evaluate.comment,jdbcType=LONGVARCHAR}, #{evaluate.createTime,jdbcType=LONGVARCHAR},
  236. #{evaluate.updateTime,jdbcType=LONGVARCHAR}, #{evaluate.studentIdList},
  237. #{evaluate.version,jdbcType=INTEGER}, #{evaluate.status,jdbcType=TINYINT},
  238. #{evaluate.times,jdbcType=INTEGER},#{evaluate.totalMinutes,jdbcType=INTEGER},#{evaluate.tenantId})
  239. </foreach>
  240. </insert>
  241. <select id="getClassGroupCourseTimes" resultType="int">
  242. SELECT COUNT(*)
  243. FROM course_schedule
  244. WHERE class_group_id_ = #{classGroupId}
  245. AND (del_flag_ = 0 OR del_flag_ IS NULL)
  246. </select>
  247. <select id="hasReportList" resultMap="CourseScheduleEvaluate">
  248. SELECT COUNT(*) times_, class_group_id_ FROM course_schedule_evaluate WHERE class_group_id_ IN
  249. <foreach collection="classGroupIds" item="classGroupId" open="(" separator="," close=")">
  250. #{classGroupId}
  251. </foreach>
  252. AND DATE_FORMAT(create_time_,'%Y%m%d') = DATE_FORMAT(#{nowDate},'%Y%m%d')
  253. GROUP BY class_group_id_;
  254. </select>
  255. <select id="getPracticeGroupsRenew" resultMap="PracticeGroupsOrgan">
  256. SELECT organ_id_, count(distinct student_id_) renew_nums_
  257. FROM practice_group
  258. WHERE group_status_ != 'LOCK'
  259. AND group_status_ != 'CANCEL'
  260. AND buy_months_ >= 1
  261. AND be_renew_group_id_ >= 1
  262. and tenant_id_ = #{tenantId}
  263. GROUP BY organ_id_
  264. </select>
  265. <!-- 获取当月成交金额,续费人数(新增人数) -->
  266. <select id="getMonthOrganMoney" resultMap="PracticeGroupsOrgan">
  267. SELECT SUM(actual_amount_) total_money_, count(distinct user_id_) buy_nums_, organ_id_
  268. FROM student_payment_order
  269. WHERE type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  270. AND create_time_ >= #{startTime}
  271. AND status_ = 'SUCCESS'
  272. and tenant_id_ = #{tenantId}
  273. GROUP BY organ_id_
  274. </select>
  275. <select id="getOrganNewPracticeGroupsOfMonth" resultMap="PracticeGroupsOrgan">
  276. SELECT SUM(actual_amount_) total_money_, count(distinct user_id_) buy_nums_, organ_id_
  277. FROM student_payment_order
  278. WHERE type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  279. AND status_ = 'SUCCESS'
  280. AND create_time_ >= #{startTime}
  281. AND user_id_ NOT IN (
  282. SELECT distinct student_id_ FROM practice_group
  283. WHERE group_status_ != 'LOCK'
  284. AND group_status_ != 'CANCEL'
  285. AND buy_months_ >= 1
  286. and tenant_id_ = #{tenantId}
  287. <if test="type==@com.ym.mec.biz.dal.enums.OrderTypeEnum@PRACTICE_GROUP_BUY">
  288. <![CDATA[ AND be_renew_group_id_ IS NULL AND create_time_ < #{startTime} ]]>
  289. </if>
  290. <if test="type==@com.ym.mec.biz.dal.enums.OrderTypeEnum@PRACTICE_GROUP_RENEW">
  291. <![CDATA[ AND be_renew_group_id_ >= 1 AND create_time_ < #{startTime} ]]>
  292. </if>
  293. )
  294. GROUP BY organ_id_
  295. </select>
  296. <resultMap id="practice4Organ" type="com.ym.mec.biz.dal.dto.Practice4OrganDto">
  297. <result column="organ_name_" property="organName"/>
  298. <result column="organ_id_" property="organId"/>
  299. <result column="try_num_" property="tryNum"/>
  300. <result column="vip_num_" property="vipNum"/>
  301. <result column="practice_num_" property="practiceNum"/>
  302. <result column="vip4_month_num_" property="vip4MonthNum"/>
  303. <result column="practice4_month_num_" property="practice4MonthNum"/>
  304. <result column="renew4_month_num_" property="renew4MonthNum"/>
  305. <result column="change4_month_num_" property="change4MonthNum"/>
  306. <result column="total_money_" property="totalMoney"/>
  307. <result column="student_ids_" property="studentIds"/>
  308. </resultMap>
  309. <!-- 体验人数(除去禁止的) -->
  310. <select id="getTryNums" resultMap="practice4Organ">
  311. SELECT pg.organ_id_, count(distinct pg.student_id_) try_num_
  312. FROM practice_group pg
  313. LEFT JOIN student s ON s.user_id_ = pg.student_id_
  314. WHERE pg.group_status_ IN ('NORMAL', 'FINISH')
  315. AND s.operating_tag_ = 1
  316. AND pg.type_='FREE'
  317. and pg.tenant_id_ = #{tenantId}
  318. GROUP BY pg.organ_id_
  319. </select>
  320. <!-- 网管课体验人数(禁止的) -->
  321. <select id="getPracticeTryNums" resultMap="practice4Organ">
  322. SELECT pg.organ_id_, count(distinct pg.student_id_) try_num_
  323. FROM practice_group pg
  324. LEFT JOIN student s ON s.user_id_ = pg.student_id_
  325. WHERE pg.group_status_ IN ('NORMAL', 'FINISH')
  326. AND pg.buy_months_ >= 1
  327. AND s.operating_tag_ = 0
  328. and pg.tenant_id_ = #{tenantId}
  329. GROUP BY pg.organ_id_
  330. </select>
  331. <!-- vip体验人数(禁止的) -->
  332. <select id="getVipTryNums" resultMap="practice4Organ">
  333. SELECT vg.organ_id_, COUNT(DISTINCT cssp.user_id_) try_num_
  334. FROM course_schedule_student_payment cssp
  335. LEFT JOIN vip_group vg ON cssp.music_group_id_ = vg.id_ AND cssp.group_type_ = 'VIP'
  336. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_ AND cs.teach_mode_ = 'ONLINE'
  337. LEFT JOIN student s ON s.user_id_ = cssp.user_id_
  338. WHERE cs.id_ >= 1
  339. AND vg.id_ >= 1
  340. AND (cs.is_lock_ IS NULL OR cs.is_lock_ = 0)
  341. AND s.operating_tag_ = 0
  342. and cssp.tenant_id_ = #{tenantId}
  343. GROUP BY vg.organ_id_
  344. </select>
  345. <select id="getPracticeAndVipTryNums" resultMap="practice4Organ">
  346. SELECT pg.organ_id_, COUNT(DISTINCT pg.student_id_) try_num_
  347. FROM practice_group pg
  348. LEFT JOIN course_schedule_student_payment cssp
  349. ON cssp.user_id_ = pg.student_id_ AND cssp.group_type_ = 'VIP'
  350. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_ AND cs.teach_mode_ = 'ONLINE'
  351. LEFT JOIN student s ON s.user_id_ = cssp.user_id_
  352. WHERE pg.group_status_ IN ('NORMAL', 'FINISH')
  353. AND pg.buy_months_ >= 1
  354. AND cs.id_ >= 1
  355. AND (cs.is_lock_ IS NULL OR cs.is_lock_ = 0)
  356. AND s.operating_tag_ = 0
  357. and pg.tenant_id_ = #{tenantId}
  358. GROUP BY pg.organ_id_
  359. </select>
  360. <select id="getVipBuyNums" resultMap="practice4Organ">
  361. SELECT su.organ_id_,COUNT(DISTINCT cssp.user_id_) vip_num_
  362. FROM course_schedule_student_payment cssp
  363. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_ AND cssp.group_type_='VIP'
  364. left JOIN sys_user su ON su.id_=cssp.user_id_
  365. WHERE CONCAT(cs.class_date_, ' ', cs.end_class_time_) >= #{classDate}
  366. <if test="endDate != null">
  367. <![CDATA[AND CONCAT(cs.class_date_, ' ', cs.end_class_time_) < #{endDate}]]>
  368. </if>
  369. AND cs.teach_mode_ = 'ONLINE'
  370. AND (cs.is_lock_ IS NULL OR cs.is_lock_=0)
  371. AND (cs.del_flag_ IS NULL OR cs.del_flag_=0)
  372. and cssp.tenant_id_ = #{tenantId}
  373. GROUP BY su.organ_id_
  374. </select>
  375. <select id="getPracticeBuyNums" resultMap="practice4Organ">
  376. SELECT pg.organ_id_, COUNT(DISTINCT cssp.user_id_) practice_num_
  377. FROM course_schedule_student_payment cssp
  378. LEFT JOIN practice_group pg ON cssp.music_group_id_ = pg.id_ AND cssp.group_type_ = 'PRACTICE'
  379. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  380. WHERE pg.id_ >= 1
  381. AND pg.group_status_ IN ('NORMAL', 'FINISH')
  382. AND cs.id_ >=1
  383. AND (cs.is_lock_ IS NULL OR cs.is_lock_=0)
  384. AND (cs.del_flag_ IS NULL OR cs.del_flag_=0)
  385. AND CONCAT(cs.class_date_, ' ', cs.end_class_time_) >= #{classDate}
  386. <if test="endDate != null">
  387. <![CDATA[AND CONCAT(cs.class_date_, ' ', cs.end_class_time_) < #{endDate}]]>
  388. </if>
  389. and cssp.tenant_id_ = #{tenantId}
  390. AND pg.buy_months_ >= 1
  391. GROUP BY pg.organ_id_
  392. </select>
  393. <select id="getPracticeAndVipNums" resultMap="practice4Organ">
  394. SELECT pg.organ_id_,COUNT(DISTINCT pg.student_id_) practice_num_
  395. FROM practice_group pg
  396. LEFT JOIN course_schedule_student_payment vcssp ON vcssp.user_id_ = pg.student_id_ AND vcssp.group_type_='VIP'
  397. LEFT JOIN course_schedule_student_payment pcssp ON pcssp.user_id_ = pg.student_id_ AND
  398. pcssp.group_type_='PRACTICE'
  399. LEFT JOIN course_schedule vcs ON vcs.id_=vcssp.course_schedule_id_ AND vcs.teach_mode_='ONLINE'
  400. LEFT JOIN course_schedule pcs ON pcs.id_=pcssp.course_schedule_id_
  401. WHERE pg.group_status_ IN ('NORMAL', 'FINISH')
  402. AND vcs.id_ >=1
  403. AND pcs.id_ >= 1
  404. AND (vcs.is_lock_ IS NULL OR vcs.is_lock_=0)
  405. AND (vcs.del_flag_ IS NULL OR vcs.del_flag_=0)
  406. AND (pcs.is_lock_ IS NULL OR pcs.is_lock_=0)
  407. AND (pcs.del_flag_ IS NULL OR pcs.del_flag_=0)
  408. AND CONCAT(vcs.class_date_, ' ', vcs.end_class_time_) >= #{classDate}
  409. AND CONCAT(pcs.class_date_, ' ', pcs.end_class_time_) >= #{classDate}
  410. <if test="endDate != null">
  411. <![CDATA[AND CONCAT(vcs.class_date_, ' ', vcs.end_class_time_) < #{endDate}
  412. AND CONCAT(pcs.class_date_, ' ', pcs.end_class_time_) < #{endDate}]]>
  413. </if>
  414. and pg.tenant_id_ = #{tenantId}
  415. AND pg.buy_months_ >= 1
  416. GROUP BY pg.organ_id_
  417. </select>
  418. <!-- 获取所有体验人数 -->
  419. <select id="getAllTryNums" resultMap="practice4Organ">
  420. SELECT su.organ_id_, COUNT(s.user_id_) try_num_
  421. FROM student s
  422. LEFT JOIN sys_user su ON su.id_ = s.user_id_
  423. WHERE s.operating_tag_ = 1
  424. AND su.organ_id_ > 0
  425. and s.tenant_id_ = #{tenantId}
  426. AND su.user_type_ LIKE '%STUDENT%'
  427. GROUP BY su.organ_id_
  428. </select>
  429. </mapper>