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

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