yxh
2026-11-08 b1f41c066b0b7c38faffddbfe73b9be8d0bd508e
ruoyi-project/src/main/resources/mapper/project/ServiceDonorchargeorganMapper.xml
@@ -76,6 +76,7 @@
            resultMap="ServiceDonorchargeorganResult">
        <include refid="selectServiceDonorchargeorganVo"/>
        <where>
            and (del_flag = 0 or del_flag is null)
            <if test="infoid != null ">and InfoID = #{infoid}</if>
            <if test="receiveTime != null ">and receive_time = #{receiveTime}</if>
            <if test="paymentid != null ">and paymentid = #{paymentid}</if>
@@ -88,6 +89,17 @@
            <if test="hospitalno != null  and hospitalno != ''">and HospitalNo = #{hospitalno}</if>
            <if test="organno != null  and organno != ''">and OrganNo = #{organno}</if>
            <if test="organname != null  and organname != ''">and OrganName like concat('%', #{organname}, '%')</if>
            <if test="organState != null  and organState != ''">and organ_state = #{organState}</if>
            <if test="payStatus != null  and payStatus != ''">
                <choose>
                    <when test="payStatus == '已付'">
                        and organcharge is not null and (organcharge - IFNULL(amount, 0)) = 0
                    </when>
                    <when test="payStatus == '未付'">
                        and organcharge is not null and (organcharge - IFNULL(amount, 0)) &lt;&gt; 0
                    </when>
                </choose>
            </if>
            <if test="organcharge != null ">and organcharge = #{organcharge}</if>
            <if test="organtime != null ">and organtime = #{organtime}</if>
            <if test="chargeoperator != null  and chargeoperator != ''">and chargeoperator = #{chargeoperator}</if>
@@ -135,6 +147,7 @@
        from service_donorchargeorgan o
                 left join service_donatebaseinfo b on b.ID = o.InfoID
        <where>
            and (o.del_flag = 0 or o.del_flag is null)
            <if test="selectAll != true ">
               and (o.paymentid IS NULL or o.paymentid=0 or organcharge-amount>0)
               and (organ_charge_state =0 OR organ_charge_state IS null)
@@ -148,8 +161,20 @@
                '%')
            </if>
            <if test="hospitalno != null  and hospitalno != ''">and o.HospitalNo = #{hospitalno}</if>
            <if test="hospitalnoIsNull == true">and (o.Hospitalname is null or o.Hospitalname = '')</if>
            <if test="organno != null  and organno != ''">and o.OrganNo = #{organno}</if>
            <if test="organname != null  and organname != ''">and o.OrganName like concat('%', #{organname}, '%')</if>
            <if test="organState != null  and organState != ''">and o.organ_state = #{organState}</if>
            <if test="payStatus != null  and payStatus != ''">
                <choose>
                    <when test="payStatus == '已付'">
                        and o.organcharge is not null and (o.organcharge - IFNULL(o.amount, 0)) = 0
                    </when>
                    <when test="payStatus == '未付'">
                        and o.organcharge is not null and (o.organcharge - IFNULL(o.amount, 0)) &lt;&gt; 0
                    </when>
                </choose>
            </if>
            <if test="organcharge != null ">and o.organcharge = #{organcharge}</if>
            <if test="organtime != null ">and o.organtime = #{organtime}</if>
            <if test="chargeoperator != null  and chargeoperator != ''">and o.chargeoperator = #{chargeoperator}</if>
@@ -163,6 +188,15 @@
        </where>
        order by b.donatetime
    </select>
    <update id="removeByIds">
        update service_donorchargeorgan
        set del_flag = 1
        where id in
        <foreach collection="ids" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <update id="updateDonorchargeorgan" parameterType="com.ruoyi.project.domain.ServiceDonorchargeorgan">
        update service_donorchargeorgan
@@ -213,4 +247,39 @@
        )
    </select>
    <resultMap id="SpStatChangeDetailResult" type="com.ruoyi.project.domain.SpStatChangeDetail">
        <result property="donatetime" column="donatetime"/>
        <result property="donorname" column="donorname"/>
        <result property="organno" column="OrganNo"/>
        <result property="organname" column="OrganName"/>
        <result property="name" column="name"/>
        <result property="caseno" column="caseno"/>
        <result property="hospitalname" column="HospitalName"/>
        <result property="organcharge" column="organcharge"/>
        <result property="amount" column="amount"/>
        <result property="nonpayment" column="nonpayment"/>
    </resultMap>
    <select id="getSpStatChangeDetail" resultMap="SpStatChangeDetailResult">
        select b.donatetime,
               o.donorname,
               o.OrganNo,
               o.OrganName,
               o.name,
               o.caseno,
               o.HospitalName,
               o.organcharge,
               o.amount,
               (ifnull(o.organcharge, 0) - ifnull(o.amount, 0)) as nonpayment
        from service_donorchargeorgan o
                 left join service_donatebaseinfo b on b.ID = o.InfoID
        where o.del_flag = 0
        <if test="PABEGTIME != null and PABEGTIME != ''">and b.donatetime &gt;= #{PABEGTIME}</if>
        <if test="PAENDTIME != null and PAENDTIME != ''">and b.donatetime &lt;= #{PAENDTIME}</if>
        <if test="PAHOSPITALNAME != null and PAHOSPITALNAME != ''">and o.HospitalName = #{PAHOSPITALNAME}</if>
        <if test='"1".equals(PACHARGESTATE)'>and ifnull(o.amount, 0) &gt; 0</if>
        <if test='"0".equals(PACHARGESTATE)'>and (ifnull(o.organcharge, 0) - ifnull(o.amount, 0)) &gt; 0</if>
        order by b.donatetime
    </select>
</mapper>