ApiStoreMapper.xml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. <resultMap type="com.kmall.api.entity.StoreWithThirdMerchBizVo" id="storeWithThirdMerchMap">
  25. <result property="id" column="id"/>
  26. <result property="storeName" column="store_name"/>
  27. <result property="storeNumber" column="store_number"/>
  28. <result property="storeAddress" column="store_address"/>
  29. <result property="provinceName" column="province_name"/>
  30. <result property="cityName" column="city_name"/>
  31. <result property="countyName" column="county_name"/>
  32. <result property="latitude" column="latitude"/>
  33. <result property="longitude" column="longitude"/>
  34. <result property="coverRadius" column="cover_radius"/>
  35. <result property="remark" column="remark"/>
  36. <result property="merchSn" column="merch_sn" jdbcType="VARCHAR" />
  37. <result property="merchName" column="merch_name" jdbcType="VARCHAR" />
  38. <result property="thirdPartyMerchCode" column="third_party_merch_code"/>
  39. <result property="thirdPartyMerchName" column="third_party_merch_name"/>
  40. <result property="isValid" column="is_valid"/>
  41. <result property="exprAgreementType" column="expr_agreement_type"/>
  42. <result property="isLoadGoods" column="is_load_goods"/>
  43. <result property="isStockShare" column="is_stock_share"/>
  44. <result property="isStoreUserShare" column="is_store_user_share"/>
  45. <result property="isValidMerch" column="is_valid"/>
  46. <result property="isMapShow" column="is_map_show"/>
  47. <result property="isDistSellStart" column="is_dist_sell_start"/>
  48. <result property="isSupplierGoods" column="is_supplier_goods"/>
  49. <result property="isFaceCheck" column="is_face_check"/>
  50. </resultMap>
  51. <select id="queryObject" resultType="com.kmall.api.entity.StoreVo">
  52. select
  53. `id`,
  54. `store_name`,
  55. `store_number`,
  56. `store_address`,
  57. `province_name`,
  58. `city_name`,
  59. `county_name`,
  60. `latitude`,
  61. `longitude`,
  62. `cover_radius`,
  63. `remark`,
  64. merch_sn,
  65. merch_name,
  66. third_party_merch_code,
  67. third_party_merch_name,
  68. moder_sn
  69. from mall_store
  70. where id = #{id} and is_valid = 0
  71. </select>
  72. <select id="queryList" resultType="com.kmall.api.entity.StoreVo">
  73. select
  74. `id`,
  75. `store_name`,
  76. `store_number`,
  77. `store_address`,
  78. `province_name`,
  79. `city_name`,
  80. `county_name`,
  81. `latitude`,
  82. `longitude`,
  83. `cover_radius`,
  84. `remark`,
  85. merch_sn,
  86. merch_name,
  87. third_party_merch_code,
  88. third_party_merch_name
  89. from mall_store
  90. WHERE 1=1 and is_valid = 0
  91. <if test="province_name != null and province_name.trim() != ''">
  92. AND province_name = #{province_name}
  93. </if>
  94. <if test="city_name != null and city_name.trim() != ''">
  95. AND city_name = #{city_name}
  96. </if>
  97. <if test="county_name != null and county_name.trim() != ''">
  98. AND county_name = #{county_name}
  99. </if>
  100. <if test="latitude != null and longitude!= null">
  101. AND cover_radius*1000 > round(6378.138*2*asin(sqrt(pow(sin( (a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
  102. +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)* pow(sin(
  103. (a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000)
  104. </if>
  105. <choose>
  106. <when test="sidx != null and sidx.trim() != ''">
  107. order by ${sidx} ${order}
  108. </when>
  109. <otherwise>
  110. order by id desc
  111. </otherwise>
  112. </choose>
  113. <if test="offset != null and limit != null">
  114. limit #{offset}, #{limit}
  115. </if>
  116. </select>
  117. <select id="queryTotal" resultType="int">
  118. select count(*) from mall_store
  119. WHERE 1=1 and is_valid = 0
  120. <if test="name != null and name.trim() != ''">
  121. AND name LIKE concat('%',#{name},'%')
  122. </if>
  123. </select>
  124. <!-- 在配送范围之内查找店铺 -->
  125. <!--<select id="queryNearbyList" resultMap="storeMap">
  126. select * from
  127. ( select
  128. `id`,
  129. `store_name`,
  130. `store_number`,
  131. `store_address`,
  132. `province_name`,
  133. `city_name`,
  134. `county_name`,
  135. `latitude`,
  136. `longitude`,
  137. `cover_radius`,
  138. `remark`,
  139. round(6378.138*2*asin(sqrt(pow(sin((a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
  140. +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)
  141. *pow(sin((a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000) as distance,
  142. merch_sn,
  143. merch_name,
  144. creater_sn,
  145. create_time,
  146. moder_sn,
  147. mod_time,
  148. tstm
  149. from mall_store a
  150. WHERE 1=1
  151. <if test="province_name != null and province_name.trim() != ''">
  152. AND province_name = #{province_name}
  153. </if>
  154. <if test="city_name != null and city_name.trim() != ''">
  155. AND city_name = #{city_name}
  156. </if>
  157. <if test="county_name != null and county_name.trim() != ''">
  158. AND county_name = #{county_name}
  159. </if>
  160. ) tmp
  161. where cover_radius * 1000 > distance
  162. order by distance asc
  163. </select>-->
  164. <!--删除距离限制-->
  165. <select id="queryNearbyList" resultMap="storeMap">
  166. select * from
  167. ( select
  168. `id`,
  169. `store_name`,
  170. `store_number`,
  171. `store_address`,
  172. `province_name`,
  173. `city_name`,
  174. `county_name`,
  175. `latitude`,
  176. `longitude`,
  177. `cover_radius`,
  178. `remark`,
  179. round(6378.138*2*asin(sqrt(pow(sin( (a.latitude*pi()/180-#{latitude}*pi()/180)/2),2)
  180. +cos(a.latitude*pi()/180)*cos(#{latitude}*pi()/180)
  181. *pow(sin((a.longitude*pi()/180-#{longitude}*pi()/180)/2),2)))*1000) as distance,
  182. merch_sn,
  183. merch_name,
  184. third_party_merch_code,
  185. third_party_merch_name
  186. from mall_store a
  187. WHERE 1=1 and is_valid = 0
  188. and (select count(1) from mall_product_store_rela r left join mall_goods g on r.goods_id = g.id where store_id = a.id and stock_num!=0 and g.is_hot=1 AND g.goods_number > 0 AND g.is_delete != 1 AND g.is_on_sale = 1)>0
  189. <if test="province_name != null and province_name.trim() != ''">
  190. AND province_name = #{province_name}
  191. </if>
  192. <if test="city_name != null and city_name.trim() != ''">
  193. AND city_name = #{city_name}
  194. </if>
  195. <if test="county_name != null and county_name.trim() != ''">
  196. AND county_name = #{county_name}
  197. </if>
  198. <if test="storeId != null and storeId != '' ">
  199. AND a.id = #{storeId}
  200. </if>
  201. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != '' ">
  202. AND a.third_party_merch_code = #{thirdPartyMerchCode}
  203. </if>
  204. ) tmp
  205. order by distance asc
  206. limit 0, 10
  207. </select>
  208. <select id="storeByIdWithThirdMerch" resultMap="storeWithThirdMerchMap">
  209. select t.id, t.merch_sn, t.merch_name, t.store_name, t.store_number,
  210. t.store_address, t.province_name,
  211. t.city_name, t.county_name,
  212. t.latitude, t.longitude, t.cover_radius, t.remark, t.is_valid,
  213. t.third_party_merch_code, t.third_party_merch_name,
  214. t.expr_agreement_type, t.is_load_goods,
  215. t1.third_merch_sn,
  216. t1.is_stock_share, t1.is_store_user_share, t1.is_map_show,
  217. t1.is_dist_sell_start, t1.is_supplier_goods,
  218. t1.is_face_check, t1.is_valid
  219. from mall_store t
  220. left join third_merchant_biz t1 on t.third_party_merch_code=t1.third_party_merch_code
  221. where 1=1 and t.is_valid='0' and t1.is_valid='0'
  222. <if test="storeId != null and storeId != '' ">
  223. AND t.id = #{storeId}
  224. </if>
  225. limit 0, 10
  226. </select>
  227. </mapper>