<?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.yiqi.system.mapper.SysOrgMapper">

    <select id="findPageOrderByDistance" resultType="com.yiqi.system.domain.vo.OrgVO" parameterType="com.yiqi.system.domain.dto.weapp.WeAppOrgQueryDTO">
        SELECT
               *,
               FLOOR((st_distance (point (longitude, latitude),point(#{weAppOrgQueryDTO.longitude},#{weAppOrgQueryDTO.latitude}) ) *111195)) AS distance
        FROM
            sys_org where source_type=#{weAppOrgQueryDTO.sourceType} and latitude is not null and longitude is not null and status='0'
        ORDER BY distance asc
        limit #{weAppOrgQueryDTO.startRow},#{weAppOrgQueryDTO.pageSize}
    </select>
</mapper>