Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

515 řádky
20 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. <result column="credit_locked" property="creditLocked"/>
  37. </resultMap>
  38. <sql id="allColumns">
  39. `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status`,`link_person`,
  40. `business_id`,`sub_business_id`,`shop_type`,`brand`,`type`,`is_public`,email,`title`,`cover_picture`,`is_admin`,`bill_setting`,`qr_code`,
  41. `introduction`,`action_desc`,`is_del`,`talk_user_main`,`talk_user_aux`,link_line_phone,credit_locked
  42. </sql>
  43. <sql id="allColumnsVo">
  44. 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`,
  45. 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`,
  46. 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
  47. </sql>
  48. <sql id="dynamicWhereConditions">
  49. where is_del = 0
  50. <if test=" null != id ">
  51. and `id` = #{id}
  52. </if>
  53. <if test=" null != tenantId ">
  54. and `tenant_id` = #{tenantId}
  55. </if>
  56. <if test=" null != imgUrl ">
  57. and `img_url` like concat('%', #{imgUrl},'%')
  58. </if>
  59. <if test=" null != name and ''!=name ">
  60. and `name` like concat('%', #{name},'%')
  61. </if>
  62. <if test=" null != linkPhone and ''!=linkPhone ">
  63. and `link_phone` like concat('%', #{linkPhone},'%')
  64. </if>
  65. <if test=" null != createDate ">
  66. and `create_date` = #{createDate}
  67. </if>
  68. <if test=" null != updateDate ">
  69. and `update_date` = #{updateDate}
  70. </if>
  71. <if test=" null != carVendorType ">
  72. and `car_vendor_type` = #{carVendorType}
  73. </if>
  74. <if test=" null != businessId ">
  75. and `business_id` = #{businessId}
  76. </if>
  77. <if test=" null != subBusinessId ">
  78. and `sub_business_id` = #{subBusinessId}
  79. </if>
  80. <if test=" null != carParams ">
  81. and `car_params` like concat('%', #{carParams},'%')
  82. </if>
  83. <if test=" null != status ">
  84. and `status` = #{status}
  85. </if>
  86. <if test=" null != linkPerson ">
  87. and `link_person` = #{linkPerson}
  88. </if>
  89. <if test=" null != type ">
  90. and `type` = #{type}
  91. </if>
  92. <if test=" null != isPublic ">
  93. and `is_public` = #{isPublic}
  94. </if>
  95. <if test=" null != email ">
  96. and `email` = #{email}
  97. </if>
  98. <if test=" null != isAdmin ">
  99. and `is_admin` = #{isAdmin}
  100. </if>
  101. <if test=" null != isDel ">
  102. and `is_del` = #{isDel}
  103. </if>
  104. <if test=" null != brand ">
  105. and `brand` = #{brand}
  106. </if>
  107. <if test=" null != creditLocked ">
  108. and `credit_locked` = #{creditLocked}
  109. </if>
  110. <if test=" null != rentShopType ">
  111. and id not in(
  112. select merchant_id from wx_rent_contract where tenant_id=#{tenantId} and rent_shop_type=1 and merchant_id is
  113. not null and status in(1,2,3,4)
  114. )
  115. </if>
  116. <if test=" null != ids ">
  117. and id in
  118. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  119. #{idItem}
  120. </foreach>
  121. </if>
  122. <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)">
  123. and id in(
  124. select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
  125. inner join wx_merchant m on ms.merchant_id = m.id
  126. inner join wx_shop s on s.id=ms.shop_id
  127. where m.tenant_id=#{tenantId} and s.is_del=0
  128. <if test=" null != businessForRule and '' != businessForRule ">
  129. and m.business_id in (${businessForRule})
  130. </if>
  131. <if test=" null != floorForRule and '' != floorForRule ">
  132. and s.`floor` in (${floorForRule})
  133. </if>
  134. )
  135. </if>
  136. <if test=" null != sortColumns">order by ${sortColumns}</if>
  137. </sql>
  138. <select id="findList" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  139. select
  140. <include refid="allColumns"/>
  141. from wx_merchant m
  142. <include refid="dynamicWhereConditions"/>
  143. </select>
  144. <select id="findListVo" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  145. select
  146. <include refid="allColumnsVo"/>
  147. from wx_merchant m left join (select merchant_id,rental_start_date,rental_end_date from wx_rent_contract where
  148. tenant_id=#{tenantId} and status in(2,3,4)) r
  149. on m.id=r.merchant_id
  150. <include refid="dynamicWhereConditionsVo"/>
  151. </select>
  152. <sql id="dataRule">
  153. <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)">
  154. and m.id in(
  155. select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
  156. inner join wx_merchant m on ms.merchant_id = m.id
  157. inner join wx_shop s on s.id=ms.shop_id
  158. where m.tenant_id=#{tenantId} and s.is_del=0
  159. <if test=" null != businessForRule and '' != businessForRule ">
  160. and m.business_id in (${businessForRule})
  161. </if>
  162. <if test=" null != floorForRule and '' != floorForRule ">
  163. and s.`floor` in (${floorForRule})
  164. </if>
  165. )
  166. </if>
  167. </sql>
  168. <sql id="dynamicWhereConditionsVo">
  169. where m.is_del = 0
  170. <if test=" null != id ">
  171. and m.`id` = #{id}
  172. </if>
  173. <if test=" null != tenantId ">
  174. and m.`tenant_id` = #{tenantId}
  175. </if>
  176. <if test=" null != imgUrl ">
  177. and m.`img_url` like concat('%', #{imgUrl},'%')
  178. </if>
  179. <if test=" null != name and ''!=name ">
  180. and m.`name` like concat('%', #{name},'%')
  181. </if>
  182. <if test=" null != linkPhone and ''!=linkPhone ">
  183. and m.`link_phone` like concat('%', #{linkPhone},'%')
  184. </if>
  185. <if test=" null != createDate ">
  186. and m.`create_date` = #{createDate}
  187. </if>
  188. <if test=" null != updateDate ">
  189. and m.`update_date` = #{updateDate}
  190. </if>
  191. <if test=" null != carVendorType ">
  192. and m.`car_vendor_type` = #{carVendorType}
  193. </if>
  194. <if test=" null != businessId ">
  195. and m.`business_id` = #{businessId}
  196. </if>
  197. <if test=" null != subBusinessId ">
  198. and m.`sub_business_id` = #{subBusinessId}
  199. </if>
  200. <if test=" null != carParams ">
  201. and m.`car_params` like concat('%', #{carParams},'%')
  202. </if>
  203. <if test=" null != status ">
  204. and m.`status` = #{status}
  205. </if>
  206. <if test=" null != linkPerson ">
  207. and m.`link_person` = #{linkPerson}
  208. </if>
  209. <if test=" null != type ">
  210. and m.`type` = #{type}
  211. </if>
  212. <if test=" null != isPublic ">
  213. and m.`is_public` = #{isPublic}
  214. </if>
  215. <if test=" null != email ">
  216. and m.`email` = #{email}
  217. </if>
  218. <if test=" null != isAdmin ">
  219. and m.`is_admin` = #{isAdmin}
  220. </if>
  221. <if test=" null != isDel ">
  222. and m.`is_del` = #{isDel}
  223. </if>
  224. <if test=" null != brand ">
  225. and m.`brand` = #{brand}
  226. </if>
  227. <if test=" null != rentShopType ">
  228. and m.id not in(
  229. select merchant_id from wx_rent_contract where tenant_id=#{tenantId} and rent_shop_type=1 and merchant_id is
  230. not null and status in(1,2,3,4)
  231. )
  232. </if>
  233. <if test=" null != ids ">
  234. and m.id in
  235. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  236. #{idItem}
  237. </foreach>
  238. </if>
  239. <include refid="dataRule"/>
  240. <if test=" null != sortColumns">order by ${sortColumns}</if>
  241. </sql>
  242. <sql id="allMerchantVoColumns">
  243. distinct m.id,m.img_url,m.name,m.link_phone,m.status,m.business_id,
  244. m.is_public,m.email,m.title,m.cover_picture,m.sub_business_id,
  245. m.shop_type,m.introduction,m.action_desc,bu.title as business_name,m.link_line_phone
  246. </sql>
  247. <select id="getMerchantByCode" parameterType="java.util.Map" resultMap="MerchantVoResultMap">
  248. select
  249. <include refid="allMerchantVoColumns"/>
  250. FROM wx_merchant m
  251. left join wx_business bu on bu.id = m.business_id
  252. <where>
  253. <if test=" null != tenantId ">
  254. and m.`tenant_id` = #{tenantId}
  255. </if>
  256. <if test=" null != status ">
  257. and m.`status` = #{status}
  258. </if>
  259. <if test=" null != merchantCode ">
  260. and md5(m.`id`) = #{merchantCode}
  261. </if>
  262. </where>
  263. </select>
  264. <resultMap id="MerchantVoResultMap" type="com.iformall.domain.vo.WxMerchantVo">
  265. <id column="id" jdbcType="BIGINT" property="id"/>
  266. <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl"/>
  267. <result column="name" jdbcType="VARCHAR" property="merchantName"/>
  268. <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/>
  269. <result column="status" jdbcType="VARCHAR" property="merchantStatus"/>
  270. <result column="business_id" jdbcType="INTEGER" property="businessId"/>
  271. <result column="sub_business_id" jdbcType="INTEGER" property="subBusinessId"/>
  272. <result column="is_public" jdbcType="INTEGER" property="isPublic"/>
  273. <result column="email" jdbcType="VARCHAR" property="email"/>
  274. <result column="title" jdbcType="VARCHAR" property="title"/>
  275. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  276. <result column="shop_type" jdbcType="VARCHAR" property="shopType"/>
  277. <result column="brand_name" jdbcType="VARCHAR" property="brandName"/>
  278. <result column="brand_img" jdbcType="VARCHAR" property="brandImg"/>
  279. <result column="summary" jdbcType="VARCHAR" property="summary"/>
  280. <result column="business_name" jdbcType="VARCHAR" property="businessName"/>
  281. <result column="introduction" jdbcType="VARCHAR" property="introduction"/>
  282. <result column="action_desc" jdbcType="VARCHAR" property="actionDesc"/>
  283. <result column="link_line_phone" property="linkLinePhone"/>
  284. <collection column="{merchantId=id}" property="shopVoList"
  285. ofType="com.iformall.domain.vo.WxShopVo"
  286. javaType="java.util.List"
  287. select="com.iformall.mapper.WxShopMapper.findShopVoList">
  288. </collection>
  289. </resultMap>
  290. <select id="findListCVo" parameterType="com.iformall.domain.dto.WxMerchantDto" resultMap="MerchantVoResultMap">
  291. select
  292. <include refid="allMerchantVoColumns"/>
  293. FROM wx_merchant m
  294. <if test=" null != building or null != floor ">
  295. join wx_merchant_shop ms on ms.merchant_id=m.id
  296. join wx_shop s on ms.shop_id=s.id
  297. <if test=" null != building">
  298. and s.building = #{building}
  299. </if>
  300. <if test=" null != floor ">
  301. and s.floor = #{floor}
  302. </if>
  303. </if>
  304. left join wx_business bu on bu.id = m.business_id
  305. where 1=1 and m.is_del=0
  306. <if test=" null != merchantName and ''!=merchantName ">
  307. and m.`name` like concat('%', #{merchantName},'%')
  308. </if>
  309. <if test=" null != merchantLinkPhone and ''!=merchantLinkPhone ">
  310. and m.`link_phone` like concat('%', #{merchantLinkPhone},'%')
  311. </if>
  312. <if test=" null != businessId ">
  313. and m.`business_id` = #{businessId}
  314. </if>
  315. <if test=" null != subBusinessId ">
  316. and m.`sub_business_id` = #{subBusinessId}
  317. </if>
  318. <if test=" null != merchantStatus ">
  319. and m.`status` = #{merchantStatus}
  320. </if>
  321. <if test=" null != isPublic">
  322. and m.`is_public` = #{isPublic}
  323. </if>
  324. <if test=" null != id">
  325. and m.`id` = #{id}
  326. </if>
  327. order by m.top_time desc
  328. </select>
  329. <select id="queryMerchantByMerchantIdOfSharingReceiver" resultType="com.iformall.domain.po.WxMerchant"
  330. parameterType="com.iformall.domain.po.WxMerchant">
  331. select m.name,psr.id from wx_merchant m
  332. left join (select * from wx_profit_sharing_receiver where status=0) psr on m.id=psr.merchant_id
  333. where m.id=#{id}
  334. </select>
  335. <select id="findQrcodeEmptyList" resultMap="BaseResultMap">
  336. select * from wx_merchant where qr_code is null;
  337. </select>
  338. <select id="findBusByFloorId" resultType="hashmap" parameterType="hashmap">
  339. select count(distinct m.id) count,b.id bid,b.`title` btitle from wx_merchant m
  340. left join wx_merchant_shop ms on(m.id = ms.merchant_id)
  341. left join wx_shop s on(ms.shop_id = s.id)
  342. left join wx_mall_floor f on(s.floor = f.id)
  343. left join wx_mall_building mb on(f.building_id = mb.id)
  344. left join wx_business b on(m.business_id = b.id)
  345. where 1=1
  346. <if test=" null != id">
  347. and f.id = #{id}
  348. </if>
  349. <if test=" null != buildingId">
  350. and mb.id = #{buildingId}
  351. </if>
  352. and m.tenant_id = #{tenantId}
  353. and s.is_del = 0
  354. and ms.is_del = 0
  355. and m.status = 1
  356. and m.is_del = 0
  357. group by m.business_id
  358. </select>
  359. <select id="hasMerchant" parameterType="com.iformall.domain.po.WxMerchant" resultType="int">
  360. select count(*) from wx_merchant where `name`=#{name} and status=#{status}
  361. <if test=" null != id">
  362. and `id` != #{id}
  363. </if>
  364. </select>
  365. <update id="updateCreditLocked" parameterType="com.iformall.domain.po.WxMerchant">
  366. update wx_merchant set credit_locked = #{creditLocked} where tenant_id = #{tenantId}
  367. </update>
  368. <select id="userTradeList" parameterType="com.iformall.domain.po.WxMerchant" resultType="com.iformall.domain.vo.WxMerchantTradeVo">
  369. select m.id,m.`img_url` cover,m.`name` merchantName,m.`link_person` linkName,
  370. (select count(*) from wx_coupon_order o
  371. left join wx_coupon co on(o.`coupon_id`=co.id)
  372. left join wx_coupon_merchant cm on(cm.product_id=co.id)
  373. inner join wx_c_user_basic_info c on(o.c_user_id=c.id)
  374. inner join wx_merchant_b_user mb on(mb.id=c.id)
  375. where cm.`merchant_id`=m.id and o.coupon_order_status=1 and mb.merchant_id=m.id
  376. <if test="starttime != null">
  377. and o.create_date &gt;= #{starttime}
  378. </if>
  379. <if test="endtime != null">
  380. and o.create_date &lt;= #{endtime}
  381. </if>
  382. ) consumeCount,
  383. (select count(distinct c.id) from wx_coupon_order o
  384. left join wx_coupon co on(o.`coupon_id`=co.id)
  385. left join wx_coupon_merchant cm on(cm.product_id=co.id)
  386. inner join wx_c_user_basic_info c on(o.c_user_id=c.id)
  387. inner join wx_merchant_b_user mb on(mb.id=c.id)
  388. where cm.`merchant_id`=m.id and o.coupon_order_status=1 and mb.merchant_id=m.id
  389. <if test="starttime != null">
  390. and o.create_date &gt;= #{starttime}
  391. </if>
  392. <if test="endtime != null">
  393. and o.create_date &lt;= #{endtime}
  394. </if>
  395. ) consumeCountP,
  396. IFNULL((select sum(co.price) from wx_coupon_order o
  397. left join wx_coupon co on(o.`coupon_id`=co.id)
  398. left join wx_coupon_merchant cm on(cm.product_id=co.id)
  399. inner join wx_c_user_basic_info c on(o.c_user_id=c.id)
  400. inner join wx_merchant_b_user mb on(mb.id=c.id)
  401. where cm.`merchant_id`=m.id and o.coupon_order_status=1 and mb.merchant_id=m.id
  402. <if test="starttime != null">
  403. and o.create_date &gt;= #{starttime}
  404. </if>
  405. <if test="endtime != null">
  406. and o.create_date &lt;= #{endtime}
  407. </if>
  408. ),0) tradeAmt
  409. from wx_merchant m where 1=1
  410. <if test=" null != name and ''!=name ">
  411. and `name` like concat('%', #{name},'%')
  412. </if>
  413. <if test=" null != linkPhone and ''!=linkPhone ">
  414. and `link_phone` like concat('%', #{linkPhone},'%')
  415. </if>
  416. <if test=" null != linkPerson and ''!=linkPerson ">
  417. and `link_person` like concat('%', #{linkPerson},'%')
  418. </if>
  419. </select>
  420. <select id="userTradeDetailList" parameterType="com.iformall.domain.po.WxMerchant" resultType="com.iformall.domain.vo.WxMerchantTradeDetailVo">
  421. select c.`nick_name` 'userName',c.`phone`,co.title couponName,co.`sale_price` couponSale ,co.price couponPrice, co.price tradeAmt,o.create_date tradeDate
  422. from wx_coupon_order o
  423. left join wx_coupon co on(o.`coupon_id`=co.id)
  424. left join wx_coupon_merchant cm on(cm.product_id=co.id)
  425. inner join wx_c_user_basic_info c on(o.c_user_id=c.id)
  426. where o.coupon_order_status=1 and o.tenant_id=#{tenantId}
  427. <if test=" null != id ">
  428. and cm.`merchant_id` = #{id}
  429. </if>
  430. <if test=" null != userName ">
  431. and c.`nick_name` like concat('%', #{userName},'%')
  432. </if>
  433. <if test=" null != phone ">
  434. and c.`phone` like concat('%', #{phone},'%')
  435. </if>
  436. <if test=" null != couponName ">
  437. and co.`title` like concat('%', #{couponName},'%')
  438. </if>
  439. <if test="starttime != null">
  440. and o.create_date &gt;= #{starttime}
  441. </if>
  442. <if test="endtime != null">
  443. and o.create_date &lt;= #{endtime}
  444. </if>
  445. order by o.create_date desc
  446. </select>
  447. </mapper>