123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?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="moder_sn" property="moderSn" jdbcType="VARCHAR" />
- <result property="thirdPartyMerchCode" column="third_party_merch_code"/>
- <result property="thirdPartyMerchName" column="third_party_merch_name"/>
- <result property="isValid" column="is_valid"/>
- </resultMap>
- <resultMap type="com.kmall.api.entity.StoreWithThirdMerchBizVo" id="storeWithThirdMerchMap">
- <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="merchSn" column="merch_sn" jdbcType="VARCHAR" />
- <result property="merchName" column="merch_name" jdbcType="VARCHAR" />
- <result property="thirdPartyMerchCode" column="third_party_merch_code"/>
- <result property="thirdPartyMerchName" column="third_party_merch_name"/>
- <result property="isValid" column="is_valid"/>
- <result property="exprAgreementType" column="expr_agreement_type"/>
- <result property="isLoadGoods" column="is_load_goods"/>
- <result property="isStockShare" column="is_stock_share"/>
- <result property="isStoreUserShare" column="is_store_user_share"/>
- <result property="isValidMerch" column="is_valid"/>
- <result property="isMapShow" column="is_map_show"/>
- <result property="isDistSellStart" column="is_dist_sell_start"/>
- <result property="isSupplierGoods" column="is_supplier_goods"/>
- <result property="isFaceCheck" column="is_face_check"/>
- </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,
- third_party_merch_code,
- third_party_merch_name,
- moder_sn
- 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,
- third_party_merch_code,
- third_party_merch_name
- 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,
- third_party_merch_code,
- third_party_merch_name
- from mall_store a
- WHERE 1=1 and is_valid = 0
- and (select count(1) from mall_product_store_rela r left join mall_goods g on r.goods_id = g.id where store_id = a.id and stock_num!=0 and g.is_hot=1 AND g.goods_number > 0 AND g.is_delete != 1 AND g.is_on_sale = 1)>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>
- <select id="storeByIdWithThirdMerch" resultMap="storeWithThirdMerchMap">
- select t.id, t.merch_sn, t.merch_name, t.store_name, t.store_number,
- t.store_address, t.province_name,
- t.city_name, t.county_name,
- t.latitude, t.longitude, t.cover_radius, t.remark, t.is_valid,
- t.third_party_merch_code, t.third_party_merch_name,
- t.expr_agreement_type, t.is_load_goods,
- t1.third_merch_sn,
- t1.is_stock_share, t1.is_store_user_share, t1.is_map_show,
- t1.is_dist_sell_start, t1.is_supplier_goods,
- t1.is_face_check, t1.is_valid
- from mall_store t
- left join third_merchant_biz t1 on t.third_party_merch_code=t1.third_party_merch_code
- where 1=1 and t.is_valid='0' and t1.is_valid='0'
- <if test="storeId != null and storeId != '' ">
- AND t.id = #{storeId}
- </if>
- limit 0, 10
- </select>
- </mapper>
|