Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

588 строки
23 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
  177. where 1=1
  178. <if test=" null != tenantId and '' != tenantId">
  179. and `tenant_id` = #{tenantId}
  180. </if>
  181. <if test=" null != parentTenantId and '' != parentTenantId">
  182. and `parent_tenant_id` = #{parentTenantId}
  183. </if>
  184. <if test=" null != name and ''!=name ">
  185. and `name` like concat('%', #{name},'%')
  186. </if>
  187. <if test=" null != linkPhone and ''!=linkPhone ">
  188. and `link_phone` like concat('%', #{linkPhone},'%')
  189. </if>
  190. <if test=" null != businessId ">
  191. and `business_id` = #{businessId}
  192. </if>
  193. <if test=" null != status ">
  194. and `status` = #{status}
  195. </if>
  196. </select>
  197. <sql id="dataRule">
  198. <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)">
  199. and m.id in(
  200. select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
  201. inner join wx_merchant m on ms.merchant_id = m.id
  202. inner join wx_shop s on s.id=ms.shop_id
  203. where s.is_del=0
  204. <if test=" null != tenantId and '' != tenantId">
  205. and m.`tenant_id` = #{tenantId}
  206. </if>
  207. <if test=" null != parentTenantId and '' != parentTenantId">
  208. and m.`parent_tenant_id` = #{parentTenantId}
  209. </if>
  210. <if test=" null != businessForRule and '' != businessForRule ">
  211. and m.business_id in (${businessForRule})
  212. </if>
  213. <if test=" null != floorForRule and '' != floorForRule ">
  214. and s.`floor` in (${floorForRule})
  215. </if>
  216. )
  217. </if>
  218. </sql>
  219. <sql id="dynamicWhereConditionsVo">
  220. where m.is_del = 0
  221. <if test=" null != id ">
  222. and m.`id` = #{id}
  223. </if>
  224. <if test=" null != tenantId and '' != tenantId">
  225. and m.`tenant_id` = #{tenantId}
  226. </if>
  227. <if test=" null != parentTenantId and '' != parentTenantId">
  228. and m.`parent_tenant_id` = #{parentTenantId}
  229. </if>
  230. <if test=" null != imgUrl ">
  231. and m.`img_url` like concat('%', #{imgUrl},'%')
  232. </if>
  233. <if test=" null != name and ''!=name ">
  234. and m.`name` like concat('%', #{name},'%')
  235. </if>
  236. <if test=" null != linkPhone and ''!=linkPhone ">
  237. and m.`link_phone` like concat('%', #{linkPhone},'%')
  238. </if>
  239. <if test=" null != createDate ">
  240. and m.`create_date` = #{createDate}
  241. </if>
  242. <if test=" null != updateDate ">
  243. and m.`update_date` = #{updateDate}
  244. </if>
  245. <if test=" null != carVendorType ">
  246. and m.`car_vendor_type` = #{carVendorType}
  247. </if>
  248. <if test=" null != businessId ">
  249. and m.`business_id` = #{businessId}
  250. </if>
  251. <if test=" null != subBusinessId ">
  252. and m.`sub_business_id` = #{subBusinessId}
  253. </if>
  254. <if test=" null != carParams ">
  255. and m.`car_params` like concat('%', #{carParams},'%')
  256. </if>
  257. <if test=" null != status ">
  258. and m.`status` = #{status}
  259. </if>
  260. <if test=" null != linkPerson ">
  261. and m.`link_person` = #{linkPerson}
  262. </if>
  263. <if test=" null != type ">
  264. and m.`type` = #{type}
  265. </if>
  266. <if test=" null != isPublic ">
  267. and m.`is_public` = #{isPublic}
  268. </if>
  269. <if test=" null != email ">
  270. and m.`email` = #{email}
  271. </if>
  272. <if test=" null != isAdmin ">
  273. and m.`is_admin` = #{isAdmin}
  274. </if>
  275. <if test=" null != isDel ">
  276. and m.`is_del` = #{isDel}
  277. </if>
  278. <if test=" null != brand ">
  279. and m.`brand` = #{brand}
  280. </if>
  281. <if test=" null != rentShopType ">
  282. and m.id not in(
  283. select merchant_id from wx_rent_contract where rent_shop_type=1
  284. <if test=" null != tenantId and '' != tenantId">
  285. and `tenant_id` = #{tenantId}
  286. </if>
  287. <if test=" null != parentTenantId and '' != parentTenantId">
  288. and `parent_tenant_id` = #{parentTenantId}
  289. </if>
  290. and merchant_id is not null and status in(1,2,3,4,8)
  291. )
  292. </if>
  293. <if test=" null != ids ">
  294. and m.id in
  295. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  296. #{idItem}
  297. </foreach>
  298. </if>
  299. <include refid="dataRule"/>
  300. <if test=" null != sortColumns">order by ${sortColumns}</if>
  301. </sql>
  302. <sql id="allMerchantVoColumns">
  303. distinct m.id,m.img_url,m.name,m.link_phone,m.status,m.business_id,
  304. m.is_public,m.email,m.title,m.cover_picture,m.sub_business_id,
  305. m.shop_type,m.introduction,m.action_desc,bu.title as business_name,m.link_line_phone
  306. </sql>
  307. <select id="getMerchantByCode" parameterType="java.util.Map" resultMap="MerchantVoResultMap">
  308. select
  309. <include refid="allMerchantVoColumns"/>
  310. FROM wx_merchant m
  311. left join wx_business bu on bu.id = m.business_id
  312. <where>
  313. <if test=" null != tenantId and '' != tenantId">
  314. and m.`tenant_id` = #{tenantId}
  315. </if>
  316. <if test=" null != parentTenantId and '' != parentTenantId">
  317. and m.`parent_tenant_id` = #{parentTenantId}
  318. </if>
  319. <if test=" null != status ">
  320. and m.`status` = #{status}
  321. </if>
  322. <if test=" null != merchantCode ">
  323. and md5(m.`id`) = #{merchantCode}
  324. </if>
  325. </where>
  326. </select>
  327. <resultMap id="MerchantVoResultMap" type="com.iformall.domain.vo.WxMerchantVo">
  328. <id column="id" jdbcType="BIGINT" property="id"/>
  329. <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl"/>
  330. <result column="name" jdbcType="VARCHAR" property="merchantName"/>
  331. <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/>
  332. <result column="status" jdbcType="VARCHAR" property="merchantStatus"/>
  333. <result column="business_id" jdbcType="INTEGER" property="businessId"/>
  334. <result column="sub_business_id" jdbcType="INTEGER" property="subBusinessId"/>
  335. <result column="is_public" jdbcType="INTEGER" property="isPublic"/>
  336. <result column="email" jdbcType="VARCHAR" property="email"/>
  337. <result column="title" jdbcType="VARCHAR" property="title"/>
  338. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  339. <result column="shop_type" jdbcType="VARCHAR" property="shopType"/>
  340. <result column="brand_name" jdbcType="VARCHAR" property="brandName"/>
  341. <result column="brand_img" jdbcType="VARCHAR" property="brandImg"/>
  342. <result column="summary" jdbcType="VARCHAR" property="summary"/>
  343. <result column="business_name" jdbcType="VARCHAR" property="businessName"/>
  344. <result column="introduction" jdbcType="VARCHAR" property="introduction"/>
  345. <result column="action_desc" jdbcType="VARCHAR" property="actionDesc"/>
  346. <result column="link_line_phone" property="linkLinePhone"/>
  347. <collection column="{merchantId=id}" property="shopVoList"
  348. ofType="com.iformall.domain.vo.WxShopVo"
  349. javaType="java.util.List"
  350. select="com.iformall.mapper.WxShopMapper.findShopVoList">
  351. </collection>
  352. </resultMap>
  353. <select id="findListCVo" parameterType="com.iformall.domain.dto.WxMerchantDto" resultMap="MerchantVoResultMap">
  354. select
  355. <include refid="allMerchantVoColumns"/>
  356. FROM wx_merchant m
  357. <if test=" null != building or null != floor ">
  358. join wx_merchant_shop ms on ms.merchant_id=m.id
  359. join wx_shop s on ms.shop_id=s.id
  360. <if test=" null != building">
  361. and s.building = #{building}
  362. </if>
  363. <if test=" null != floor ">
  364. and s.floor = #{floor}
  365. </if>
  366. </if>
  367. left join wx_business bu on bu.id = m.business_id
  368. where 1=1 and m.is_del=0
  369. <if test=" null != tenantId">
  370. and m.`tenant_id` = #{tenantId}
  371. </if>
  372. <if test=" null != parentTenantId">
  373. and m.`parent_tenant_id` = #{parentTenantId}
  374. </if>
  375. <if test=" null != merchantName and ''!=merchantName ">
  376. and m.`name` like concat('%', #{merchantName},'%')
  377. </if>
  378. <if test=" null != merchantLinkPhone and ''!=merchantLinkPhone ">
  379. and m.`link_phone` like concat('%', #{merchantLinkPhone},'%')
  380. </if>
  381. <if test=" null != businessId ">
  382. and m.`business_id` = #{businessId}
  383. </if>
  384. <if test=" null != subBusinessId ">
  385. and m.`sub_business_id` = #{subBusinessId}
  386. </if>
  387. <if test=" null != merchantStatus ">
  388. and m.`status` = #{merchantStatus}
  389. </if>
  390. <if test=" null != isPublic">
  391. and m.`is_public` = #{isPublic}
  392. </if>
  393. <if test=" null != id">
  394. and m.`id` = #{id}
  395. </if>
  396. order by m.top_time desc
  397. </select>
  398. <select id="queryMerchantByMerchantIdOfSharingReceiver" resultType="com.iformall.domain.po.WxMerchant"
  399. parameterType="com.iformall.domain.po.WxMerchant">
  400. select m.name,psr.id from wx_merchant m
  401. left join (select * from wx_profit_sharing_receiver where status=0) psr on m.id=psr.merchant_id
  402. where m.id=#{id}
  403. </select>
  404. <select id="findQrcodeEmptyList" resultMap="BaseResultMap">
  405. select * from wx_merchant where qr_code is null;
  406. </select>
  407. <select id="findBusByFloorId" resultType="hashmap" parameterType="hashmap">
  408. select count(distinct m.id) count,b.id bid,b.`title` btitle from wx_merchant m
  409. left join wx_merchant_shop ms on(m.id = ms.merchant_id)
  410. left join wx_shop s on(ms.shop_id = s.id)
  411. left join wx_mall_floor f on(s.floor = f.id)
  412. left join wx_mall_building mb on(f.building_id = mb.id)
  413. left join wx_business b on(m.business_id = b.id)
  414. where 1=1
  415. <if test=" null != id">
  416. and f.id = #{id}
  417. </if>
  418. <if test=" null != buildingId">
  419. and mb.id = #{buildingId}
  420. </if>
  421. and m.tenant_id = #{tenantId}
  422. <if test=" null != parentTenantId">
  423. and m.parent_tenant_id = #{parentTenantId}
  424. </if>
  425. and s.is_del = 0
  426. and ms.is_del = 0
  427. and m.status = 1
  428. and m.is_del = 0
  429. group by m.business_id
  430. </select>
  431. <select id="hasMerchant" parameterType="com.iformall.domain.po.WxMerchant" resultType="int">
  432. select count(*) from wx_merchant where `name`=#{name} and status=#{status}
  433. <if test=" null != id">
  434. and `id` != #{id}
  435. </if>
  436. </select>
  437. <update id="updateCreditLocked" parameterType="com.iformall.domain.po.WxMerchant">
  438. update wx_merchant set credit_locked = #{creditLocked} where tenant_id = #{tenantId}
  439. </update>
  440. <select id="userTradeList" parameterType="com.iformall.domain.po.WxMerchant" resultType="com.iformall.domain.vo.WxMerchantTradeVo">
  441. SELECT m.id, m.`img_url` cover, m.`name` merchantName, m.`link_person` linkName,
  442. ifnull(consume.consumeCount,0) consumeCount,ifnull(consume.consumeCountP,0) as consumeCountP,
  443. ifnull(consume.tradeAmt,0) tradeAmt
  444. FROM wx_merchant m
  445. left join (select count(co.c_user_id) AS consumeCountP,
  446. count(DISTINCT co.c_user_id) AS consumeCount,sum(co.coupon_price) AS tradeAmt, m.id as merchant_id from
  447. wx_coupon_order co
  448. left join (select m.id,mbu.id as b_user_id from wx_merchant m
  449. left join wx_merchant_b_user mbu on m.id=mbu.merchant_id where mbu.status=0) m
  450. on co.b_user_id=m.b_user_id
  451. WHERE co.coupon_order_status = 1
  452. <if test="tenantId != null">
  453. and co.tenant_id = #{tenantId}
  454. </if>
  455. <if test="parentTenantId != null">
  456. and co.parent_tenant_id = #{parentTenantId}
  457. </if>
  458. <if test="starttime != null">
  459. and co.create_date &gt;= #{starttime}
  460. </if>
  461. <if test="endtime != null">
  462. and co.create_date &lt;= #{endtime}
  463. </if>
  464. group by m.id
  465. ) consume on consume.merchant_id=m.id
  466. where m.status=1
  467. <if test=" null != name and ''!=name ">
  468. and `name` like concat('%', #{name},'%')
  469. </if>
  470. <if test=" null != linkPhone and ''!=linkPhone ">
  471. and `link_phone` like concat('%', #{linkPhone},'%')
  472. </if>
  473. <if test=" null != linkPerson and ''!=linkPerson ">
  474. and `link_person` like concat('%', #{linkPerson},'%')
  475. </if>
  476. <if test=" null != sortColumns">order by ${sortColumns}</if>
  477. </select>
  478. <select id="userTradeDetailList" parameterType="com.iformall.domain.po.WxMerchant" resultType="com.iformall.domain.vo.WxMerchantTradeDetailVo">
  479. select cb.`name` 'userName',cb.`phone`,co.title couponName,co.`sale_price` couponSale ,co.price couponPrice,
  480. co.price tradeAmt,o.create_date tradeDate
  481. from wx_coupon_order o
  482. left join wx_coupon co on(o.`coupon_id`=co.id)
  483. left join wx_c_user_basic_info cb on o.c_user_id=cb.id
  484. where o.coupon_order_status=1
  485. <if test=" null != tenantId and '' != tenantId">
  486. and o.`tenant_id` = #{tenantId}
  487. </if>
  488. <if test=" null != parentTenantId and '' != parentTenantId">
  489. and o.`parent_tenant_id` = #{parentTenantId}
  490. </if>
  491. <if test=" null != id ">
  492. and o.b_user_id in(
  493. select id from wx_merchant_b_user where status=0 and merchant_id=#{id}
  494. )
  495. </if>
  496. <if test=" null != userName and '' != userName ">
  497. and cb.`name` like concat('%', #{userName},'%')
  498. </if>
  499. <if test=" null != phone and '' != phone">
  500. and cb.`phone` like concat('%', #{phone},'%')
  501. </if>
  502. <if test=" null != couponName and '' != couponName">
  503. and co.`title` like concat('%', #{couponName},'%')
  504. </if>
  505. <if test="starttime != null">
  506. and o.create_date &gt;= #{starttime}
  507. </if>
  508. <if test="endtime != null">
  509. and o.create_date &lt;= #{endtime}
  510. </if>
  511. <if test=" null != sortColumns">order by ${sortColumns}</if>
  512. <if test=" null == sortColumns">order by o.create_date desc</if>
  513. </select>
  514. <select id="findByTrade" parameterType="java.util.Map" resultMap="BaseResultMap">
  515. select * from wx_merchant where id in(
  516. select merchant_id from wx_coupon_merchant where product_id=#{id}
  517. )limit 1
  518. </select>
  519. </mapper>