Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

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