MusicGroupPaymentCalenderMapper.xml 21 KB

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