<iftest="query.supplierId!=null and query.supplierId!=''">
LEFT JOIN bms_supplier_channel ON bms_supplier_channel.`channel_id` = `bms_channel_point`.`channel_id`
</if>
<where>
<iftest="query.supplierId!=null and query.supplierId!=''"> and bms_supplier_channel.`supplier_id` = #{query.supplierId} </if>
<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>
<iftest="query.createTime != null"> and `bms_channel_point`.`create_time` = #{query.createTime}</if>
<iftest="query.updateTime != null"> and `bms_channel_point`.`update_time` = #{query.updateTime}</if>
<iftest="query.tenantId != null and query.tenantId != ''"> and `bms_channel_point`.`tenant_id` = #{query.tenantId}</if>
<iftest="query.delFlag != null and query.delFlag != ''"> and `bms_channel_point`.`del_flag` = #{query.delFlag}</if>
<iftest="query.createBy != null and query.createBy != ''"> and `bms_channel_point`.`create_by` = #{query.createBy}</if>
<iftest="query.updateBy != null and query.updateBy != ''"> and `bms_channel_point`.`update_by` = #{query.updateBy}</if>
<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">