ApiStoreMapper.xml 6.1 KB

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