From 0a492b64ca1a4e40cc9ea56eddd1afe2c09a12b3 Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期四, 05 六月 2025 16:27:11 +0800 Subject: [PATCH] 财务管理 --- ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml | 81 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 81 insertions(+), 0 deletions(-) diff --git a/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml b/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml index 697616a..c1a5b93 100644 --- a/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml @@ -195,4 +195,85 @@ GROUP BY DATE(pay_time) ORDER BY DATE(pay_time) ASC </select> + <select id="financeTop" resultType="com.ruoyi.system.pojo.vo.FinanceFlowsTopVO"> + SELECT + SUM(price) AS totalIncome, + SUM(commission_platform) AS totalProfit, + SUM(commission_price) AS totalCommission, + SUM(price - commission_platform - commission_price) AS sellerIncome + FROM tb_order + WHERE status IN (4, 5, 6) + AND is_refund = 0 + </select> + <select id="flowsPage" resultType="com.ruoyi.system.pojo.vo.FinanceFlowsPageVO"> + SELECT + order_no, + price, + commission_price, + commission_platform, + pay_time AS operateTime, + (price - commission_platform - commission_price) as seller, + 1 AS type -- 收入类型 + FROM tb_order + WHERE + ((status IN (4, 5, 6)) -- 只查询已支付订单 + or + (status=-1 and is_refund =1)) -- 已取消且已退款的订单 + <if test="null != dto.orderNo and '' != dto.orderNo"> + and order_no LIKE CONCAT('%', #{dto.orderNo}, '%') + </if> + <if test="null != dto.operateTimeStart and null != dto.operateTimeEnd"> + and pay_time between #{dto.operateTimeStart} and #{dto.operateTimeEnd} + </if> + AND ( #{dto.type} IS NULL OR 1 = #{dto.type} ) + UNION ALL + SELECT + order_no, + 0 AS price, + 0 AS commission_price, + 0 AS commission_platform, + refund_time AS operateTime, + 0 as seller, + 2 AS type -- 退款类型 + FROM tb_order + WHERE is_refund = 1 -- 只查询已退款订单 + <if test="null != dto.orderNo and '' != dto.orderNo"> + and order_no LIKE CONCAT('%', #{dto.orderNo}, '%') + </if> + <if test="null != dto.operateTimeStart and null != dto.operateTimeEnd"> + and refund_time between #{dto.operateTimeStart} and #{dto.operateTimeEnd} + </if> + AND ( #{dto.type} IS NULL OR 2 = #{dto.type} ) + ORDER BY operateTime DESC + LIMIT #{dto.pageNum}, #{dto.pageSize}; + </select> + <select id="countFlowsPage" resultType="java.lang.Long"> + SELECT COUNT(*) FROM ( + select 1 + from + tb_order + WHERE + ((status IN (4, 5, 6)) -- 只查询已支付订单 + or + (status=-1 and is_refund =1)) -- 已取消且已退款的订单 + <if test="null != dto.orderNo and '' != dto.orderNo"> + and order_no LIKE CONCAT('%', #{dto.orderNo}, '%') + </if> + <if test="null != dto.operateTimeStart and null != dto.operateTimeEnd"> + and pay_time between #{dto.operateTimeStart} and #{dto.operateTimeEnd} + </if> + AND ( #{dto.type} IS NULL OR 1 = #{dto.type} ) + UNION ALL + select 1 + FROM tb_order + WHERE is_refund = 1 -- 只查询已退款订单 + <if test="null != dto.orderNo and '' != dto.orderNo"> + and order_no LIKE CONCAT('%', #{dto.orderNo}, '%') + </if> + <if test="null != dto.operateTimeStart and null != dto.operateTimeEnd"> + and refund_time between #{dto.operateTimeStart} and #{dto.operateTimeEnd} + </if> + AND ( #{dto.type} IS NULL OR 2 = #{dto.type} ) + ) AS t + </select> </mapper> \ No newline at end of file -- Gitblit v1.7.1