You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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