MusicGroupPaymentCalenderMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  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="music_group_organization_course_settings_id_" property="musicGroupOrganizationCourseSettingId"/>
  12. <result column="pay_user_type_" property="payUserType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  13. <result column="start_payment_date_" property="startPaymentDate"/>
  14. <result column="deadline_payment_date_" property="deadlinePaymentDate"/>
  15. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  16. <result column="expect_num_" property="expectNum"/>
  17. <result column="actual_num_" property="actualNum"/>
  18. <result column="memo_" property="memo"/>
  19. <result column="audit_memo_" property="auditMemo"/>
  20. <result column="reject_reason_" property="rejectReason"/>
  21. <result column="is_give_music_network_" property="isGiveMusicNetwork"/>
  22. <result column="create_time_" property="createTime"/>
  23. <result column="update_time_" property="updateTime"/>
  24. <result column="payment_valid_start_date_" property="paymentValidStartDate"/>
  25. <result column="payment_valid_end_date_" property="paymentValidEndDate"/>
  26. <result column="payment_pattern_" property="paymentPattern"/>
  27. <result column="payment_type_" property="paymentType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  28. <result column="batch_no_" property="batchNo"/>
  29. <result column="payment_amount_" property="paymentAmount"/>
  30. <result column="attribute1_" property="attribute1"/>
  31. <result column="attribute2_" property="attribute2"/>
  32. </resultMap>
  33. <!-- 根据主键查询一条记录 -->
  34. <select id="get" resultMap="MusicGroupPaymentCalender">
  35. SELECT * FROM music_group_payment_calender WHERE id_ = #{id}
  36. </select>
  37. <!-- 全查询 -->
  38. <select id="findAll" resultMap="MusicGroupPaymentCalender">
  39. SELECT * FROM music_group_payment_calender ORDER BY id_
  40. </select>
  41. <!-- 向数据库增加一条记录 -->
  42. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
  43. keyColumn="id_" keyProperty="id">
  44. INSERT INTO music_group_payment_calender
  45. (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
  46. actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,
  47. payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_)
  48. VALUES(#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  49. #{rejectReason},#{startPaymentDate},#{deadlinePaymentDate},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  50. #{expectNum},#{actualNum},#{memo},#{isGiveMusicNetwork},now(),now(),
  51. #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  52. #{paymentAmount},#{batchNo},#{auditMemo},#{operator},#{attribute1},#{attribute2})
  53. </insert>
  54. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
  55. keyColumn="id_" keyProperty="id">
  56. INSERT INTO music_group_payment_calender
  57. (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
  58. actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_amount_,
  59. payment_type_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_)
  60. VALUES
  61. <foreach collection="list" item="item" index="index" separator=",">
  62. (#{item.musicGroupId},#{item.musicGroupOrganizationCourseSettingId},#{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.rejectReason},#{item.startPaymentDate},#{item.deadlinePaymentDate},#{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  63. #{item.expectNum},#{item.actualNum},#{item.memo},#{item.isGiveMusicNetwork},now(),now(),
  64. #{item.paymentValidStartDate},#{item.paymentValidEndDate},#{item.paymentPattern},#{item.paymentAmount},#{item.paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  65. #{item.batchNo},#{item.auditMemo},#{item.operator},#{item.attribute1},#{item.attribute2})
  66. </foreach>
  67. </insert>
  68. <!-- 根据主键查询一条记录 -->
  69. <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
  70. UPDATE music_group_payment_calender
  71. <set>
  72. <if test="auditMemo != null and auditMemo != ''">
  73. audit_memo_ = #{auditMemo},
  74. </if>
  75. <if test="paymentType != null">
  76. payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  77. </if>
  78. <if test="paymentValidStartDate != null">
  79. payment_valid_start_date_ = #{paymentValidStartDate},
  80. payment_valid_end_date_ = #{paymentValidEndDate},
  81. </if>
  82. <if test="paymentPattern != null">
  83. payment_pattern_ = #{paymentPattern},
  84. </if>
  85. <if test="isGiveMusicNetwork != null">
  86. is_give_music_network_ = #{isGiveMusicNetwork},
  87. </if>
  88. <if test="deadlinePaymentDate != null">
  89. deadline_payment_date_ = #{deadlinePaymentDate},
  90. </if>
  91. <if test="status != null">
  92. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  93. </if>
  94. <if test="expectNum != null">
  95. expect_num_ = #{expectNum},
  96. </if>
  97. <if test="actualNum != null">
  98. actual_num_ = #{actualNum},
  99. </if>
  100. <if test="memo != null">
  101. memo_ = #{memo},
  102. </if>
  103. <if test="startPaymentDate != null">
  104. start_payment_date_ = #{startPaymentDate},
  105. </if>
  106. <if test="musicGroupOrganizationCourseSettingId != null">
  107. music_group_organization_course_settings_id_ = #{musicGroupOrganizationCourseSettingId},
  108. </if>
  109. <if test="payUserType != null">
  110. pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  111. </if>
  112. <if test="rejectReason != null">
  113. reject_reason_ = #{rejectReason},
  114. </if>
  115. <if test="updateTime != null">
  116. update_time_ = NOW(),
  117. </if>
  118. <if test="musicGroupId != null">
  119. music_group_id_ = #{musicGroupId},
  120. </if>
  121. <if test="batchNo != null">
  122. batch_no_ = #{batchNo},
  123. </if>
  124. <if test="paymentAmount != null">
  125. payment_amount_ = #{paymentAmount},
  126. </if>
  127. <if test="attribute1 != null">
  128. attribute1_ = #{attribute1},
  129. </if>
  130. <if test="attribute2 != null">
  131. attribute2_ = #{attribute2},
  132. </if>
  133. </set>
  134. WHERE id_ = #{id}
  135. </update>
  136. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
  137. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  138. UPDATE music_group_payment_calender
  139. <set>
  140. <if test="item.paymentPattern != null">
  141. payment_pattern_ = #{item.paymentPattern},
  142. </if>
  143. <if test="item.isGiveMusicNetwork != null">
  144. is_give_music_network_ = #{item.isGiveMusicNetwork},
  145. </if>
  146. <if test="item.deadlinePaymentDate != null">
  147. deadline_payment_date_ = #{item.deadlinePaymentDate},
  148. </if>
  149. <if test="item.status != null">
  150. status_ = #{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  151. </if>
  152. <if test="item.expectNum != null">
  153. expect_num_ = #{item.expectNum},
  154. </if>
  155. <if test="item.actualNum != null">
  156. actual_num_ = #{item.actualNum},
  157. </if>
  158. <if test="item.memo != null">
  159. memo_ = #{item.memo},
  160. </if>
  161. <if test="item.startPaymentDate != null">
  162. start_payment_date_ = #{item.startPaymentDate},
  163. </if>
  164. <if test="item.musicGroupOrganizationCourseSettingId != null">
  165. music_group_organization_course_settings_id_ = #{item.musicGroupOrganizationCourseSettingId},
  166. </if>
  167. <if test="item.payUserType != null">
  168. pay_user_type_ = #{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  169. </if>
  170. <if test="item.rejectReason != null">
  171. reject_reason_ = #{item.rejectReason},
  172. </if>
  173. <if test="item.updateTime != null">
  174. update_time_ = NOW(),
  175. </if>
  176. <if test="item.musicGroupId != null">
  177. music_group_id_ = #{item.musicGroupId},
  178. </if>
  179. <if test="item.batchNo != null">
  180. batch_no_ = #{item.batchNo},
  181. </if>
  182. <if test="item.paymentAmount != null">
  183. payment_amount_ = #{item.paymentAmount},
  184. </if>
  185. <if test="item.attribute1 != null">
  186. attribute1_ = #{item.attribute1},
  187. </if>
  188. <if test="item.attribute2 != null">
  189. attribute2_ = #{item.attribute2},
  190. </if>
  191. </set>
  192. WHERE id_ = #{item.id}
  193. </foreach>
  194. </update>
  195. <!-- 根据主键删除一条记录 -->
  196. <delete id="delete">
  197. DELETE FROM music_group_payment_calender WHERE id_ = #{id}
  198. </delete>
  199. <delete id="delByGroupId">
  200. DELETE FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId}
  201. </delete>
  202. <!-- 分页查询 -->
  203. <select id="queryPage" resultMap="MusicGroupPaymentCalender" parameterType="map">
  204. SELECT * FROM music_group_payment_calender mgpc
  205. <where>
  206. <if test="musicGroupId != null">
  207. and mgpc.music_group_id_ = #{musicGroupId}
  208. </if>
  209. <if test="payUserType != null">
  210. and mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  211. </if>
  212. <if test="status != null">
  213. and mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  214. </if>
  215. </where>
  216. ORDER BY mgpc.payment_valid_start_date_ DESC
  217. <include refid="global.limit"/>
  218. </select>
  219. <!-- 查询当前表的总记录数 -->
  220. <select id="queryCount" resultType="int">
  221. SELECT COUNT(mgpc.id_) FROM music_group_payment_calender mgpc
  222. <where>
  223. <if test="musicGroupId != null">
  224. and mgpc.music_group_id_ = #{musicGroupId}
  225. </if>
  226. <if test="payUserType != null">
  227. and mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  228. </if>
  229. <if test="status != null">
  230. and mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  231. </if>
  232. </where>
  233. </select>
  234. <select id="findByMusicGroupId" resultMap="MusicGroupPaymentCalender">
  235. SELECT * FROM music_group_payment_calender mgpc
  236. WHERE music_group_id_ = #{musicGroupId}
  237. ORDER BY id_
  238. </select>
  239. <select id="queryByPaymentStatus" resultMap="MusicGroupPaymentCalender">
  240. SELECT * FROM music_group_payment_calender mgpc
  241. <where>
  242. <if test="status != null">
  243. status_ in
  244. <foreach collection="status" item="item" open="(" close=")" separator=",">
  245. #{item,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  246. </foreach>
  247. </if>
  248. <if test="payUserType != null">
  249. AND pay_user_type_ = #{payUserType}
  250. </if>
  251. </where>
  252. </select>
  253. <select id="getForLock" resultMap="MusicGroupPaymentCalender">
  254. SELECT * FROM music_group_payment_calender WHERE id_ = #{id} FOR UPDATE
  255. </select>
  256. <select id="queryIntersectionByPaymentDate" resultType="int" parameterType="map">
  257. SELECT count(*) FROM music_group_payment_calender mgpc
  258. WHERE music_group_id_ = #{musicGroupId}
  259. and (start_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate}
  260. or deadline_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate})
  261. <if test="calenderId != null">
  262. AND mgpc.id_ != #{calenderId}
  263. </if>
  264. </select>
  265. <select id="getLastStartOne" resultMap="MusicGroupPaymentCalender">
  266. SELECT * FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId} ORDER BY start_payment_date_ DESC LIMIT 1
  267. </select>
  268. <select id="queryIntersectionByDate" resultType="java.lang.Integer">
  269. SELECT COUNT(DISTINCT mgpcd.id_) FROM music_group_payment_calender mgpc
  270. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  271. WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpcd.payment_status_ != 'PAID_COMPLETED'
  272. AND (DATE_FORMAT(mgpcd.start_payment_date_,'%Y-%m-%d') between #{startTime} AND #{endTime}
  273. OR DATE_FORMAT(mgpcd.deadline_payment_date_,'%Y-%m-%d') between #{startTime} AND #{endTime})
  274. </select>
  275. <select id="queryIntersectionByValidDate" resultType="java.lang.Integer">
  276. SELECT COUNT(*) FROM music_group_payment_calender mgpc
  277. WHERE music_group_id_ = #{musicGroupId}
  278. AND (payment_valid_end_date_ IS NULL OR payment_valid_start_date_ BETWEEN #{paymentValidStartDate} AND #{paymentValidEndDate}
  279. OR payment_valid_end_date_ BETWEEN #{paymentValidStartDate} AND #{paymentValidEndDate}) AND payment_valid_start_date_ IS NOT NULL
  280. <if test="payUserType != null">
  281. and pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  282. </if>
  283. <if test="calenderId != null">
  284. AND mgpc.id_ != #{calenderId}
  285. </if>
  286. </select>
  287. <select id="queryCalenderByDay" resultType="java.util.Map">
  288. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(mgpcd.payment_status_) 'value'
  289. FROM music_group_payment_calender_detail mgpcd
  290. WHERE mgpcd.music_group_payment_calender_id_ IN
  291. (SELECT id_ FROM music_group_payment_calender WHERE status_ != 0
  292. AND DATEDIFF(#{format},DATE_FORMAT(start_payment_date_,'%Y-%m-%d')) = #{configValue})
  293. AND mgpcd.payment_status_ = 'NON_PAYMENT'
  294. GROUP BY mgpcd.music_group_payment_calender_id_
  295. </select>
  296. <select id="queryByIds" resultMap="MusicGroupPaymentCalender">
  297. SELECT * FROM music_group_payment_calender WHERE id_ IN
  298. <foreach collection="calenderId" open="(" close=")" item="item" separator=",">
  299. #{item}
  300. </foreach>
  301. </select>
  302. <select id="queryEndIds" resultType="java.lang.Long">
  303. SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
  304. WHERE mgpc.payment_valid_end_date_ IS NOT NULL AND DATEDIFF(mgpc.payment_valid_end_date_,#{format}) = #{configValue} AND mgpc.payment_type_ IN ('MUSIC_APPLY','MUSIC_RENEW')
  305. </select>
  306. <resultMap id="CalenderPushDto" type="com.ym.mec.biz.dal.dto.CalenderPushDto">
  307. <result property="paymentValidEndDate" column="payment_valid_end_date_"/>
  308. <result property="paymentValidStartDate" column="payment_valid_start_date_"/>
  309. <result property="teacherId" column="educational_teacher_id_"/>
  310. <result property="musicGroupName" column="name_"/>
  311. <result property="teacherPhone" column="phone_"/>
  312. <result property="calenderId" column="id_"/>
  313. </resultMap>
  314. <select id="getCalenderPushDto" resultMap="CalenderPushDto">
  315. SELECT mgpc.id_,mgpc.payment_valid_start_date_,mgpc.payment_valid_end_date_,
  316. mg.educational_teacher_id_,mg.name_,su.phone_
  317. FROM music_group_payment_calender mgpc
  318. LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
  319. LEFT JOIN sys_user su ON su.id_ = mg.educational_teacher_id_
  320. WHERE mgpc.id_ IN
  321. <foreach collection="calenderIds" open="(" close=")" separator="," item="item">
  322. #{item}
  323. </foreach>
  324. </select>
  325. <select id="getMusicCalenderPushDto" resultMap="CalenderPushDto">
  326. SELECT mg.payment_valid_start_date_,mg.payment_valid_end_date_,
  327. mg.educational_teacher_id_,su.phone_,mg.name_ FROM music_group mg
  328. LEFT JOIN sys_user su ON mg.educational_teacher_id_ = su.id_
  329. WHERE mg.payment_valid_end_date_ IS NOT NULL AND
  330. DATEDIFF(mg.payment_valid_end_date_,#{format}) = #{configValue}
  331. </select>
  332. <select id="getMusicGroupUnusedFirstPaymentCalender" resultMap="MusicGroupPaymentCalender">
  333. SELECT
  334. mgpc.*
  335. FROM
  336. music_group_payment_calender_detail mgpcd
  337. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  338. LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
  339. WHERE
  340. mgpcd.music_group_payment_calender_id_ = mgpccs.music_group_payment_calender_id_
  341. AND mgpc.music_group_id_ = #{musicGroupId}
  342. AND mgpcd.use_in_course_ = 0
  343. AND mgpcd.user_id_ IN
  344. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  345. #{studentId}
  346. </foreach>
  347. ORDER BY
  348. mgpc.payment_valid_start_date_
  349. LIMIT 1;
  350. </select>
  351. <select id="getUnusedFirstPaymentCalenderWithCalenders" resultMap="MusicGroupPaymentCalender">
  352. SELECT * FROM music_group_payment_calender mgpc
  353. WHERE id_ IN
  354. <foreach collection="calenderIds" item="calenderId" open="(" close=")" separator=",">
  355. #{calenderId}
  356. </foreach>
  357. ORDER BY create_time_ LIMIT 1;
  358. </select>
  359. <select id="findByBatchNo" resultMap="MusicGroupPaymentCalender">
  360. SELECT * FROM music_group_payment_calender WHERE batch_no_=#{batchNo}
  361. </select>
  362. <resultMap id="MusicGroupPaymentCalenderAuditDtoMap" type="com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto">
  363. <result property="musicGroupId" column="music_group_id_"/>
  364. <result property="musicGroupName" column="music_group_name_"/>
  365. <result property="organId" column="organ_id_"/>
  366. <result property="createTime" column="create_time_"/>
  367. <result property="paymentType" column="payment_type_"/>
  368. <result property="memo" column="memo_"/>
  369. <result property="operator" column="operator_"/>
  370. <result property="auditStatus" column="status_"/>
  371. <result property="addCourseTotalTime" column="course_total_minuties_"/>
  372. <result property="courseCurrentPrice" column="course_current_price_"/>
  373. <result property="courseOriginalPrice" column="course_original_price_"/>
  374. <result property="musicGroupPaymentCalenderId" column="id_"/>
  375. <result property="payUserType" column="pay_user_type_"/>
  376. <result property="calenderSettingsName" column="calender_settings_name_"/>
  377. <result property="paymentPattern" column="payment_pattern_"/>
  378. <result property="paymentValidStartDate" column="payment_valid_start_date_"/>
  379. <result property="paymentValidEndDate" column="payment_valid_end_date_"/>
  380. <result property="startPaymentDate" column="start_payment_date_"/>
  381. <result property="deadlinePaymentDate" column="deadline_payment_date_"/>
  382. <result property="auditMemo" column="audit_memo_"/>
  383. <result property="paymentAmount" column="payment_amount_"/>
  384. <result property="isGiveMusicNetwork" column="is_give_music_network_"/>
  385. </resultMap>
  386. <sql id="MusicGroupPaymentCalenderAuditDtoSql">
  387. <where>
  388. <if test="paymentType != null">
  389. AND mgpc.payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  390. </if>
  391. <if test="status != null">
  392. AND mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  393. </if>
  394. <if test="organId != null and organId != ''">
  395. AND FIND_IN_SET(mg.organ_id_,#{organId})
  396. </if>
  397. <if test="search != null and search != ''">
  398. AND (mg.id_ LIKE CONCAT('%',#{search},'%') OR mg.name_ LIKE CONCAT('%',#{search},'%'))
  399. </if>
  400. </where>
  401. </sql>
  402. <select id="countAuditList" resultType="java.lang.Integer">
  403. SELECT COUNT(DISTINCT mgpc.id_)
  404. FROM music_group_payment_calender mgpc
  405. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  406. <include refid="MusicGroupPaymentCalenderAuditDtoSql"/>
  407. </select>
  408. <select id="queryAuditList" resultMap="MusicGroupPaymentCalenderAuditDtoMap">
  409. SELECT mgpc.id_,mgpc.music_group_id_,mgpc.create_time_,mgpc.payment_type_,mgpc.operator_,
  410. mgpc.pay_user_type_,mgpc.memo_,mgpc.status_,SUM(mgpccs.course_total_minuties_) course_total_minuties_,
  411. SUM(mgpccs.course_original_price_) course_original_price_,SUM(mgpccs.course_current_price_) course_current_price_,
  412. MAX(mg.name_) music_group_name_,MAX(mg.organ_id_) organ_id_,mgpc.payment_pattern_
  413. FROM music_group_payment_calender mgpc
  414. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  415. LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
  416. <include refid="MusicGroupPaymentCalenderAuditDtoSql"/>
  417. GROUP BY mgpc.id_
  418. ORDER BY create_time_ DESC
  419. <include refid="global.limit"/>
  420. </select>
  421. <select id="countExpectNum" resultType="java.util.Map">
  422. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
  423. WHERE mgpcd.music_group_payment_calender_id_ = #{id}
  424. GROUP BY mgpcd.music_group_payment_calender_id_
  425. </select>
  426. <select id="countActualNum" resultType="java.util.Map">
  427. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
  428. WHERE mgpcd.music_group_payment_calender_id_ = #{id}
  429. AND mgpcd.payment_status_ = 'PAID_COMPLETED'
  430. GROUP BY mgpcd.music_group_payment_calender_id_
  431. </select>
  432. <select id="getAuditDetail" resultMap="MusicGroupPaymentCalenderAuditDtoMap">
  433. SELECT mgpc.id_,mgpc.music_group_id_,mgpc.create_time_,mgpc.payment_type_,mgpc.operator_,
  434. mgpc.pay_user_type_,mgpc.memo_,mgpc.status_,SUM(mgpccs.course_total_minuties_) course_total_minuties_,
  435. SUM(mgpccs.course_original_price_) course_original_price_,SUM(mgpccs.course_current_price_) course_current_price_,
  436. MAX(mg.name_) music_group_name_,MAX(mg.organ_id_) organ_id_,MAX(mgpccs.name_) calender_settings_name_,mgpc.payment_pattern_,mgpc.payment_valid_start_date_,
  437. mgpc.payment_valid_end_date_,mgpc.start_payment_date_,mgpc.deadline_payment_date_,mgpc.audit_memo_,mgpc.payment_amount_,mgpc.is_give_music_network_
  438. FROM music_group_payment_calender mgpc
  439. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  440. LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
  441. WHERE mgpc.id_ = #{calenderId} LIMIT 1
  442. </select>
  443. <select id="findByMusicGroupRegCalender" resultMap="MusicGroupPaymentCalender">
  444. SELECT * FROM music_group_payment_calender WHERE music_group_id_=#{musicGroupId} AND payment_type_='MUSIC_APPLY'
  445. </select>
  446. <select id="getCalenderSettingsName" resultType="java.lang.String">
  447. SELECT name_ FROM music_group_payment_calender_course_settings
  448. WHERE music_group_payment_calender_id_ = #{calenderId} LIMIT 1
  449. </select>
  450. <select id="countAuditReject" resultType="java.lang.Integer">
  451. SELECT COUNT(0) FROM music_group_payment_calender
  452. WHERE music_group_id_ = #{musicGroupId} AND payment_type_='MUSIC_APPLY' AND status_ IN ('REJECT','AUDITING')
  453. <if test="calenderId != null">
  454. AND id_ != #{calenderId}
  455. </if>
  456. </select>
  457. <select id="getMusicGroupRegCalender" resultMap="MusicGroupPaymentCalender">
  458. SELECT * FROM music_group_payment_calender
  459. WHERE music_group_id_ = #{musicGroupId}
  460. AND payment_type_ = 'MUSIC_APPLY'
  461. AND pay_user_type_='STUDENT'
  462. AND status_='OPEN'
  463. </select>
  464. <select id="queryUserPaymentStatus" resultType="java.util.Map">
  465. SELECT mg.id_ 'key',CASE WHEN COUNT(mgpc.id_) = 0 OR COUNT(DISTINCT mgpcd.id_) > 0 THEN 'NON_PAYMENT' ELSE 'PAID_COMPLETED' END 'value'
  466. FROM music_group mg
  467. LEFT JOIN music_group_payment_calender mgpc ON mgpc.music_group_id_ = mg.id_
  468. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  469. AND mgpcd.user_id_ = #{userId} AND mgpcd.payment_status_ = 'NON_PAYMENT'
  470. WHERE FIND_IN_SET(mg.id_,#{musicGroupId})
  471. GROUP BY mg.id_
  472. </select>
  473. </mapper>