|
|
@@ -310,15 +310,19 @@
|
|
|
<result property="enterprisePrice" column="enterprise_price"/>
|
|
|
<result property="parkingFee" column="parking_fee"/>
|
|
|
<result property="address" column="address"/>
|
|
|
+ <result property="longitude" column="station_lng"/>
|
|
|
+ <result property="latitude" column="station_lat"/>
|
|
|
</resultMap>
|
|
|
|
|
|
- <!-- 小程序首页地图模式查询最近站点信息 -->
|
|
|
- <select id="selectNearestStationMap" resultMap="AppletStationInfoMapResultMap">
|
|
|
+ <!-- 小程序首页地图模式查询站点列表(按距离排序) -->
|
|
|
+ <select id="selectStationMapList" resultMap="AppletStationInfoMapResultMap">
|
|
|
SELECT
|
|
|
tpsi.id AS station_info_id,
|
|
|
tpsi.station_name,
|
|
|
tpsi.station_tips,
|
|
|
tpsi.address,
|
|
|
+ tpsi.station_lng,
|
|
|
+ tpsi.station_lat,
|
|
|
CAST(tpsi.park_fee AS DECIMAL(10,2)) AS parking_fee,
|
|
|
<!-- 计算距离(km) -->
|
|
|
ROUND(
|
|
|
@@ -402,8 +406,69 @@
|
|
|
ORDER BY pf.start_time DESC
|
|
|
LIMIT 1
|
|
|
) AS platform_price,
|
|
|
- <!-- 企业价(如果有企业ID) -->
|
|
|
- <if test="firmId != null">
|
|
|
+ <!-- 企业价(地图模式不需要) -->
|
|
|
+ NULL AS enterprise_price
|
|
|
+ FROM third_party_station_info tpsi
|
|
|
+ LEFT JOIN third_party_connector_info tpci ON tpsi.station_id = tpci.station_id AND tpci.is_deleted = 0
|
|
|
+ WHERE tpsi.is_deleted = 0
|
|
|
+ AND tpsi.equipment_owner_id = 'MA6DP6BE7'
|
|
|
+ AND tpsi.policy_configured = 1
|
|
|
+ <!-- 确保存在平台价配置 -->
|
|
|
+ AND EXISTS (
|
|
|
+ SELECT 1 FROM c_policy_fee pf_check
|
|
|
+ WHERE pf_check.station_info_id = tpsi.id
|
|
|
+ AND pf_check.sales_type = 0
|
|
|
+ AND pf_check.is_deleted = 0
|
|
|
+ AND (pf_check.op_fee IS NOT NULL OR pf_check.comp_sales_fee IS NOT NULL)
|
|
|
+ )
|
|
|
+ GROUP BY tpsi.id
|
|
|
+ ORDER BY distance ASC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 小程序站点详情查询结果映射 -->
|
|
|
+ <resultMap id="AppletStationDetailResultMap" type="com.zsElectric.boot.business.model.vo.AppletStationDetailVO">
|
|
|
+ <result property="stationId" column="station_info_id"/>
|
|
|
+ <result property="stationName" column="station_name"/>
|
|
|
+ <result property="tips" column="station_tips"/>
|
|
|
+ <result property="distance" column="distance"/>
|
|
|
+ <result property="address" column="address"/>
|
|
|
+ <result property="pictures" column="pictures"/>
|
|
|
+ <result property="currentPrice" column="current_price"/>
|
|
|
+ <result property="currentPeriod" column="current_period"/>
|
|
|
+ <result property="enterprisePrice" column="enterprise_price"/>
|
|
|
+ <result property="originalPrice" column="original_price"/>
|
|
|
+ <result property="businessHours" column="business_hours"/>
|
|
|
+ <result property="serviceProvider" column="service_provider"/>
|
|
|
+ <result property="invoiceProvider" column="invoice_provider"/>
|
|
|
+ <result property="customerServiceHotline" column="customer_service_hotline"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 小程序查询站点详情 -->
|
|
|
+ <select id="selectStationDetail" resultMap="AppletStationDetailResultMap">
|
|
|
+ SELECT
|
|
|
+ tpsi.id AS station_info_id,
|
|
|
+ tpsi.station_name,
|
|
|
+ tpsi.station_tips,
|
|
|
+ tpsi.address,
|
|
|
+ tpsi.banner_pictures AS pictures,
|
|
|
+ tpsi.own_business_hours AS business_hours,
|
|
|
+ tpsi.customer_service_hotline,
|
|
|
+ '华能贵州盘州市风电有限责任公司' AS service_provider,
|
|
|
+ '华能贵州盘州市风电有限责任公司' AS invoice_provider,
|
|
|
+ <!-- 计算距离(km) -->
|
|
|
+ <if test="longitude != null and latitude != null">
|
|
|
+ ROUND(
|
|
|
+ 6371 * ACOS(
|
|
|
+ COS(RADIANS(#{latitude})) * COS(RADIANS(tpsi.station_lat))
|
|
|
+ * COS(RADIANS(tpsi.station_lng) - RADIANS(#{longitude}))
|
|
|
+ + SIN(RADIANS(#{latitude})) * SIN(RADIANS(tpsi.station_lat))
|
|
|
+ ), 2
|
|
|
+ ) AS distance,
|
|
|
+ </if>
|
|
|
+ <if test="longitude == null or latitude == null">
|
|
|
+ NULL AS distance,
|
|
|
+ </if>
|
|
|
+ <!-- 当前价(电费+服务费+运营费+综合销售费) -->
|
|
|
(
|
|
|
SELECT
|
|
|
ROUND(
|
|
|
@@ -414,8 +479,78 @@
|
|
|
FROM c_policy_fee pf
|
|
|
INNER JOIN third_party_policy_info tppi ON pf.start_time = tppi.start_time
|
|
|
INNER JOIN third_party_equipment_price_policy tpepp ON tppi.price_policy_id = tpepp.id AND tpepp.is_deleted = 0
|
|
|
+ INNER JOIN third_party_connector_info tpci3 ON tpepp.connector_id = tpci3.connector_id AND tpci3.is_deleted = 0
|
|
|
+ WHERE tpci3.station_id = tpsi.station_id
|
|
|
+ AND pf.station_info_id = tpsi.id
|
|
|
+ AND pf.sales_type = 0
|
|
|
+ AND pf.is_deleted = 0
|
|
|
+ AND tppi.is_deleted = 0
|
|
|
+ AND pf.start_time <= #{currentTime}
|
|
|
+ ORDER BY pf.start_time DESC
|
|
|
+ LIMIT 1
|
|
|
+ ) AS current_price,
|
|
|
+ <!-- 当前时段名称 -->
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ CONCAT(
|
|
|
+ CASE tppi.period_flag
|
|
|
+ WHEN 1 THEN '尖'
|
|
|
+ WHEN 2 THEN '峰'
|
|
|
+ WHEN 3 THEN '平'
|
|
|
+ WHEN 4 THEN '谷'
|
|
|
+ ELSE ''
|
|
|
+ END,
|
|
|
+ CONCAT(SUBSTRING(tppi.start_time, 1, 2), ':', SUBSTRING(tppi.start_time, 3, 2)),
|
|
|
+ '-',
|
|
|
+ IFNULL(
|
|
|
+ (
|
|
|
+ SELECT CONCAT(SUBSTRING(next_tppi.start_time, 1, 2), ':', SUBSTRING(next_tppi.start_time, 3, 2))
|
|
|
+ FROM third_party_policy_info next_tppi
|
|
|
+ WHERE next_tppi.price_policy_id = tppi.price_policy_id
|
|
|
+ AND next_tppi.is_deleted = 0
|
|
|
+ AND next_tppi.start_time > tppi.start_time
|
|
|
+ ORDER BY next_tppi.start_time ASC
|
|
|
+ LIMIT 1
|
|
|
+ ),
|
|
|
+ '24:00'
|
|
|
+ )
|
|
|
+ )
|
|
|
+ FROM third_party_policy_info tppi
|
|
|
+ INNER JOIN third_party_equipment_price_policy tpepp ON tppi.price_policy_id = tpepp.id AND tpepp.is_deleted = 0
|
|
|
+ INNER JOIN third_party_connector_info tpci2 ON tpepp.connector_id = tpci2.connector_id AND tpci2.is_deleted = 0
|
|
|
+ WHERE tpci2.station_id = tpsi.station_id
|
|
|
+ AND tppi.is_deleted = 0
|
|
|
+ AND tppi.start_time <= #{currentTime}
|
|
|
+ ORDER BY tppi.start_time DESC
|
|
|
+ LIMIT 1
|
|
|
+ ) AS current_period,
|
|
|
+ <!-- 原价(电费+服务费) -->
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ ROUND(IFNULL(tppi.elec_price, 0) + IFNULL(tppi.service_price, 0), 4)
|
|
|
+ FROM third_party_policy_info tppi
|
|
|
+ INNER JOIN third_party_equipment_price_policy tpepp ON tppi.price_policy_id = tpepp.id AND tpepp.is_deleted = 0
|
|
|
INNER JOIN third_party_connector_info tpci4 ON tpepp.connector_id = tpci4.connector_id AND tpci4.is_deleted = 0
|
|
|
WHERE tpci4.station_id = tpsi.station_id
|
|
|
+ AND tppi.is_deleted = 0
|
|
|
+ AND tppi.start_time <= #{currentTime}
|
|
|
+ ORDER BY tppi.start_time DESC
|
|
|
+ LIMIT 1
|
|
|
+ ) AS original_price,
|
|
|
+ <!-- 企业价 -->
|
|
|
+ <if test="firmId != null">
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ ROUND(
|
|
|
+ IFNULL(tppi.elec_price, 0) + IFNULL(tppi.service_price, 0)
|
|
|
+ + IFNULL(pf.op_fee, 0) + IFNULL(pf.comp_sales_fee, 0),
|
|
|
+ 4
|
|
|
+ )
|
|
|
+ FROM c_policy_fee pf
|
|
|
+ INNER JOIN third_party_policy_info tppi ON pf.start_time = tppi.start_time
|
|
|
+ INNER JOIN third_party_equipment_price_policy tpepp ON tppi.price_policy_id = tpepp.id AND tpepp.is_deleted = 0
|
|
|
+ INNER JOIN third_party_connector_info tpci5 ON tpepp.connector_id = tpci5.connector_id AND tpci5.is_deleted = 0
|
|
|
+ WHERE tpci5.station_id = tpsi.station_id
|
|
|
AND pf.station_info_id = tpsi.id
|
|
|
AND pf.sales_type = 1
|
|
|
AND pf.firm_id = #{firmId}
|
|
|
@@ -430,21 +565,8 @@
|
|
|
NULL AS enterprise_price
|
|
|
</if>
|
|
|
FROM third_party_station_info tpsi
|
|
|
- LEFT JOIN third_party_connector_info tpci ON tpsi.station_id = tpci.station_id AND tpci.is_deleted = 0
|
|
|
WHERE tpsi.is_deleted = 0
|
|
|
- AND tpsi.equipment_owner_id = 'MA6DP6BE7'
|
|
|
- AND tpsi.policy_configured = 1
|
|
|
- <!-- 确保存在平台价配置 -->
|
|
|
- AND EXISTS (
|
|
|
- SELECT 1 FROM c_policy_fee pf_check
|
|
|
- WHERE pf_check.station_info_id = tpsi.id
|
|
|
- AND pf_check.sales_type = 0
|
|
|
- AND pf_check.is_deleted = 0
|
|
|
- AND (pf_check.op_fee IS NOT NULL OR pf_check.comp_sales_fee IS NOT NULL)
|
|
|
- )
|
|
|
- GROUP BY tpsi.id
|
|
|
- ORDER BY distance ASC
|
|
|
- LIMIT 1
|
|
|
+ AND tpsi.id = #{stationId}
|
|
|
</select>
|
|
|
|
|
|
</mapper>
|