|
@@ -0,0 +1,36 @@
|
|
|
|
+<?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.chelvc.cloud.vehicle.server.dao.MerchantMapper">
|
|
|
|
+ <sql id="BASIC_MERCHANT_SELECT">
|
|
|
|
+ select mt.id, mt.user_id, mt.referrer_id, mt.name, mt.logo, mt.cover, mt.liaison, mt.mobile, mt.level,
|
|
|
|
+ mt.address, mt.longitude, mt.latitude, mt.recommend, mt.status, mt.create_time
|
|
|
|
+ from `merchant` mt
|
|
|
|
+ </sql>
|
|
|
|
+
|
|
|
|
+ <select id="listRecommendMerchants" resultType="com.chelvc.cloud.vehicle.api.dto.MerchantDTO">
|
|
|
|
+ select mt.id, mt.user_id, mt.referrer_id, mt.name, mt.logo, mt.cover, mt.liaison, mt.mobile, mt.level,
|
|
|
|
+ mt.address, mt.longitude, mt.latitude, mt.recommend, mt.status, mt.create_time,
|
|
|
|
+ round(st_distance_sphere(
|
|
|
|
+ point(mt.longitude, mt.latitude), point(#{param.longitude}, #{param.latitude})
|
|
|
|
+ )) distance
|
|
|
|
+ from `merchant` mt
|
|
|
|
+ where mt.status = 'ONLINE' and mt.recommend = 1
|
|
|
|
+ order mt.create_time desc limit #{size}
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="listNearbyMerchants" resultType="com.chelvc.cloud.vehicle.api.dto.MerchantDTO">
|
|
|
|
+ select mt.id, mt.user_id, mt.referrer_id, mt.name, mt.logo, mt.cover, mt.liaison, mt.mobile, mt.level,
|
|
|
|
+ mt.address, mt.longitude, mt.latitude, t.distance, mt.recommend, mt.status, mt.create_time
|
|
|
|
+ from `merchant` mt
|
|
|
|
+ inner join (
|
|
|
|
+ select id,
|
|
|
|
+ round(st_distance_sphere(
|
|
|
|
+ point(longitude, latitude), point(#{param.longitude}, #{param.latitude})
|
|
|
|
+ )) distance
|
|
|
|
+ from `merchant`
|
|
|
|
+ where status = 'ONLINE'
|
|
|
|
+ having distance <![CDATA[<=]]> #{param.distance}
|
|
|
|
+ order by distance asc limit #{size}
|
|
|
|
+ ) t on t.id = mt.id
|
|
|
|
+ </select>
|
|
|
|
+</mapper>
|