<?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.zsElectric.boot.charging.mapper.ThirdPartyPolicyInfoMapper">

    <!-- 根据stationInfoId和startTime查询电价和服务费 -->
    <select id="selectElecAndServicePriceByStation" resultType="com.zsElectric.boot.charging.entity.ThirdPartyPolicyInfo">
        SELECT 
            tppi.id,
            tppi.elec_price,
            tppi.service_price,
            tppi.period_flag
        FROM third_party_station_info tpsi
        INNER JOIN third_party_connector_info tpci 
            ON tpci.station_id = tpsi.station_id AND tpci.is_deleted = 0
        INNER JOIN third_party_equipment_price_policy tpepp 
            ON tpepp.connector_id = tpci.connector_id AND tpepp.is_deleted = 0
        INNER JOIN third_party_policy_info tppi 
            ON tppi.price_policy_id = tpepp.id AND tppi.is_deleted = 0
        WHERE tpsi.id = #{stationInfoId}
            AND tpsi.is_deleted = 0
            AND tppi.start_time = #{startTime}
        LIMIT 1
    </select>

</mapper>
