ApiStoreMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. <!--<select id="queryNearbyList" resultMap="storeMap">-->
  92. <!--select * from-->
  93. <!--( select-->
  94. <!--`id`,-->
  95. <!--`store_name`,-->
  96. <!--`store_number`,-->
  97. <!--`store_address`,-->
  98. <!--`province_name`,-->
  99. <!--`city_name`,-->
  100. <!--`county_name`,-->
  101. <!--`latitude`,-->
  102. <!--`longitude`,-->
  103. <!--`cover_radius`,-->
  104. <!--`remark`,-->
  105. <!--round(6378.138*2*asin(sqrt(pow(sin( (a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)-->
  106. <!--+cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)* pow(sin(-->
  107. <!--(a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000) as distance-->
  108. <!--from mall_store a-->
  109. <!--WHERE 1=1-->
  110. <!--<if test="province_name != null and province_name.trim() != ''">-->
  111. <!--AND province_name = #{province_name}-->
  112. <!--</if>-->
  113. <!--<if test="city_name != null and city_name.trim() != ''">-->
  114. <!--AND city_name = #{city_name}-->
  115. <!--</if>-->
  116. <!--<if test="county_name != null and county_name.trim() != ''">-->
  117. <!--AND county_name = #{county_name}-->
  118. <!--</if>-->
  119. <!--) tmp-->
  120. <!--where cover_radius * 1000 > distance-->
  121. <!--order by distance asc-->
  122. <!--</select>-->
  123. <!--删除距离限制-->
  124. <select id="queryNearbyList" resultMap="storeMap">
  125. select * from
  126. ( select
  127. `id`,
  128. `store_name`,
  129. `store_number`,
  130. `store_address`,
  131. `province_name`,
  132. `city_name`,
  133. `county_name`,
  134. `latitude`,
  135. `longitude`,
  136. `cover_radius`,
  137. `remark`,
  138. round(6378.138*2*asin(sqrt(pow(sin( (a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
  139. +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)* pow(sin(
  140. (a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000) as distance,merch_sn, merch_name, creater_sn, create_time,
  141. moder_sn, mod_time, tstm
  142. from mall_store a
  143. WHERE 1=1
  144. <if test="province_name != null and province_name.trim() != ''">
  145. AND province_name = #{province_name}
  146. </if>
  147. <if test="city_name != null and city_name.trim() != ''">
  148. AND city_name = #{city_name}
  149. </if>
  150. <if test="county_name != null and county_name.trim() != ''">
  151. AND county_name = #{county_name}
  152. </if>
  153. ) tmp
  154. order by distance asc
  155. </select>
  156. </mapper>