ApiStoreMapper.xml 6.4 KB

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