puzhibing
2026-09-29 a70433b2ee5bb37823ab73422a01251343cb5f58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?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.ruoyi.order.mapper.TChargingOrderAccountingStrategyMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.order.api.model.TChargingOrderAccountingStrategy">
        <id column="id" property="id" />
        <result column="charging_order_id" property="chargingOrderId" />
        <result column="`type`" property="type" />
        <result column="start_time" property="startTime" />
        <result column="end_time" property="endTime" />
        <result column="electrovalence" property="electrovalence" />
        <result column="service_charge" property="serviceCharge" />
        <result column="cost_service_charge" property="costServiceCharge" />
        <result column="charging_capacity" property="chargingCapacity" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, charging_order_id, `type`, start_time, end_time, electrovalence, service_charge, cost_service_charge, charging_capacity
    </sql>
 
    <!-- 车队白名单订单聚合:主表 fleet_id+status=5 JOIN 计费明细表,SUM per-stage 字段 -->
    <select id="fleetAggregateByFleet" resultType="java.util.LinkedHashMap">
        SELECT IFNULL(SUM(s.charging_capacity), 0) AS cumulativeCharge,
               IFNULL(SUM(s.period_electric_price), 0) AS cumulativeElectrovalence,
               IFNULL(SUM(s.period_service_price), 0) AS cumulativeServiceCharge
        FROM t_charging_order o
        INNER JOIN t_charging_order_accounting_strategy s ON s.charging_order_id = o.id
        WHERE o.del_flag = 0 AND o.status = 5 AND o.fleet_id = #{fleetId}
    </select>
 
</mapper>