MusicGroupPaymentCalenderMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  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.MusicGroupPaymentCalenderDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" id="MusicGroupPaymentCalender">
  9. <result column="id_" property="id"/>
  10. <result column="music_group_id_" property="musicGroupId"/>
  11. <result column="tenant_id_" property="tenantId"/>
  12. <result column="organ_id_" property="organId"/>
  13. <result column="name_" property="name"/>
  14. <result column="music_group_organization_course_settings_id_" property="musicGroupOrganizationCourseSettingId"/>
  15. <result column="pay_user_type_" property="payUserType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  16. <result column="start_payment_date_" property="startPaymentDate"/>
  17. <result column="deadline_payment_date_" property="deadlinePaymentDate"/>
  18. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  19. <result column="expect_num_" property="expectNum"/>
  20. <result column="actual_num_" property="actualNum"/>
  21. <result column="memo_" property="memo"/>
  22. <result column="audit_memo_" property="auditMemo"/>
  23. <result column="reject_reason_" property="rejectReason"/>
  24. <result column="is_give_music_network_" property="isGiveMusicNetwork"/>
  25. <result column="create_time_" property="createTime"/>
  26. <result column="update_time_" property="updateTime"/>
  27. <result column="payment_valid_start_date_" property="paymentValidStartDate"/>
  28. <result column="payment_valid_end_date_" property="paymentValidEndDate"/>
  29. <result column="payment_pattern_" property="paymentPattern"/>
  30. <result column="payment_type_" property="paymentType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  31. <result column="batch_no_" property="batchNo"/>
  32. <result column="payment_amount_" property="paymentAmount"/>
  33. <result column="attribute1_" property="attribute1"/>
  34. <result column="attribute2_" property="attribute2"/>
  35. <result column="student_ids_" property="studentIds"/>
  36. <result column="member_payment_amount_" property="memberPaymentAmount"/>
  37. <result column="original_member_payment_amount_" property="originalMemberPaymentAmount"/>
  38. <result column="member_rank_setting_id_" property="memberRankSettingId"/>
  39. <result column="member_valid_date_" property="memberValidDate"/>
  40. <result column="current_total_amount_" property="currentTotalAmount"/>
  41. <result column="original_total_amount_" property="originalTotalAmount"/>
  42. <result column="payment_item_show_state_" property="paymentItemShowState"/>
  43. <result column="is_show_sale_price_" property="isShowSalePrice"/>
  44. <result column="calender_fee_type_" property="calenderFeeType"/>
  45. <result column="calender_fee_json_" property="calenderFeeJson"/>
  46. <result column="contract_url_" property="contractUrl"/>
  47. </resultMap>
  48. <!-- 根据主键查询一条记录 -->
  49. <select id="get" resultMap="MusicGroupPaymentCalender">
  50. SELECT * FROM music_group_payment_calender WHERE id_ = #{id}
  51. </select>
  52. <!-- 全查询 -->
  53. <select id="findAll" resultMap="MusicGroupPaymentCalender">
  54. SELECT * FROM music_group_payment_calender where tenant_id_ = #{tenantId} ORDER BY id_
  55. </select>
  56. <!-- 向数据库增加一条记录 -->
  57. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
  58. keyColumn="id_" keyProperty="id">
  59. INSERT INTO music_group_payment_calender
  60. (name_,music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
  61. actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,
  62. payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_,attribute1_,
  63. attribute2_,student_ids_,member_payment_amount_,member_rank_setting_id_,member_valid_date_
  64. ,original_member_payment_amount_,current_total_amount_,original_total_amount_,tenant_id_,organ_id_,
  65. cloud_teacher_payment_flag_,payment_item_show_state_,is_show_sale_price_,calender_fee_type_,calender_fee_json_,contract_url_)
  66. VALUES(#{name},#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  67. #{rejectReason},#{startPaymentDate},#{deadlinePaymentDate},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  68. #{expectNum},#{actualNum},#{memo},#{isGiveMusicNetwork},now(),now(),
  69. #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  70. #{paymentAmount},#{batchNo},#{auditMemo},#{operator},#{attribute1},#{attribute2},#{studentIds},
  71. #{memberPaymentAmount},#{memberRankSettingId},#{memberValidDate},#{originalMemberPaymentAmount},
  72. #{currentTotalAmount},#{originalTotalAmount},#{tenantId},#{organId},#{cloudTeacherPaymentFlag},
  73. #{paymentItemShowState},#{isShowSalePrice},#{calenderFeeType},#{calenderFeeJson},#{contractUrl})
  74. </insert>
  75. <!-- 根据主键查询一条记录 -->
  76. <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
  77. UPDATE music_group_payment_calender
  78. <set>
  79. <if test="name != null and name != ''">
  80. name_ = #{name},
  81. </if>
  82. <if test="currentTotalAmount != null">
  83. current_total_amount_ = #{currentTotalAmount},
  84. </if>
  85. <if test="originalTotalAmount != null">
  86. original_total_amount_ = #{originalTotalAmount},
  87. </if>
  88. <if test="originalMemberPaymentAmount != null">
  89. original_member_payment_amount_ = #{originalMemberPaymentAmount},
  90. </if>
  91. <if test="memberPaymentAmount != null">
  92. member_payment_amount_ = #{memberPaymentAmount},
  93. </if>
  94. <if test="memberRankSettingId != null">
  95. member_rank_setting_id_ = #{memberRankSettingId},
  96. </if>
  97. <if test="memberValidDate != null">
  98. member_valid_date_ = #{memberValidDate},
  99. </if>
  100. <if test="studentIds != null and studentIds != ''">
  101. student_ids_ = #{studentIds},
  102. </if>
  103. <if test="auditMemo != null and auditMemo != ''">
  104. audit_memo_ = #{auditMemo},
  105. </if>
  106. <if test="paymentType != null">
  107. payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  108. </if>
  109. <if test="paymentValidStartDate != null">
  110. payment_valid_start_date_ = #{paymentValidStartDate},
  111. payment_valid_end_date_ = #{paymentValidEndDate},
  112. </if>
  113. <if test="paymentPattern != null">
  114. payment_pattern_ = #{paymentPattern},
  115. </if>
  116. <if test="isGiveMusicNetwork != null">
  117. is_give_music_network_ = #{isGiveMusicNetwork},
  118. </if>
  119. <if test="deadlinePaymentDate != null">
  120. deadline_payment_date_ = #{deadlinePaymentDate},
  121. </if>
  122. <if test="status != null">
  123. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  124. </if>
  125. <if test="expectNum != null">
  126. expect_num_ = #{expectNum},
  127. </if>
  128. <if test="actualNum != null">
  129. actual_num_ = #{actualNum},
  130. </if>
  131. <if test="memo != null">
  132. memo_ = #{memo},
  133. </if>
  134. <if test="startPaymentDate != null">
  135. start_payment_date_ = #{startPaymentDate},
  136. </if>
  137. <if test="musicGroupOrganizationCourseSettingId != null">
  138. music_group_organization_course_settings_id_ = #{musicGroupOrganizationCourseSettingId},
  139. </if>
  140. <if test="payUserType != null">
  141. pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  142. </if>
  143. <if test="rejectReason != null">
  144. reject_reason_ = #{rejectReason},
  145. </if>
  146. <if test="updateTime != null">
  147. update_time_ = NOW(),
  148. </if>
  149. <if test="musicGroupId != null">
  150. music_group_id_ = #{musicGroupId},
  151. </if>
  152. <if test="batchNo != null">
  153. batch_no_ = #{batchNo},
  154. </if>
  155. <if test="paymentAmount != null">
  156. payment_amount_ = #{paymentAmount},
  157. </if>
  158. <if test="attribute1 != null">
  159. attribute1_ = #{attribute1},
  160. </if>
  161. <if test="attribute2 != null">
  162. attribute2_ = #{attribute2},
  163. </if>
  164. <if test="paymentItemShowState != null">
  165. payment_item_show_state_ = #{paymentItemShowState},
  166. </if>
  167. <if test="isShowSalePrice != null">
  168. is_show_sale_price_ = #{isShowSalePrice},
  169. </if>
  170. </set>
  171. WHERE id_ = #{id} and tenant_id_ = #{tenantId}
  172. </update>
  173. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
  174. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  175. UPDATE music_group_payment_calender
  176. <set>
  177. <if test="item.name != null">
  178. name_ = #{item.name},
  179. </if>
  180. <if test="item.currentTotalAmount != null">
  181. current_total_amount_ = #{item.currentTotalAmount},
  182. </if>
  183. <if test="item.originalTotalAmount != null">
  184. original_total_amount_ = #{item.originalTotalAmount},
  185. </if>
  186. <if test="item.originalMemberPaymentAmount != null">
  187. original_member_payment_amount_ = #{item.originalMemberPaymentAmount},
  188. </if>
  189. <if test="item.memberPaymentAmount != null">
  190. member_payment_amount_ = #{item.memberPaymentAmount},
  191. </if>
  192. <if test="item.memberRankSettingId != null">
  193. member_rank_setting_id_ = #{item.memberRankSettingId},
  194. </if>
  195. <if test="item.memberValidDate != null">
  196. member_valid_date_ = #{item.memberValidDate},
  197. </if>
  198. <if test="item.studentIds != null and item.studentIds != ''">
  199. student_ids_ = #{item.studentIds},
  200. </if>
  201. <if test="item.paymentPattern != null">
  202. payment_pattern_ = #{item.paymentPattern},
  203. </if>
  204. <if test="item.isGiveMusicNetwork != null">
  205. is_give_music_network_ = #{item.isGiveMusicNetwork},
  206. </if>
  207. <if test="item.deadlinePaymentDate != null">
  208. deadline_payment_date_ = #{item.deadlinePaymentDate},
  209. </if>
  210. <if test="item.status != null">
  211. status_ = #{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  212. </if>
  213. <if test="item.expectNum != null">
  214. expect_num_ = #{item.expectNum},
  215. </if>
  216. <if test="item.actualNum != null">
  217. actual_num_ = #{item.actualNum},
  218. </if>
  219. <if test="item.memo != null">
  220. memo_ = #{item.memo},
  221. </if>
  222. <if test="item.auditMemo != null">
  223. audit_memo_ = #{item.auditMemo},
  224. </if>
  225. <if test="item.startPaymentDate != null">
  226. start_payment_date_ = #{item.startPaymentDate},
  227. </if>
  228. <if test="item.musicGroupOrganizationCourseSettingId != null">
  229. music_group_organization_course_settings_id_ = #{item.musicGroupOrganizationCourseSettingId},
  230. </if>
  231. <if test="item.payUserType != null">
  232. pay_user_type_ = #{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  233. </if>
  234. <if test="item.rejectReason != null">
  235. reject_reason_ = #{item.rejectReason},
  236. </if>
  237. <if test="item.updateTime != null">
  238. update_time_ = NOW(),
  239. </if>
  240. <if test="item.musicGroupId != null">
  241. music_group_id_ = #{item.musicGroupId},
  242. </if>
  243. <if test="item.batchNo != null">
  244. batch_no_ = #{item.batchNo},
  245. </if>
  246. <if test="item.paymentAmount != null">
  247. payment_amount_ = #{item.paymentAmount},
  248. </if>
  249. <if test="item.attribute1 != null">
  250. attribute1_ = #{item.attribute1},
  251. </if>
  252. <if test="item.attribute2 != null">
  253. attribute2_ = #{item.attribute2},
  254. </if>
  255. <if test="item.paymentItemShowState != null">
  256. payment_item_show_state_ = #{item.paymentItemShowState},
  257. </if>
  258. <if test="item.isShowSalePrice != null">
  259. is_show_sale_price_ = #{item.isShowSalePrice},
  260. </if>
  261. </set>
  262. WHERE id_ = #{item.id} and tenant_id_ = #{item.tenantId}
  263. </foreach>
  264. </update>
  265. <update id="cutCalenderExpectNum">
  266. UPDATE music_group_payment_calender
  267. SET expect_num_ = expect_num_ - 1
  268. WHERE id_ IN (SELECT music_group_payment_calender_id_ FROM music_group_payment_calender_detail
  269. WHERE user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT')
  270. AND expect_num_ > 0 AND music_group_id_ = #{musicGroupId}
  271. </update>
  272. <update id="updatePaymentNum">
  273. UPDATE music_group_payment_calender SET expect_num_ = expect_num_ + #{expectNum},actual_num_ = actual_num_ + #{actualNum} WHERE id_ = #{calenderId}
  274. </update>
  275. <select id="findStudentNoPaymentCalender" resultType="java.lang.Long">
  276. SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
  277. WHERE mgpc.student_ids_ = #{userId} AND mgpc.payment_type_ = 'ADD_STUDENT'
  278. AND mgpc.music_group_id_ = #{musicGroupId} AND status_ in ('AUDITING','REJECT')
  279. </select>
  280. <!-- 根据主键删除一条记录 -->
  281. <delete id="delete">
  282. DELETE FROM music_group_payment_calender WHERE id_ = #{id}
  283. </delete>
  284. <!-- 根据主键删除一条记录 -->
  285. <delete id="delByIds">
  286. DELETE FROM music_group_payment_calender WHERE id_ IN
  287. <foreach collection="calenderIds" item="item" separator="," open="(" close=")">
  288. #{item}
  289. </foreach>
  290. </delete>
  291. <delete id="delByGroupId">
  292. DELETE FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId}
  293. </delete>
  294. <!-- 分页查询 -->
  295. <select id="queryPage" resultMap="MusicGroupPaymentCalender" parameterType="map">
  296. SELECT mgpc.*
  297. FROM music_group_payment_calender mgpc
  298. <include refid="queryPageSql"/>
  299. ORDER BY mgpc.id_ DESC
  300. <include refid="global.limit"/>
  301. </select>
  302. <sql id="queryPageSql">
  303. <where>
  304. mgpc.tenant_id_ = #{tenantId}
  305. <if test="musicGroupId != null">
  306. AND mgpc.music_group_id_ = #{musicGroupId}
  307. </if>
  308. <if test="batchNo != null">
  309. AND mgpc.batch_no_ = #{batchNo}
  310. </if>
  311. <if test="payUserType != null">
  312. AND mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  313. </if>
  314. <if test="paymentType != null">
  315. AND mgpc.payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  316. </if>
  317. <if test="status != null">
  318. AND mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  319. </if>
  320. </where>
  321. </sql>
  322. <!-- 查询当前表的总记录数 -->
  323. <select id="queryCount" resultType="int">
  324. SELECT COUNT(mgpc.id_) FROM music_group_payment_calender mgpc
  325. <include refid="queryPageSql"/>
  326. </select>
  327. <select id="findByMusicGroupId" resultMap="MusicGroupPaymentCalender">
  328. SELECT * FROM music_group_payment_calender mgpc
  329. WHERE music_group_id_ = #{musicGroupId}
  330. ORDER BY id_
  331. </select>
  332. <select id="queryByPaymentStatus" resultMap="MusicGroupPaymentCalender">
  333. SELECT * FROM music_group_payment_calender mgpc
  334. <where>
  335. <if test="status != null">
  336. status_ in
  337. <foreach collection="status" item="item" open="(" close=")" separator=",">
  338. #{item,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  339. </foreach>
  340. </if>
  341. <if test="payUserType != null">
  342. AND pay_user_type_ = #{payUserType}
  343. </if>
  344. <if test="musicGroupId != null">
  345. AND music_group_id_ = #{musicGroupId}
  346. </if>
  347. </where>
  348. </select>
  349. <select id="getForLock" resultMap="MusicGroupPaymentCalender">
  350. SELECT * FROM music_group_payment_calender WHERE id_ = #{id} FOR UPDATE
  351. </select>
  352. <select id="queryIntersectionByPaymentDate" resultType="int" parameterType="map">
  353. SELECT count(*) FROM music_group_payment_calender mgpc
  354. WHERE music_group_id_ = #{musicGroupId}
  355. and (start_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate}
  356. or deadline_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate})
  357. <if test="calenderId != null">
  358. AND mgpc.id_ != #{calenderId}
  359. </if>
  360. </select>
  361. <select id="getLastStartOne" resultMap="MusicGroupPaymentCalender">
  362. SELECT * FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId} ORDER BY start_payment_date_ DESC LIMIT 1
  363. </select>
  364. <select id="queryIntersectionByDate" resultType="java.lang.Integer">
  365. SELECT COUNT(DISTINCT mgpcd.id_) FROM music_group_payment_calender mgpc
  366. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  367. WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpcd.payment_status_ != 'PAID_COMPLETED'
  368. AND (DATE_FORMAT(mgpcd.start_payment_date_,'%Y-%m-%d') between #{startTime} AND #{endTime}
  369. OR DATE_FORMAT(mgpcd.deadline_payment_date_,'%Y-%m-%d') between #{startTime} AND #{endTime})
  370. </select>
  371. <select id="queryCalenderByDay" resultType="java.util.Map">
  372. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(mgpcd.payment_status_) 'value'
  373. FROM music_group_payment_calender_detail mgpcd
  374. WHERE mgpcd.music_group_payment_calender_id_ IN
  375. (SELECT id_ FROM music_group_payment_calender WHERE status_ != 0
  376. AND DATEDIFF(#{format},DATE_FORMAT(start_payment_date_,'%Y-%m-%d')) = #{configValue})
  377. AND mgpcd.payment_status_ = 'NON_PAYMENT'
  378. GROUP BY mgpcd.music_group_payment_calender_id_
  379. </select>
  380. <select id="queryByIds" resultMap="MusicGroupPaymentCalender">
  381. SELECT * FROM music_group_payment_calender WHERE id_ IN
  382. <foreach collection="calenderId" open="(" close=")" item="item" separator=",">
  383. #{item}
  384. </foreach>
  385. </select>
  386. <select id="queryEndIds" resultType="java.lang.Long">
  387. SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
  388. WHERE mgpc.payment_valid_end_date_ IS NOT NULL AND DATEDIFF(mgpc.payment_valid_end_date_,#{format}) = #{configValue}
  389. AND mgpc.payment_type_ IN ('MUSIC_APPLY','MUSIC_RENEW')
  390. <if test="musicGroupIds != null">
  391. AND mgpc.music_group_id_ IN
  392. <foreach collection="musicGroupIds" open="(" close=")" item="item" separator=",">
  393. #{item}
  394. </foreach>
  395. </if>
  396. </select>
  397. <resultMap id="CalenderPushDto" type="com.ym.mec.biz.dal.dto.CalenderPushDto">
  398. <result property="paymentValidEndDate" column="payment_valid_end_date_"/>
  399. <result property="paymentValidStartDate" column="payment_valid_start_date_"/>
  400. <result property="teacherId" column="educational_teacher_id_"/>
  401. <result property="musicGroupName" column="name_"/>
  402. <result property="teacherPhone" column="phone_"/>
  403. <result property="calenderId" column="id_"/>
  404. </resultMap>
  405. <select id="getCalenderPushDto" resultMap="CalenderPushDto">
  406. SELECT mgpc.id_,mgpc.payment_valid_start_date_,mgpc.payment_valid_end_date_,
  407. mg.educational_teacher_id_,mg.name_,su.phone_
  408. FROM music_group_payment_calender mgpc
  409. LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
  410. LEFT JOIN sys_user su ON su.id_ = mg.educational_teacher_id_
  411. WHERE mgpc.id_ IN
  412. <foreach collection="calenderIds" open="(" close=")" separator="," item="item">
  413. #{item}
  414. </foreach>
  415. </select>
  416. <select id="getMusicCalenderPushDto" resultMap="CalenderPushDto">
  417. SELECT mg.payment_valid_start_date_,mg.payment_valid_end_date_,
  418. mg.educational_teacher_id_,su.phone_,mg.name_ FROM music_group mg
  419. LEFT JOIN sys_user su ON mg.educational_teacher_id_ = su.id_
  420. WHERE mg.payment_valid_end_date_ IS NOT NULL AND
  421. DATEDIFF(mg.payment_valid_end_date_,#{format}) = #{configValue}
  422. </select>
  423. <select id="getUnusedFirstPaymentCalenderWithCalenders" resultMap="MusicGroupPaymentCalender">
  424. SELECT * FROM music_group_payment_calender mgpc
  425. WHERE id_ IN
  426. <foreach collection="calenderIds" item="calenderId" open="(" close=")" separator=",">
  427. #{calenderId}
  428. </foreach>
  429. ORDER BY create_time_ LIMIT 1;
  430. </select>
  431. <select id="findByBatchNo" resultMap="MusicGroupPaymentCalender">
  432. SELECT * FROM music_group_payment_calender WHERE FIND_IN_SET(batch_no_,#{batchNo})
  433. </select>
  434. <resultMap id="MusicGroupPaymentCalenderAuditDtoMap" type="com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto">
  435. <result property="musicGroupId" column="music_group_id_"/>
  436. <result column="music_group_organization_course_settings_id_" property="musicGroupOrganizationCourseSettingsId" />
  437. <result property="batchNo" column="batch_no_"/>
  438. <result property="musicGroupName" column="music_group_name_"/>
  439. <result property="organId" column="organ_id_"/>
  440. <result property="organName" column="organ_name_"/>
  441. <result property="createTime" column="create_time_"/>
  442. <result property="paymentType" column="payment_type_"/>
  443. <result property="memo" column="memo_"/>
  444. <result property="operator" column="operator_"/>
  445. <result property="auditStatus" column="status_"/>
  446. <result property="addCourseTotalTime" column="course_total_minuties_"/>
  447. <result property="courseCurrentPrice" column="course_current_price_"/>
  448. <result property="courseOriginalPrice" column="course_original_price_"/>
  449. <result property="currentTotalAMount" column="current_total_amount_"/>
  450. <result property="originalTotalAMount" column="original_total_amount_"/>
  451. <result property="musicGroupPaymentCalenderId" column="id_"/>
  452. <result property="payUserType" column="pay_user_type_"/>
  453. <result property="calenderSettingsName" column="calender_settings_name_"/>
  454. <result property="paymentPattern" column="payment_pattern_"/>
  455. <result property="paymentValidStartDate" column="payment_valid_start_date_"/>
  456. <result property="paymentValidEndDate" column="payment_valid_end_date_"/>
  457. <result property="startPaymentDate" column="start_payment_date_"/>
  458. <result property="deadlinePaymentDate" column="deadline_payment_date_"/>
  459. <result property="auditMemo" column="audit_memo_"/>
  460. <result property="paymentAmount" column="payment_amount_"/>
  461. <result property="isGiveMusicNetwork" column="is_give_music_network_"/>
  462. <result property="memberPaymentAmount" column="member_payment_amount_"/>
  463. <result property="originalMemberPaymentAmount" column="original_member_payment_amount_"/>
  464. </resultMap>
  465. <sql id="MusicGroupPaymentCalenderAuditDtoSql">
  466. <where>
  467. mgpc.batch_no_ IS NOT NULL and mgpc.tenant_id_ = #{tenantId} AND mg.del_flag_ = 0
  468. <if test="paymentType != null">
  469. AND mgpc.payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  470. </if>
  471. <if test="payUserType != null">
  472. AND mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  473. </if>
  474. <if test="status != null">
  475. AND mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  476. </if>
  477. <if test="organId != null and organId != ''">
  478. AND FIND_IN_SET(mg.organ_id_,#{organId})
  479. </if>
  480. <if test="search != null and search != ''">
  481. AND (mg.id_ LIKE CONCAT('%',#{search},'%') OR mg.name_ LIKE CONCAT('%',#{search},'%'))
  482. </if>
  483. </where>
  484. </sql>
  485. <select id="countAuditList" resultType="java.lang.Integer">
  486. SELECT COUNT(DISTINCT mgpc.batch_no_)
  487. FROM music_group_payment_calender mgpc
  488. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  489. <include refid="MusicGroupPaymentCalenderAuditDtoSql"/>
  490. </select>
  491. <select id="queryAuditList" resultMap="MusicGroupPaymentCalenderAuditDtoMap">
  492. SELECT mgpc.batch_no_,MAX(mgpc.music_group_id_) music_group_id_
  493. ,MAX(mgpc.create_time_) create_time_,MIN(mgpc.payment_type_) payment_type_,MAX(mgpc.operator_) operator_,
  494. MAX(mgpc.pay_user_type_) pay_user_type_,MAX(mgpc.memo_) memo_,MAX(mgpc.audit_memo_) audit_memo_,MAX(mgpc.status_) status_,
  495. CASE WHEN MAX(mgpc.payment_type_) = 'SPAN_GROUP_CLASS_ADJUST' THEN MAX(mgsca.master_class_course_times_) ELSE SUM(mgpccs.course_total_minuties_) END course_total_minuties_,
  496. CASE WHEN MAX(mgpc.payment_type_) = 'SPAN_GROUP_CLASS_ADJUST' THEN MAX(mgpc.payment_amount_) ELSE SUM(mgpccs.course_original_price_) END course_original_price_,
  497. SUM(mgpccs.course_current_price_) course_current_price_,
  498. mgpc.member_payment_amount_,
  499. mgpc.original_member_payment_amount_,mgpc.current_total_amount_,mgpc.original_total_amount_,
  500. MAX(mg.name_) music_group_name_,MAX(mg.organ_id_) organ_id_,MAX(mgpc.payment_pattern_)payment_pattern_
  501. FROM music_group_payment_calender mgpc
  502. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  503. LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
  504. LEFT JOIN music_group_student_class_adjust mgsca ON mgsca.batch_no_ = mgpc.batch_no_
  505. <include refid="MusicGroupPaymentCalenderAuditDtoSql"/>
  506. GROUP BY mgpc.batch_no_
  507. ORDER BY create_time_ DESC
  508. <include refid="global.limit"/>
  509. </select>
  510. <select id="countExpectNum" resultType="java.util.Map">
  511. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
  512. WHERE mgpcd.music_group_payment_calender_id_ = #{id}
  513. GROUP BY mgpcd.music_group_payment_calender_id_
  514. </select>
  515. <select id="countActualNum" resultType="java.util.Map">
  516. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
  517. WHERE mgpcd.music_group_payment_calender_id_ = #{id}
  518. AND mgpcd.payment_status_ = 'PAID_COMPLETED'
  519. GROUP BY mgpcd.music_group_payment_calender_id_
  520. </select>
  521. <select id="getAuditDetail" resultMap="MusicGroupPaymentCalenderAuditDtoMap">
  522. SELECT mgpc.batch_no_,MAX(mgpc.music_group_id_) music_group_id_
  523. ,MAX(mgpc.create_time_) create_time_,MAX(mgpc.payment_type_) payment_type_,MAX(mgpc.music_group_organization_course_settings_id_) music_group_organization_course_settings_id_,
  524. MAX(mgpc.pay_user_type_) pay_user_type_,MAX(mg.name_) music_group_name_,MAX(mgpc.payment_pattern_)payment_pattern_,MAX(o.name_) organ_name_
  525. FROM music_group_payment_calender mgpc
  526. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  527. LEFT JOIN organization o ON o.id_ = mg.organ_id_
  528. WHERE mgpc.batch_no_ = #{batchNo}
  529. GROUP BY mgpc.batch_no_
  530. </select>
  531. <select id="findByMusicGroupRegCalender" resultMap="MusicGroupPaymentCalender">
  532. SELECT * FROM music_group_payment_calender WHERE music_group_id_=#{musicGroupId} AND payment_type_='MUSIC_APPLY'
  533. </select>
  534. <select id="getCalenderSettingsName" resultType="java.lang.String">
  535. SELECT name_ FROM music_group_payment_calender_course_settings
  536. WHERE music_group_payment_calender_id_ = #{calenderId} LIMIT 1
  537. </select>
  538. <select id="countAuditReject" resultType="java.lang.Integer">
  539. SELECT COUNT(0) FROM music_group_payment_calender
  540. WHERE music_group_id_ = #{musicGroupId} AND payment_type_='MUSIC_APPLY' AND status_ IN ('REJECT','AUDITING')
  541. <if test="calenderId != null">
  542. AND id_ != #{calenderId}
  543. </if>
  544. </select>
  545. <select id="getMusicGroupRegCalender" resultMap="MusicGroupPaymentCalender">
  546. SELECT * FROM music_group_payment_calender
  547. WHERE music_group_id_ = #{musicGroupId}
  548. AND payment_type_ = 'MUSIC_APPLY'
  549. AND pay_user_type_='STUDENT'
  550. </select>
  551. <select id="queryUserPaymentStatus" resultType="java.util.Map">
  552. SELECT mg.id_ 'key',CASE WHEN MIN(mgpcd.payment_status_) IS NULL THEN 'PAID_COMPLETED' ELSE MIN(mgpcd.payment_status_) END 'value'
  553. FROM music_group mg
  554. LEFT JOIN music_group_payment_calender mgpc ON mgpc.music_group_id_ = mg.id_
  555. AND mgpc.status_ IN ('NO','OPEN','OVER')
  556. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_ AND mgpcd.user_id_ = #{userId}
  557. WHERE FIND_IN_SET(mg.id_,#{musicGroupId}) AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT'
  558. GROUP BY mg.id_
  559. </select>
  560. <select id="queryUserCoursePaymentStatus" resultType="java.util.Map">
  561. SELECT mgpcd.user_id_ 'key',
  562. CASE WHEN MIN(mgpcd.payment_status_) IS NULL THEN 'PAID_COMPLETED' ELSE MIN(mgpcd.payment_status_) END 'value'
  563. FROM music_group mg
  564. LEFT JOIN music_group_payment_calender mgpc ON mgpc.music_group_id_ = mg.id_
  565. AND mgpc.status_ IN ('NO','OPEN','OVER')
  566. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  567. WHERE mg.id_ = #{musicGroupId} AND mgpcd.expect_amount_ > 0 AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT' AND mgpcd.user_id_ IN
  568. <foreach collection="studentId" item="item" separator="," open="(" close=")">
  569. #{item}
  570. </foreach>
  571. GROUP BY mgpcd.user_id_
  572. </select>
  573. <select id="findByBatchNoAndStudentId" resultType="Long">
  574. SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
  575. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  576. WHERE FIND_IN_SET(batch_no_,#{batchNo}) AND mgpcd.user_id_ = #{studentId}
  577. </select>
  578. <select id="getPaymentCalenderWithCalenderIdsAndPayUserType" resultMap="MusicGroupPaymentCalender">
  579. SELECT * FROM music_group_payment_calender
  580. WHERE id_ IN
  581. <foreach collection="calenderIds" item="calenderId" open="(" close=")" separator=",">
  582. #{calenderId}
  583. </foreach>
  584. AND pay_user_type_ = #{payUserType}
  585. AND status_ IN ('NO', 'OPEN', 'OVER', 'PAID');
  586. </select>
  587. <select id="getSchoolCalender" resultMap="MusicGroupPaymentCalender">
  588. SELECT * FROM music_group_payment_calender WHERE id_ = #{calenderId} AND status_ IN ('NO', 'OPEN', 'OVER', 'PAID');
  589. </select>
  590. <select id="queryMusicGroupIds" resultType="java.lang.String">
  591. SELECT DISTINCT music_group_id_ FROM music_group_payment_calender
  592. WHERE id_ IN
  593. <foreach collection="calenderIds" item="calenderId" open="(" close=")" separator=",">
  594. #{calenderId}
  595. </foreach>
  596. </select>
  597. <select id="getMusicGroupCalenderBatchNoTimes" resultMap="MusicGroupPaymentCalender">
  598. SELECT batch_no_, COUNT(*) expect_num_ FROM music_group_payment_calender
  599. WHERE music_group_id_ = #{musicGroupId}
  600. AND status_ IN ('AUDITING','NO', 'OPEN', 'OVER', 'PAID')
  601. GROUP BY batch_no_
  602. </select>
  603. <select id="getMusicGroupRegCalenderByIds" resultMap="MusicGroupPaymentCalender">
  604. SELECT * FROM music_group_payment_calender WHERE music_group_id_ IN
  605. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  606. #{id}
  607. </foreach>
  608. AND payment_type_='MUSIC_APPLY' AND batch_no_ IS NOT NULL
  609. </select>
  610. <select id="getMusicGroupCalenderBatchNoByIds" resultMap="MusicGroupPaymentCalender">
  611. SELECT music_group_id_,batch_no_, COUNT(*) expect_num_ FROM music_group_payment_calender
  612. WHERE music_group_id_ IN
  613. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  614. #{id}
  615. </foreach>
  616. AND status_ IN ('AUDITING','NO', 'OPEN', 'OVER', 'PAID')
  617. AND batch_no_ IS NOT NULL
  618. GROUP BY music_group_id_,batch_no_
  619. </select>
  620. <select id="queryCalenderStudentIds" resultType="java.lang.String">
  621. SELECT GROUP_CONCAT(DISTINCT student_ids_) FROM music_group_payment_calender
  622. WHERE status_ IN ('AUDITING','REJECT') AND music_group_id_ = #{musicGroupId}
  623. <if test="batchNo != null and batchNo != ''">
  624. AND batch_no_ != #{batchNo}
  625. </if>
  626. </select>
  627. <sql id="queryCalenderPageSql">
  628. <where>
  629. mg.del_flag_ = 0
  630. <if test="search != null and search != ''">
  631. AND (mgpc.music_group_id_ = #{search} OR mg.name_ LIKE CONCAT('%',#{search},'%'))
  632. </if>
  633. <if test="musicGroupId != null">
  634. AND mgpc.music_group_id_ = #{musicGroupId}
  635. </if>
  636. <if test="batchNo != null">
  637. AND mgpc.batch_no_ = #{batchNo}
  638. </if>
  639. <if test="payUserType != null">
  640. AND mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  641. </if>
  642. <if test="paymentType != null">
  643. AND mgpc.payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  644. </if>
  645. <if test="status != null">
  646. AND mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  647. </if>
  648. <if test="organId != null and organId != ''">
  649. AND FIND_IN_SET(mgpc.organ_id_,#{organId})
  650. </if>
  651. <if test="tenantId != null">
  652. AND mgpc.tenant_id_ = #{tenantId}
  653. </if>
  654. </where>
  655. </sql>
  656. <select id="countCalender" resultType="java.lang.Integer">
  657. SELECT COUNT(mgpc.id_) FROM music_group_payment_calender mgpc
  658. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  659. <include refid="queryCalenderPageSql"/>
  660. </select>
  661. <resultMap id="MusicGroupPaymentCalenderResultDto" type="com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderResultDto"
  662. extends="MusicGroupPaymentCalender">
  663. <result column="music_group_name_" property="musicGroupName"/>
  664. <result column="operator_name_" property="operatorName"/>
  665. </resultMap>
  666. <select id="queryCalenderPage" resultMap="MusicGroupPaymentCalenderResultDto">
  667. SELECT mgpc.id_,mgpc.music_group_id_,mgpc.music_group_organization_course_settings_id_,mgpc.pay_user_type_,mgpc.reject_reason_,
  668. mgpc.start_payment_date_,mgpc.deadline_payment_date_,mgpc.status_,mgpc.expect_num_,
  669. mgpc.actual_num_,mgpc.memo_,mgpc.create_time_,mgpc.update_time_,
  670. mgpc.payment_pattern_,mgpc.payment_type_,mgpc.batch_no_,mgpc.audit_memo_,mgpc.operator_,mgpc.attribute1_,
  671. mgpc.attribute2_,mgpc.student_ids_,mgpc.current_total_amount_,mgpc.original_total_amount_,mg.name_ music_group_name_,mgpc.organ_id_
  672. FROM music_group_payment_calender mgpc
  673. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  674. <include refid="queryCalenderPageSql"/>
  675. ORDER BY mgpc.id_ DESC
  676. <include refid="global.limit"/>
  677. </select>
  678. <select id="queryChargeStandard" resultType="java.util.Map">
  679. SELECT `music_group_id_` 'key',`current_total_amount_` 'value' FROM `music_group_payment_calender` WHERE `id_` in
  680. (
  681. SELECT max(pc.`id_`) FROM `music_group_payment_calender` pc WHERE pc.`payment_type_` in ('MUSIC_APPLY','MUSIC_RENEW') and FIND_IN_SET(pc.music_group_id_, #{musicGroupIdList})
  682. GROUP BY pc.`music_group_id_`
  683. )
  684. </select>
  685. <select id="findCooperationByIds" resultType="java.util.Map">
  686. SELECT mgpc.id_ 'key',mg.cooperation_organ_id_ 'value' FROM music_group_payment_calender mgpc
  687. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  688. WHERE mgpc.id_ IN
  689. <foreach collection="calenderIds" item="id" open="(" close=")" separator=",">
  690. #{id}
  691. </foreach>
  692. </select>
  693. </mapper>