shopMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ydd.module.mapper.ShopMapper">
  6. <resultMap type="Shop" id="ShopResult">
  7. <result property="id" column="id" />
  8. <result property="merchantId" column="merchant_id" />
  9. <result property="name" column="name" />
  10. <result property="code" column="code" />
  11. <result property="categoryId" column="category_id" />
  12. <result property="provinceId" column="province_id" />
  13. <result property="cityId" column="city_id" />
  14. <result property="districtId" column="district_id" />
  15. <result property="address" column="address" />
  16. <result property="lng" column="lng" />
  17. <result property="lat" column="lat" />
  18. <result property="type" column="type" />
  19. <result property="tag" column="tag" />
  20. <result property="doorHeadPhoto" column="door_head_photo" />
  21. <result property="photoAlbum" column="photo_album" />
  22. <result property="openingHours" column="opening_hours" />
  23. <result property="contactName" column="contact_name" />
  24. <result property="mobile" column="mobile" />
  25. <result property="startDate" column="start_date" />
  26. <result property="endDate" column="end_date" />
  27. <result property="startTime" column="start_time" />
  28. <result property="endTime" column="end_time" />
  29. <result property="status" column="status" />
  30. </resultMap>
  31. <select id="findList" resultType="com.ydd.module.dto.ShopDto">
  32. select
  33. *
  34. from
  35. lb_shop
  36. where
  37. merchant_id = #{merchantId}
  38. <if test="shopId != null">
  39. and id = #{shopId}
  40. </if>
  41. and deleted = 0 and status = 1
  42. </select>
  43. <select id="findDeliveryList" resultType="com.ydd.module.dto.DeliveryDto">
  44. select
  45. sd.*,d.name,d.logo,d.type,d.id DspDeliveryId
  46. from
  47. lb_shop_delivery as sd
  48. left join lb_dsp_delivery as d
  49. on d.id = sd.delivery_id
  50. where
  51. sd.shop_id = #{shopId}
  52. </select>
  53. <select id="findDetail" resultType="com.ydd.module.dto.ShopDto">
  54. select
  55. *
  56. from
  57. lb_shop
  58. where
  59. id = #{shopId} and deleted = 0
  60. </select>
  61. <select id="getShopNameById" resultType="java.lang.String">
  62. select
  63. `name`
  64. from
  65. lb_shop
  66. where
  67. id = #{shopId}
  68. </select>
  69. <select id="findByMerchantIds" resultType="java.lang.Integer">
  70. SELECT id FROM lb_shop WHERE 1 = 1
  71. AND deleted = 0
  72. AND merchant_id IN
  73. <foreach collection="merchantIds" index="index" item="merchantId" open="(" separator="," close=")">
  74. #{merchantId}
  75. </foreach>
  76. </select>
  77. <select id="findByMerchantId" resultType="java.lang.Integer">
  78. select id from lb_shop where 1=1
  79. and merchant_id = #{merchantId}
  80. </select>
  81. <select id="getByCode" resultType="com.ydd.module.domain.Shop">
  82. select * from lb_shop where code = #{code} and deleted = 0
  83. </select>
  84. <select id="getAddress" resultType="com.ydd.module.domain.Shop">
  85. SELECT
  86. id,
  87. `name`,
  88. `code`,
  89. province_name,
  90. city_name,
  91. district_name,
  92. address,
  93. street,
  94. lng,
  95. lat,
  96. city_code,
  97. contact_name contact,
  98. mobile phone
  99. FROM
  100. lb_shop
  101. WHERE
  102. deleted = 0
  103. AND `status` = 1
  104. AND merchant_id = #{merchantId}
  105. <if test="shopId != null">
  106. AND id = #{shopId}
  107. </if>
  108. </select>
  109. <select id="getShopByMerchantId" resultType="java.lang.Long">
  110. SELECT id FROM lb_shop WHERE merchant_id = #{merchantId} and deleted = 0
  111. <if test="shopId != null">
  112. and id != #{shopId}
  113. </if>
  114. </select>
  115. <select id="getByDeliveryId" resultType="com.ydd.module.domain.Shop">
  116. SELECT
  117. id
  118. FROM
  119. lb_shop
  120. WHERE
  121. deleted = 0
  122. AND id NOT IN (
  123. SELECT shop_id FROM lb_shop_delivery WHERE delivery_id = #{deliveryId} AND id &lt;4422 AND shop_id IN ( SELECT id FROM lb_shop WHERE deleted = 0 )
  124. )
  125. </select>
  126. <select id="getOpenQrCode" resultType="java.lang.Integer">
  127. SELECT open_qr_code
  128. FROM lb_shop
  129. WHERE id = #{shopId}
  130. AND deleted = 0
  131. </select>
  132. <select id="findListByMerchantId" resultType="com.ydd.module.dto.ShopBindDto">
  133. select
  134. id as shopId,
  135. name as shopName
  136. from
  137. lb_shop
  138. where
  139. merchant_id = #{merchantId} and deleted = 0
  140. </select>
  141. <select id="findListById" resultType="com.ydd.module.dto.ShopBindDto">
  142. select
  143. id as shopId,
  144. name as shopName
  145. from
  146. lb_shop
  147. where
  148. id = #{shopId} and deleted = 0
  149. </select>
  150. <select id="getIdListByFreightPackageId" resultType="java.lang.Long">
  151. SELECT id FROM lb_shop
  152. WHERE freight_package_id = #{freightPackageId} AND deleted = 0
  153. </select>
  154. <select id="queryShopListByMerchantId" resultType="com.ydd.module.dto.DadaDspMerchantShopInfoDto">
  155. select
  156. id,
  157. name as shopName,
  158. contact_name,
  159. mobile as contactMobile,
  160. province_name,
  161. city_name,
  162. district_name,
  163. address,
  164. street,
  165. create_time,
  166. status
  167. from lb_shop
  168. where merchant_id = #{params.merchantId}
  169. <if test="params.name != null and params.name != ''">
  170. and name like concat('%', #{params.name}, '%')
  171. </if>
  172. <if test="params.contactName != null and params.contactName != ''">
  173. and contact_name like concat('%', #{params.contactName}, '%')
  174. </if>
  175. <if test="params.mobile != null and params.mobile != ''">
  176. and mobile like concat('%', #{params.mobile}, '%')
  177. </if>
  178. <if test="params.startTime != null and params.startTime != ''">
  179. AND create_time >= #{params.startTime}
  180. </if>
  181. <if test="params.endTime != null and params.startTime != ''">
  182. AND #{params.endTime} >= create_time
  183. </if>
  184. order by id desc
  185. </select>
  186. <select id="queryDadaShopList" resultType="com.ydd.module.dto.DadaShopListDto">
  187. select
  188. s.id,
  189. s.name,
  190. s.code,
  191. s.type,
  192. s.contact_name,
  193. s.mobile,
  194. s.create_time,
  195. s.status,
  196. s.freight_package_id,
  197. m.freight_package_id as merchantFreightPackageId,
  198. m.merchant_name,
  199. ifnull(lm.amount, 0) as amount,
  200. mc.name as categoryName
  201. from lb_shop s
  202. left join lb_merchant m on s.merchant_id = m.id
  203. left join lb_member lm on lm.merchant_id = m.id and member_type = 2
  204. left join lb_merchant_category mc on s.category_id = mc.id
  205. where 1 = 1 and m.dada_dsp_id is not null
  206. <if test="params.dadaDspId != null and params.dadaDspId != ''">
  207. and lm.dada_dsp_id = #{params.dadaDspId}
  208. </if>
  209. <if test="params.name != null and params.name != ''">
  210. and s.name like concat('%', #{params.name}, '%')
  211. </if>
  212. <if test="params.mobile != null and params.mobile != ''">
  213. and s.mobile like concat('%', #{params.mobile}, '%')
  214. </if>
  215. <if test="params.merchantId != null and params.merchantId != ''">
  216. AND s.merchant_id = #{params.merchantId}
  217. </if>
  218. <if test="params.categoryId != null and params.categoryId != ''">
  219. AND s.category_id = #{params.categoryId}
  220. </if>
  221. <if test="params.startTime != null and params.startTime != ''">
  222. AND s.create_time >= #{params.startTime}
  223. </if>
  224. <if test="params.endTime != null and params.startTime != ''">
  225. AND #{params.endTime} >= s.create_time
  226. </if>
  227. <if test="params.amountStart != null and params.amountStart != ''">
  228. AND lm.amount >= #{params.amountStart}
  229. </if>
  230. <if test="params.amountEnd != null and params.amountEnd != ''">
  231. AND #{params.amountEnd} >= lm.amount
  232. </if>
  233. <if test="params.freightPackageId != null and params.freightPackageId != ''">
  234. <if test="params.dimension != null">
  235. <if test="params.dimension == 0">
  236. AND s.freight_package_id is null AND m.freight_package_id is null
  237. </if>
  238. <if test="params.dimension == 1">
  239. AND m.freight_package_id = #{params.freightPackageId} AND s.freight_package_id is null
  240. </if>
  241. <if test="params.dimension == 2">
  242. AND s.freight_package_id = #{params.freightPackageId}
  243. </if>
  244. </if>
  245. </if>
  246. order by s.id desc
  247. </select>
  248. <select id="getDiscountPackageList" resultType="com.ydd.module.dto.ShopDiscountPackageStatisticsDto">
  249. SELECT
  250. s.city_name,
  251. s.district_name,
  252. s.name as shopName,
  253. d.name as packageName,
  254. a.name as agentName
  255. FROM
  256. lb_shop s
  257. JOIN lb_package_discount d ON s.package_discount_id = d.id
  258. JOIN lb_merchant m ON s.merchant_id = m.id
  259. JOIN lb_agent a ON m.agent_id = a.id
  260. WHERE 1 = 1
  261. <if test="params.shopName != null and params.shopName != ''">
  262. AND s.name like concat('%', #{params.shopName}, '%')
  263. </if>
  264. <if test="params.packageName != null and params.packageName != ''">
  265. AND d.name like concat('%', #{params.packageName}, '%')
  266. </if>
  267. </select>
  268. <select id="findShopIdByMerchantId" resultType="java.lang.Long">
  269. SELECT id FROM lb_shop WHERE 1 = 1
  270. AND deleted = 0
  271. <if test="merchantIds != null and merchantIds.size > 0">
  272. AND merchant_id IN
  273. <foreach collection="merchantIds" index="index" item="merchantId" open="(" separator="," close=")">
  274. #{merchantId}
  275. </foreach>
  276. </if>
  277. </select>
  278. <select id="getShopByMerchantIds" resultType="com.ydd.module.domain.Shop">
  279. SELECT id, merchant_id
  280. FROM lb_shop
  281. WHERE deleted = 0
  282. <if test="merchantIds != null and merchantIds.size > 0">
  283. AND merchant_id IN
  284. <foreach collection="merchantIds" index="index" item="merchantId" open="(" separator="," close=")">
  285. #{merchantId}
  286. </foreach>
  287. </if>
  288. </select>
  289. <select id="findShopSelectList" resultType="com.ydd.module.dto.ShopSelectDto">
  290. select id, name
  291. from lb_shop
  292. where deleted = 0 and status = 1
  293. and merchant_id = #{params.merchantId}
  294. <if test="params.memberType == 3 and params.shopId != null">
  295. and id = #{shopId}
  296. </if>
  297. </select>
  298. </mapper>