Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

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