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.
 
 
 
 
 

535 regels
22 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="is_public" jdbcType="SMALLINT" property="isPublic"/>
  24. <result column="is_private" jdbcType="SMALLINT" property="isPrivate"/>
  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="search_card_by_phone" jdbcType="INTEGER" property="searchCardByPhone"/>
  41. <result column="rental_start_date" property="rentalStartDate"/>
  42. <result column="rental_end_date" property="rentalEndDate"/>
  43. <result column="credit_locked" property="creditLocked"/>
  44. <result column="entry_amount" jdbcType="INTEGER" property="entryAmount"/>
  45. <result column="cash_out_number" jdbcType="INTEGER" property="cashOutNumber"/>
  46. <result column="cash_out_count" jdbcType="INTEGER" property="cashOutCount"/>
  47. <result column="cash_out_last_time" jdbcType="TIMESTAMP" property="cashOutLastTime"/>
  48. <result column="create_from" jdbcType="INTEGER" property="createFrom"/>
  49. <result column="create_from_id" jdbcType="VARCHAR" property="createFromId"/>
  50. <result column="create_shop_number" jdbcType="VARCHAR" property="createShopNumber"/>
  51. <result column="create_shop_type" jdbcType="INTEGER" property="createShopType"/>
  52. </resultMap>
  53. <sql id="allColumns">
  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.`is_public`,m.`is_private`,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,m.search_card_by_phone,m.credit_locked,m.credit_locked,m.entry_amount,m.cash_out_count,
  57. m.cash_out_last_time,m.create_from,m.create_from_id,m.create_shop_number,m.create_shop_type
  58. </sql>
  59. <sql id="dynamicWhereConditions">
  60. where m.is_del = 0
  61. <if test=" null != id ">
  62. and m.`id` = #{id}
  63. </if>
  64. <if test=" null != tenantId and '' != tenantId">
  65. and m.`tenant_id` = #{tenantId}
  66. </if>
  67. <if test=" null != parentTenantId and '' != parentTenantId">
  68. and m.`parent_tenant_id` = #{parentTenantId}
  69. </if>
  70. <if test=" null != imgUrl ">
  71. and m.`img_url` like concat('%', #{imgUrl},'%')
  72. </if>
  73. <if test=" null != encode and ''!=encode ">
  74. and m.`encode` like concat('%', #{encode},'%')
  75. </if>
  76. <if test=" null != name and ''!=name ">
  77. and m.`name` like concat('%', #{name},'%')
  78. </if>
  79. <if test=" null != linkPhone and ''!=linkPhone ">
  80. and m.`link_phone` like concat('%', #{linkPhone},'%')
  81. </if>
  82. <if test=" null != linkPerson and ''!=linkPerson ">
  83. and m.`link_person` like concat('%', #{linkPerson},'%')
  84. </if>
  85. <if test=" null != createDate ">
  86. and m.`create_date` = #{createDate}
  87. </if>
  88. <if test=" null != updateDate ">
  89. and m.`update_date` = #{updateDate}
  90. </if>
  91. <if test="starttime != null">
  92. and m.create_date &gt;= #{starttime}
  93. </if>
  94. <if test="endtime != null">
  95. and m.create_date &lt;= #{endtime}
  96. </if>
  97. <if test=" null != carVendorType ">
  98. and m.`car_vendor_type` = #{carVendorType}
  99. </if>
  100. <if test=" null != hasCarVendor ">
  101. and m.`car_vendor_type` is not null and m.`car_vendor_type` > 0
  102. </if>
  103. <if test=" null != noCarVendor ">
  104. and (m.`car_vendor_type` = 0 or m.`car_vendor_type` is null)
  105. </if>
  106. <if test=" null != businessId ">
  107. and m.`business_id` = #{businessId}
  108. </if>
  109. <if test=" null != businessForRule and '' != businessForRule ">
  110. and m.business_id in (${businessForRule}) and m.is_del=0
  111. </if>
  112. <if test=" null != businessTypes ">
  113. and JSON_CONTAINS(m.business_types,JSON_OBJECT('id', #{businessTypes}))
  114. </if>
  115. <if test=" null != subBusinessId ">
  116. and m.`sub_business_id` = #{subBusinessId}
  117. </if>
  118. <if test=" null != carParams ">
  119. and m.`car_params` like concat('%', #{carParams},'%')
  120. </if>
  121. <if test=" null != status ">
  122. and m.`status` = #{status}
  123. </if>
  124. <if test=" null != isPublic ">
  125. and m.`is_public` = #{isPublic}
  126. </if>
  127. <if test=" null != isPrivate ">
  128. and m.`is_private` = #{isPrivate}
  129. </if>
  130. <if test=" null != email ">
  131. and m.`email` = #{email}
  132. </if>
  133. <if test=" null != isAdmin ">
  134. and m.`is_admin` = #{isAdmin}
  135. </if>
  136. <if test=" null != mark ">
  137. <if test="mark == 0" >
  138. and (m.`mark` is null or m.`mark` &lt;&gt; 1)
  139. </if>
  140. <if test="mark == 1" >
  141. and m.`mark` = 1
  142. </if>
  143. </if>
  144. <if test=" null != isDel ">
  145. and m.`is_del` = #{isDel}
  146. </if>
  147. <if test=" null != brand ">
  148. and m.`brand` = #{brand}
  149. </if>
  150. <if test=" null != creditLocked ">
  151. and m.`credit_locked` = #{creditLocked}
  152. </if>
  153. <if test=" null != createFrom ">
  154. and m.`create_from` = #{createFrom}
  155. </if>
  156. <if test=" null != createFromId and '' != createFromId">
  157. and m.`create_from_id` = #{createFromId}
  158. </if>
  159. <if test=" null != createShopNumber and '' != createShopNumber">
  160. and m.`create_shop_number` = #{createShopNumber}
  161. </if>
  162. <if test=" null != createShopType ">
  163. and m.`create_shop_type` = #{createShopType}
  164. </if>
  165. <if test=" null != searchKey and '' != searchKey ">
  166. and (m.`name` like concat('%', #{searchKey},'%') or m.`link_phone` like concat('%', #{searchKey},'%'))
  167. </if>
  168. <if test=" null != privateRentShopTypeList and privateRentShopTypeList.size > 0">
  169. and m.`create_shop_type` in
  170. <foreach collection="privateRentShopTypeList" index="index" item="prstItem" open="(" separator="," close=")">
  171. #{prstItem}
  172. </foreach>
  173. </if>
  174. <if test=" null != adminTypes and adminTypes.size > 0">
  175. and m.`is_admin` in
  176. <foreach collection="adminTypes" index="index" item="typeItem" open="(" separator="," close=")">
  177. #{typeItem}
  178. </foreach>
  179. </if>
  180. <if test=" null != ids and ids.size > 0">
  181. and m.id in
  182. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  183. #{idItem}
  184. </foreach>
  185. </if>
  186. <if test=" null != notInids and notInids.size > 0">
  187. and m.id NOT IN
  188. <foreach collection="notInids" index="index" item="notInIdItem" open="(" separator="," close=")">
  189. #{notInIdItem}
  190. </foreach>
  191. </if>
  192. <if test="merchantIds != null and merchantIds.size > 0">
  193. and m.id NOT IN
  194. <foreach collection="merchantIds" index="index" item="idItem" open="(" separator="," close=")">
  195. #{idItem}
  196. </foreach>
  197. </if>
  198. <if test=" null != sortColumns">order by ${sortColumns}</if>
  199. </sql>
  200. <select id="findIdNameList" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  201. select id,name
  202. from wx_merchant m
  203. <include refid="dynamicWhereConditions"/>
  204. </select>
  205. <select id="findList" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  206. select
  207. <include refid="allColumns"/>
  208. from wx_merchant m
  209. <include refid="dynamicWhereConditions"/>
  210. </select>
  211. <select id="findByTenantIds" parameterType="java.util.Map" resultMap="BaseResultMap">
  212. select
  213. <include refid="allColumns"/>
  214. from wx_merchant m
  215. where m.is_del = 0
  216. and m.`status` = 1
  217. <if test=" null != tenantIds ">
  218. and m.tenant_id in
  219. <foreach collection="tenantIds" index="index" item="tenantId" open="(" separator="," close=")">
  220. #{tenantId}
  221. </foreach>
  222. </if>
  223. </select>
  224. <select id="findIdList" parameterType="com.iformall.domain.po.WxMerchant" resultType="Long">
  225. select id
  226. from wx_merchant m
  227. <include refid="dynamicWhereConditions"/>
  228. </select>
  229. <select id="getMerchantByEncode" parameterType="String" resultMap="BaseResultMap">
  230. select
  231. <include refid="allColumns"/>
  232. from wx_merchant m where m.encode = #{encode}
  233. </select>
  234. <select id="getMerchantByCode" parameterType="java.util.Map" resultMap="BaseResultMap">
  235. select <include refid="allColumns"/>
  236. FROM wx_merchant m where md5(m.`id`) = #{merchantCode}
  237. <if test=" null != tenantId and '' != tenantId">
  238. and m.`tenant_id` = #{tenantId}
  239. </if>
  240. <if test=" null != parentTenantId and '' != parentTenantId">
  241. and m.`parent_tenant_id` = #{parentTenantId}
  242. </if>
  243. <if test=" null != status ">
  244. and m.`status` = #{status}
  245. </if>
  246. </select>
  247. <select id="findListCVo" parameterType="com.iformall.domain.dto.WxMerchantDto" resultMap="BaseResultMap">
  248. select
  249. <include refid="allColumns"/>
  250. FROM wx_merchant m where m.is_del=0
  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 != merchantName and ''!=merchantName ">
  258. and m.`name` like concat('%', #{merchantName},'%')
  259. </if>
  260. <if test=" null != merchantLinkPhone and ''!=merchantLinkPhone ">
  261. and m.`link_phone` like concat('%', #{merchantLinkPhone},'%')
  262. </if>
  263. <if test=" null != businessId ">
  264. and m.`business_id` = #{businessId}
  265. </if>
  266. <if test=" null != subBusinessId ">
  267. and m.`sub_business_id` = #{subBusinessId}
  268. </if>
  269. <if test=" null != merchantStatus ">
  270. and m.`status` = #{merchantStatus}
  271. </if>
  272. <if test=" null != isPublic">
  273. and m.`is_public` = #{isPublic}
  274. </if>
  275. <if test=" null != isPrivate">
  276. and m.`is_private` = #{isPrivate}
  277. </if>
  278. <if test=" null != isAdmin ">
  279. and m.`is_admin` = #{isAdmin}
  280. </if>
  281. <if test=" null != id">
  282. and m.`id` = #{id}
  283. </if>
  284. <if test=" null != adminTypes and adminTypes.size > 0">
  285. and m.`is_admin` in
  286. <foreach collection="adminTypes" index="index" item="typeItem" open="(" separator="," close=")">
  287. #{typeItem}
  288. </foreach>
  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. order by m.top_time desc
  297. </select>
  298. <select id="findQrcodeEmptyList" resultMap="BaseResultMap">
  299. select <include refid="allColumns"/> from wx_merchant m where (m.qr_code is null or m.tt_qr_code is null);
  300. </select>
  301. <select id="findBusByFloorId" resultType="hashmap" parameterType="hashmap">
  302. select count(distinct m.id) count,m.business_id bid
  303. from wx_merchant m
  304. where m.status = 1 and m.is_del = 0
  305. <if test=" null != tenantId and '' != tenantId">
  306. and m.`tenant_id` = #{tenantId}
  307. </if>
  308. <if test=" null != parentTenantId and '' != parentTenantId">
  309. and m.`parent_tenant_id` = #{parentTenantId}
  310. </if>
  311. <if test=" null != ids ">
  312. and m.id in
  313. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  314. #{idItem}
  315. </foreach>
  316. </if>
  317. group by m.business_id
  318. </select>
  319. <select id="hasMerchant" parameterType="com.iformall.domain.po.WxMerchant" resultType="int">
  320. select count(1) from wx_merchant where `name`=#{name}
  321. <if test=" null != status ">
  322. and `status` = #{status}
  323. </if>
  324. <if test=" null != id">
  325. and `id` != #{id}
  326. </if>
  327. </select>
  328. <select id="hasMerchantEncode" parameterType="com.iformall.domain.po.WxMerchant" resultType="int">
  329. select count(1) from wx_merchant where `encode`=#{encode}
  330. <if test=" null != status ">
  331. and `status` = #{status}
  332. </if>
  333. <if test=" null != id">
  334. and `id` != #{id}
  335. </if>
  336. </select>
  337. <select id="hasMerchantBrand" parameterType="com.iformall.domain.po.WxMerchant" resultType="int">
  338. select count(1) from wx_merchant where `brand`=#{brand}
  339. <if test=" null != status ">
  340. and `status` = #{status}
  341. </if>
  342. <if test=" null != id">
  343. and `id` != #{id}
  344. </if>
  345. </select>
  346. <select id="hasMerchantIsAdmin" parameterType="com.iformall.domain.po.WxMerchant" resultType="int">
  347. select count(1) from wx_merchant where `is_admin`=#{isAdmin}
  348. <if test=" null != status ">
  349. and `status` = #{status}
  350. </if>
  351. <if test=" null != id">
  352. and `id` != #{id}
  353. </if>
  354. </select>
  355. <update id="updateCreditLocked" parameterType="com.iformall.domain.po.WxMerchant">
  356. update wx_merchant set credit_locked = #{creditLocked} where tenant_id = #{tenantId}
  357. </update>
  358. <select id="userTradeMerchantList" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  359. SELECT m.id, m.`img_url` , m.`name` ,m.`encode` , m.`link_person`
  360. FROM wx_merchant m
  361. where m.status=1
  362. <if test=" null != name and ''!=name ">
  363. and `name` like concat('%', #{name},'%')
  364. </if>
  365. <if test=" null != linkPhone and ''!=linkPhone ">
  366. and `link_phone` like concat('%', #{linkPhone},'%')
  367. </if>
  368. <if test=" null != linkPerson and ''!=linkPerson ">
  369. and `link_person` like concat('%', #{linkPerson},'%')
  370. </if>
  371. <if test=" null != sortColumns">order by ${sortColumns}</if>
  372. </select>
  373. <select id="findByTrade" parameterType="java.util.Map" resultMap="BaseResultMap">
  374. select <include refid="allColumns"/> from wx_merchant m where
  375. m.id in
  376. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  377. #{idItem}
  378. </foreach>
  379. limit 1
  380. </select>
  381. <select id="getMerchantList" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap">
  382. select <include refid="allColumns"/>
  383. from wx_merchant m
  384. where m.is_del=0 and m.status=1
  385. <if test=" null != tenantId and '' != tenantId">
  386. and m.`tenant_id` = #{tenantId}
  387. </if>
  388. <if test=" null != parentTenantId and '' != parentTenantId">
  389. and m.`parent_tenant_id` = #{parentTenantId}
  390. </if>
  391. <if test=" null != isPrivate">
  392. and m.`is_private` = #{isPrivate}
  393. </if>
  394. order by m.create_date desc
  395. </select>
  396. <update id="increaseCash" parameterType="com.iformall.domain.po.WxMerchant">
  397. update wx_merchant set cash_out_number = cash_out_number+#{cashOutNumber} where id = #{id}
  398. </update>
  399. <update id="reduceCash" parameterType="com.iformall.domain.po.WxMerchant">
  400. 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}
  401. </update>
  402. <update id="increaseCashCount" parameterType="com.iformall.domain.po.WxMerchant">
  403. update wx_merchant set cash_out_count = cash_out_count+1 where id = #{id}
  404. </update>
  405. <update id="reSetCashCount" parameterType="com.iformall.domain.po.WxMerchant">
  406. update wx_merchant set cash_out_count = 0 where id = #{id}
  407. </update>
  408. <update id="recordedAmount" parameterType="com.iformall.domain.po.WxMerchant">
  409. update wx_merchant set
  410. entry_amount = ifnull(entry_amount,0)+#{entryAmount}
  411. /*,cash_out_number = ifnull(cash_out_number,0)+#{cashOutNumber}*/
  412. where id = #{id}
  413. </update>
  414. <select id="findShopMerchant" parameterType="Long" resultType="hashmap">
  415. select
  416. 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`,
  417. m.`business_id`,m.`business_types`,m.`sub_business_id`,m.`shop_type`,m.`brand`,m.`is_public`,m.`is_private`,m.email,m.`title`,m.`cover_picture`,m.`is_admin`,m.`bill_setting`,m.`qr_code`,m.`tt_qr_code`,
  418. 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
  419. from wx_merchant m where m.id = #{id}
  420. </select>
  421. <select id="detailShopMerchantById" parameterType="hashmap" resultType="hashmap">
  422. select
  423. 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`,
  424. m.`car_vendor_type`,m.`car_params`,m.`status`,m.`link_person`,
  425. m.`business_id`,m.`business_types`,m.`sub_business_id`,m.`shop_type`,m.`brand`,m.`is_public`,m.`is_private`,m.email,m.`title`,m.`cover_picture`,m.`is_admin`,m.`bill_setting`,m.`qr_code`,m.`tt_qr_code`,
  426. 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
  427. from wx_merchant m where m.id = #{id} and m.is_del = 0
  428. <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
  429. and m.`tenant_id` = #{tenantInfo.tenantId}
  430. </if>
  431. <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
  432. and m.`parent_tenant_id` = #{tenantInfo.parentTenantId}
  433. </if>
  434. </select>
  435. <update id="deleteByUpdate" parameterType="Long">
  436. update wx_merchant set is_del = 1
  437. where id = #{id}
  438. </update>
  439. <select id="getMerchantListByIds" resultType="com.iformall.domain.po.WxMerchant">
  440. select <include refid="allColumns"/>
  441. from wx_merchant m
  442. where m.is_del=0
  443. <!-- and m.is_admin=0 -->
  444. <if test="relationIds != null and relationIds.size > 0">
  445. and m.id in
  446. <foreach collection="relationIds" index="index" item="idItem" open="(" separator="," close=")">
  447. #{idItem}
  448. </foreach>
  449. </if>
  450. </select>
  451. <select id="countMerchant" resultType="java.lang.Integer">
  452. SELECT
  453. COUNT(1)
  454. FROM
  455. wx_merchant
  456. WHERE
  457. is_del = 0
  458. AND status = 1
  459. AND ( `car_vendor_type` = 0 OR `car_vendor_type` IS NULL )
  460. AND `is_private` = 0
  461. AND `is_admin` IN (0, 1)
  462. AND tenant_id IN
  463. <foreach collection="tenantIds" index="index" item="tenantId" open="(" separator="," close=")">
  464. #{tenantId}
  465. </foreach>
  466. </select>
  467. </mapper>