CloudTeacherOrderMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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.CloudTeacherOrderDao">
  4. <resultMap id="CloudTeacherOrder" type="com.ym.mec.biz.dal.entity.CloudTeacherOrder">
  5. <!--@mbg.generated-->
  6. <!--@Table cloud_teacher_order-->
  7. <id column="id_" property="id"/>
  8. <result column="organ_id_" property="organId"/>
  9. <result column="student_id_" property="studentId"/>
  10. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  11. <result column="level_" property="level"/>
  12. <result column="time_" property="time"/>
  13. <result column="amount_" property="amount"/>
  14. <result column="operating_amount_" property="operatingAmount"/>
  15. <result column="refund_amount_" property="refundAmount"/>
  16. <result column="status_" property="status"/>
  17. <result column="start_time_" property="startTime"/>
  18. <result column="end_time_" property="endTime"/>
  19. <result column="order_id_" property="orderId"/>
  20. <result column="platform_order_id_" property="platformOrderId"/>
  21. <result column="remark_" property="remark"/>
  22. <result column="active_remark_" property="activeRemark"/>
  23. <result column="version_" property="version"/>
  24. <result column="create_time_" property="createTime"/>
  25. <result column="update_time_" property="updateTime"/>
  26. <result column="music_group_id_" property="musicGroupId"/>
  27. <result column="tenant_id_" property="tenantId" />
  28. </resultMap>
  29. <resultMap type="com.ym.mec.biz.dal.dto.CloudTeacherOrderDto" id="CloudTeacherOrderDto">
  30. <id column="id_" property="cloudTeacherOrder.id"/>
  31. <result column="organ_id_" property="cloudTeacherOrder.organId"/>
  32. <result column="student_id_" property="cloudTeacherOrder.studentId"/>
  33. <result column="type_" property="cloudTeacherOrder.type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  34. <result column="level_" property="cloudTeacherOrder.level"/>
  35. <result column="time_" property="cloudTeacherOrder.time"/>
  36. <result column="amount_" property="cloudTeacherOrder.amount"/>
  37. <result column="operating_amount_" property="cloudTeacherOrder.operatingAmount"/>
  38. <result column="refund_amount_" property="cloudTeacherOrder.refundAmount"/>
  39. <result column="status_" property="cloudTeacherOrder.status"/>
  40. <result column="start_time_" property="cloudTeacherOrder.startTime"/>
  41. <result column="end_time_" property="cloudTeacherOrder.endTime"/>
  42. <result column="order_id_" property="cloudTeacherOrder.orderId"/>
  43. <result column="platform_order_id_" property="cloudTeacherOrder.platformOrderId"/>
  44. <result column="trans_status_" property="studentPaymentOrder.status"/>
  45. <result column="expect_amount_" property="studentPaymentOrder.expectAmount"/>
  46. <result column="pay_time_" property="studentPaymentOrder.payTime"/>
  47. <result column="order_create_time_" property="studentPaymentOrder.createTime"/>
  48. <result column="name_" property="memberRankSetting.name"/>
  49. <result column="icon_" property="memberRankSetting.icon"/>
  50. <result column="music_group_id_" property="studentPaymentOrder.musicGroupId"/>
  51. </resultMap>
  52. <select id="get" resultMap="CloudTeacherOrder">
  53. select * from cloud_teacher_order where id_ = #{id}
  54. </select>
  55. <delete id="delete">
  56. delete from cloud_teacher_order
  57. where id_ = #{id}
  58. </delete>
  59. <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.CloudTeacherOrder"
  60. useGeneratedKeys="true">
  61. INSERT INTO cloud_teacher_order (organ_id_,student_id_, type_, level_, time_, amount_, operating_amount_, refund_amount_, status_,
  62. order_id_,platform_order_id_,start_time_,end_time_,remark_, create_time_, update_time_,music_group_id_,active_remark_,tenant_id_)
  63. VALUES (#{organId},#{studentId}, #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{level}, #{time}, #{amount}, #{operatingAmount}, #{refundAmount},
  64. #{status},#{orderId},#{platformOrderId},#{startTime},#{endTime}, #{remark}, NOW(), NOW(),#{musicGroupId},#{activeRemark},#{tenantId})
  65. </insert>
  66. <update id="update" parameterType="com.ym.mec.biz.dal.entity.CloudTeacherOrder">
  67. <!--@mbg.generated-->
  68. update cloud_teacher_order
  69. <set>
  70. <if test="activeRemark != null">
  71. active_remark_ = #{activeRemark},
  72. </if>
  73. <if test="musicGroupId != null">
  74. music_group_id_ = #{musicGroupId},
  75. </if>
  76. <if test="organId != null">
  77. organ_id_ = #{organId},
  78. </if>
  79. <if test="studentId != null">
  80. student_id_ = #{studentId},
  81. </if>
  82. <if test="type != null">
  83. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  84. </if>
  85. <if test="level != null">
  86. level_ = #{level},
  87. </if>
  88. <if test="time != null">
  89. time_ = #{time},
  90. </if>
  91. <if test="amount != null">
  92. amount_ = #{amount},
  93. </if>
  94. <if test="operatingAmount != null">
  95. operating_amount_ = #{operatingAmount},
  96. </if>
  97. <if test="refundAmount != null">
  98. refund_amount_ = #{refundAmount},
  99. </if>
  100. <if test="status != null">
  101. status_ = #{status},
  102. </if>
  103. <if test="startTime != null">
  104. start_time_ = #{startTime},
  105. </if>
  106. <if test="endTime != null">
  107. end_time_ = #{endTime},
  108. </if>
  109. <if test="orderId != null">
  110. order_id_ = #{orderId},
  111. </if>
  112. <if test="platformOrderId != null">
  113. platform_order_id_ = #{platformOrderId},
  114. </if>
  115. <if test="remark != null">
  116. remark_ = #{remark},
  117. </if>
  118. version_ = version_+1,
  119. update_time_ = NOW(),
  120. </set>
  121. where id_ = #{id} AND version_ = #{version} and tenant_id_ = #{tenantId}
  122. </update>
  123. <select id="findByPlatformOrderId" resultMap="CloudTeacherOrder">
  124. select * from cloud_teacher_order cto
  125. left join sys_user su on cto.student_id_ = su.id_
  126. where cto.platform_order_id_ = #{platformOrderId} and su.del_flag_ = 0
  127. </select>
  128. <resultMap type="com.ym.mec.biz.dal.dto.Mapper" id="mapper">
  129. <result column="userId" property="key"/>
  130. <result column="phone" property="value"/>
  131. </resultMap>
  132. <select id="findUserNameByOrderId" resultMap="mapper">
  133. select su.id_ as userId, su.phone_ as phone from cloud_teacher_order cto
  134. left join sys_user su on cto.student_id_ = su.id_
  135. where platform_order_id_ = #{platformOrderId} and su.del_flag_ = 0
  136. </select>
  137. <update id="updateOrderStatusOK">
  138. update cloud_teacher_order set status_ = 2,
  139. `start_time_` = CURRENT_DATE(),
  140. `end_time_` = case
  141. when type_ = 1 then concat(date_add(CURRENT_DATE(), interval `time_` day) , ' 00:00:00')
  142. when type_ = 2 then concat(date_add(CURRENT_DATE(), interval `time_` month) , ' 00:00:00')
  143. when type_ = 3 then concat(date_add(CURRENT_DATE(), interval `time_` * 3 month) , ' 00:00:00')
  144. when type_ = 4 then concat(date_add(CURRENT_DATE(), interval `time_` * 6 month) , ' 00:00:00')
  145. when type_ = 5 then concat(date_add(CURRENT_DATE(), interval `time_` year) , ' 00:00:00')
  146. end
  147. where platform_order_id_ = #{platformOrderId}
  148. </update>
  149. <update id="updateOrderId">
  150. update cloud_teacher_order
  151. set platform_order_id_ = #{platformOrderId} , pay_amount_ = #{amount}
  152. where id_ = #{cloudTeacherOrderId}
  153. </update>
  154. <!-- 全查询 -->
  155. <select id="findAll" resultMap="CloudTeacherOrder">
  156. SELECT *
  157. FROM cloud_teacher_order where tenant_id_ = #{tenantId}
  158. </select>
  159. <!-- 分页查询 -->
  160. <select id="queryPage" resultMap="CloudTeacherOrderDto" parameterType="map">
  161. SELECT cto.*,spo.status_ trans_status_,spo.expect_amount_,spo.pay_time_,spo.create_time_ order_create_time_,mrs.name_,mrs.icon_ FROM cloud_teacher_order cto
  162. left join student_payment_order spo on cto.order_id_ = spo.id_
  163. left join member_rank_setting mrs on mrs.id_ = cto.level_
  164. where spo.type_ = 'MEMBER'
  165. <if test="status != null">
  166. and cto.status_ = #{status}
  167. </if>
  168. <if test="studentId != null">
  169. and cto.student_id_ = #{studentId}
  170. </if>
  171. <if test="tenantId != null">
  172. and cto.tenant_id_ = #{tenantId}
  173. </if>
  174. order by spo.pay_time_ desc,spo.id_ desc
  175. <include refid="global.limit"/>
  176. </select>
  177. <!-- 查询当前表的总记录数 -->
  178. <select id="queryCount" resultType="int">
  179. SELECT COUNT(cto.id_)
  180. FROM cloud_teacher_order cto LEFT JOIN student_payment_order spo on cto.order_id_ = spo.id_
  181. where spo.type_ = 'MEMBER'
  182. <if test="status != null">
  183. and cto.status_ = #{status}
  184. </if>
  185. <if test="studentId != null">
  186. and cto.student_id_ = #{studentId}
  187. </if>
  188. <if test="tenantId != null">
  189. and cto.tenant_id_ = #{tenantId}
  190. </if>
  191. order by cto.create_time_ desc
  192. </select>
  193. <select id="getNoStartCloudTeacherOrder" resultMap="CloudTeacherOrder">
  194. SELECT cto.*
  195. FROM cloud_teacher_order cto
  196. WHERE cto.status_ = 1 and cto.tenant_id_ = #{tenantId}
  197. </select>
  198. <select id="getStudentCloudTeacherOrders" resultMap="CloudTeacherOrder">
  199. SELECT *
  200. FROM cloud_teacher_order
  201. WHERE order_id_ IN (
  202. SELECT id_
  203. FROM student_payment_order
  204. WHERE status_ = 'SUCCESS'
  205. AND user_id_ IN
  206. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  207. #{studentId}
  208. </foreach>
  209. GROUP BY user_id_
  210. )
  211. AND student_id_ IN
  212. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  213. #{studentId}
  214. </foreach>
  215. AND status_ IN (1,2)
  216. </select>
  217. <select id="queryByOrderId" resultMap="CloudTeacherOrder">
  218. SELECT cto.* FROM cloud_teacher_order cto
  219. WHERE order_id_ = #{orderId}
  220. </select>
  221. <select id="queryOrderInfoByOrderId" resultMap="CloudTeacherOrderDto">
  222. SELECT cto.*,spo.status_ trans_status_,spo.expect_amount_,mrs.name_,mrs.icon_ FROM cloud_teacher_order cto
  223. left join student_payment_order spo on cto.order_id_ = spo.id_
  224. left join member_rank_setting mrs on mrs.id_ = cto.level_
  225. where spo.type_ = 'MEMBER' and order_id_ = #{orderId}
  226. </select>
  227. <select id="queryNoStartByUserIds" resultType="java.util.Map">
  228. SELECT student_id_ 'key',create_time_ 'value' FROM cloud_teacher_order
  229. WHERE status_ = 1
  230. <if test="userIds != null and userIds.size > 0">
  231. AND student_id_ IN
  232. <foreach collection="userIds" separator="," item="userId" open="(" close=")">
  233. #{userId}
  234. </foreach>
  235. </if>
  236. GROUP BY student_id_
  237. </select>
  238. <resultMap id="CloudTeacherActiveTargetDetailDto" type="com.ym.mec.biz.dal.dto.CloudTeacherActiveTargetDetailDto">
  239. <result property="userId" column="student_id_"/>
  240. <result property="username" column="username_"/>
  241. <result property="amount" column="amount_"/>
  242. <result property="remark" column="remark_"/>
  243. <result property="cooperationName" column="cooperation_name_"/>
  244. <result property="musicGroupName" column="music_group_name_"/>
  245. <result property="chargeType" column="charge_type_name_"/>
  246. <result property="subjectName" column="subject_name_"/>
  247. <result property="currentGradeNum" column="current_grade_num_"/>
  248. <result property="createTime" column="create_time_"/>
  249. </resultMap>
  250. <select id="queryCloudTeacherActiveDetail" resultMap="CloudTeacherActiveTargetDetailDto">
  251. SELECT su.username_,cto.remark_,cto.amount_,cto.student_id_,GROUP_CONCAT(DISTINCT co.name_) cooperation_name_,
  252. GROUP_CONCAT(DISTINCT mg.name_) music_group_name_,GROUP_CONCAT(DISTINCT case when mg.course_view_type_ = 2 then '会员收费' when mg.course_view_type_ = 3 then '免费' else '课程收费' end) charge_type_name_,
  253. sj.name_ subject_name_,st.current_grade_num_,cto.create_time_
  254. FROM cloud_teacher_order cto
  255. LEFT JOIN sys_user su ON su.id_ = cto.student_id_
  256. LEFT JOIN student_registration sr ON sr.user_id_ = cto.student_id_ AND sr.music_group_status_ = 'NORMAL'
  257. LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_ AND mg.status_ = 'PROGRESS'
  258. LEFT JOIN cooperation_organ co ON co.id_ = mg.cooperation_organ_id_
  259. LEFT JOIN student st ON st.user_id_ = cto.student_id_
  260. LEFT JOIN `subject` sj ON sj.id_ = st.subject_id_list_
  261. <include refid="queryCloudTeacherActiveDetailSql"/>
  262. GROUP BY cto.id_
  263. ORDER BY cto.id_ DESC
  264. <include refid="global.limit"/>
  265. </select>
  266. <select id="countCloudTeacherActiveDetail" resultType="int">
  267. SELECT COUNT(DISTINCT cto.id_)
  268. FROM cloud_teacher_order cto
  269. LEFT JOIN sys_user su ON su.id_ = cto.student_id_
  270. LEFT JOIN student st ON st.user_id_ = cto.student_id_
  271. LEFT JOIN student_registration sr ON sr.user_id_ = cto.student_id_ AND sr.music_group_status_ = 'NORMAL'
  272. LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_ AND mg.status_ = 'PROGRESS'
  273. <include refid="queryCloudTeacherActiveDetailSql"/>
  274. </select>
  275. <select id="queryActiveOrderPage" resultType="string">
  276. SELECT GROUP_CONCAT(DISTINCT cto.remark_) FROM cloud_teacher_order cto
  277. LEFT JOIN student_payment_order spo ON spo.id_ = cto.order_id_
  278. WHERE spo.status_ = 'SUCCESS' AND cto.active_remark_ = #{activeRemark}
  279. AND cto.student_id_ = #{userId} AND cto.remark_ != '单月'
  280. <if test="remark != null and remark != ''">
  281. AND cto.remark_ = #{remark}
  282. </if>
  283. </select>
  284. <select id="getStudentIds" resultType="java.lang.Integer">
  285. SELECT DISTINCT student_id_ FROM cloud_teacher_order WHERE active_remark_ IS NULL AND status_ != 0 and tenant_id_ = #{tenantId}
  286. </select>
  287. <select id="queryActiveAmountMap" resultType="java.util.Map">
  288. SELECT student_id_ 'key',SUM(amount_) 'value' FROM cloud_teacher_order
  289. WHERE status_ != 0 AND active_remark_ = '202109'
  290. <if test="studentIds != null and studentIds.size > 0">
  291. AND student_id_ IN
  292. <foreach collection="studentIds" separator="," item="userId" open="(" close=")">
  293. #{userId}
  294. </foreach>
  295. </if>
  296. GROUP BY student_id_
  297. </select>
  298. <resultMap id="cloudTeacherStudent" type="com.ym.mec.biz.dal.entity.CloudTeacherStudent">
  299. <result property="type" column="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  300. </resultMap>
  301. <!-- 查询激活或未激活记录 -->
  302. <select id="queryInactive" resultMap="cloudTeacherStudent">
  303. select
  304. cto.id_ as cloudTeacherOrderId,
  305. cto.student_id_ as studentId,
  306. cto.type_ as type,
  307. case cto.type_
  308. WHEN 'DAY' THEN '天'
  309. WHEN 'MONTH' THEN '月'
  310. WHEN 'QUARTERLY' THEN '季'
  311. WHEN 'YEAR_HALF' THEN '半年'
  312. WHEN 'YEAR' THEN '年' ELSE ''
  313. end as typeName,
  314. cto.time_ as time,
  315. sj.id_ as subject,
  316. sj.name_ as subjectName,
  317. cto.tenant_id_ as tenantId,
  318. u.username_ as name,
  319. u.phone_ as phone
  320. from cloud_teacher_order cto
  321. left join student s on cto.student_id_ = s.user_id_
  322. left join sys_user u on cto.student_id_ = u.id_
  323. left join subject sj on s.subject_id_list_ = sj.id_
  324. <if test="musicGroupId != null and musicGroupId != ''">
  325. left join student_registration sr ON cto.student_id_ = sr.user_id_
  326. </if>
  327. <where>
  328. cto.status_ = #{status} AND cto.tenant_id_ = #{tenantId}
  329. <if test="organIds != null and organIds != ''">
  330. AND FIND_IN_SET(u.organ_id_ , #{organIds})
  331. </if>
  332. <if test="musicGroupId != null and musicGroupId != ''">
  333. AND sr.music_group_id_ = #{musicGroupId}
  334. </if>
  335. <if test="queryCondition != null and queryCondition != ''">
  336. AND (u.username_ LIKE CONCAT('%', #{queryCondition}, '%') or u.phone_ = #{queryCondition} or u.id_ = #{queryCondition})
  337. </if>
  338. <if test="subjectId">
  339. AND (s.subject_id_list_ = #{subjectId})
  340. </if>
  341. </where>
  342. ORDER BY cto.id_ DESC
  343. <include refid="global.limit"/>
  344. </select>
  345. <select id="findInactiveCount" resultType="java.lang.Integer">
  346. select count(1) from cloud_teacher_order cto
  347. left join student s on cto.student_id_ = s.user_id_
  348. left join sys_user u on cto.student_id_ = u.id_
  349. left join subject sj on s.subject_id_list_ = sj.id_
  350. <if test="musicGroupId != null and musicGroupId != ''">
  351. left join student_registration sr ON cto.student_id_ = sr.user_id_
  352. </if>
  353. <where>
  354. cto.status_ = #{status} AND cto.tenant_id_ = #{tenantId}
  355. <if test="organIds != null and organIds != ''">
  356. AND FIND_IN_SET(u.organ_id_ , #{organIds})
  357. </if>
  358. <if test="musicGroupId != null and musicGroupId != ''">
  359. AND sr.music_group_id_ = #{musicGroupId}
  360. </if>
  361. <if test="queryCondition != null and queryCondition != ''">
  362. AND (u.username_ LIKE CONCAT('%', #{queryCondition}, '%') or u.phone_ = #{queryCondition} or u.id_ = #{queryCondition})
  363. </if>
  364. <if test="subjectId">
  365. AND (s.subject_id_list_ = #{subjectId})
  366. </if>
  367. </where>
  368. </select>
  369. <!-- 查询订单记录 -->
  370. <select id="findRecordCount" resultType="java.lang.Integer">
  371. SELECT count(1) FROM tenant_order_record tor
  372. LEFT JOIN cloud_teacher_order cto ON tor.id_ = cto.platform_order_id_
  373. LEFT JOIN student s ON cto.student_id_ = s.user_id_
  374. LEFT JOIN sys_user u ON cto.student_id_ = u.id_
  375. <where>
  376. cto.tenant_id_ = #{tenantId} AND tor.order_type_ = 'CLOUD_TEACHER' AND tor.order_state_ = 1
  377. <if test="queryCondition != null and queryCondition != ''">
  378. AND (u.username_ LIKE CONCAT('%', #{queryCondition}, '%') or u.phone_ = #{queryCondition} or u.id_ = #{queryCondition})
  379. </if>
  380. <if test="orderNo != null and orderNo != ''">
  381. AND tor.order_no_ LIKE CONCAT('%', #{orderNo}, '%')
  382. </if>
  383. <if test="startTime != null">
  384. <![CDATA[ AND tor.created_time_ >= #{startTime} ]]>
  385. </if>
  386. <if test="endTime != null">
  387. <![CDATA[ AND tor.created_time_ <= #{endTime} ]]>
  388. </if>
  389. </where>
  390. </select>
  391. <select id="queryRecord" resultMap="cloudTeacherStudent">
  392. SELECT
  393. cto.id_ AS cloudTeacherOrderId,
  394. cto.student_id_ AS studentId,
  395. cto.type_ AS type,
  396. CASE cto.type_ WHEN 'DAY' THEN '天'
  397. WHEN 'MONTH' THEN '月'
  398. WHEN 'QUARTERLY' THEN '季'
  399. WHEN 'YEAR_HALF' THEN '半年'
  400. WHEN 'YEAR' THEN '年' ELSE ''
  401. END AS typeName,
  402. cto.time_ AS time,
  403. u.tenant_id_ AS tenantId,
  404. u.username_ AS name,
  405. u.phone_ AS phone,
  406. tor.order_no_ as orderNo,
  407. tor.trans_no_ as transNo,
  408. tor.created_time_ as orderTime,
  409. cto.pay_amount_ as amount
  410. FROM tenant_order_record tor
  411. LEFT JOIN cloud_teacher_order cto ON tor.id_ = cto.platform_order_id_
  412. LEFT JOIN student s ON cto.student_id_ = s.user_id_
  413. LEFT JOIN sys_user u ON cto.student_id_ = u.id_
  414. <where>
  415. cto.tenant_id_ = #{tenantId} AND tor.order_type_ = 'CLOUD_TEACHER' AND tor.order_state_ = 1
  416. <if test="queryCondition != null and queryCondition != ''">
  417. AND (u.username_ LIKE CONCAT('%', #{queryCondition}, '%') or u.phone_ = #{queryCondition} or u.id_ = #{queryCondition})
  418. </if>
  419. <if test="orderNo != null and orderNo != ''">
  420. AND tor.order_no_ LIKE CONCAT('%', #{orderNo}, '%')
  421. </if>
  422. <if test="startTime != null">
  423. <![CDATA[ AND tor.created_time_ >= #{startTime} ]]>
  424. </if>
  425. <if test="endTime != null">
  426. <![CDATA[ AND tor.created_time_ <= #{endTime} ]]>
  427. </if>
  428. </where>
  429. <include refid="global.limit"/>
  430. </select>
  431. <select id="checkOrdered" resultType="java.lang.Integer">
  432. select count(1) from cloud_teacher_order where id_ in (${cloudTeacherStudentIds}) and status_ = 2 and platform_order_id_ is not null
  433. </select>
  434. <sql id="queryCloudTeacherActiveDetailSql">
  435. <where>
  436. cto.status_ != 0 AND cto.active_remark_ = '202109'
  437. <if test="organIds != null and organIds != ''">
  438. AND FIND_IN_SET(su.organ_id_,#{organIds})
  439. </if>
  440. <if test="search != null and search != ''">
  441. AND (su.id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR mg.id_ LIKE CONCAT('%',#{search},'%'))
  442. </if>
  443. <if test="subjectId != null">
  444. AND st.subject_id_list_ = #{subjectId}
  445. </if>
  446. <if test="tenantId != null">
  447. AND cto.tenant_id_ = #{tenantId}
  448. </if>
  449. <if test="remarkType != null and remarkType != ''">
  450. AND cto.remark_ = #{remarkType}
  451. </if>
  452. </where>
  453. </sql>
  454. <insert id="batchInsert">
  455. INSERT INTO cloud_teacher_order (organ_id_,student_id_, type_, level_, time_, amount_,status_,
  456. remark_,create_time_, update_time_,tenant_id_)
  457. VALUES
  458. <foreach collection="userIds" item="userId" separator=",">
  459. (#{bean.organId},#{userId},#{bean.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{bean.level},
  460. #{bean.time}, #{bean.amount},#{bean.status},#{bean.remark},NOW(),NOW(),#{bean.tenantId})
  461. </foreach>
  462. </insert>
  463. <select id="queryByUserIdAndStatus" resultMap="CloudTeacherOrder">
  464. select cto.* from cloud_teacher_order cto where cto.student_id_ = #{userId} and cto.status_ = #{status}
  465. </select>
  466. <select id="getWaitActivateMap" resultType="java.util.Map">
  467. select cto.organ_id_ 'key',COUNT(DISTINCT cto.student_id_) 'value' from cloud_teacher_order cto
  468. left join student s ON s.user_id_ = cto.student_id_
  469. left join student_registration sr ON sr.user_id_ = cto.student_id_
  470. left join music_group mg ON mg.id_ = sr.music_group_id_
  471. where cto.status_ = 1 AND (s.membership_end_time_ &lt; NOW() OR s.membership_end_time_ IS NULL)
  472. AND sr.music_group_status_ = 'NORMAL' AND mg.status_ IN ('PROGRESS','PAUSE')
  473. <if test="organIds != null and organIds.size > 0">
  474. AND cto.organ_id_ IN
  475. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  476. #{organId}
  477. </foreach>
  478. </if>
  479. group by cto.organ_id_
  480. </select>
  481. </mapper>