CloudTeacherOrderMapper.xml 23 KB

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