<?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.tradebill.mapper.XhpcHistoryOrderMapper">

    <select id="findOneBySerialNumber" resultType="com.xhpc.tradebill.domain.XhpcHistoryOrderDomain">
        select
               o.*,
               s.name as 'charging_station_name'
        from
        xhpc_history_order o
            left join xhpc_charging_station s on o.charging_station_id=s.charging_station_id
        where serial_number=#{serialNumber}
    </select>

    <select id="findOneByInternetSerialNumber" resultType="com.xhpc.tradebill.domain.XhpcHistoryOrderDomain">
        select
            o.*,
            s.name as 'charging_station_name',
            c.charging_degree as 'charging_degree',
            c.charging_time as 'charging_time'
        from xhpc_history_order o
        left join xhpc_charging_station s on o.charging_station_id=s.charging_station_id
        left join xhpc_charge_order c on o.charge_order_id=c.charge_order_id
        where o.internet_serial_number=#{internetSerialNumber}
    </select>

    <select id="findListByInternetSerialNumbers" resultType="com.xhpc.tradebill.domain.XhpcHistoryOrderDomain">
        select
            o.*,
            s.name as 'charging_station_name',
                c.charging_degree as 'charging_degree',
                c.charging_time as 'charging_time'
        from xhpc_history_order o
                 left join xhpc_charging_station s on o.charging_station_id=s.charging_station_id
                 left join xhpc_charge_order c on o.charge_order_id=c.charge_order_id
        where o.internet_serial_number in
        <foreach collection="orderNumbers" item="orderNumber" open="(" close=")" separator=",">
            #{orderNumber}
        </foreach>
    </select>
</mapper>