| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528 | 
							- <?xml version="1.0" encoding="UTF-8" ?>
 
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
- <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
 
- <mapper namespace="com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao">
 
- 	<resultMap type="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail"
 
- 		id="MusicGroupPaymentCalenderDetail">
 
- 		<result column="id_" property="id" />
 
- 		<result column="music_group_payment_calender_id_" property="musicGroupPaymentCalenderId" />
 
- 		<result column="user_id_" property="userId" />
 
- 		<result column="expect_amount_" property="expectAmount" />
 
- 		<result column="actual_amount_" property="actualAmount" />
 
- 		<result column="payment_status_" property="paymentStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 
- 		<result column="user_status_" property="userStatus" />
 
- 		<result column="music_group_id_" property="musicGroupId" />
 
- 		<result column="pay_time_" property="payTime" />
 
- 		<result column="start_payment_date_" property="startPaymentDate" />
 
- 		<result column="deadline_payment_date_" property="deadlinePaymentDate" />
 
- 		<result column="start_payment_date_mgpc_" property="startPaymentDateMgpc" />
 
- 		<result column="deadline_payment_date_mgpc_" property="deadlinePaymentDateMgpc" />
 
- 		<result column="payment_order_id_" property="paymentOrderId"/>
 
- 		<result column="update_time_" property="updateTime" />
 
- 		<result column="create_time_" property="createTime" />
 
- 		<result column="open_" property="open"/>
 
- 		<result column="open_" property="openFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 
- 		<result column="use_in_course_" property="useInCourse"/>
 
- 		<result column="responsible_user_id_" property="responsibleUserId"/>
 
- 		<result column="responsible_record_" property="responsibleRecord"/>
 
- 		<result column="responsible_username_" property="responsible.username"/>
 
- 		<association property="sysUser" javaType="com.ym.mec.auth.api.entity.SysUser">
 
- 			<result column="username_" property="username" />
 
- 			<result column="phone_" property="phone" />
 
- 		</association>
 
- 		<association property="studentRegistration" javaType="com.ym.mec.biz.dal.entity.StudentRegistration">
 
- 			<result column="subject_names_" property="subjectName" />
 
- 			<result column="music_group_status_" property="musicGroupStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 
- 		</association>
 
- 	</resultMap>
 
- 	<!-- 根据主键查询一条记录 -->
 
- 	<select id="get" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT * FROM music_group_payment_calender_detail WHERE id_ = #{id}
 
- 	</select>
 
- 	<!-- 全查询 -->
 
- 	<select id="findAll" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT * FROM music_group_payment_calender_detail ORDER BY id_
 
- 	</select>
 
- 	<!-- 向数据库增加一条记录 -->
 
- 	<insert id="insert"
 
- 		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail"
 
- 		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 
- 		INSERT INTO music_group_payment_calender_detail
 
- 		(id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,
 
- 		user_status_,pay_time_,update_time_,create_time_,start_payment_date_,deadline_payment_date_,payment_order_id_,use_in_course_,responsible_user_id_,responsible_record_)
 
