123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <?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.MusicGroupCalenderRefundPeriodDao">
-
- <resultMap type="com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod" id="MusicGroupCalenderRefundPeriod">
- <result column="id_" property="id" />
- <result column="organ_id_" property="organId" />
- <result column="order_nos_" property="orderNos" />
- <result column="cooperation_organ_id_" property="cooperationOrganId" />
- <result column="calender_id_" property="calenderId" />
- <result column="refund_date_" property="refundDate" />
- <result column="refund_amount_" property="refundAmount" />
- <result column="income_" property="income" />
- <result column="sub_refund_amount_" property="subRefundAmount" />
- <result column="refund_flag_" property="refundFlag" />
- <result column="memo_" property="memo" />
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- </resultMap>
- <update id="batchUpdate">
- <foreach collection="refundPeriods" item="bean" index="index" open="" close="" separator=";">
- UPDATE music_group_calender_refund_period <set>
- <if test="bean.orderNos != null and bean.orderNos != ''">
- order_nos_ = #{bean.orderNos},
- </if>
- <if test="bean.memo != null and bean.memo != ''">
- memo_ = #{bean.memo},
- </if>
- <if test="bean.refundDate != null and bean.refundDate != ''">
- refund_date_ = #{bean.refundDate},
- </if>
- <if test="bean.subRefundAmount != null">
- sub_refund_amount_ = #{bean.subRefundAmount},
- </if>
- <if test="bean.refundAmount != null">
- refund_amount_ = #{bean.refundAmount},
- </if>
- <if test="bean.income != null">
- income_ = #{bean.income},
- </if>
- <if test="bean.refundFlag != null">
- refund_flag_ = #{bean.refundFlag},
- </if>
- </set> WHERE id_ = #{bean.id}
- </foreach>
- </update>
- <delete id="deleteByCalenderId">
- DELETE FROM music_group_calender_refund_period WHERE calender_id_ = #{calenderId}
- </delete>
- <!-- 全查询 -->
- <select id="findAll" resultMap="MusicGroupCalenderRefundPeriod">
- SELECT * FROM music_group_calender_refund_period
- </select>
-
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- INSERT INTO music_group_calender_refund_period (organ_id_,cooperation_organ_id_,calender_id_,
- refund_date_,refund_amount_,sub_refund_amount_,income_,refund_flag_,order_nos_,responsible_person_,create_time_,update_time_)
- VALUES(#{organId},#{cooperationOrganId},#{calenderId},#{refundDate},#{refundAmount},#{subRefundAmount},#{income},#{refundFlag},#{orderNos},#{responsiblePerson},NOW(),NOW())
- </insert>
- <insert id="batchInsert">
- INSERT INTO music_group_calender_refund_period (organ_id_,cooperation_organ_id_,calender_id_,
- refund_date_,refund_amount_,sub_refund_amount_,income_,refund_flag_,
- order_nos_,responsible_person_,create_time_,update_time_)
- VALUES
- <foreach collection="refundPeriods" separator="," item="bean">
- (#{bean.organId},#{bean.cooperationOrganId},#{bean.calenderId},#{bean.refundDate},
- #{bean.refundAmount},#{bean.subRefundAmount},#{bean.income},#{bean.refundFlag},#{bean.orderNos},
- #{bean.responsiblePerson},#{bean.createTime},#{bean.updateTime})
- </foreach>
- </insert>
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod">
- UPDATE music_group_calender_refund_period <set>
- <if test="orderNos != null and orderNos != ''">
- order_nos_ = #{orderNos},
- </if>
- <if test="subRefundAmount != null">
- sub_refund_amount_ = #{subRefundAmount},
- </if>
- <if test="income != null">
- income_ = #{income},
- </if>
- <if test="refundFlag != null">
- refund_flag_ = #{refundFlag},
- </if>
- update_time_ = NOW()
- </set> WHERE id_ = #{id}
- </update>
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="MusicGroupCalenderRefundPeriod" parameterType="map">
- SELECT * FROM music_group_calender_refund_period <include refid="global.limit"/>
- </select>
-
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM music_group_calender_refund_period
- </select>
- <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>
- mgpc.status_ IN ('OPEN','OVER','PAID')
- <if test="errorType != null and errorType != ''">
- <if test="errorType == 'COOPERATION_PAYMENT_ERROR'">
- AND TIMESTAMPDIFF(DAY,crp.refund_date_,DATE_FORMAT(NOW(),'%Y-%m-%d')) >= 1 AND refund_flag_ = 0
- </if>
- <if test="errorType == 'COOPERATION_PAYMENT_ALERT'">
- AND TIMESTAMPDIFF(DAY,crp.refund_date_,DATE_FORMAT(NOW(),'%Y-%m-%d')) BETWEEN -2 AND 0 AND refund_flag_ = 0
- </if>
- </if>
- <if test="organId != null and organId != ''">
- AND FIND_IN_SET(crp.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_
- left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_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_
- left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_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="income" column="income_"/>
- <result property="memo" column="memo_"/>
- <result property="nextRefundDate" column="nextRefundDate"/>
- <result property="refundStatus" column="refundStatus"/>
- <result property="contractUrl" column="contract_url_"/>
- </resultMap>
- <sql id="queryCoopCalenderSql">
- <where>
- mgpc.status_ IN ('OPEN','OVER','PAID')
- <if test="cooperationId != null">
- AND crp.cooperation_organ_id_ = #{cooperationId}
- </if>
- <if test="calenderId != null">
- AND crp.calender_id_ = #{calenderId}
- </if>
- <if test="refundStartDate != null and refundStartDate != ''">
- AND crp.refund_date_ BETWEEN #{refundStartDate} AND #{refundEndDate}
- </if>
- <if test="search != null and search != ''">
- AND (mg.name_ LIKE CONCAT('%',#{search},'%') OR mg.id_ = #{search})
- </if>
- </where>
- </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_,crp.memo_,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,SUM(crp.income_) income_,
- MIN(CASE WHEN crp.refund_flag_ = 0 THEN crp.refund_date_ ELSE NULL END) nextRefundDate,crp.organ_id_,mgpc.contract_url_
- 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(sub_refund_amount_) END from music_group_calender_refund_period crp
- left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
- left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
- <include refid="queryCoopRefundSql"/>
- </select>
- <select id="queryByIds" resultMap="MusicGroupCalenderRefundPeriod">
- SELECT * FROM music_group_calender_refund_period WHERE id_ IN
- <foreach collection="periodsIds" item="id" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </select>
- </mapper>
|