Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

782 wiersze
32 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="encode" jdbcType="VARCHAR" property="encode"/>
  11. <result column="link_phone" jdbcType="VARCHAR" property="linkPhone"/>
  12. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  13. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  14. <result column="car_vendor_type" jdbcType="INTEGER" property="carVendorType"/>
  15. <result column="car_params" jdbcType="VARCHAR" property="carParams"/>
  16. <result column="status" jdbcType="INTEGER" property="status"/>
  17. <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/>
  18. <result column="business_id" jdbcType="INTEGER" property="businessId"/>
  19. <result column="business_types" jdbcType="VARCHAR" property="businessTypes"/>
  20. <result column="sub_business_id" jdbcType="INTEGER" property="subBusinessId"/>
  21. <result column="shop_type" jdbcType="INTEGER" property="shopType"/>
  22. <result column="brand" jdbcType="VARCHAR" property="brand"/>
  23. <result column="type" jdbcType="SMALLINT" property="type"/>
  24. <result column="is_public" jdbcType="SMALLINT" property="isPublic"/>
  25. <result column="email" jdbcType="VARCHAR" property="email"/>
  26. <result column="title" jdbcType="VARCHAR" property="title"/>
  27. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  28. <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/>
  29. <result column="bill_setting" jdbcType="INTEGER" property="billSetting"/>
  30. <result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
  31. <result column="introduction" jdbcType="VARCHAR" property="introduction"/>
  32. <result column="action_desc" jdbcType="VARCHAR" property="actionDesc"/>
  33. <result column="mark" jdbcType="INTEGER" property="mark"/>
  34. <result column="mark_time" jdbcType="TIMESTAMP" property="markTime"/>
  35. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  36. <result column="talk_user_main" jdbcType="VARCHAR" property="talkUserMain"/>
  37. <result column="talk_user_aux" jdbcType="VARCHAR" property="talkUserAux"/>
  38. <result column="link_line_phone" property="linkLinePhone"/>
  39. <result column="rental_start_date" property="rentalStartDate"/>
  40. <result column="rental_end_date" property="rentalEndDate"/>
  41. <result column="credit_locked" property="creditLocked"/>
  42. <result column="entry_amount" jdbcType="INTEGER" property="entryAmount"/>
  43. <result column="cash_out_number" jdbcType="INTEGER" property="cashOutNumber"/>
  44. <result column="cash_out_count" jdbcType="INTEGER" property="cashOutCount"/>
  45. <result column="cash_out_last_time" jdbcType="TIMESTAMP" property="cashOutLastTime"/>
  46. </resultMap>
  47. <sql id="allColumns">
  48. m.`id`,m.`tenant_id`,m.`parent_tenant_id`,m.`img_url`,m.`name`,m.`encode`,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.`business_types`,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.`mark`,m.mark_time,m.`is_del`,m.`talk_user_main`,m.`talk_user_aux`,m.link_line_phone,m.credit_locked,m.credit_locked,m.entry_amount,m.cash_out_count,m.cash_out_last_time
  51. </sql>
  52. <sql id="allColumnsVo">
  53. m.`id`,m.`tenant_id`,m.`parent_tenant_id`,m.`img_url`,m.`name`,m.`encode`,m.`link_phone`,m.`create_date`,m.`update_date`,m.`car_vendor_type`,m.`car_params`,m.`status`,m.`link_person`,
  54. m.`business_id`,m.`business_types`,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`,
  55. m.`introduction`,m.`action_desc`,m.`mark`,m.mark_time,m.`is_del`,m.`talk_user_main`,m.`talk_user_aux`,m.link_line_phone,r.rental_start_date,r.rental_end_date,m.entry_amount,m.cash_out_number,m.cash_out_count,m.cash_out_last_time
  56. </sql>
  57. <sql id="dynamicWhereConditions">
  58. where m.is_del = 0
  59. <if test=" null != id ">
  60. and m.`id` = #{id}
  61. </if>
  62. <if test=" null != tenantId and '' != tenantId">
  63. and m.`tenant_id` = #{tenantId}
  64. </if>
  65. <if test=" null != parentTenantId and '' != parentTenantId">
  66. and m.`parent_tenant_id` = #{parentTenantId}
  67. </if>
  68. <if test=" null != imgUrl ">
  69. and m.`img_url` like concat('%', #{imgUrl},'%')
  70. </if>
  71. <if test=" null != encode and ''!=encode ">
  72. and m.`encode` like concat('%', #{encode},'%')
  73. </if>
  74. <if test=" null != name and ''!=name ">
  75. and m.`name` like concat('%', #{name},'%')
  76. </if>
  77. <if test=" null != linkPhone and ''!=linkPhone ">
  78. and m.`link_phone` like concat('%', #{linkPhone},'%')
  79. </if>
  80. <if test=" null != linkPerson and ''!=linkPerson ">
  81. and m.`link_person` like concat('%', #{linkPerson},'%')
  82. </if>
  83. <if test="starttime != null">
  84. and m.create_date &gt;= #{starttime}
  85. </if>
  86. <if test="endtime != null">
  87. and m.create_date &lt;= #{endtime}
  88. </if>
  89. <if test=" null != carVendorType ">
  90. and m.`car_vendor_type` = #{carVendorType}
  91. </if>
  92. <if test=" null != businessId ">
  93. and m.`business_id` = #{businessId}
  94. </if>
  95. <if test=" null != businessTypes ">
  96. and JSON_CONTAINS(m.business_types,JSON_OBJECT('id', #{businessTypes}))
  97. </if>
  98. <if test=" null != subBusinessId ">
  99. and m.`sub_business_id` = #{subBusinessId}
  100. </if>
  101. <if test=" null != carParams ">
  102. and m.`car_params` like concat('%', #{carParams},'%')
  103. </if>
  104. <if test=" null != status ">
  105. and m.`status` = #{status}
  106. </if>
  107. <if test=" null != type ">
  108. and m.`type` = #{type}
  109. </if>
  110. <if test=" null != isPublic ">
  111. and m.`is_public` = #{isPublic}
  112. </if>
  113. <if test=" null != email ">
  114. and m.`email` = #{email}
  115. </if>
  116. <if test=" null != isAdmin ">
  117. and m.`is_admin` = #{isAdmin}
  118. </if>
  119. <if test=" null != mark ">
  120. <if test="mark == 0" >
  121. and (m.`mark` is null or m.`mark` &lt;&gt; 1)
  122. </if>
  123. <if test="mark == 1" >
  124. and m.`mark` = 1
  125. </if>
  126. </if>
  127. <if test=" null != isDel ">
  128. and m.`is_del` = #{isDel}
  129. </if>
  130. <if test=" null != brand ">
  131. and m.`brand` = #{brand}
  132. </if>
  133. <if test=" null != creditLocked ">
  134. and m.`credit_locked` = #{creditLocked}
  135. </if>
  136. <if test=" null != rentShopType ">
  137. and m.id not in(
  138. select merchant_id from wx_rent_contract where rent_shop_type=1
  139. <if test=" null != tenantId and '' != tenantId">
  140. and `tenant_id` = #{tenantId}
  141. </if>
  142. <if test=" null != parentTenantId and '' != parentTenantId">
  143. and `parent_tenant_id` = #{parentTenantId}
  144. </if>
  145. and merchant_id is not null and status in(1,2,3,4)
  146. )
  147. </if>
  148. <if test=" null != ids ">
  149. and m.id in
  150. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  151. #{idItem}
  152. </foreach>
  153. </if>
  154. <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)">
  155. and m.id in(
  156. select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
  157. inner join wx_merchant m on ms.merchant_id = m.id
  158. inner join wx_shop s on s.id=ms.shop_id
  159. where s.is_del=0
  160. <if test=" null != tenantId and '' != tenantId">
  161. and m.`tenant_id` = #{tenantId}
  162. </if>
  163. <if test=" null != parentTenantId and '' != parentTenantId">
  164. and m.`parent_tenant_id` = #{parentTenantId}
  165. </if>
  166. <if test=" null != businessForRule and '' != businessForRule ">
  167. and m.business_id in (${businessForRule})
  168. </if>
  169. <if test=" null != floorForRule and '' != floorForRule ">
  170. and s.`floor` in (${floorForRule})
  171. </if>
  172. )
  173. </if>
  174. <if test=" null != sortColumns">order by ${sortColumns}</if>
  175. </sql>
  176. <select id="findIdNameList" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  177. select id,name
  178. from wx_merchant m
  179. <include refid="dynamicWhereConditions"/>
  180. </select>
  181. <select id="findList" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  182. select
  183. <include refid="allColumns"/>
  184. from wx_merchant m
  185. <include refid="dynamicWhereConditions"/>
  186. </select>
  187. <select id="findFollowList" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  188. select
  189. <include refid="allColumns"/>
  190. form tt_user_follow uf
  191. left join wx_merchant m on uf.merchern_id = m.id
  192. where uf.is_del = 0 and uf.user_id = ${cUserId}
  193. and m.is_del = 0
  194. <if test=" null != status ">
  195. and m.`status` = #{status}
  196. </if>
  197. <if test=" null != isPublic ">
  198. and m.`is_public` = #{isPublic}
  199. </if>
  200. <if test=" null != name and ''!=name ">
  201. and m.`name` like concat('%', #{name},'%')
  202. </if>
  203. <if test=" null != businessTypes ">
  204. and JSON_CONTAINS(m.business_types,JSON_OBJECT('id', #{businessTypes}))
  205. </if>
  206. order by uf.create_date desc
  207. </select>
  208. <select id="findListVo" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  209. select
  210. <include refid="allColumnsVo"/>
  211. from wx_merchant m left join (select merchant_id,rental_start_date,rental_end_date from wx_rent_contract
  212. where 1=1
  213. <if test=" null != tenantId and '' != tenantId">
  214. and `tenant_id` = #{tenantId}
  215. </if>
  216. <if test=" null != parentTenantId and '' != parentTenantId">
  217. and `parent_tenant_id` = #{parentTenantId}
  218. </if>
  219. and status in(2,3,4)) r
  220. on m.id=r.merchant_id
  221. <include refid="dynamicWhereConditionsVo"/>
  222. <if test=" null != sortColumns">order by ${sortColumns}</if>
  223. </select>
  224. <select id="findListVo2" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  225. select distinct m.* from wx_merchant m
  226. left join wx_merchant_b_user wmbu on wmbu.merchant_id = m.id
  227. <include refid="dynamicWhereConditionsVo"/>
  228. <if test=" null != phone and ''!=phone ">
  229. and wmbu.`phone` like concat('%', #{phone},'%')
  230. and wmbu.`status` = 0
  231. </if>
  232. <if test=" null != sortColumns">order by ${sortColumns}</if>
  233. </select>
  234. <select id="getMerchantByEncode" parameterType="String" resultMap="BaseResultMap">
  235. select
  236. <include refid="allColumns"/>
  237. from wx_merchant m where m.encode = #{encode}
  238. </select>
  239. <sql id="dataRule">
  240. <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)">
  241. and m.id in(
  242. select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
  243. inner join wx_merchant m on ms.merchant_id = m.id
  244. inner join wx_shop s on s.id=ms.shop_id
  245. where s.is_del=0
  246. <if test=" null != tenantId and '' != tenantId">
  247. and m.`tenant_id` = #{tenantId}
  248. </if>
  249. <if test=" null != parentTenantId and '' != parentTenantId">
  250. and m.`parent_tenant_id` = #{parentTenantId}
  251. </if>
  252. <if test=" null != businessForRule and '' != businessForRule ">
  253. and m.business_id in (${businessForRule})
  254. </if>
  255. <if test=" null != floorForRule and '' != floorForRule ">
  256. and s.`floor` in (${floorForRule})
  257. </if>
  258. )
  259. </if>
  260. </sql>
  261. <sql id="dynamicWhereConditionsVo">
  262. where m.is_del = 0
  263. <if test=" null != id ">
  264. and m.`id` = #{id}
  265. </if>
  266. <if test=" null != tenantId and '' != tenantId">
  267. and m.`tenant_id` = #{tenantId}
  268. </if>
  269. <if test=" null != parentTenantId and '' != parentTenantId">
  270. and m.`parent_tenant_id` = #{parentTenantId}
  271. </if>
  272. <if test=" null != imgUrl ">
  273. and m.`img_url` like concat('%', #{imgUrl},'%')
  274. </if>
  275. <if test=" null != name and '' != name ">
  276. and m.`name` like concat('%', #{name},'%')
  277. </if>
  278. <if test=" null != encode and '' != encode ">
  279. and m.`encode` like concat('%', #{encode},'%')
  280. </if>
  281. <if test=" null != linkPhone and '' != linkPhone ">
  282. and m.`link_phone` like concat('%', #{linkPhone},'%')
  283. </if>
  284. <if test=" null != createDate ">
  285. and m.`create_date` = #{createDate}
  286. </if>
  287. <if test=" null != updateDate ">
  288. and m.`update_date` = #{updateDate}
  289. </if>
  290. <if test=" null != carVendorType ">
  291. and m.`car_vendor_type` = #{carVendorType}
  292. </if>
  293. <if test=" null != businessId ">
  294. and m.`business_id` = #{businessId}
  295. </if>
  296. <if test=" null != subBusinessId ">
  297. and m.`sub_business_id` = #{subBusinessId}
  298. </if>
  299. <if test=" null != carParams ">
  300. and m.`car_params` like concat('%', #{carParams},'%')
  301. </if>
  302. <if test=" null != status ">
  303. and m.`status` = #{status}
  304. </if>
  305. <if test=" null != linkPerson ">
  306. and m.`link_person` = #{linkPerson}
  307. </if>
  308. <if test=" null != type ">
  309. and m.`type` = #{type}
  310. </if>
  311. <if test=" null != isPublic ">
  312. and m.`is_public` = #{isPublic}
  313. </if>
  314. <if test=" null != email ">
  315. and m.`email` = #{email}
  316. </if>
  317. <if test=" null != isAdmin ">
  318. and m.`is_admin` = #{isAdmin}
  319. </if>
  320. <if test=" null != mark ">
  321. <if test="mark == 0" >
  322. and (m.`mark` is null or m.`mark` &lt;&gt; 1)
  323. </if>
  324. <if test="mark == 1" >
  325. and m.`mark` = 1
  326. </if>
  327. </if>
  328. <if test=" null != isDel ">
  329. and m.`is_del` = #{isDel}
  330. </if>
  331. <if test=" null != brand ">
  332. and m.`brand` = #{brand}
  333. </if>
  334. <if test=" null != rentShopType ">
  335. and m.id not in(
  336. select merchant_id from wx_rent_contract where rent_shop_type=1
  337. <if test=" null != tenantId and '' != tenantId">
  338. and `tenant_id` = #{tenantId}
  339. </if>
  340. <if test=" null != parentTenantId and '' != parentTenantId">
  341. and `parent_tenant_id` = #{parentTenantId}
  342. </if>
  343. and merchant_id is not null and status in(1,2,3,4,8)
  344. )
  345. </if>
  346. <if test=" null != ids ">
  347. and m.id in
  348. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  349. #{idItem}
  350. </foreach>
  351. </if>
  352. <if test=" null != building or null != floor">
  353. and m.id in(
  354. select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
  355. inner join wx_merchant m on ms.merchant_id = m.id
  356. inner join wx_shop s on s.id=ms.shop_id
  357. where s.is_del=0
  358. <if test=" null != building ">
  359. and s.`building`= #{building}
  360. </if>
  361. <if test=" null != floor">
  362. and s.`floor` = #{floor}
  363. </if>
  364. )
  365. </if>
  366. <include refid="dataRule"/>
  367. </sql>
  368. <sql id="allMerchantVoColumns">
  369. distinct m.id,m.img_url,m.name,m.encode,m.link_phone,m.status,m.business_id,
  370. m.is_public,m.email,m.title,m.cover_picture,m.sub_business_id,
  371. m.shop_type,m.introduction,m.action_desc,bu.title as business_name,m.link_line_phone,m.top_time
  372. </sql>
  373. <select id="getMerchantByCode" parameterType="java.util.Map" resultMap="MerchantVoResultMap">
  374. select
  375. <include refid="allMerchantVoColumns"/>
  376. FROM wx_merchant m
  377. left join wx_business bu on bu.id = m.business_id
  378. <where>
  379. <if test=" null != tenantId and '' != tenantId">
  380. and m.`tenant_id` = #{tenantId}
  381. </if>
  382. <if test=" null != parentTenantId and '' != parentTenantId">
  383. and m.`parent_tenant_id` = #{parentTenantId}
  384. </if>
  385. <if test=" null != status ">
  386. and m.`status` = #{status}
  387. </if>
  388. <if test=" null != merchantCode ">
  389. and md5(m.`id`) = #{merchantCode}
  390. </if>
  391. </where>
  392. </select>
  393. <resultMap id="MerchantVoResultMap" type="com.iformall.domain.vo.WxMerchantVo">
  394. <id column="id" jdbcType="BIGINT" property="id"/>
  395. <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl"/>
  396. <result column="name" jdbcType="VARCHAR" property="merchantName"/>
  397. <result column="encode" jdbcType="VARCHAR" property="merchantEncode"/>
  398. <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/>
  399. <result column="status" jdbcType="VARCHAR" property="merchantStatus"/>
  400. <result column="business_id" jdbcType="INTEGER" property="businessId"/>
  401. <result column="sub_business_id" jdbcType="INTEGER" property="subBusinessId"/>
  402. <result column="is_public" jdbcType="INTEGER" property="isPublic"/>
  403. <result column="email" jdbcType="VARCHAR" property="email"/>
  404. <result column="title" jdbcType="VARCHAR" property="title"/>
  405. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  406. <result column="shop_type" jdbcType="VARCHAR" property="shopType"/>
  407. <result column="brand_name" jdbcType="VARCHAR" property="brandName"/>
  408. <result column="brand_img" jdbcType="VARCHAR" property="brandImg"/>
  409. <result column="summary" jdbcType="VARCHAR" property="summary"/>
  410. <result column="business_name" jdbcType="VARCHAR" property="businessName"/>
  411. <result column="introduction" jdbcType="VARCHAR" property="introduction"/>
  412. <result column="action_desc" jdbcType="VARCHAR" property="actionDesc"/>
  413. <result column="link_line_phone" property="linkLinePhone"/>
  414. <result column="top_time" property="topTime"/>
  415. <collection column="{merchantId=id}" property="shopVoList"
  416. ofType="com.iformall.domain.vo.WxShopVo"
  417. javaType="java.util.List"
  418. select="com.iformall.mapper.WxShopMapper.findShopVoList">
  419. </collection>
  420. </resultMap>
  421. <select id="findListCVo" parameterType="com.iformall.domain.dto.WxMerchantDto" resultMap="MerchantVoResultMap">
  422. select
  423. <include refid="allMerchantVoColumns"/>
  424. FROM wx_merchant m
  425. <if test=" null != building or null != floor ">
  426. join wx_merchant_shop ms on ms.merchant_id=m.id
  427. join wx_shop s on ms.shop_id=s.id
  428. <if test=" null != building">
  429. and s.building = #{building}
  430. </if>
  431. <if test=" null != floor ">
  432. and s.floor = #{floor}
  433. </if>
  434. </if>
  435. left join wx_business bu on bu.id = m.business_id
  436. where 1=1 and m.is_del=0
  437. <if test=" null != tenantId and '' != tenantId">
  438. and m.`tenant_id` = #{tenantId}
  439. </if>
  440. <if test=" null != parentTenantId and '' != parentTenantId">
  441. and m.`parent_tenant_id` = #{parentTenantId}
  442. </if>
  443. <if test=" null != merchantName and ''!=merchantName ">
  444. and m.`name` like concat('%', #{merchantName},'%')
  445. </if>
  446. <if test=" null != merchantLinkPhone and ''!=merchantLinkPhone ">
  447. and m.`link_phone` like concat('%', #{merchantLinkPhone},'%')
  448. </if>
  449. <if test=" null != businessId ">
  450. and m.`business_id` = #{businessId}
  451. </if>
  452. <if test=" null != subBusinessId ">
  453. and m.`sub_business_id` = #{subBusinessId}
  454. </if>
  455. <if test=" null != merchantStatus ">
  456. and m.`status` = #{merchantStatus}
  457. </if>
  458. <if test=" null != isPublic">
  459. and m.`is_public` = #{isPublic}
  460. </if>
  461. <if test=" null != id">
  462. and m.`id` = #{id}
  463. </if>
  464. order by m.top_time desc
  465. </select>
  466. <select id="queryMerchantByMerchantIdOfSharingReceiver" resultType="com.iformall.domain.po.WxMerchant"
  467. parameterType="com.iformall.domain.po.WxMerchant">
  468. select m.name,psr.id from wx_merchant m
  469. left join (select * from wx_profit_sharing_receiver where status=0) psr on m.id=psr.merchant_id
  470. where m.id=#{id}
  471. </select>
  472. <select id="findQrcodeEmptyList" resultMap="BaseResultMap">
  473. select * from wx_merchant where qr_code is null;
  474. </select>
  475. <select id="findBusByFloorId" resultType="hashmap" parameterType="hashmap">
  476. select count(distinct m.id) count,b.id bid,b.`title` btitle from wx_merchant m
  477. left join wx_merchant_shop ms on(m.id = ms.merchant_id)
  478. left join wx_shop s on(ms.shop_id = s.id)
  479. left join wx_mall_floor f on(s.floor = f.id)
  480. left join wx_mall_building mb on(f.building_id = mb.id)
  481. left join wx_business b on(m.business_id = b.id)
  482. where 1=1
  483. <if test=" null != id">
  484. and f.id = #{id}
  485. </if>
  486. <if test=" null != buildingId">
  487. and mb.id = #{buildingId}
  488. </if>
  489. <if test=" null != tenantId and '' != tenantId">
  490. and m.`tenant_id` = #{tenantId}
  491. </if>
  492. <if test=" null != parentTenantId and '' != parentTenantId">
  493. and m.`parent_tenant_id` = #{parentTenantId}
  494. </if>
  495. and s.is_del = 0
  496. and ms.is_del = 0
  497. and m.status = 1
  498. and m.is_del = 0
  499. group by m.business_id
  500. </select>
  501. <select id="hasMerchant" parameterType="com.iformall.domain.po.WxMerchant" resultType="int">
  502. select count(*) from wx_merchant where `name`=#{name} and status=#{status}
  503. <if test=" null != id">
  504. and `id` != #{id}
  505. </if>
  506. </select>
  507. <select id="hasMerchantEncode" parameterType="com.iformall.domain.po.WxMerchant" resultType="int">
  508. select count(*) from wx_merchant where `encode`=#{encode}
  509. <if test=" null != id">
  510. and `id` != #{id}
  511. </if>
  512. </select>
  513. <update id="updateCreditLocked" parameterType="com.iformall.domain.po.WxMerchant">
  514. update wx_merchant set credit_locked = #{creditLocked} where tenant_id = #{tenantId}
  515. </update>
  516. <select id="userTradeList" parameterType="com.iformall.domain.po.WxMerchant" resultType="com.iformall.domain.vo.WxMerchantTradeVo">
  517. SELECT m.id, m.`img_url` cover, m.`name` merchantName,m.`encode` merchantEncode, m.`link_person` linkName,
  518. ifnull(consume.consumeCount,0) consumeCount,ifnull(consume.consumeCountP,0) as consumeCountP,
  519. ifnull(consume.tradeAmt,0) tradeAmt
  520. FROM wx_merchant m
  521. left join (select count(co.c_user_id) AS consumeCountP,
  522. count(DISTINCT co.c_user_id) AS consumeCount,sum(co.coupon_price) AS tradeAmt, m.id as merchant_id from
  523. wx_coupon_order co
  524. left join (select m.id,mbu.id as b_user_id from wx_merchant m
  525. left join wx_merchant_b_user mbu on m.id=mbu.merchant_id where mbu.status=0) m
  526. on co.b_user_id=m.b_user_id
  527. WHERE co.coupon_order_status = 1
  528. <if test=" null != tenantId and '' != tenantId">
  529. and co.`tenant_id` = #{tenantId}
  530. </if>
  531. <if test=" null != parentTenantId and '' != parentTenantId">
  532. and co.`parent_tenant_id` = #{parentTenantId}
  533. </if>
  534. <if test="starttime != null">
  535. and co.create_date &gt;= #{starttime}
  536. </if>
  537. <if test="endtime != null">
  538. and co.create_date &lt;= #{endtime}
  539. </if>
  540. group by m.id
  541. ) consume on consume.merchant_id=m.id
  542. where m.status=1
  543. <if test=" null != name and ''!=name ">
  544. and `name` like concat('%', #{name},'%')
  545. </if>
  546. <if test=" null != linkPhone and ''!=linkPhone ">
  547. and `link_phone` like concat('%', #{linkPhone},'%')
  548. </if>
  549. <if test=" null != linkPerson and ''!=linkPerson ">
  550. and `link_person` like concat('%', #{linkPerson},'%')
  551. </if>
  552. <if test=" null != sortColumns">order by ${sortColumns}</if>
  553. </select>
  554. <select id="userTradeDetailList" parameterType="com.iformall.domain.po.WxMerchant" resultType="com.iformall.domain.vo.WxMerchantTradeDetailVo">
  555. select cb.`name` 'userName',cb.`phone`,co.title couponName,co.`sale_price` couponSale ,co.price couponPrice,
  556. co.price tradeAmt,o.create_date tradeDate
  557. from wx_coupon_order o
  558. left join wx_coupon co on(o.`coupon_id`=co.id)
  559. left join wx_c_user_basic_info cb on o.c_user_id=cb.id
  560. where o.coupon_order_status=1
  561. <if test=" null != tenantId and '' != tenantId">
  562. and o.`tenant_id` = #{tenantId}
  563. </if>
  564. <if test=" null != parentTenantId and '' != parentTenantId">
  565. and o.`parent_tenant_id` = #{parentTenantId}
  566. </if>
  567. <if test=" null != id ">
  568. and o.b_user_id in(
  569. select id from wx_merchant_b_user where status=0 and merchant_id=#{id}
  570. )
  571. </if>
  572. <if test=" null != userName and '' != userName ">
  573. and cb.`name` like concat('%', #{userName},'%')
  574. </if>
  575. <if test=" null != phone and '' != phone">
  576. and cb.`phone` like concat('%', #{phone},'%')
  577. </if>
  578. <if test=" null != couponName and '' != couponName">
  579. and co.`title` like concat('%', #{couponName},'%')
  580. </if>
  581. <if test="starttime != null">
  582. and o.create_date &gt;= #{starttime}
  583. </if>
  584. <if test="endtime != null">
  585. and o.create_date &lt;= #{endtime}
  586. </if>
  587. <if test=" null != sortColumns">order by ${sortColumns}</if>
  588. <if test=" null == sortColumns">order by o.create_date desc</if>
  589. </select>
  590. <select id="findByTrade" parameterType="java.util.Map" resultMap="BaseResultMap">
  591. select * from wx_merchant where id in(
  592. select merchant_id from wx_coupon_merchant where product_id=#{id}
  593. )limit 1
  594. </select>
  595. <select id="getMerchantList" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  596. select * from wx_merchant where 1=1 and is_del=0 and status=1
  597. <if test=" null != tenantId and '' != tenantId">
  598. and `tenant_id` = #{tenantId}
  599. </if>
  600. <if test=" null != parentTenantId and '' != parentTenantId">
  601. and `parent_tenant_id` = #{parentTenantId}
  602. </if>
  603. order by create_date desc
  604. </select>
  605. <update id="increaseCash" parameterType="com.iformall.domain.po.WxMerchant">
  606. update wx_merchant set cash_out_number = cash_out_number+#{cashOutNumber} where id = #{id}
  607. </update>
  608. <update id="reduceCash" parameterType="com.iformall.domain.po.WxMerchant">
  609. 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}
  610. </update>
  611. <update id="increaseCashCount" parameterType="com.iformall.domain.po.WxMerchant">
  612. update wx_merchant set cash_out_count = cash_out_count+1 where id = #{id}
  613. </update>
  614. <update id="reSetCashCount" parameterType="com.iformall.domain.po.WxMerchant">
  615. update wx_merchant set cash_out_count = 0 where id = #{id}
  616. </update>
  617. <update id="recordedAmount" parameterType="com.iformall.domain.po.WxMerchant">
  618. update wx_merchant set
  619. entry_amount = ifnull(entry_amount,0)+#{entryAmount}
  620. /*,cash_out_number = ifnull(cash_out_number,0)+#{cashOutNumber}*/
  621. where id = #{id}
  622. </update>
  623. <select id="findTtList" parameterType="com.iformall.domain.vo.TtMerchantVo" resultType="com.iformall.domain.vo.TtMerchantVo">
  624. select
  625. m.`id`,m.`tenant_id` tenantId,m.`parent_tenant_id` parentTenantId,m.`img_url` imgUrl,m.`name` name,
  626. m.`encode` encode,m.`link_phone` linkPhone,m.`create_date` createDate,m.`update_date` updateDate,m.`status` status,m.`link_person` linkPerson,
  627. m.`business_types businessTypes`,m.`is_public` isPublic,m.email email,m.`title` title,m.`cover_picture` coverPicture,m.`is_admin` isAdmin,m.`qr_code` qrCode,
  628. m.`introduction` introduction,m.`mark` mark,m.mark_time markTime,m.link_line_phone linkLinePhone,m.credit_locked creditLocked,m.entry_amount entryAmount,m.cash_out_number cashOutNumber,
  629. mall.valid_start validStart,mall.valid_end validEnd
  630. from wx_merchant m
  631. LEFT JOIN wx_mall mall on m.tenant_id = mall.tenant_id
  632. where m.is_del = 0
  633. <if test=" null != id ">
  634. and m.`id` = #{id}
  635. </if>
  636. <if test=" null != tenantId and '' != tenantId">
  637. and m.`tenant_id` = #{tenantId}
  638. </if>
  639. <if test=" null != parentTenantId and '' != parentTenantId">
  640. and m.`parent_tenant_id` = #{parentTenantId}
  641. </if>
  642. <if test=" null != encode and ''!=encode ">
  643. and m.`encode` like concat('%', #{encode},'%')
  644. </if>
  645. <if test=" null != name and ''!=name ">
  646. and m.`name` like concat('%', #{name},'%')
  647. </if>
  648. <if test=" null != linkPhone and ''!=linkPhone ">
  649. and m.`link_phone` like concat('%', #{linkPhone},'%')
  650. </if>
  651. <if test=" null != linkPerson and ''!=linkPerson ">
  652. and m.`link_person` like concat('%', #{linkPerson},'%')
  653. </if>
  654. <if test="starttime != null">
  655. and m.create_date &gt;= #{starttime}
  656. </if>
  657. <if test="endtime != null">
  658. and m.create_date &lt;= #{endtime}
  659. </if>
  660. <if test=" null != businessTypes ">
  661. and JSON_CONTAINS(m.business_types,JSON_OBJECT('id', #{businessTypes}))
  662. </if>
  663. <if test=" null != status ">
  664. and m.`status` = #{status}
  665. </if>
  666. <if test=" null != isPublic ">
  667. and m.`is_public` = #{isPublic}
  668. </if>
  669. <if test=" null != isAdmin ">
  670. and m.`is_admin` = #{isAdmin}
  671. </if>
  672. <if test=" null != mark ">
  673. <if test="mark == 0" >
  674. and (m.`mark` is null or m.`mark` &lt;&gt; 1)
  675. </if>
  676. <if test="mark == 1" >
  677. and m.`mark` = 1
  678. </if>
  679. </if>
  680. <if test=" null != creditLocked ">
  681. and m.`credit_locked` = #{creditLocked}
  682. </if>
  683. order by m.create_date desc
  684. </select>
  685. </mapper>