ApiStoreMapper.xml 6.7 KB

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