ShopDetailMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.yami.shop.dao.ShopDetailMapper">
  4. <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.ShopDetail">
  5. <!--
  6. WARNING - @mbg.generated
  7. -->
  8. <id column="shop_id" jdbcType="BIGINT" property="shopId"/>
  9. <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
  10. <result column="out_station_no" jdbcType="VARCHAR" property="outStationNo"/>
  11. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  12. <result column="intro" jdbcType="VARCHAR" property="intro"/>
  13. <result column="shop_owner" jdbcType="VARCHAR" property="shopOwner"/>
  14. <result column="mobile" jdbcType="VARCHAR" property="mobile"/>
  15. <result column="tel" jdbcType="VARCHAR" property="tel"/>
  16. <result column="shop_lat" jdbcType="VARCHAR" property="shopLat"/>
  17. <result column="shop_lng" jdbcType="VARCHAR" property="shopLng"/>
  18. <result column="shop_address" jdbcType="VARCHAR" property="shopAddress"/>
  19. <result column="province" jdbcType="VARCHAR" property="province"/>
  20. <result column="province_id" jdbcType="BIGINT" property="provinceId"/>
  21. <result column="city" jdbcType="VARCHAR" property="city"/>
  22. <result column="city_id" jdbcType="BIGINT" property="cityId"/>
  23. <result column="area" jdbcType="VARCHAR" property="area"/>
  24. <result column="area_id" jdbcType="BIGINT" property="areaId"/>
  25. <result column="shop_logo" jdbcType="VARCHAR" property="shopLogo"/>
  26. <result column="shop_status" jdbcType="TINYINT" property="shopStatus"/>
  27. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  28. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  29. <result column="is_distribution" jdbcType="TINYINT" property="isDistribution"/>
  30. <result column="business_license" jdbcType="VARCHAR" property="businessLicense"/>
  31. <result column="identity_card_front" jdbcType="VARCHAR" property="identityCardFront"/>
  32. <result column="identity_card_later" jdbcType="VARCHAR" property="identityCardLater"/>
  33. <result column="shop_code" jdbcType="VARCHAR" property="shopCode"/>
  34. <result column="map_type" jdbcType="VARCHAR" property="mapType"/>
  35. <result column="category" jdbcType="VARCHAR" property="category"/>
  36. <result column="sync" jdbcType="TINYINT" property="sync"/>
  37. </resultMap>
  38. <select id="getShopByMobile" resultMap="BaseResultMap">
  39. select *
  40. from tz_shop_detail
  41. where mobile = #{mobile}
  42. </select>
  43. <update id="updatePasswordByUserName">
  44. update tz_shop_detail
  45. set `password` = #{newPassword}
  46. where mobile = #{username}
  47. </update>
  48. <select id="getShopDetailByUserId" resultMap="BaseResultMap">
  49. select *
  50. from tz_shop_detail
  51. where user_id = #{userId}
  52. </select>
  53. <update id="updateStatus">
  54. UPDATE tz_shop_detail sd
  55. SET sd.`update_time` = NOW(),
  56. sd.`shop_status` = #{status}
  57. WHERE sd.`shop_id` = #{shopId}
  58. </update>
  59. <update id="hbUpdateStatus">
  60. UPDATE tz_shop_detail
  61. SET update_time = NOW(),
  62. shop_status = #{shopStatus},
  63. run_status = #{runStatus}
  64. WHERE shop_id = #{shopId}
  65. </update>
  66. <select id="listHotShopsHead" resultType="com.yami.shop.bean.app.dto.ShopHeadInfoDto">
  67. SELECT sd.`shop_id`,
  68. sd.`out_station_no`,
  69. sd.`shop_name`,
  70. sd.`shop_logo`,
  71. sd.shop_status,
  72. COUNT(ucs.`shop_id`) fansCount,
  73. sd.`tel`
  74. FROM tz_shop_detail sd
  75. LEFT JOIN `tz_user_collection_shop` ucs
  76. ON ucs.`shop_id` = sd.`shop_id`
  77. GROUP BY sd.`shop_id`
  78. HAVING sd.shop_status = 1
  79. ORDER BY fansCount DESC LIMIT 8
  80. </select>
  81. <select id="searchShops" resultType="com.yami.shop.bean.app.dto.ShopHeadInfoDto">
  82. SELECT
  83. sd.`shop_id`,
  84. sd.`out_station_no`,
  85. sd.`shop_name`,
  86. sd.`shop_logo`,
  87. sd.shop_status,
  88. COUNT(ucs.`shop_id`) fansCount,
  89. sd.`tel`
  90. FROM
  91. tz_shop_detail sd
  92. LEFT JOIN `tz_user_collection_shop` ucs
  93. ON ucs.`shop_id` = sd.`shop_id`
  94. GROUP BY sd.`shop_id`
  95. HAVING sd.shop_status = 1
  96. <if test="shopHeadInfoDto.shopName != null and shopHeadInfoDto.shopName != ''">
  97. and sd.`shop_name` like concat('%', #{shopHeadInfoDto.shopName}, '%')
  98. </if>
  99. ORDER BY fansCount DESC
  100. </select>
  101. <select id="selectShopDetailById" resultType="com.yami.shop.bean.model.ShopDetail">
  102. select *
  103. from tz_shop_detail
  104. where shop_id = #{shopId}
  105. </select>
  106. <select id="neighborShop" resultType="com.yami.shop.bean.model.ShopDetail">
  107. select DISTINCT
  108. sd.shop_id,
  109. shop_name,
  110. sd.shop_lat ,
  111. sd.shop_lng,
  112. ( 6371 * acos( cos( radians(#{lat}) ) * cos( radians( shop_lat ) ) * cos( radians( shop_lng ) - radians(#{lon})
  113. ) + sin( radians(#{lat}) ) * sin( radians( shop_lat ) ) ) ) distance
  114. from
  115. tz_shop_detail sd
  116. right join tz_transport2 tp on tp.shop_id = sd.shop_id
  117. right join tz_channel_shop tcs on tcs.shop_id = sd.shop_id
  118. where shop_status = 1
  119. <if test="null != platform">
  120. and tcs.`channel_id`= #{platform} and tcs.`is_delete`=0
  121. </if>
  122. order by
  123. distance
  124. </select>
  125. <select id="selectByOutStationNo" resultType="com.yami.shop.bean.model.ShopDetail">
  126. select *
  127. from tz_shop_detail
  128. where out_station_no = #{outStationNo}
  129. </select>
  130. <select id="selectByHbStationId" resultType="com.yami.shop.bean.model.ShopDetail">
  131. select *
  132. from tz_shop_detail
  133. where hb_station_id = #{hbStationId}
  134. </select>
  135. </mapper>