109 lines
4.0 KiB
XML
109 lines
4.0 KiB
XML
<?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.suisung.mall.shop.chain.mapper.ShopChainBaseMapper">
|
|
|
|
<!-- 通用查询结果列 -->
|
|
<sql id="Base_Column_List">
|
|
chain_id
|
|
, store_id, chain_name, chain_mobile, chain_telephone, chain_contacter, chain_lng, chain_lat,
|
|
chain_district_info, chain_district_id, chain_address, chain_opening_hours, chain_close_hours,
|
|
chain_traffic_line, chain_img, chain_time
|
|
</sql>
|
|
<select id="getAll" resultType="java.util.Map">
|
|
SELECT *,
|
|
(round(6378.138 * 2 * asin(sqrt(pow(sin(
|
|
(chain_lat * pi() / 180 - #{params.lat} * pi() / 180) / 2),
|
|
2) +
|
|
cos(chain_lat * pi() / 180) * cos(#{params.lat} * pi() / 180) * pow(sin(
|
|
(chain_lng * pi() / 180 - #{params.lng} * pi() / 180) / 2),
|
|
2))) *
|
|
1000)) as distance
|
|
FROM shop_chain_base
|
|
<where>
|
|
<if test="params.chain_ids!=null">
|
|
chain_id IN
|
|
<foreach collection="params.chain_ids" item="chain_id" index="index" open="(" close=")" separator=",">
|
|
#{chain_id}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
<if test="params.distance!=null">
|
|
HAVING distance < #{params.distance}
|
|
</if>
|
|
ORDER BY distance ASC
|
|
</select>
|
|
|
|
<select id="getAllCount" resultType="java.lang.Integer">
|
|
select count(1) from (
|
|
SELECT *,
|
|
(round(6378.138 * 2 * asin(sqrt(pow(sin(
|
|
(chain_lat * pi() / 180 - #{params.lat} * pi() / 180) / 2),
|
|
2) +
|
|
cos(chain_lat * pi() / 180) * cos(#{params.lat} * pi() / 180) * pow(sin(
|
|
(chain_lng * pi() / 180 - #{params.lng} * pi() / 180) / 2),
|
|
2))) *
|
|
1000)) as distance
|
|
FROM shop_chain_base
|
|
<where>
|
|
<if test="params.chain_ids!=null">
|
|
chain_id IN
|
|
<foreach collection="params.chain_ids" item="chain_id" index="index" open="(" close=")" separator=",">
|
|
#{chain_id}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
<if test="params.distance!=null">
|
|
HAVING distance < #{params.distance}
|
|
</if>
|
|
ORDER BY distance ASC
|
|
) as tmp
|
|
</select>
|
|
|
|
<select id="getAllchian" resultType="java.util.Map">
|
|
SELECT *, calculated_distance as distance
|
|
FROM (
|
|
SELECT *,
|
|
(round(6378.138 * 2 * asin(sqrt(
|
|
pow(sin((chain_lat * pi() / 180 - #{params.lat} * pi() / 180) / 2), 2) +
|
|
cos(chain_lat * pi() / 180) * cos( #{params.lat} * pi() / 180) *
|
|
pow(sin((chain_lng * pi() / 180 - #{params.lng} * pi() / 180) / 2), 2))) *
|
|
1000)) as calculated_distance
|
|
FROM shop_chain_base
|
|
) AS temp
|
|
<where>
|
|
<if test="params.store_id!=null and params.store_id!=0">
|
|
store_id=#{params.store_id}
|
|
</if>
|
|
</where>
|
|
<if test="params.distance!=null">
|
|
HAVING distance < #{params.distance}
|
|
</if>
|
|
ORDER BY distance ASC
|
|
</select>
|
|
|
|
<select id="getAllchianCount" resultType="java.lang.Integer">
|
|
select count(1) from (
|
|
SELECT *, calculated_distance as distance
|
|
FROM (
|
|
SELECT *,
|
|
(round(6378.138 * 2 * asin(sqrt(
|
|
pow(sin((chain_lat * pi() / 180 - #{params.lat} * pi() / 180) / 2), 2) +
|
|
cos(chain_lat * pi() / 180) * cos( #{params.lat} * pi() / 180) *
|
|
pow(sin((chain_lng * pi() / 180 - #{params.lng} * pi() / 180) / 2), 2))) *
|
|
1000)) as calculated_distance
|
|
FROM shop_chain_base
|
|
) AS temp
|
|
<where>
|
|
<if test="params.store_id!=null and params.store_id!=0">
|
|
store_id=#{params.store_id}
|
|
</if>
|
|
</where>
|
|
<if test="params.distance!=null">
|
|
HAVING distance < #{params.distance}
|
|
</if>
|
|
ORDER BY distance ASC
|
|
) as tmp
|
|
</select>
|
|
|
|
</mapper>
|