No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

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