luodangjia
2024-12-19 60f70f7409ec1ece8905e088fb43e0cb0258a70b
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -77,4 +77,23 @@
        </if>
        order by create_time desc
    </select>
    <select id="getOrderStatistics" resultType="com.ruoyi.order.vo.OrderStatistics">
        SELECT
            count(*),
            SUM( CASE WHEN tor.order_type = 1 THEN 1 ELSE 0 END ) a,
            SUM( CASE WHEN tor.order_type = 2 THEN 1 ELSE 0 END ) b,
            SUM( tor.total_amount ) c,
            SUM( CASE WHEN tor.order_type = 1 THEN tor.total_amount ELSE 0 END ),
            SUM( CASE WHEN tor.order_type = 2 THEN tor.total_amount ELSE 0 END )
        FROM
            t_order tor
        <where>
            <if test="startTime != null">
                and tor.create_time <![CDATA[>=]]> #{startTime}
            </if>
            <if test="endTime != null">
                and tor.create_time <![CDATA[<=]]> #{endTime}
            </if>
        </where>
    </select>
</mapper>