POINT ( bms_channel_point.local_y, bms_channel_point.local_x ),
POINT ( #{query.localY}, #{query.localX} )) AS distance
</if>
FROM ( SELECT DISTINCT mu.point_id target_id FROM `his_user_channel_point` mu WHERE 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
FROM
( SELECT channel_id FROM `bms_supplier_channel`
LEFT JOIN `his_user_supplier` ON `his_user_supplier`.supplier_id = bms_supplier_channel.supplier_id
) tmp left join`bms_channel_point` `bms_channel_point` ON `tmp`.channel_id = bms_channel_point.`channel_id`
<where>
and `bms_channel_point`.`del_flag` = 0
<iftest="query.id != null"> and `bms_channel_point`.`id` = #{query.id}</if>
<iftest="query.channelId != null"> and `bms_channel_point`.`channel_id` = #{query.channelId}</if>
<iftest="query.channelName != null and query.channelName != ''"> and `bms_channel_point`.`channel_name` like concat('%',#{query.channelName},'%') </if>
<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>
<iftest="query.shopArea != null and query.shopArea != ''"> and `bms_channel_point`.`shop_area` = #{query.shopArea}</if>
<iftest="query.countCheckstand != null"> and `bms_channel_point`.`count_checkstand` = #{query.countCheckstand}</if>
<iftest="query.pointLevel != null and query.pointLevel != ''"> and `bms_channel_point`.`point_level` = #{query.pointLevel}</if>
<iftest="query.pointType != null and query.pointType != ''"> and `bms_channel_point`.`point_type` like concat('%',#{query.pointType},'%') </if>
<iftest="query.address != null and query.address != ''"> and `bms_channel_point`.`address` = #{query.address}</if>
<iftest="query.saleRegionId != null and query.saleRegionId != ''"> and `bms_channel_point`.`sale_region_id` = #{query.saleRegionId}</if>
<iftest="query.saleRegionPath != null and query.saleRegionPath != ''"> and `bms_channel_point`.`sale_region_path` like concat('%',#{query.saleRegionPath},'%') </if>
<iftest="query.saleRegionPathIds != null and query.saleRegionPathIds != ''"> and `bms_channel_point`.`sale_region_path_ids` = #{query.saleRegionPathIds}</if>
<iftest="query.bizRegionId != null and query.bizRegionId != ''"> and `bms_channel_point`.`biz_region_id` = #{query.bizRegionId}</if>
<iftest="query.bizRegionPath != null and query.bizRegionPath != ''"> and `bms_channel_point`.`biz_region_path` like concat('%',#{query.bizRegionPath},'%') </if>
<iftest="query.bizRegionPathIds != null and query.bizRegionPathIds != ''"> and `bms_channel_point`.`biz_region_path_ids` = #{query.bizRegionPathIds}</if>
<iftest="query.remark != null and query.remark != ''"> and `bms_channel_point`.`remark` = #{query.remark}</if>