- 		VALUES(#{id},#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},#{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 
- 		#{userStatus},#{payTime},NOW(),NOW(),#{startPaymentDate},#{deadlinePaymentDate},#{paymentOrderId},#{useInCourse},#{responsibleUserId},#{responsibleRecord})
 
- 	</insert>
 
-     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
 
-             keyProperty="id">
 
-         INSERT INTO music_group_payment_calender_detail
 
- 		(id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,
 
- 		payment_status_,user_status_,pay_time_,update_time_,create_time_,start_payment_date_,deadline_payment_date_,payment_order_id_,use_in_course_,responsible_user_id_,responsible_record_)
 
- 		VALUES
 
- 		<foreach collection="list" item="item" separator=",">
 
-             (#{item.id},#{item.musicGroupPaymentCalenderId},#{item.userId},#{item.expectAmount},
 
-             #{item.actualAmount},#{item.paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.userStatus},#{item.payTime},
 
-             #{item.updateTime},#{item.createTime},#{item.startPaymentDate},#{item.deadlinePaymentDate},#{item.paymentOrderId},#{item.useInCourse},#{item.responsibleUserId},#{item.responsibleRecord})
 
-         </foreach>
 
-     </insert>
 
- 	<!-- 根据主键查询一条记录 -->
 
- 	<update id="update"
 
- 		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
 
- 		UPDATE music_group_payment_calender_detail
 
- 		<set>
 
- 			<if test="startPaymentDate != null">
 
- 				start_payment_date_ = #{startPaymentDate},
 
- 			</if>
 
- 			<if test="deadlinePaymentDate != null">
 
- 				deadline_payment_date_ = #{deadlinePaymentDate},
 
- 			</if>
 
- 			<if test="open != null">
 
- 				open_ = #{open},
 
- 			</if>
 
- 			<if test="userId != null">
 
- 				user_id_ = #{userId},
 
- 			</if>
 
- 			<if test="userStatus != null">
 
- 				user_status_ = #{userStatus},
 
- 			</if>
 
- 			<if test="paymentStatus != null">
 
- 				payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 
- 			</if>
 
- 			<if test="expectAmount != null">
 
- 				expect_amount_ = #{expectAmount},
 
- 			</if>
 
- 			<if test="updateTime != null">
 
- 				update_time_ = #{updateTime},
 
- 			</if>
 
- 			<if test="musicGroupPaymentCalenderId != null">
 
- 				music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
 
- 			</if>
 
- 			<if test="actualAmount != null">
 
- 				actual_amount_ = #{actualAmount},
 
- 			</if>
 
- 			<if test="payTime != null">
 
- 				pay_time_ = #{payTime},
 
- 			</if>
 
- 			<if test="paymentOrderId != null">
 
- 				payment_order_id_ = #{paymentOrderId},
 
- 			</if>
 
- 			<if test="useInCourse != null">
 
- 				use_in_course_ = #{useInCourse},
 
- 			</if>
 
- 			<if test="responsibleUserId != null">
 
- 				responsible_user_id_ = #{responsibleUserId},
 
- 			</if>
 
- 			<if test="responsibleRecord != null">
 
- 				responsible_record_ = #{responsibleRecord},
 
- 			</if>
 
- 		</set>
 
- 		WHERE id_ = #{id}
 
- 	</update>
 
- 	<update id="batchUpdate">
 
- 		<foreach collection="calenderDetails" item="item" index="index" open="" close="" separator=";">
 
- 			UPDATE music_group_payment_calender_detail
 
- 			<set>
 
- 				<if test="item.startPaymentDate != null">
 
- 					start_payment_date_ = #{item.startPaymentDate},
 
- 				</if>
 
- 				<if test="item.deadlinePaymentDate != null">
 
- 					deadline_payment_date_ = #{item.deadlinePaymentDate},
 
- 				</if>
 
- 				<if test="item.open != null">
 
- 					open_ = #{item.open},
 
- 				</if>
 
- 				<if test="item.userId != null">
 
- 					user_id_ = #{item.userId},
 
- 				</if>
 
- 				<if test="item.userStatus != null">
 
- 					user_status_ = #{item.userStatus},
 
- 				</if>
 
- 				<if test="item.paymentStatus != null">
 
- 					payment_status_ = #{item.paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 
- 				</if>
 
- 				<if test="item.expectAmount != null">
 
- 					expect_amount_ = #{item.expectAmount},
 
- 				</if>
 
- 				<if test="item.updateTime != null">
 
- 					update_time_ = #{item.updateTime},
 
- 				</if>
 
- 				<if test="item.musicGroupPaymentCalenderId != null">
 
- 					music_group_payment_calender_id_ = #{item.musicGroupPaymentCalenderId},
 
- 				</if>
 
- 				<if test="item.actualAmount != null">
 
- 					actual_amount_ = #{item.actualAmount},
 
- 				</if>
 
- 				<if test="item.payTime != null">
 
- 					pay_time_ = #{item.payTime},
 
- 				</if>
 
- 				<if test="item.paymentOrderId != null">
 
- 					payment_order_id_ = #{item.paymentOrderId},
 
- 				</if>
 
- 				<if test="item.useInCourse != null">
 
- 					use_in_course_ = #{item.useInCourse},
 
- 				</if>
 
- 				<if test="item.responsibleUserId != null">
 
- 					responsible_user_id_ = #{item.responsibleUserId},
 
- 				</if>
 
- 				<if test="item.responsibleRecord != null">
 
- 					responsible_record_ = #{item.responsibleRecord},
 
- 				</if>
 
- 			</set>
 
- 			WHERE id_ = #{item.id}
 
- 		</foreach>
 
- 	</update>
 
- 	<update id="refreshUserMusicGroupPaymentStatusTask">
 
- 		UPDATE music_group_payment_calender_detail mgpcd
 
- 		SET mgpcd.open_ = 0,mgpcd.start_payment_date_ = NULL,mgpcd.deadline_payment_date_ = NULL
 
- 		WHERE mgpcd.deadline_payment_date_ < DATE_FORMAT(NOW(),'%Y-%m-%d')
 
- 	</update>
 
- 	<!-- 根据主键删除一条记录 -->
 
- 	<delete id="delete">
 
- 		DELETE FROM music_group_payment_calender_detail WHERE id_ = #{id}
 
- 	</delete>
 
- 	<delete id="batchDel">
 
- 		DELETE FROM music_group_payment_calender_detail WHERE FIND_IN_SET(id_,#{musicGroupPaymentCalenderIdDetails})
 
- 	</delete>
 
-     <delete id="deleteByCalenderId">
 
- 		DELETE FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{id}
 
- 	</delete>
 
- 	
 
- 	<select id="queryNotPaymentStudentByUserIdAndMusicGroupId" resultMap="MusicGroupPaymentCalenderDetail" parameterType="map">
 
- 		select * FROM music_group_payment_calender_detail
 
- 		WHERE music_group_payment_calender_id_ IN (SELECT mgpc.id_ FROM music_group_payment_calender mgpc
 
- 		WHERE mgpc.music_group_id_ = #{musicGroupId})
 
- 		AND user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT'
 
- 	</select>
 
- 	<!-- 分页查询 -->
 
- 	<select id="queryPage" resultMap="MusicGroupPaymentCalenderDetail" parameterType="map">
 
- 		SELECT su.username_,su.phone_,st.name_ subject_names_,sr.music_group_status_,tu.real_name_ responsible_username_,
 
- 		CASE WHEN mgpcd.start_payment_date_ IS NULL THEN mgpc.start_payment_date_ ELSE mgpcd.start_payment_date_ END start_payment_date_mgpc_,
 
- 		CASE WHEN mgpcd.deadline_payment_date_ IS NULL THEN mgpc.deadline_payment_date_ ELSE mgpcd.deadline_payment_date_ END deadline_payment_date_mgpc_,
 
- 		CASE WHEN mgpc.status_ = 'OPEN' OR mgpcd.open_ = 1 THEN 1 ELSE 0 END open_,mgpcd.*
 
- 		FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN sys_user su ON su.id_ = mgpcd.user_id_
 
- 		left join sys_user tu on tu.id_ = mgpcd.responsible_user_id_
 
- 		LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_
 
- 		LEFT JOIN `subject` st ON st.id_ = sr.actual_subject_id_
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 
- 		<include refid="queryPageSql"/>
 
- 		ORDER BY mgpc.update_time_ DESC
 
- 		<include refid="global.limit" />
 
- 	</select>
 
- 	<sql id="queryPageSql">
 
- 		<where>
 
- 			mgpc.music_group_id_ = sr.music_group_id_
 
- 			<if test="search != null and search != ''">
 
- 				AND (mgpcd.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
 
- 			</if>
 
- 			<if test="id != null">
 
- 				AND mgpcd.music_group_payment_calender_id_ = #{id}
 
- 			</if>
 
- 			<if test="paymentStatus != null and paymentStatus != ''">
 
- 				AND mgpcd.payment_status_ = #{paymentStatus}
 
- 			</if>
 
- 			<if test="musicGroupId != null and musicGroupId != ''">
 
- 				AND mgpc.music_group_id_ = #{musicGroupId}
 
- 			</if>
 
- 			<if test="userId != null">
 
- 				AND mgpcd.user_id_ = #{userId}
 
- 			</if>
 
- 			<if test="musicGroupStatus != null and musicGroupStatus != ''">
 
- 				AND sr.music_group_status_ = #{musicGroupStatus}
 
- 			</if>
 
- 			<if test="subjectId != null">
 
- 				AND #{subjectId} = sr.actual_subject_id_
 
- 			</if>
 
- 			<if test="responsibleRealName != null and responsibleRealName != ''">
 
- 				AND (mgpcd.responsible_user_id_ = #{responsibleRealName} OR tu.real_name_ LIKE CONCAT('%',#{responsibleRealName},'%') OR tu.phone_ LIKE CONCAT('%',#{responsibleRealName},'%'))
 
- 			</if>
 
- 		</where>
 
- 	</sql>
 
- 	<!-- 查询当前表的总记录数 -->
 
- 	<select id="queryCount" resultType="int">
 
- 		SELECT COUNT(DISTINCT mgpcd.id_) FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_
 
- 		LEFT JOIN `subject` st ON st.id_ = sr.actual_subject_id_
 
- 		LEFT JOIN sys_user su ON su.id_ = mgpcd.user_id_
 
- 		left join sys_user tu on tu.id_ = mgpcd.responsible_user_id_
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 
- 		<include refid="queryPageSql"/>
 
- 	</select>
 
- 	<select id="queryListByIds" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT mgpcd.*,mgpc.music_group_id_ FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 
- 		WHERE FIND_IN_SET(mgpcd.id_,#{ids})
 
- 		GROUP BY mgpcd.id_
 
- 	</select>
 
- 	
 
- 	<select id="queryByCalenderId" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT * FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{calenderId}
 
- 		<if test="paymentStatus != null">
 
- 			AND payment_status_ = #{paymentStatus}
 
- 		</if>
 
- 	</select>
 
-     <select id="findMusicGroupStudentWithSubject" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
 
- 		SELECT DISTINCT su.id_ userId,su.username_ userName, su.avatar_ avatar, su.phone_ phone
 
- 		from music_group_student_fee_ mgstf
 
- 		LEFT JOIN sys_user su ON su.id_=mgstf.user_id_
 
- 		WHERE mgstf.music_group_id_=#{musicGroupId}
 
- 		AND mgstf.subject_id_=#{subjectId}
 
- 		AND mgstf.remain_network_class_times_>0
 
- 		ORDER BY su.id_
 
- 	</select>
 
- 	<select id="getUserLastCalenderDetail" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT * FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
 
- 		WHERE mgpc.music_group_id_=#{musicGroupId} AND mgpcd.user_id_=#{userId} AND mgpcd.payment_status_ = 'NON_PAYMENT'
 
- 		AND (mgpc.status_ = 'OPEN' OR mgpcd.open_ = 1)
 
- 		ORDER BY mgpc.start_payment_date_ DESC LIMIT 1
 
- 	</select>
 
- 	<select id="queryCanOpenList" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT * FROM music_group_payment_calender_detail
 
- 		WHERE FIND_IN_SET(id_,#{ids}) AND payment_status_ = 'NON_PAYMENT' AND open_ = 0
 
- 	</select>
 
- 	<select id="queryIntersectionByPaymentDate" resultType="java.lang.Integer">
 
- 		SELECT COUNT(mgpcd.id_) FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
 
- 		WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpcd.user_id_ = #{userId}
 
- 		AND  mgpcd.open_ = 1
 
- 	</select>
 
- 	<select id="queryCanPushList" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT mgpcd.*,mgpc.music_group_id_ FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 
- 		LEFT JOIN student_registration sr ON sr.music_group_id_ = mgpc.music_group_id_
 
- 		WHERE mgpcd.payment_status_ = 'NON_PAYMENT' AND sr.music_group_status_ != 'QUIT' AND mgpc.id_ = #{musicGroupPaymentCalenderId}
 
- 		GROUP BY mgpcd.id_
 
- 	</select>
 
- 	<select id="queryNoPaymentCanPushList" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT mgpcd.*,mgpc.music_group_id_ FROM music_group_payment_calender mgpc
 
- 		LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 
- 		WHERE DATE_FORMAT(mgpc.create_time_,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND mgpc.status_ = 'OPEN' AND mgpcd.payment_status_ = 'NON_PAYMENT'
 
- 	</select>
 
- 	<select id="queryPaymentPushMap" resultType="java.util.Map">
 
- 		SELECT mgpcd.user_id_ 'key',mgpc.music_group_id_ 'value' FROM music_group_payment_calender mgpc
 
- 		LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 
- 		WHERE DATE_FORMAT(mgpc.create_time_,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND mgpc.status_ = 'OPEN' AND mgpcd.payment_status_ = 'NON_PAYMENT'
 
- 	</select>
 
- 	<select id="queryStudentIds" resultType="java.lang.Integer">
 
- 		SELECT user_id_ FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{calenderId}
 
- 	</select>
 
-     <select id="countOpenPayment" resultType="java.lang.Integer">
 
- 		SELECT COUNT(DISTINCT mgpcd.id_) FROM music_group_payment_calender mgpc
 
- 		LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 
- 		WHERE mgpcd.user_id_ = #{userId} AND mgpc.music_group_id_ = #{musicGroupId} AND (mgpc.status_ = 'OPEN' OR mgpcd.open_ = 1)
 
- 		AND mgpcd.payment_status_ != 'PAID_COMPLETED'
 
- 	</select>
 
- 	<select id="getCalenderDetailWithCalender" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT
 
- 			mgpcd.*
 
- 		FROM
 
- 			music_group_payment_calender_detail mgpcd
 
- 		WHERE
 
- 			mgpcd.music_group_payment_calender_id_ = #{calenderId}
 
- 	</select>
 
-     <select id="getWithCalenderIds" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT
 
- 			mgpcd.*
 
- 		FROM
 
- 			music_group_payment_calender_detail mgpcd
 
- 		WHERE
 
- 			mgpcd.music_group_payment_calender_id_ IN
 
- 			<foreach collection="calenderIds" item="calenderId" open="(" close=")" separator=",">
 
- 				#{calenderId}
 
- 			</foreach>
 
- 	</select>
 
- 	<resultMap id="SimpleUserDtoMap" type="com.ym.mec.biz.dal.dto.SimpleUserDto">
 
- 		<result property="userName" column="username_"/>
 
- 		<result property="userId" column="id_"/>
 
- 		<result property="subjectNames" column="subject_name_"/>
 
- 		<result property="actualAmount" column="actual_amount_"/>
 
- 	</resultMap>
 
-     <select id="querySimpleUserDto" resultMap="SimpleUserDtoMap">
 
- 		SELECT su.id_,su.username_,s.name_ subject_name_,mgpcd.actual_amount_
 
- 		FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 
- 		LEFT JOIN sys_user su ON su.id_ = mgpcd.user_id_
 
- 		LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_ AND sr.music_group_status_ != 'QUIT' AND sr.music_group_id_ = mgpc.music_group_id_
 
- 		LEFT JOIN `subject` s ON s.id_ = sr.subject_id_
 
- 		WHERE mgpc.batch_no_ = #{batchNo}
 
- 	</select>
 
- 	<select id="sumActualAmount" resultType="java.math.BigDecimal">
 
- 		SELECT SUM(mgpcd.actual_amount_) FROM music_group_payment_calender_detail mgpcd
 
- 		WHERE mgpcd.music_group_payment_calender_id_ = #{id}
 
- 	</select>
 
- 	<select id="findByCalenderIdAndUserId" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT * FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{calenderId} AND user_id_ = #{userId} LIMIT 1
 
- 	</select>
 
- 	<select id="findByOrderId" resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT * FROM music_group_payment_calender_detail WHERE payment_order_id_ = #{orderId} LIMIT 1
 
- 	</select>
 
- 	<select id="queryNoPaymentStudentIds" resultType="java.lang.Integer">
 
- 		SELECT user_id_ FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{calenderId} AND payment_status_ = 'NON_PAYMENT'
 
- 	</select>
 
- 	<select id="queryNoPaymentAndNotZeroStudent" resultType="java.util.Map">
 
- 		SELECT mgpcd.user_id_ 'key',su.phone_ 'value' FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN sys_user su ON su.id_ = mgpcd.user_id_
 
- 		WHERE music_group_payment_calender_id_ = #{calenderId} AND expect_amount_ != 0 AND payment_status_ = 'NON_PAYMENT'
 
- 		<if test="studentIds != null">
 
- 			AND mgpcd.user_id_ IN
 
- 			<foreach collection="studentIds" separator="," close=")" open="(" item="item">
 
- 				#{item}
 
- 			</foreach>
 
- 		</if>
 
-     </select>
 
- 	<select id="queryNoPaymentTotalAmount" resultType="java.util.Map">
 
- 		SELECT mgpcd.user_id_ 'key',SUM(mgpcd.expect_amount_) 'value' FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
 
- 		WHERE mgpc.batch_no_ IS NOT NULL AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpcd.expect_amount_ > 0
 
- 		AND mgpc.music_group_id_ = #{musicGroupId} AND mgpc.status_ IN ('OPEN','OVER','PAID')
 
- 		GROUP BY mgpcd.user_id_
 
- 	</select>
 
- 	<select id="queryNoPaymentUserIds" resultType="java.lang.Integer">
 
- 		SELECT mgpcd.user_id_ FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
 
- 		WHERE mgpc.batch_no_ IS NOT NULL AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpcd.expect_amount_ > 0
 
- 		  AND mgpc.music_group_id_ = #{musicGroupId} AND mgpc.status_ IN ('OPEN','OVER','PAID')
 
- 		<if test="userIds != null">
 
- 			AND mgpcd.user_id_ IN
 
- 			<foreach collection="userIds" open="(" close=")" separator="," item="item">
 
- 				#{item}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY mgpcd.user_id_  HAVING SUM(mgpcd.expect_amount_) > 0
 
- 	</select>
 
- 	<resultMap id="MusicArrearageStudentDto" type="com.ym.mec.biz.dal.dto.MusicArrearageStudentDto">
 
- 		<result property="userId" column="user_id_"/>
 
- 		<result property="studentName" column="student_name_"/>
 
- 		<result property="organName" column="organ_name_"/>
 
- 		<result property="cooperationName" column="cooperation_name_"/>
 
- 		<result property="musicGroupId" column="music_group_id_"/>
 
- 		<result property="musicGroupName" column="music_group_name_"/>
 
- 		<result property="eduTeacherName" column="edu_teacher_name_"/>
 
- 		<result property="subjectName" column="subject_name_"/>
 
- 		<result property="gender" column="gender_"/>
 
- 		<result property="parentName" column="parent_name_"/>
 
- 		<result property="phone" column="phone_"/>
 
- 		<result property="noPaymentAmount" column="no_payment_amount_"/>
 
- 	</resultMap>
 
- 	<sql id="queryArrearageStudentsCondition">
 
- 		<where>
 
- 			mg.status_ = 'PROGRESS'
 
- 			AND DATE_FORMAT( NOW(), '%Y-%m-%d' ) >= DATE_FORMAT( mgpc.payment_valid_start_date_, '%Y-%m-%d' )
 
- 			AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT'
 
- 			AND mgpcd.expect_amount_ > 0
 
- 			<if test="organIds!=null and organIds.size()>0">
 
- 				AND mg.organ_id_ IN
 
- 				<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 					#{organId}
 
- 				</foreach>
 
- 			</if>
 
- 			<if test="musicGroupId!=null and musicGroupId!=''">
 
- 				AND mgpc.music_group_id_ = #{musicGroupId}
 
- 			</if>
 
- 			<if test="cooperationOrganId!=null">
 
- 				AND mg.cooperation_organ_id_ = #{cooperationOrganId}
 
- 			</if>
 
- 			<if test="eduTeacherId!=null">
 
- 				AND mg.educational_teacher_id_=#{eduTeacherId}
 
- 			</if>
 
- 			<if test="search!=null and search!=''">
 
- 				AND (mgpcd.user_id_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
 
- 			</if>
 
- 		</where>
 
- 	</sql>
 
-     <select id="queryArrearageStudents" resultMap="MusicArrearageStudentDto">
 
- 		SELECT
 
- 			mgpcd.user_id_,
 
- 			SUM( mgpcd.expect_amount_ ) no_payment_amount_,
 
- 			su.username_ student_name_,
 
- 			organ.name_ organ_name_,
 
- 			co.name_ cooperation_name_,
 
- 		    mgpc.music_group_id_,
 
- 			mg.name_ music_group_name_,
 
- 			edu.real_name_ edu_teacher_name_,
 
- 			MAX( sub.name_ ) subject_name_,
 
- 			su.gender_ gender_,
 
- 			su.real_name_ parent_name_,
 
- 			su.phone_ phone_
 
- 		FROM
 
- 			music_group_payment_calender_detail mgpcd
 
- 			LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
 
- 			LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
 
- 			LEFT JOIN student_registration sr ON sr.music_group_id_ = mgpc.music_group_id_
 
- 			AND mgpcd.user_id_ = sr.user_id_
 
- 			LEFT JOIN sys_user su ON mgpcd.user_id_ = su.id_
 
- 			LEFT JOIN sys_user edu ON edu.id_ = mg.educational_teacher_id_
 
- 			LEFT JOIN organization organ ON organ.id_ = mg.organ_id_
 
- 			LEFT JOIN `subject` sub ON sr.actual_subject_id_ = sub.id_
 
- 			LEFT JOIN cooperation_organ co ON mg.cooperation_organ_id_ = co.id_
 
- 		<include refid="queryArrearageStudentsCondition"/>
 
- 		GROUP BY
 
- 			mgpc.music_group_id_,mgpcd.user_id_
 
- 		<include refid="global.limit" />
 
- 	</select>
 
- 	<select id="countArrearageStudents" resultType="int">
 
- 		SELECT
 
- 			COUNT(DISTINCT mgpc.music_group_id_,mgpcd.user_id_)
 
- 		FROM
 
- 			music_group_payment_calender_detail mgpcd
 
- 			LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
 
- 			LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
 
- 			<if test="search!=null and search!=''">
 
- 				LEFT JOIN sys_user su ON mgpcd.user_id_ = su.id_
 
- 			</if>
 
- 		<include refid="queryArrearageStudentsCondition"/>
 
- 	</select>
 
- 	<select id="getNoPaymentStudentMusicGroups" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.MusicGroup">
 
- 		SELECT
 
- 			DISTINCT mg.id_,mg.name_
 
- 		FROM
 
- 		music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
 
- 		LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
 
- 		WHERE mg.status_ = 'PROGRESS'
 
- 			AND DATE_FORMAT( NOW(), '%Y-%m-%d' ) >= DATE_FORMAT( mgpc.payment_valid_start_date_, '%Y-%m-%d' )
 
- 			AND mgpcd.payment_status_ = 'NON_PAYMENT'
 
- 			AND mgpcd.expect_amount_ > 0
 
- 			<if test="organIds!=null and organIds.size()>0">
 
- 				AND mg.organ_id_ IN
 
- 				<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 					#{organId}
 
- 				</foreach>
 
- 			</if>
 
- 	</select>
 
- 	<select id="queryNoPaymentCanPushByCalenderId"
 
- 			resultMap="MusicGroupPaymentCalenderDetail">
 
- 		SELECT mgpcd.* FROM music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 
- 		WHERE (mgpc.status_ = 'OPEN' OR mgpcd.open_ = 1) AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpcd.expect_amount_ != 0
 
- 		AND mgpcd.music_group_payment_calender_id_ = #{calenderId} AND FIND_IN_SET(mgpcd.user_id_,#{studentIds})
 
- 	</select>
 
-     <update id="updateNoPaymentAndZeroPaymentStatus">
 
- 		UPDATE music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 
- 		SET mgpcd.payment_status_ = 'PAID_COMPLETED',mgpcd.actual_amount_ = 0,mgpcd.update_time_ = NOW()
 
- 		WHERE mgpcd.music_group_payment_calender_id_ = #{calenderId} AND mgpcd.expect_amount_ = 0
 
- 		AND mgpcd.payment_status_ = 'NON_PAYMENT' AND (mgpcd.open_ = 1 OR mgpc.status_ = 'OPEN')
 
- 	</update>
 
- </mapper>
 
 
  |