ApiStoreMapper.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kmall.api.dao.ApiStoreMapper">
  4. <resultMap type="com.kmall.api.entity.StoreVo" id="storeMap">
  5. <result property="id" column="id"/>
  6. <result property="storeName" column="store_name"/>
  7. <result property="storeNumber" column="store_number"/>
  8. <result property="storeAddress" column="store_address"/>
  9. <result property="provinceName" column="province_name"/>
  10. <result property="cityName" column="city_name"/>
  11. <result property="countyName" column="county_name"/>
  12. <result property="latitude" column="latitude"/>
  13. <result property="longitude" column="longitude"/>
  14. <result property="coverRadius" column="cover_radius"/>
  15. <result property="remark" column="remark"/>
  16. <result property="distance" column="distance"/>
  17. <result column="merch_sn" property="merchSn" jdbcType="VARCHAR" />
  18. <result column="merch_name" property="merchName" jdbcType="VARCHAR" />
  19. <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
  20. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  21. <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  22. <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
  23. <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
  24. <result property="thirdPartyMerchCode" column="third_party_merch_code"/>
  25. <result property="thirdPartyMerchName" column="third_party_merch_name"/>
  26. <result property="isValid" column="is_valid"/>
  27. </resultMap>
  28. <select id="queryObject" resultType="com.kmall.api.entity.StoreVo">
  29. select
  30. `id`,
  31. `store_name`,
  32. `store_number`,
  33. `store_address`,
  34. `province_name`,
  35. `city_name`,
  36. `county_name`,
  37. `latitude`,
  38. `longitude`,
  39. `cover_radius`,
  40. `remark`,merch_sn, merch_name, creater_sn, create_time,third_party_merch_code,third_party_merch_name,
  41. moder_sn, mod_time, tstm
  42. from mall_store
  43. where id = #{id} and is_valid = 0
  44. </select>
  45. <select id="queryList" resultType="com.kmall.api.entity.StoreVo">
  46. select
  47. `id`,
  48. `store_name`,
  49. `store_number`,
  50. `store_address`,
  51. `province_name`,
  52. `city_name`,
  53. `county_name`,
  54. `latitude`,
  55. `longitude`,
  56. `cover_radius`,
  57. `remark`,merch_sn, merch_name, creater_sn, create_time,third_party_merch_code,third_party_merch_name,
  58. moder_sn, mod_time, tstm
  59. from mall_store
  60. WHERE 1=1 and is_valid = 0
  61. <if test="province_name != null and province_name.trim() != ''">
  62. AND province_name = #{province_name}
  63. </if>
  64. <if test="city_name != null and city_name.trim() != ''">
  65. AND city_name = #{city_name}
  66. </if>
  67. <if test="county_name != null and county_name.trim() != ''">
  68. AND county_name = #{county_name}
  69. </if>
  70. <if test="latitude != null and longitude!= null">
  71. AND cover_radius*1000 > round(6378.138*2*asin(sqrt(pow(sin( (a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
  72. +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)* pow(sin(
  73. (a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000)
  74. </if>
  75. <choose>
  76. <when test="sidx != null and sidx.trim() != ''">
  77. order by ${sidx} ${order}
  78. </when>
  79. <otherwise>
  80. order by id desc
  81. </otherwise>
  82. </choose>
  83. <if test="offset != null and limit != null">
  84. limit #{offset}, #{limit}
  85. </if>
  86. </select>
  87. <select id="queryTotal" resultType="int">
  88. select count(*) from mall_store
  89. WHERE 1=1 and is_valid = 0
  90. <if test="name != null and name.trim() != ''">
  91. AND name LIKE concat('%',#{name},'%')
  92. </if>
  93. </select>
  94. <!-- 在配送范围之内查找店铺 -->
  95. <!--<select id="queryNearbyList" resultMap="storeMap">
  96. select * from
  97. ( select
  98. `id`,
  99. `store_name`,
  100. `store_number`,
  101. `store_address`,
  102. `province_name`,
  103. `city_name`,
  104. `county_name`,
  105. `latitude`,
  106. `longitude`,
  107. `cover_radius`,
  108. `remark`,
  109. round(6378.138*2*asin(sqrt(pow(sin((a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
  110. +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)
  111. *pow(sin((a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000) as distance,
  112. merch_sn,
  113. merch_name,
  114. creater_sn,
  115. create_time,
  116. moder_sn,
  117. mod_time,
  118. tstm
  119. from mall_store a
  120. WHERE 1=1
  121. <if test="province_name != null and province_name.trim() != ''">
  122. AND province_name = #{province_name}
  123. </if>
  124. <if test="city_name != null and city_name.trim() != ''">
  125. AND city_name = #{city_name}
  126. </if>
  127. <if test="county_name != null and county_name.trim() != ''">
  128. AND county_name = #{county_name}
  129. </if>
  130. ) tmp
  131. where cover_radius * 1000 > distance
  132. order by distance asc
  133. </select>-->
  134. <!--删除距离限制-->
  135. <select id="queryNearbyList" resultMap="storeMap">
  136. select * from
  137. ( select
  138. `id`,
  139. `store_name`,
  140. `store_number`,
  141. `store_address`,
  142. `province_name`,
  143. `city_name`,
  144. `county_name`,
  145. `latitude`,
  146. `longitude`,
  147. `cover_radius`,
  148. `remark`,
  149. round(6378.138*2*asin(sqrt(pow(sin( (a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
  150. +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)
  151. *pow(sin((a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000) as distance,
  152. merch_sn,
  153. merch_name,
  154. creater_sn,
  155. create_time,
  156. moder_sn,
  157. mod_time,
  158. tstm,third_party_merch_code,third_party_merch_name
  159. from mall_store a
  160. WHERE 1=1 and is_valid = 0
  161. <if test="province_name != null and province_name.trim() != ''">
  162. AND province_name = #{province_name}
  163. </if>
  164. <if test="city_name != null and city_name.trim() != ''">
  165. AND city_name = #{city_name}
  166. </if>
  167. <if test="county_name != null and county_name.trim() != ''">
  168. AND county_name = #{county_name}
  169. </if>
  170. <if test="storeId != null and storeId != '' ">
  171. AND a.id = #{storeId}
  172. </if>
  173. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != '' ">
  174. AND a.third_party_merch_code = #{thirdPartyMerchCode}
  175. </if>
  176. ) tmp
  177. order by distance asc
  178. limit 0, 10
  179. </select>
  180. </mapper>