123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?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.kmall.api.dao.ApiStoreMapper">
- <resultMap type="com.kmall.api.entity.StoreVo" id="storeMap">
- <result property="id" column="id"/>
- <result property="storeName" column="store_name"/>
- <result property="storeNumber" column="store_number"/>
- <result property="storeAddress" column="store_address"/>
- <result property="provinceName" column="province_name"/>
- <result property="cityName" column="city_name"/>
- <result property="countyName" column="county_name"/>
- <result property="latitude" column="latitude"/>
- <result property="longitude" column="longitude"/>
- <result property="coverRadius" column="cover_radius"/>
- <result property="remark" column="remark"/>
- <result property="distance" column="distance"/>
- <result column="merch_sn" property="merchSn" jdbcType="VARCHAR" />
- <result column="merch_name" property="merchName" jdbcType="VARCHAR" />
- <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
- <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
- <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
- <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
- <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
- <result property="thirdPartyMerchCode" column="third_party_merch_code"/>
- <result property="thirdPartyMerchName" column="third_party_merch_name"/>
- <result property="isValid" column="is_valid"/>
- </resultMap>
- <select id="queryObject" resultType="com.kmall.api.entity.StoreVo">
- select
- `id`,
- `store_name`,
- `store_number`,
- `store_address`,
- `province_name`,
- `city_name`,
- `county_name`,
- `latitude`,
- `longitude`,
- `cover_radius`,
- `remark`,merch_sn, merch_name, creater_sn, create_time,third_party_merch_code,third_party_merch_name,
- moder_sn, mod_time, tstm
- from mall_store
- where id = #{id} and is_valid = 0
- </select>
- <select id="queryList" resultType="com.kmall.api.entity.StoreVo">
- select
- `id`,
- `store_name`,
- `store_number`,
- `store_address`,
- `province_name`,
- `city_name`,
- `county_name`,
- `latitude`,
- `longitude`,
- `cover_radius`,
- `remark`,merch_sn, merch_name, creater_sn, create_time,third_party_merch_code,third_party_merch_name,
- moder_sn, mod_time, tstm
- from mall_store
- WHERE 1=1 and is_valid = 0
- <if test="province_name != null and province_name.trim() != ''">
- AND province_name = #{province_name}
- </if>
- <if test="city_name != null and city_name.trim() != ''">
- AND city_name = #{city_name}
- </if>
- <if test="county_name != null and county_name.trim() != ''">
- AND county_name = #{county_name}
- </if>
- <if test="latitude != null and longitude!= null">
- AND cover_radius*1000 > round(6378.138*2*asin(sqrt(pow(sin( (a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
- +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)* pow(sin(
- (a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000)
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- <otherwise>
- order by id desc
- </otherwise>
- </choose>
- <if test="offset != null and limit != null">
- limit #{offset}, #{limit}
- </if>
- </select>
- <select id="queryTotal" resultType="int">
- select count(*) from mall_store
- WHERE 1=1 and is_valid = 0
- <if test="name != null and name.trim() != ''">
- AND name LIKE concat('%',#{name},'%')
- </if>
- </select>
- <!-- 在配送范围之内查找店铺 -->
- <!--<select id="queryNearbyList" resultMap="storeMap">
- select * from
- ( select
- `id`,
- `store_name`,
- `store_number`,
- `store_address`,
- `province_name`,
- `city_name`,
- `county_name`,
- `latitude`,
- `longitude`,
- `cover_radius`,
- `remark`,
- round(6378.138*2*asin(sqrt(pow(sin((a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
- +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)
- *pow(sin((a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000) as distance,
- merch_sn,
- merch_name,
- creater_sn,
- create_time,
- moder_sn,
- mod_time,
- tstm
- from mall_store a
- WHERE 1=1
- <if test="province_name != null and province_name.trim() != ''">
- AND province_name = #{province_name}
- </if>
- <if test="city_name != null and city_name.trim() != ''">
- AND city_name = #{city_name}
- </if>
- <if test="county_name != null and county_name.trim() != ''">
- AND county_name = #{county_name}
- </if>
- ) tmp
- where cover_radius * 1000 > distance
- order by distance asc
- </select>-->
- <!--删除距离限制-->
- <select id="queryNearbyList" resultMap="storeMap">
- select * from
- ( select
- `id`,
- `store_name`,
- `store_number`,
- `store_address`,
- `province_name`,
- `city_name`,
- `county_name`,
- `latitude`,
- `longitude`,
- `cover_radius`,
- `remark`,
- round(6378.138*2*asin(sqrt(pow(sin( (a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
- +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)
- *pow(sin((a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000) as distance,
- merch_sn,
- merch_name,
- creater_sn,
- create_time,
- moder_sn,
- mod_time,
- tstm,third_party_merch_code,third_party_merch_name
- from mall_store a
- WHERE 1=1 and is_valid = 0
- <if test="province_name != null and province_name.trim() != ''">
- AND province_name = #{province_name}
- </if>
- <if test="city_name != null and city_name.trim() != ''">
- AND city_name = #{city_name}
- </if>
- <if test="county_name != null and county_name.trim() != ''">
- AND county_name = #{county_name}
- </if>
- <if test="storeId != null and storeId != '' ">
- AND a.id = #{storeId}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != '' ">
- AND a.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- ) tmp
- order by distance asc
- limit 0, 10
- </select>
- </mapper>
|