<iftest="query.localY!=null and query.localX!=null">
,st_distance_sphere (
POINT ( bms_channel_point.local_y, bms_channel_point.local_x ),
POINT ( #{query.localY}, #{query.localX} )) AS distance
</if>
FROM ( SELECT mu.target_id target_id FROM `bms_master_user` mu WHERE mu.type = 'point' AND del_flag = 0 AND user_id = #{query.userId} AND tenant_id = #{query.tenantId} ) pmu
LEFT JOIN `bms_channel_point` `bms_channel_point` ON `bms_channel_point`.id = pmu.target_id
<where>
and `bms_channel_point`.`del_flag` = 0
<iftest="query.pointCode != null and query.pointCode != ''"> and `bms_channel_point`.`point_code` like concat('%',#{query.pointCode},'%') </if>
<iftest="query.pointName != null and query.pointName != ''"> and `bms_channel_point`.`point_name` like concat('%',#{query.pointName},'%') </if>
</where>
ORDER BY
<iftest="query.localY!=null and query.localX!=null">