You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

409 lines
16 KiB

  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.iformall.mapper.WxMerchantMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMerchant">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="img_url" jdbcType="VARCHAR" property="imgUrl"/>
  8. <result column="name" jdbcType="VARCHAR" property="name"/>
  9. <result column="link_phone" jdbcType="VARCHAR" property="linkPhone"/>
  10. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  11. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  12. <result column="car_vendor_type" jdbcType="INTEGER" property="carVendorType"/>
  13. <result column="car_params" jdbcType="VARCHAR" property="carParams"/>
  14. <result column="status" jdbcType="INTEGER" property="status"/>
  15. <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/>
  16. <result column="business_id" jdbcType="INTEGER" property="businessId"/>
  17. <result column="sub_business_id" jdbcType="INTEGER" property="subBusinessId"/>
  18. <result column="shop_type" jdbcType="INTEGER" property="shopType"/>
  19. <result column="brand" jdbcType="VARCHAR" property="brand"/>
  20. <result column="type" jdbcType="SMALLINT" property="type"/>
  21. <result column="is_public" jdbcType="SMALLINT" property="isPublic"/>
  22. <result column="email" jdbcType="VARCHAR" property="email"/>
  23. <result column="title" jdbcType="VARCHAR" property="title"/>
  24. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  25. <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/>
  26. <result column="bill_setting" jdbcType="INTEGER" property="billSetting"/>
  27. <result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
  28. <result column="introduction" jdbcType="VARCHAR" property="introduction"/>
  29. <result column="action_desc" jdbcType="VARCHAR" property="actionDesc"/>
  30. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  31. <result column="talk_user_main" jdbcType="VARCHAR" property="talkUserMain"/>
  32. <result column="talk_user_aux" jdbcType="VARCHAR" property="talkUserAux"/>
  33. <result column="link_line_phone" property="linkLinePhone"/>
  34. <result column="rental_start_date" property="rentalStartDate"/>
  35. <result column="rental_end_date" property="rentalEndDate"/>
  36. </resultMap>
  37. <sql id="allColumns">
  38. `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status`,`link_person`,
  39. `business_id`,`sub_business_id`,`shop_type`,`brand`,`type`,`is_public`,email,`title`,`cover_picture`,`is_admin`,`bill_setting`,`qr_code`,
  40. `introduction`,`action_desc`,`is_del`,`talk_user_main`,`talk_user_aux`,link_line_phone
  41. </sql>
  42. <sql id="allColumnsVo">
  43. m.`id`,m.`tenant_id`,m.`img_url`,m.`name`,m.`link_phone`,m.`create_date`,m.`update_date`,m.`car_vendor_type`,m.`car_params`,m.`status`,m.`link_person`,
  44. m.`business_id`,m.`sub_business_id`,m.`shop_type`,m.`brand`,m.`type`,m.`is_public`,m.email,m.`title`,m.`cover_picture`,m.`is_admin`,m.`bill_setting`,m.`qr_code`,
  45. m.`introduction`,m.`action_desc`,m.`is_del`,m.`talk_user_main`,m.`talk_user_aux`,m.link_line_phone,r.rental_start_date,r.rental_end_date
  46. </sql>
  47. <sql id="dynamicWhereConditions">
  48. where is_del = 0
  49. <if test=" null != id ">
  50. and `id` = #{id}
  51. </if>
  52. <if test=" null != tenantId ">
  53. and `tenant_id` = #{tenantId}
  54. </if>
  55. <if test=" null != imgUrl ">
  56. and `img_url` like concat('%', #{imgUrl},'%')
  57. </if>
  58. <if test=" null != name and ''!=name ">
  59. and `name` like concat('%', #{name},'%')
  60. </if>
  61. <if test=" null != linkPhone and ''!=linkPhone ">
  62. and `link_phone` like concat('%', #{linkPhone},'%')
  63. </if>
  64. <if test=" null != createDate ">
  65. and `create_date` = #{createDate}
  66. </if>
  67. <if test=" null != updateDate ">
  68. and `update_date` = #{updateDate}
  69. </if>
  70. <if test=" null != carVendorType ">
  71. and `car_vendor_type` = #{carVendorType}
  72. </if>
  73. <if test=" null != businessId ">
  74. and `business_id` = #{businessId}
  75. </if>
  76. <if test=" null != subBusinessId ">
  77. and `sub_business_id` = #{subBusinessId}
  78. </if>
  79. <if test=" null != carParams ">
  80. and `car_params` like concat('%', #{carParams},'%')
  81. </if>
  82. <if test=" null != status ">
  83. and `status` = #{status}
  84. </if>
  85. <if test=" null != linkPerson ">
  86. and `link_person` = #{linkPerson}
  87. </if>
  88. <if test=" null != type ">
  89. and `type` = #{type}
  90. </if>
  91. <if test=" null != isPublic ">
  92. and `is_public` = #{isPublic}
  93. </if>
  94. <if test=" null != email ">
  95. and `email` = #{email}
  96. </if>
  97. <if test=" null != isAdmin ">
  98. and `is_admin` = #{isAdmin}
  99. </if>
  100. <if test=" null != isDel ">
  101. and `is_del` = #{isDel}
  102. </if>
  103. <if test=" null != brand ">
  104. and `brand` = #{brand}
  105. </if>
  106. <if test=" null != rentShopType ">
  107. and id not in(
  108. select merchant_id from wx_rent_contract where tenant_id=#{tenantId} and rent_shop_type=1 and merchant_id is
  109. not null and status in(1,2,3,4)
  110. )
  111. </if>
  112. <if test=" null != ids ">
  113. and id in
  114. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  115. #{idItem}
  116. </foreach>
  117. </if>
  118. <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)">
  119. and id in(
  120. select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
  121. inner join wx_merchant m on ms.merchant_id = m.id
  122. inner join wx_shop s on s.id=ms.shop_id
  123. where m.tenant_id=#{tenantId} and s.is_del=0
  124. <if test=" null != businessForRule and '' != businessForRule ">
  125. and m.business_id in (${businessForRule})
  126. </if>
  127. <if test=" null != floorForRule and '' != floorForRule ">
  128. and s.`floor` in (${floorForRule})
  129. </if>
  130. )
  131. </if>
  132. <if test=" null != sortColumns">order by ${sortColumns}</if>
  133. </sql>
  134. <select id="findList" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  135. select
  136. <include refid="allColumns"/>
  137. from wx_merchant m
  138. <include refid="dynamicWhereConditions"/>
  139. </select>
  140. <select id="findListVo" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  141. select
  142. <include refid="allColumnsVo"/>
  143. from wx_merchant m left join (select merchant_id,rental_start_date,rental_end_date from wx_rent_contract where
  144. tenant_id=#{tenantId} and status in(2,3,4)) r
  145. on m.id=r.merchant_id
  146. <include refid="dynamicWhereConditionsVo"/>
  147. </select>
  148. <sql id="dataRule">
  149. <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)">
  150. and m.id in(
  151. select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
  152. inner join wx_merchant m on ms.merchant_id = m.id
  153. inner join wx_shop s on s.id=ms.shop_id
  154. where m.tenant_id=#{tenantId} and s.is_del=0
  155. <if test=" null != businessForRule and '' != businessForRule ">
  156. and m.business_id in (${businessForRule})
  157. </if>
  158. <if test=" null != floorForRule and '' != floorForRule ">
  159. and s.`floor` in (${floorForRule})
  160. </if>
  161. )
  162. </if>
  163. </sql>
  164. <sql id="dynamicWhereConditionsVo">
  165. where m.is_del = 0
  166. <if test=" null != id ">
  167. and m.`id` = #{id}
  168. </if>
  169. <if test=" null != tenantId ">
  170. and m.`tenant_id` = #{tenantId}
  171. </if>
  172. <if test=" null != imgUrl ">
  173. and m.`img_url` like concat('%', #{imgUrl},'%')
  174. </if>
  175. <if test=" null != name and ''!=name ">
  176. and m.`name` like concat('%', #{name},'%')
  177. </if>
  178. <if test=" null != linkPhone and ''!=linkPhone ">
  179. and m.`link_phone` like concat('%', #{linkPhone},'%')
  180. </if>
  181. <if test=" null != createDate ">
  182. and m.`create_date` = #{createDate}
  183. </if>
  184. <if test=" null != updateDate ">
  185. and m.`update_date` = #{updateDate}
  186. </if>
  187. <if test=" null != carVendorType ">
  188. and m.`car_vendor_type` = #{carVendorType}
  189. </if>
  190. <if test=" null != businessId ">
  191. and m.`business_id` = #{businessId}
  192. </if>
  193. <if test=" null != subBusinessId ">
  194. and m.`sub_business_id` = #{subBusinessId}
  195. </if>
  196. <if test=" null != carParams ">
  197. and m.`car_params` like concat('%', #{carParams},'%')
  198. </if>
  199. <if test=" null != status ">
  200. and m.`status` = #{status}
  201. </if>
  202. <if test=" null != linkPerson ">
  203. and m.`link_person` = #{linkPerson}
  204. </if>
  205. <if test=" null != type ">
  206. and m.`type` = #{type}
  207. </if>
  208. <if test=" null != isPublic ">
  209. and m.`is_public` = #{isPublic}
  210. </if>
  211. <if test=" null != email ">
  212. and m.`email` = #{email}
  213. </if>
  214. <if test=" null != isAdmin ">
  215. and m.`is_admin` = #{isAdmin}
  216. </if>
  217. <if test=" null != isDel ">
  218. and m.`is_del` = #{isDel}
  219. </if>
  220. <if test=" null != brand ">
  221. and m.`brand` = #{brand}
  222. </if>
  223. <if test=" null != rentShopType ">
  224. and m.id not in(
  225. select merchant_id from wx_rent_contract where tenant_id=#{tenantId} and rent_shop_type=1 and merchant_id is
  226. not null and status in(1,2,3,4)
  227. )
  228. </if>
  229. <if test=" null != ids ">
  230. and m.id in
  231. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  232. #{idItem}
  233. </foreach>
  234. </if>
  235. <include refid="dataRule"/>
  236. <if test=" null != sortColumns">order by ${sortColumns}</if>
  237. </sql>
  238. <sql id="allMerchantVoColumns">
  239. m.id,m.img_url,m.name,m.link_phone,m.status,m.business_id,
  240. m.is_public,m.email,m.title,m.cover_picture,m.sub_business_id,
  241. m.shop_type,m.introduction,m.action_desc,bu.title as business_name,m.link_line_phone
  242. </sql>
  243. <select id="getMerchantByCode" parameterType="java.util.Map" resultMap="MerchantVoResultMap">
  244. select
  245. <include refid="allMerchantVoColumns"/>
  246. FROM wx_merchant m
  247. left join wx_business bu on bu.id = m.business_id
  248. <where>
  249. <if test=" null != tenantId ">
  250. and m.`tenant_id` = #{tenantId}
  251. </if>
  252. <if test=" null != status ">
  253. and m.`status` = #{status}
  254. </if>
  255. <if test=" null != merchantCode ">
  256. and md5(m.`id`) = #{merchantCode}
  257. </if>
  258. </where>
  259. </select>
  260. <resultMap id="MerchantVoResultMap" type="com.iformall.domain.vo.WxMerchantVo">
  261. <id column="id" jdbcType="BIGINT" property="id"/>
  262. <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl"/>
  263. <result column="name" jdbcType="VARCHAR" property="merchantName"/>
  264. <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/>
  265. <result column="status" jdbcType="VARCHAR" property="merchantStatus"/>
  266. <result column="business_id" jdbcType="INTEGER" property="businessId"/>
  267. <result column="sub_business_id" jdbcType="INTEGER" property="subBusinessId"/>
  268. <result column="is_public" jdbcType="INTEGER" property="isPublic"/>
  269. <result column="email" jdbcType="VARCHAR" property="email"/>
  270. <result column="title" jdbcType="VARCHAR" property="title"/>
  271. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  272. <result column="shop_type" jdbcType="VARCHAR" property="shopType"/>
  273. <result column="brand_name" jdbcType="VARCHAR" property="brandName"/>
  274. <result column="brand_img" jdbcType="VARCHAR" property="brandImg"/>
  275. <result column="summary" jdbcType="VARCHAR" property="summary"/>
  276. <result column="business_name" jdbcType="VARCHAR" property="businessName"/>
  277. <result column="introduction" jdbcType="VARCHAR" property="introduction"/>
  278. <result column="action_desc" jdbcType="VARCHAR" property="actionDesc"/>
  279. <result column="link_line_phone" property="linkLinePhone"/>
  280. <collection column="{merchantId=id}" property="shopVoList"
  281. ofType="com.iformall.domain.vo.WxShopVo"
  282. javaType="java.util.List"
  283. select="com.iformall.mapper.WxShopMapper.findShopVoList">
  284. </collection>
  285. </resultMap>
  286. <select id="findListCVo" parameterType="com.iformall.domain.vo.WxMerchantVo" resultMap="MerchantVoResultMap">
  287. select
  288. <include refid="allMerchantVoColumns"/>
  289. FROM wx_merchant m
  290. left join wx_business bu on bu.id = m.business_id
  291. where 1=1 and m.is_del=0
  292. <if test=" null != merchantName and ''!=merchantName ">
  293. and m.`name` like concat('%', #{merchantName},'%')
  294. </if>
  295. <if test=" null != merchantLinkPhone and ''!=merchantLinkPhone ">
  296. and m.`link_phone` like concat('%', #{merchantLinkPhone},'%')
  297. </if>
  298. <if test=" null != businessId ">
  299. and m.`business_id` = #{businessId}
  300. </if>
  301. <if test=" null != subBusinessId ">
  302. and m.`sub_business_id` = #{subBusinessId}
  303. </if>
  304. <if test=" null != merchantStatus ">
  305. and m.`status` = #{merchantStatus}
  306. </if>
  307. <if test=" null != isPublic">
  308. and m.`is_public` = #{isPublic}
  309. </if>
  310. <if test=" null != id">
  311. and m.`id` = #{id}
  312. </if>
  313. order by m.top_time desc
  314. </select>
  315. <select id="queryMerchantByMerchantIdOfSharingReceiver" resultType="com.iformall.domain.po.WxMerchant"
  316. parameterType="com.iformall.domain.po.WxMerchant">
  317. select m.name,psr.id from wx_merchant m
  318. left join (select * from wx_profit_sharing_receiver where status=0) psr on m.id=psr.merchant_id
  319. where m.id=#{id}
  320. </select>
  321. <select id="findQrcodeEmptyList" resultMap="BaseResultMap">
  322. select * from wx_merchant where qr_code is null;
  323. </select>
  324. <select id="findBusByFloorId" resultType="hashmap" parameterType="hashmap">
  325. select count(distinct m.id) count,b.id bid,b.`title` btitle from wx_merchant m
  326. left join wx_merchant_shop ms on(m.id = ms.merchant_id)
  327. left join wx_shop s on(ms.shop_id = s.id)
  328. left join wx_mall_floor f on(s.floor = f.id)
  329. left join wx_mall_building mb on(f.building_id = mb.id)
  330. left join wx_business b on(m.business_id = b.id)
  331. where 1=1
  332. <if test=" null != id">
  333. and f.id = #{id}
  334. </if>
  335. <if test=" null != buildingId">
  336. and mb.id = #{buildingId}
  337. </if>
  338. and m.tenant_id = #{tenantId}
  339. and s.is_del = 0
  340. and ms.is_del = 0
  341. and m.status = 1
  342. and m.is_del = 0
  343. group by m.business_id
  344. </select>
  345. <select id="hasMerchant" parameterType="com.iformall.domain.po.WxMerchant" resultType="int">
  346. select count(*) from wx_merchant where `name`=#{name} and status=#{status}
  347. <if test=" null != id">
  348. and `id` != #{id}
  349. </if>
  350. </select>
  351. </mapper>