无关风月
2025-02-19 efb2457e0f7b6e5a76999c239d8b079b21c88eb0
ruoyi-system/src/main/resources/mapper/system/TFlowManagementMapper.xml
@@ -28,4 +28,46 @@
        id, sys_serial_number, bank_serial_number, flow_money, deduction_money, remaining_money, pay_time, payer, flow_status, flow_type, pay_type, payment_bill_id, create_time, update_time, create_by, update_by, disabled
    </sql>
    <!-- 定义结果映射 -->
    <resultMap id="PaymentStatsResultMap" type="com.ruoyi.system.vo.TFlowManagementStatisticsVo">
        <result property="totalAmount" column="total_amount" />
        <result property="wechatAmount" column="wechat_amount" />
        <result property="alipayAmount" column="alipay_amount" />
        <result property="offlineAmount" column="offline_amount" />
    </resultMap>
    <!-- 统计总额和微信支付金额 -->
    <select id="getPaymentStats" resultMap="PaymentStatsResultMap">
        SELECT SUM(flow_money) AS total_amount,
               SUM(CASE WHEN pay_type = 1 THEN flow_money ELSE 0 END ) AS wechat_amount,
               SUM(CASE WHEN pay_type = 2 THEN flow_money ELSE 0 END ) AS alipay_amount,
               SUM(CASE WHEN pay_type = 3 THEN flow_money ELSE 0 END ) AS offline_amount
        FROM
            t_flow_management
        <where>
            <if test="req.sysSerialNumber != null and req.sysSerialNumber != ''">
                 and sys_serial_number = #{req.sysSerialNumber}
            </if>
            <if test="req.bankSerialNumber != null and req.bankSerialNumber != ''">
                 and bank_serial_number = #{req.bankSerialNumber}
            </if>
            <if test="req.payer != null and req.payer != ''">
                 and payer like concat('%', #{req.payer}, '%')
            </if>
            <if test="req.payType != null and req.payType != ''">
                 and pay_type = #{req.payType}
            </if>
            <if test="req.payStartTime != null and req.payStartTime != ''">
                 and pay_time &gt;= #{req.payStartTime}
            </if>
            <if test="req.payEndTime != null and req.payEndTime != ''">
                 and pay_time &lt;= #{req.payEndTime}
            </if>
            AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
    </select>
</mapper>