|
@@ -3,45 +3,78 @@
|
|
|
<mapper namespace="com.chelvc.cloud.vehicle.server.dao.MerchantMapper">
|
|
|
<sql id="BASIC_MERCHANT_SELECT">
|
|
|
select mt.id, mt.user_id, mt.name, mt.logo, mt.banners, mt.liaison, mt.mobile, mt.opening, mt.address,
|
|
|
- mt.score, mt.sale, mt.longitude, mt.latitude, mt.recommend, mt.status, mt.creator, mt.create_time,
|
|
|
+ mt.score, mt.sale, mt.region, mt.longitude, mt.latitude, mt.recommend, mt.status, mt.creator, mt.create_time,
|
|
|
mt.updater, mt.update_time
|
|
|
from `merchant` mt
|
|
|
</sql>
|
|
|
|
|
|
- <select id="listRecommendMerchants" resultType="com.chelvc.cloud.vehicle.api.dto.MerchantDTO">
|
|
|
- select mt.id, mt.user_id, mt.name, mt.logo, mt.banners, mt.liaison, mt.mobile, mt.opening, mt.address,
|
|
|
- mt.score, mt.sale, mt.longitude, mt.latitude, mt.recommend, mt.status, mt.creator, mt.create_time,
|
|
|
- mt.updater, mt.update_time,
|
|
|
+ <select id="listNearbyMerchants" resultType="com.chelvc.cloud.vehicle.api.dto.MerchantDTO">
|
|
|
+ select mt.id, mt.name, mt.logo, mt.score, mt.sale, mt.address,
|
|
|
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 by mt.create_time desc limit #{size}
|
|
|
+ <where>
|
|
|
+ <if test="region > 0">
|
|
|
+ mt.region = #{region}
|
|
|
+ </if>
|
|
|
+ and mt.status = 'ONLINE'
|
|
|
+ </where>
|
|
|
+ order by distance asc limit #{size}
|
|
|
</select>
|
|
|
|
|
|
- <select id="listNearbyMerchants" resultType="com.chelvc.cloud.vehicle.api.dto.MerchantDTO">
|
|
|
- select mt.id, mt.user_id, mt.name, mt.logo, mt.banners, mt.liaison, mt.mobile, mt.opening, mt.address,
|
|
|
- mt.score, mt.sale, mt.longitude, mt.latitude, mt.recommend, mt.status, mt.creator, mt.create_time,
|
|
|
- mt.updater, mt.update_time, t.distance
|
|
|
+ <select id="listRecommendMerchants" resultType="com.chelvc.cloud.vehicle.api.dto.MerchantDTO">
|
|
|
+ select mt.id, mt.name, mt.logo, mt.score, mt.sale, mt.address,
|
|
|
+ round(st_distance_sphere(
|
|
|
+ point(mt.longitude, mt.latitude), point(#{param.longitude}, #{param.latitude})
|
|
|
+ )) distance
|
|
|
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
|
|
|
+ <where>
|
|
|
+ <if test="region > 0">
|
|
|
+ mt.region = #{region}
|
|
|
+ </if>
|
|
|
+ and mt.status = 'ONLINE' and mt.recommend = 1
|
|
|
+ </where>
|
|
|
+ order by distance asc limit #{size}
|
|
|
</select>
|
|
|
|
|
|
<select id="listSimpleMerchants" resultType="com.chelvc.cloud.vehicle.api.dto.MerchantDTO">
|
|
|
- select
|
|
|
- from `merchant`
|
|
|
+ select mt.id, mt.name, mt.logo, mt.score, mt.sale, mt.address,
|
|
|
+ round(st_distance_sphere(
|
|
|
+ point(mt.longitude, mt.latitude), point(#{param.longitude}, #{param.latitude})
|
|
|
+ )) distance
|
|
|
+ from `merchant` mt
|
|
|
+ <if test="param.categoryId != null or (param.keyword != null and !keyword.isEmpty())">
|
|
|
+ inner join `goods` gs on gs.merchant_id = mt.id
|
|
|
+ <if test="param.categoryId != null">
|
|
|
+ and gs.category_id = #{param.categoryId}
|
|
|
+ </if>
|
|
|
+ <if test="param.keyword != null and !keyword.isEmpty()">
|
|
|
+ and (gs.name like concat('%', #{param.keyword}, '%') or gs.description like concat('%', #{param.keyword}, '%'))
|
|
|
+ </if>
|
|
|
+ and gs.status = 'ONLINE'
|
|
|
+ </if>
|
|
|
<where>
|
|
|
-
|
|
|
+ <if test="param.offset != null">
|
|
|
+ mt.id > #{param.offset}
|
|
|
+ </if>
|
|
|
+ <if test="region > 0">
|
|
|
+ and mt.region = #{region}
|
|
|
+ </if>
|
|
|
+ and mt.status = 'ONLINE'
|
|
|
</where>
|
|
|
+ <if test="param.sort != null and param.sort.name == 'SYNTHESE'">
|
|
|
+ order by mt.recommend desc
|
|
|
+ </if>
|
|
|
+ <if test="param.sort != null and param.sort.name == 'NEAREST'">
|
|
|
+ order by distance desc
|
|
|
+ </if>
|
|
|
+ <if test="param.sort != null and param.sort.name == 'FAVORITE'">
|
|
|
+ order by mt.score desc
|
|
|
+ </if>
|
|
|
+ <if test="param.sort != null and param.sort.name == 'BESTSELLING'">
|
|
|
+ order by mt.sale desc
|
|
|
+ </if>
|
|
|
+ limit #{size}
|
|
|
</select>
|
|
|
</mapper>
|