Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

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