ApiStoreMapper.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  20. <result property="thirdPartyMerchCode" column="third_party_merch_code"/>
  21. <result property="thirdPartyMerchName" column="third_party_merch_name"/>
  22. <result property="isValid" column="is_valid"/>
  23. </resultMap>
  24. <select id="queryObject" resultType="com.kmall.api.entity.StoreVo">
  25. select
  26. `id`,
  27. `store_name`,
  28. `store_number`,
  29. `store_address`,
  30. `province_name`,
  31. `city_name`,
  32. `county_name`,
  33. `latitude`,
  34. `longitude`,
  35. `cover_radius`,
  36. `remark`,
  37. merch_sn,
  38. merch_name,
  39. third_party_merch_code,
  40. third_party_merch_name,
  41. moder_sn
  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`,
  58. merch_sn,
  59. merch_name,
  60. third_party_merch_code,
  61. third_party_merch_name
  62. from mall_store
  63. WHERE 1=1 and is_valid = 0
  64. <if test="province_name != null and province_name.trim() != ''">
  65. AND province_name = #{province_name}
  66. </if>
  67. <if test="city_name != null and city_name.trim() != ''">
  68. AND city_name = #{city_name}
  69. </if>
  70. <if test="county_name != null and county_name.trim() != ''">
  71. AND county_name = #{county_name}
  72. </if>
  73. <if test="latitude != null and longitude!= null">
  74. AND cover_radius*1000 > round(6378.138*2*asin(sqrt(pow(sin( (a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
  75. +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)* pow(sin(
  76. (a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000)
  77. </if>
  78. <choose>
  79. <when test="sidx != null and sidx.trim() != ''">
  80. order by ${sidx} ${order}
  81. </when>
  82. <otherwise>
  83. order by id desc
  84. </otherwise>
  85. </choose>
  86. <if test="offset != null and limit != null">
  87. limit #{offset}, #{limit}
  88. </if>
  89. </select>
  90. <select id="queryTotal" resultType="int">
  91. select count(*) from mall_store
  92. WHERE 1=1 and is_valid = 0
  93. <if test="name != null and name.trim() != ''">
  94. AND name LIKE concat('%',#{name},'%')
  95. </if>
  96. </select>
  97. <!-- 在配送范围之内查找店铺 -->
  98. <!--<select id="queryNearbyList" resultMap="storeMap">
  99. select * from
  100. ( select
  101. `id`,
  102. `store_name`,
  103. `store_number`,
  104. `store_address`,
  105. `province_name`,
  106. `city_name`,
  107. `county_name`,
  108. `latitude`,
  109. `longitude`,
  110. `cover_radius`,
  111. `remark`,
  112. round(6378.138*2*asin(sqrt(pow(sin((a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
  113. +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)
  114. *pow(sin((a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000) as distance,
  115. merch_sn,
  116. merch_name,
  117. creater_sn,
  118. create_time,
  119. moder_sn,
  120. mod_time,
  121. tstm
  122. from mall_store a
  123. WHERE 1=1
  124. <if test="province_name != null and province_name.trim() != ''">
  125. AND province_name = #{province_name}
  126. </if>
  127. <if test="city_name != null and city_name.trim() != ''">
  128. AND city_name = #{city_name}
  129. </if>
  130. <if test="county_name != null and county_name.trim() != ''">
  131. AND county_name = #{county_name}
  132. </if>
  133. ) tmp
  134. where cover_radius * 1000 > distance
  135. order by distance asc
  136. </select>-->
  137. <!--删除距离限制-->
  138. <select id="queryNearbyList" resultMap="storeMap">
  139. select * from
  140. ( select
  141. `id`,
  142. `store_name`,
  143. `store_number`,
  144. `store_address`,
  145. `province_name`,
  146. `city_name`,
  147. `county_name`,
  148. `latitude`,
  149. `longitude`,
  150. `cover_radius`,
  151. `remark`,
  152. round(6378.138*2*asin(sqrt(pow(sin( (a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
  153. +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)
  154. *pow(sin((a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000) as distance,
  155. merch_sn,
  156. merch_name,
  157. third_party_merch_code,
  158. 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>