<?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.TVinChargingOrderMapper">
|
|
<sql id="queryCondition">
|
<where>
|
o.del_flag = 0
|
<if test="query.siteIds != null and query.siteIds.size() > 0">
|
AND o.site_id IN
|
<foreach collection="query.siteIds" item="siteId" open="(" separator="," close=")">#{siteId}</foreach>
|
</if>
|
<if test="query.code != null and query.code != ''">AND o.code LIKE CONCAT('%', #{query.code}, '%')</if>
|
<if test="query.vin != null and query.vin != ''">
|
AND (o.actual_vin LIKE CONCAT('%', #{query.vin}, '%') OR o.expected_vin LIKE CONCAT('%', #{query.vin}, '%'))
|
</if>
|
<if test="query.plateNum != null and query.plateNum != ''">AND o.plate_num LIKE CONCAT('%', #{query.plateNum}, '%')</if>
|
<if test="query.phone != null and query.phone != ''">AND o.phone LIKE CONCAT('%', #{query.phone}, '%')</if>
|
<if test="query.status != null">AND o.status = #{query.status}</if>
|
<if test="query.siteId != null">AND o.site_id = #{query.siteId}</if>
|
<if test="query.pileId != null">AND o.charging_pile_id = #{query.pileId}</if>
|
<if test="query.gunId != null">AND o.charging_gun_id = #{query.gunId}</if>
|
<if test="query.startTime1 != null and query.startTime1 != ''">AND o.start_time BETWEEN #{query.startTime1} AND #{query.startTime2}</if>
|
<if test="query.endTime1 != null and query.endTime1 != ''">AND o.end_time BETWEEN #{query.endTime1} AND #{query.endTime2}</if>
|
</where>
|
</sql>
|
|
<select id="pageList" resultType="com.ruoyi.order.api.vo.ChargingOrderVO">
|
SELECT o.*, COALESCE(o.actual_vin, o.expected_vin) AS actual_vin, o.plate_num AS license_plate
|
FROM t_vin_charging_order o
|
<include refid="queryCondition"/>
|
ORDER BY o.create_time DESC, o.id DESC
|
LIMIT #{offset}, #{pageSize}
|
</select>
|
|
<select id="count" resultType="long">
|
SELECT COUNT(1) FROM t_vin_charging_order o <include refid="queryCondition"/>
|
</select>
|
|
<select id="summary" resultType="java.util.LinkedHashMap">
|
SELECT COUNT(1) AS orderCount,
|
IFNULL(SUM(o.charging_capacity), 0) AS total,
|
IFNULL(SUM(CASE WHEN o.start_time IS NOT NULL AND o.end_time IS NOT NULL THEN UNIX_TIMESTAMP(o.end_time) - UNIX_TIMESTAMP(o.start_time) ELSE 0 END), 0) AS time,
|
IFNULL(SUM(o.payment_amount), 0) AS income,
|
IFNULL(SUM(o.electrovalence), 0) AS electronicMoney,
|
IFNULL(SUM(o.service_charge), 0) AS serviceMoney
|
FROM t_vin_charging_order o
|
<include refid="queryCondition"/>
|
</select>
|
|
<select id="countAccountingStrategies" resultType="java.util.LinkedHashMap">
|
SELECT charging_order_id AS chargingOrderId, COUNT(1) AS periodCount
|
FROM t_vin_charging_order_accounting_strategy
|
WHERE charging_order_id IN
|
<foreach collection="chargingOrderIds" item="chargingOrderId" open="(" separator="," close=")">
|
#{chargingOrderId}
|
</foreach>
|
GROUP BY charging_order_id
|
</select>
|
|
<select id="accountingStrategyList" resultType="java.util.LinkedHashMap">
|
SELECT id, charging_order_id AS chargingOrderId, accounting_strategy_detail_id AS accountingStrategyDetailId,
|
start_time AS startTime, end_time AS endTime, type, electrovalence,
|
service_charge AS serviceCharge, cost_service_charge AS costServiceCharge,
|
charging_capacity AS chargingCapacity, period_electric_price AS periodElectricPrice,
|
period_service_price AS periodServicePrice, create_time AS createTime
|
FROM t_vin_charging_order_accounting_strategy
|
WHERE charging_order_id = #{chargingOrderId}
|
ORDER BY start_time ASC, id ASC
|
</select>
|
</mapper>
|