|
@@ -35,7 +35,8 @@
|
|
|
refund_date_,refund_amount_,sub_refund_amount_,create_time_,update_time_)
|
|
|
VALUES
|
|
|
<foreach collection="refundPeriods" separator="," item="bean">
|
|
|
- (#{organId},#{cooperationOrganId},#{calenderId},#{refundDate},#{refundAmount},#{subRefundAmount},#{createTime},#{updateTime})
|
|
|
+ (#{bean.organId},#{bean.cooperationOrganId},#{bean.calenderId},#{bean.refundDate},
|
|
|
+ #{bean.refundAmount},#{bean.subRefundAmount},#{bean.createTime},#{bean.updateTime})
|
|
|
</foreach>
|
|
|
</insert>
|
|
|
|
|
@@ -52,4 +53,95 @@
|
|
|
<select id="findByCalenderId" resultMap="MusicGroupCalenderRefundPeriod">
|
|
|
SELECT * FROM music_group_calender_refund_period where calender_id_ = #{calenderId} ORDER BY refund_date_
|
|
|
</select>
|
|
|
+ <resultMap id="CooperationRefundDto" type="com.ym.mec.biz.dal.dto.CooperationRefundDto">
|
|
|
+ <result property="organId" column="organ_id_"/>
|
|
|
+ <result property="cooperationOrganId" column="cooperation_organ_id_"/>
|
|
|
+ <result property="cooperationOrganName" column="cooperation_organ_name_"/>
|
|
|
+ <result property="receivable" column="receivable_"/>
|
|
|
+ <result property="prepaidFee" column="prepaidFee"/>
|
|
|
+ <result property="educationUserId" column="education_user_id_"/>
|
|
|
+ </resultMap>
|
|
|
+ <sql id="queryCoopRefundSql">
|
|
|
+ <where>
|
|
|
+ <if test="organId != null and organId != ''">
|
|
|
+ AND FIND_IN_SET(co.organ_id_,#{organId})
|
|
|
+ </if>
|
|
|
+ <if test="search != null and search != ''">
|
|
|
+ AND (co.name_ LIKE CONCAT('%',#{search},'%') OR co.id_ = #{search})
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+ <select id="countCoopRefund" resultType="java.lang.Integer">
|
|
|
+ select COUNT(DISTINCT crp.cooperation_organ_id_)
|
|
|
+ from music_group_calender_refund_period crp
|
|
|
+ left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
|
|
|
+ <include refid="queryCoopRefundSql"/>
|
|
|
+ </select>
|
|
|
+ <select id="queryCoopRefund" resultMap="CooperationRefundDto">
|
|
|
+ select co.organ_id_,crp.cooperation_organ_id_,co.name_ cooperation_organ_name_,
|
|
|
+ SUM(refund_amount_) receivable_,SUM(sub_refund_amount_) prepaidFee,co.education_user_id_
|
|
|
+ from music_group_calender_refund_period crp
|
|
|
+ left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
|
|
|
+ <include refid="queryCoopRefundSql"/>
|
|
|
+ group by crp.cooperation_organ_id_
|
|
|
+ order by crp.id_ DESC
|
|
|
+ </select>
|
|
|
+ <resultMap id="CooperationCalenderRefundDto" type="com.ym.mec.biz.dal.dto.CooperationCalenderRefundDto">
|
|
|
+ <result property="calenderId" column="calender_id_"/>
|
|
|
+ <result property="batchNo" column="batch_no_"/>
|
|
|
+ <result property="paymentType" column="payment_type_"/>
|
|
|
+ <result property="musicGroupId" column="music_group_id_"/>
|
|
|
+ <result property="musicGroupName" column="music_group_name_"/>
|
|
|
+ <result property="calenderFeeType" column="calender_fee_type_"/>
|
|
|
+ <result property="receivable" column="receivable_"/>
|
|
|
+ <result property="prepaidFee" column="prepaidFee"/>
|
|
|
+ <result property="nextRefundDate" column="nextRefundDate"/>
|
|
|
+ <result property="refundStatus" column="refundStatus"/>
|
|
|
+ </resultMap>
|
|
|
+ <sql id="queryCoopCalenderSql">
|
|
|
+ <if test="calenderId != null">
|
|
|
+ AND crp.calender_id_
|
|
|
+ </if>
|
|
|
+ <if test="refundStartDate != null and refundStartDate != ''">
|
|
|
+ AND crp.refund_date_ BETWEEN #{refundStartDate} AND #{refundEndDate}
|
|
|
+ </if>
|
|
|
+ <if test="search != '' and search != ''">
|
|
|
+ AND (mg.name_ LIKE CONCAT('%',#{search},'%') OR mg.id_ = #{search})
|
|
|
+ </if>
|
|
|
+ </sql>
|
|
|
+ <sql id="queryCoopCalenderHavingSql">
|
|
|
+ <if test="refundStatus != null and refundStatus != ''">
|
|
|
+ <if test="refundStatus = 'ING'">
|
|
|
+ HAVING SUM(crp.sub_refund_amount_) > 0
|
|
|
+ </if>
|
|
|
+ <if test="refundStatus = 'END'">
|
|
|
+ HAVING SUM(crp.sub_refund_amount_) = 0
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </sql>
|
|
|
+ <select id="queryCoopCalender" resultMap="CooperationCalenderRefundDto">
|
|
|
+ select crp.calender_id_,mgpc.music_group_id_,mg.name_ music_group_name_,mgpc.batch_no_,mgpc.payment_type_,mgpc.calender_fee_type_,
|
|
|
+ SUM(crp.refund_amount_) receivable_,SUM(crp.sub_refund_amount_) prepaidFee,
|
|
|
+ MIN(CASE WHEN crp.refund_flag_ = 0 THEN crp.refund_date_ ELSE NULL END) nextRefundDate
|
|
|
+ from music_group_calender_refund_period crp
|
|
|
+ left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
|
|
|
+ left join music_group mg ON mg.id_ = mgpc.music_group_id_
|
|
|
+ <include refid="queryCoopCalenderSql"/>
|
|
|
+ group by crp.calender_id_
|
|
|
+ <include refid="queryCoopCalenderHavingSql"/>
|
|
|
+ </select>
|
|
|
+ <select id="countCoopCalender" resultType="java.lang.Integer">
|
|
|
+ select COUNT(calender_id_) from (select crp.calender_id_
|
|
|
+ from music_group_calender_refund_period crp
|
|
|
+ left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
|
|
|
+ left join music_group mg ON mg.id_ = mgpc.music_group_id_
|
|
|
+ <include refid="queryCoopCalenderSql"/>
|
|
|
+ group by crp.calender_id_
|
|
|
+ <include refid="queryCoopCalenderHavingSql"/>)crp
|
|
|
+ </select>
|
|
|
+ <select id="sumCoopRefund" resultType="java.math.BigDecimal">
|
|
|
+ select CASE WHEN crp.id_ IS NULL THEN 0 ELSE SUM(refund_amount_) - SUM(sub_refund_amount_) END from music_group_calender_refund_period crp
|
|
|
+ left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
|
|
|
+ <include refid="queryCoopRefundSql"/>
|
|
|
+ </select>
|
|
|
</mapper>
|