<?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.xhpc.order.mapper.XhpcStopChargingOrderMapper">


    <select id="list" resultType="map">
          select cs.name as stationName,
          cs.charging_station_id as chargingStationId,
          t.terminal_id as terminalId,
          t.name as terminalName,
          o.user_id as userId,
          o.charge_order_id as chargeOrderId,
          t.serial_number as termialSerialNumber
          from xhpc_charge_order as o
          left join xhpc_charging_station as cs
          on o.charging_station_id = cs.charging_station_id
          left join xhpc_terminal as t
          on o.terminal_id = t.terminal_id
          where o.status=1
          <if test="userId!=null">
            and o.user_id = #{userId}
          </if>
          <if test="chargingStationId!=null">
            and cs.charging_station_id = #{chargingStationId}
          </if>
          <if test="terminalId!=null">
            and t.terminal_id = #{terminalId}
          </if>

    </select>
</mapper>