Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

704 rader
33 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.WxRentContractMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxRentContract">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  7. <result column="price" jdbcType="INTEGER" property="price"/>
  8. <result column="rental_start_date" jdbcType="TIMESTAMP" property="rentalStartDate"/>
  9. <result column="rental_end_date" jdbcType="TIMESTAMP" property="rentalEndDate"/>
  10. <result column="sign_date" jdbcType="TIMESTAMP" property="signDate"/>
  11. <result column="receive_period" jdbcType="INTEGER" property="receivePeriod"/>
  12. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  13. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  14. <result column="filepath" jdbcType="VARCHAR" property="filepath"/>
  15. <result column="status" jdbcType="INTEGER" property="status"/>
  16. <result column="contract_number" jdbcType="VARCHAR" property="contractNumber"/>
  17. <result column="deposit" jdbcType="INTEGER" property="deposit"/>
  18. <result column="pay_date" jdbcType="INTEGER" property="payDate"/>
  19. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  20. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
  21. <result column="brand" jdbcType="VARCHAR" property="brand"/>
  22. <result column="business_id" jdbcType="INTEGER" property="businessId"/>
  23. <result column="shop_type" jdbcType="INTEGER" property="shopType"/>
  24. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
  25. <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
  26. <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/>
  27. <result column="link_phone" jdbcType="VARCHAR" property="linkPhone"/>
  28. <result column="pay_account" jdbcType="VARCHAR" property="payAccount"/>
  29. <result column="filename" jdbcType="VARCHAR" property="filename"/>
  30. <result column="lease" jdbcType="INTEGER" property="lease"/>
  31. <result column="type" jdbcType="INTEGER" property="type"/>
  32. <result column="revenue" jdbcType="INTEGER" property="revenue"/>
  33. <result column="adjust_ratio" jdbcType="VARCHAR" property="adjustRatio"/>
  34. <result column="adjust_period" jdbcType="INTEGER" property="adjustPeriod"/>
  35. <result column="pay_ratio" jdbcType="INTEGER" property="payRatio"/>
  36. <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/>
  37. <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/>
  38. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  39. <result column="bank_name" jdbcType="VARCHAR" property="bankName"/>
  40. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  41. <result column="fix_start_date" property="fixStartDate"/>
  42. <result column="fix_end_date" property="fixEndDate"/>
  43. <result column="business_type" property="businessType"/>
  44. <result column="receive_period" property="receivePeriod"/>
  45. <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
  46. <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
  47. <result column="price_unit" property="priceUnit"/>
  48. <result column="rent_price" property="rentPrice"/>
  49. <result column="subject_name" property="subjectName"/>
  50. <result column="rent_start_type" property="rentStartType"/><result column="type" jdbcType="INTEGER" property="type"/>
  51. <result column="revenue" jdbcType="INTEGER" property="revenue"/>
  52. <result column="adjust_ratio" jdbcType="VARCHAR" property="adjustRatio"/>
  53. <result column="adjust_period" jdbcType="INTEGER" property="adjustPeriod"/>
  54. <result column="pay_ratio" jdbcType="INTEGER" property="payRatio"/>
  55. <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/>
  56. <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/>
  57. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  58. <result column="bank_name" jdbcType="VARCHAR" property="bankName"/>
  59. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  60. <result column="fix_start_date" property="fixStartDate"/>
  61. <result column="fix_end_date" property="fixEndDate"/>
  62. <result column="business_type" property="businessType"/>
  63. <result column="receive_period" property="receivePeriod"/>
  64. <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
  65. <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
  66. <result column="price_unit" property="priceUnit"/>
  67. <result column="rent_price" property="rentPrice"/>
  68. <result column="subject_name" property="subjectName"/>
  69. <result column="rent_start_type" property="rentStartType"/>
  70. <result column="shop_name" property="shopName"/>
  71. <result column="from_id" property="fromId"/>
  72. <result column="rent_input_way" property="rentInputWay"/>
  73. <result column="adjust_ratio_way" property="adjustRatioWay"/>
  74. <result column="operation_type" property="operationType"/>
  75. <result column="late_pay_ratio" property="latePayRatio"/>
  76. <result column="late_pay_day" property="latePayDay"/>
  77. <result column="bus_discount_ratio" property="busDiscountRatio"/>
  78. <result column="bus_discount_time" property="busDiscountTime"/>
  79. </resultMap>
  80. <sql id="allColumns">
  81. `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,
  82. `tenant_id`,`parent_tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`,
  83. `brand`,`business_id`,`shop_type`,`updatetime`,`createtime`,`link_person`,`link_phone`,
  84. `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`,
  85. `start_date`,`end_date`,`shop_name`,`from_id`,
  86. `apply_status`,`bank_name`,`rent_shop_type`,`fix_start_date`,`fix_end_date`,
  87. `business_type`,`rent_info`, `file_names`,price_unit,rent_price,`subject_name`,rent_start_type,
  88. `rent_input_way`,`adjust_ratio_way`,`operation_type`,late_pay_ratio,late_pay_day,bus_discount_ratio,bus_discount_time
  89. </sql>
  90. <sql id="dynamicWhereConditions">
  91. where 1 = 1
  92. <if test=" null != id ">and `id` = #{id}</if>
  93. <if test=" null != fromId ">and `from_id` = #{fromId}</if>
  94. <if test=" null != merchantId and '' != merchantId">and `merchant_id` = #{merchantId}</if>
  95. <if test=" null != price and '' != price">and `price` = #{price}</if>
  96. <if test=" null != rentalStartDate and '' != rentalStartDate">and `rental_start_date` = #{rentalStartDate}</if>
  97. <if test=" null != rentalEndDate and '' != rentalEndDate">and `rental_end_date` = #{rentalEndDate}</if>
  98. <if test=" null != signDate and '' != signDate">and `sign_date` = #{signDate}</if>
  99. <if test=" null != receivePeriod and '' != receivePeriod">and `receive_period` = #{receivePeriod}</if>
  100. <if test=" null != tenantId and '' != tenantId">
  101. and `tenant_id` = #{tenantId}
  102. </if>
  103. <if test=" null != parentTenantId and '' != parentTenantId">
  104. and `parent_tenant_id` = #{parentTenantId}
  105. </if>
  106. <if test=" null != filepath and '' != filepath">and `filepath` = #{filepath}</if>
  107. <if test=" null != status and '' != status">and `status` = #{status}</if>
  108. <if test=" null != contractNumber and '' != contractNumber">and `contract_number` = #{contractNumber}</if>
  109. <if test=" null != deposit and '' != deposit">and `deposit` = #{deposit}</if>
  110. <if test=" null != payDate and '' != payDate">and `pay_date` = #{payDate}</if>
  111. <if test=" null != isDel and '' != isDel">and `is_del` = #{isDel}</if>
  112. <if test=" null != merchantName and '' != merchantName">and `merchant_name` like concat('%', #{merchantName},'%') </if>
  113. <if test=" null != brand and '' != brand">and `brand` = #{brand}</if>
  114. <if test=" null != businessId and '' != businessId">and `business_id` = #{businessId}</if>
  115. <if test=" null != shopType and '' != shopType">and `shop_type` = #{shopType}</if>
  116. <if test=" null != updatetime and '' != updatetime">and `updatetime` = #{updatetime}</if>
  117. <if test=" null != createtime and '' != createtime">and `createtime` = #{createtime}</if>
  118. <if test=" null != linkPerson and '' != linkPerson">and `link_person` = #{linkPerson}</if>
  119. <if test=" null != linkPhone and '' != linkPhone">and `link_phone` = #{linkPhone}</if>
  120. <if test=" null != payAccount and '' != payAccount">and `pay_account` = #{payAccount}</if>
  121. <if test=" null != filename and '' != filename">and `filename` = #{filename}</if>
  122. <if test=" null != lease and '' != lease">and `lease` = #{lease}</if>
  123. <if test=" null != type and '' != type">and `type` = #{type}</if>
  124. <if test=" null != startDate and '' != startDate">and `start_date` = #{startDate}</if>
  125. <if test=" null != endDate and '' != endDate">and `end_date` = #{endDate}</if>
  126. <if test=" null != rentShopType and '' != rentShopType">and `rent_shop_type` = #{rentShopType}</if>
  127. <if test=" null != operationType and '' != operationType">and `operation_type` = #{operationType}</if>
  128. <if test=" null != queryShopId and '' != queryShopId">and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{queryShopId},'"'))</if>
  129. <if test=" null != statuss ">
  130. and status in
  131. <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
  132. #{statusItem}
  133. </foreach>
  134. </if>
  135. <if test=" null != ids ">
  136. and id in
  137. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  138. #{idItem}
  139. </foreach>
  140. </if>
  141. <if test=" null != sortColumns">order by ${sortColumns}</if>
  142. </sql>
  143. <select id="findList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  144. select
  145. <include refid="allColumns"/>
  146. from wx_rent_contract
  147. <include refid="dynamicWhereConditions"/>
  148. </select>
  149. <!-- 需要修改 -->
  150. <!-- <select id="queryRentContractData" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
  151. select rc.id,rc.merchant_name merchantName,rc.rental_start_date rentalStartDate,rc.rental_end_date rentalEndDate,rc.`status`,
  152. rc.price,rc.contract_number contractNumber,s.shop_number shopNumber,f.floor_name floorName,b.building_name buildingName,
  153. rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate,rc.merchant_id merchantId,rc.type,
  154. rc.start_date startDate,rc.end_date endDate,br.`name` brandName,rc.apply_status applyStatus,rc.bank_name
  155. bankName,rc.rent_shop_type rentShopType,rc.fix_start_date fixStartDate,rc.fix_end_date fixEndDate
  156. ,rc.business_type businessType,rc.adjust_period adjustPeriod,rc.rent_info rentInfo, rc.file_names
  157. fileNames,rc.price_unit,rc.subject_name subjectName,rc.`rent_input_way` rentInputWay,rc.`adjust_ratio_way`
  158. adjustRatioWay,rc.bus_discount_ratio,rc.bus_discount_time
  159. from wx_rent_contract rc
  160. left join wx_shop s on rc.shop_id=s.id
  161. left join wx_mall_floor f on s.floor=f.id
  162. left join wx_mall_building b on s.building=b.id
  163. left join wx_brand br on rc.brand=br.id
  164. <where>
  165. <if test=" null != tenantId and '' != tenantId">
  166. and rc.`tenant_id` = #{tenantId}
  167. </if>
  168. <if test=" null != parentTenantId and '' != parentTenantId">
  169. and rc.`parent_tenant_id` = #{parentTenantId}
  170. </if>
  171. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like concat('%',#{merchantName},'%')</if>
  172. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  173. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  174. </if>
  175. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  176. and s.`shop_number` like concat('%',#{shopNumber},'%')
  177. </if>
  178. <if test=" null != status ">and rc.`status` = #{status}</if>
  179. <if test=" null != shopId">and rc.`shop_id` = #{shopId}</if>
  180. <if test=" null != type ">and rc.`type` = #{type}</if>
  181. <if test=" null != rentShopType ">and rc.`rent_shop_type` = #{rentShopType}</if>
  182. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  183. <if test=" null != building and ''!= building">and b.id = #{building}</if>
  184. <if test=" null != floor and ''!= floor">and f.id = #{floor}</if>
  185. <if test=" null != operationType ">and `operation_type` = #{operationType}</if>
  186. <if test=" null != businessForRule and '' != businessForRule ">
  187. and rc.business_id in (${businessForRule})
  188. </if>
  189. <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule ">
  190. and rc.`id` in
  191. <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")">
  192. select id from wx_rent_contract where 1=1
  193. <if test=" null != tenantId and '' != tenantId">
  194. and `tenant_id` = #{tenantId}
  195. </if>
  196. <if test=" null != parentTenantId and '' != parentTenantId">
  197. and `parent_tenant_id` = #{parentTenantId}
  198. </if>
  199. and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select
  200. id from wx_shop where 1=1
  201. <if test=" null != tenantId and '' != tenantId">
  202. and `tenant_id` = #{tenantId}
  203. </if>
  204. <if test=" null != parentTenantId and '' != parentTenantId">
  205. and `parent_tenant_id` = #{parentTenantId}
  206. </if>
  207. and floor in (${floorForRule}))
  208. </foreach>
  209. </if>
  210. <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != floorForRule ">
  211. and rc.shop_id in (select id from wx_shop where 1=1
  212. <if test=" null != tenantId and '' != tenantId">
  213. and `tenant_id` = #{tenantId}
  214. </if>
  215. <if test=" null != parentTenantId and '' != parentTenantId">
  216. and `parent_tenant_id` = #{parentTenantId}
  217. </if>
  218. and floor in (${floorForRule}))
  219. </if>
  220. <if test=" null != merchantId">and rc.`merchant_id` = #{merchantId}</if>
  221. </where>
  222. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  223. <if test=" null == sortColumns"> order by rc.createtime desc,rc.id desc </if>
  224. </select> -->
  225. <select id="queryRentContractCountByStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  226. select count(1) from wx_rent_contract where status=#{status}
  227. <if test=" null != tenantId and '' != tenantId">
  228. and `tenant_id` = #{tenantId}
  229. </if>
  230. <if test=" null != parentTenantId and '' != parentTenantId">
  231. and `parent_tenant_id` = #{parentTenantId}
  232. </if>
  233. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  234. </select>
  235. <!-- <select id="queryRentContractWaitSignStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  236. select count(id) from wx_rent_contract where status=#{status}
  237. <if test=" null != tenantId and '' != tenantId">
  238. and `tenant_id` = #{tenantId}
  239. </if>
  240. <if test=" null != parentTenantId and '' != parentTenantId">
  241. and `parent_tenant_id` = #{parentTenantId}
  242. </if>
  243. <if test=" null != rentShopType ">
  244. and rent_shop_type = #{rentShopType}
  245. </if>
  246. </select> -->
  247. <!-- <select id="queryRentContractEndSoonStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  248. select count(id) from wx_rent_contract where status=4
  249. <if test=" null != tenantId and '' != tenantId">
  250. and `tenant_id` = #{tenantId}
  251. </if>
  252. <if test=" null != parentTenantId and '' != parentTenantId">
  253. and `parent_tenant_id` = #{parentTenantId}
  254. </if>
  255. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  256. </select> -->
  257. <!-- <select id="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  258. select count(id) from wx_rent_contract where status in (2,3,4)
  259. <if test=" null != tenantId and '' != tenantId">
  260. and `tenant_id` = #{tenantId}
  261. </if>
  262. <if test=" null != parentTenantId and '' != parentTenantId">
  263. and `parent_tenant_id` = #{parentTenantId}
  264. </if>
  265. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  266. </select> -->
  267. <!-- <select id="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  268. select count(id) from wx_rent_contract where status!=0 and status!=1 and status!=6 and status!=7 and rental_end_date &lt;now()
  269. <if test=" null != tenantId and '' != tenantId">
  270. and `tenant_id` = #{tenantId}
  271. </if>
  272. <if test=" null != parentTenantId and '' != parentTenantId">
  273. and `parent_tenant_id` = #{parentTenantId}
  274. </if>
  275. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  276. </select> -->
  277. <!-- <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxRentContract">
  278. update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8)
  279. <if test=" null != tenantId and '' != tenantId">
  280. and `tenant_id` = #{tenantId}
  281. </if>
  282. <if test=" null != parentTenantId and '' != parentTenantId">
  283. and `parent_tenant_id` = #{parentTenantId}
  284. </if>
  285. and DATEDIFF(rental_end_date,now()) &lt;= 30 and rental_end_date > now()
  286. </update> -->
  287. <!-- <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  288. update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8)
  289. <if test=" null != tenantId and '' != tenantId">
  290. and `tenant_id` = #{tenantId}
  291. </if>
  292. <if test=" null != parentTenantId and '' != parentTenantId">
  293. and `parent_tenant_id` = #{parentTenantId}
  294. </if>
  295. and rental_start_date &lt;= now() and rental_end_date >= now()
  296. </update> -->
  297. <!-- <update id="updateRentContractEndStatus" parameterType="com.iformall.domain.po.WxRentContract">
  298. update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8)
  299. <if test=" null != tenantId and '' != tenantId">
  300. and `tenant_id` = #{tenantId}
  301. </if>
  302. <if test=" null != parentTenantId and '' != parentTenantId">
  303. and `parent_tenant_id` = #{parentTenantId}
  304. </if>
  305. and rental_end_date &lt;now()
  306. </update> -->
  307. <!-- <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxRentContract">
  308. update wx_rent_contract set status=#{status} where status not in(0,5,6,7)
  309. <if test=" null != tenantId and '' != tenantId">
  310. and `tenant_id` = #{tenantId}
  311. </if>
  312. <if test=" null != parentTenantId and '' != parentTenantId">
  313. and `parent_tenant_id` = #{parentTenantId}
  314. </if>
  315. and merchant_id is null
  316. </update> -->
  317. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract">
  318. update wx_rent_contract
  319. set apply_status=#{applyStatus}
  320. <if test=" null != businessType ">,business_type=#{businessType}</if>
  321. <if test=" null != status ">,status=#{status}</if>
  322. where id=#{id}
  323. </update>
  324. <update id="updateStatus" parameterType="com.iformall.domain.po.WxRentContract">
  325. update wx_rent_contract set status=#{status} where id=#{id}
  326. </update>
  327. <!-- <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  328. update wx_rent_contract set status=#{status} where shop_id in (
  329. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE status in(2,3,4)
  330. <if test=" null != tenantId and '' != tenantId">
  331. and `tenant_id` = #{tenantId}
  332. </if>
  333. <if test=" null != parentTenantId and '' != parentTenantId">
  334. and `parent_tenant_id` = #{parentTenantId}
  335. </if>
  336. )s) and status in(0,1) and status!=7 and rent_shop_type=2
  337. </update> -->
  338. <!-- <select id="getRentContractList" parameterType="com.iformall.domain.po.WxRentContract"
  339. resultType="com.iformall.domain.po.WxRentContract">
  340. select s.shop_id,s.shop_number,s.building_name building, s.floor_name floor,s.build_area,rc.* from (
  341. select s.id shop_id,ms.merchant_id,s.shop_number,b.building_name,f.floor_name,s.build_area,s.floor,s.building
  342. from wx_shop s
  343. left join wx_mall_building b on s.building=b.id
  344. left join wx_mall_floor f on s.floor=f.id
  345. left join wx_merchant_shop ms on s.id=ms.shop_id
  346. where ms.is_del=0) s
  347. inner join (select * from wx_rent_contract where status in(2,3,4)) rc on s.merchant_id=rc.merchant_id
  348. where 1=1
  349. <if test=" null != tenantId and '' != tenantId">
  350. and rc.`tenant_id` = #{tenantId}
  351. </if>
  352. <if test=" null != parentTenantId and '' != parentTenantId">
  353. and rc.`parent_tenant_id` = #{parentTenantId}
  354. </if>
  355. <if test=" null != shopNumber and ''!=shopNumber">
  356. and s.shop_number like concat('%', #{shopNumber},'%')
  357. </if>
  358. <if test=" null != floor and ''!=floor">
  359. and s.floor = #{floor}
  360. </if>
  361. <if test=" null != building and ''!=building">
  362. and s.building = #{building}
  363. </if>
  364. order by rc.id desc
  365. </select> -->
  366. <select id="updateStatusForUnsign" parameterType="com.iformall.domain.po.WxRentContract">
  367. update wx_rent_contract set status=1 where status=2 and merchant_id is null
  368. <if test=" null != tenantId and '' != tenantId">
  369. and `tenant_id` = #{tenantId}
  370. </if>
  371. <if test=" null != parentTenantId and '' != parentTenantId">
  372. and `parent_tenant_id` = #{parentTenantId}
  373. </if>
  374. </select>
  375. <!-- <select id="getRentInvalidList" parameterType="com.iformall.domain.po.WxRentContract"
  376. resultType="com.iformall.domain.po.WxRentContract">
  377. select id from wx_rent_contract where shop_id in (
  378. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE status in(2,3,4)
  379. <if test=" null != tenantId and '' != tenantId">
  380. and `tenant_id` = #{tenantId}
  381. </if>
  382. <if test=" null != parentTenantId and '' != parentTenantId">
  383. and `parent_tenant_id` = #{parentTenantId}
  384. </if>
  385. )s) and status in(0,1) and status!=7 and apply_status=1
  386. <if test=" null != tenantId and '' != tenantId">
  387. and `tenant_id` = #{tenantId}
  388. </if>
  389. <if test=" null != parentTenantId and '' != parentTenantId">
  390. and `parent_tenant_id` = #{parentTenantId}
  391. </if>
  392. </select> -->
  393. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  394. select count(1) from wx_rent_contract r,wx_bill_rent b
  395. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  396. </select>
  397. <select id="getMerchants" parameterType="com.iformall.domain.po.WxRentContract"
  398. resultType="com.iformall.domain.po.WxRentContract">
  399. select <include refid="allColumns"/> from wx_rent_contract where status in(2,3,4)
  400. and merchant_id not in(select merchant_id from wx_property_contract where status in(2,3,4))
  401. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  402. </select>
  403. <select id="selectRentContractCountByShopId" parameterType="java.util.Map" resultType="int">
  404. select count(1) from wx_rent_contract where 1=1
  405. <if test=" null != tenantId and '' != tenantId">
  406. and `tenant_id` = #{tenantId}
  407. </if>
  408. <if test=" null != parentTenantId and '' != parentTenantId">
  409. and `parent_tenant_id` = #{parentTenantId}
  410. </if>
  411. and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{shopId},'"')) and status in (2,3,4)
  412. <if test="id!=null">
  413. and id!=#{id}
  414. </if>
  415. </select>
  416. <select id="selectRentContractByShopId" parameterType="com.iformall.domain.po.WxRentContract"
  417. resultType="com.iformall.domain.po.WxRentContract">
  418. select <include refid="allColumns"/> from wx_rent_contract
  419. where 1=1
  420. <if test=" null != tenantId and '' != tenantId">
  421. and `tenant_id` = #{tenantId}
  422. </if>
  423. <if test=" null != parentTenantId and '' != parentTenantId">
  424. and `parent_tenant_id` = #{parentTenantId}
  425. </if>
  426. and json_contains(json_extract(rent_info,'$[*].id'),concat('"',${shopId},'"')) and rent_shop_type =1
  427. <if test=" null != status ">and status=#{status} and status!=7</if>
  428. </select>
  429. <!-- <update id="updateInvalidContract" parameterType="com.iformall.domain.po.WxRentContract">
  430. update wx_rent_contract set status=#{status}
  431. where 1=1
  432. <if test=" null != tenantId and '' != tenantId">
  433. and `tenant_id` = #{tenantId}
  434. </if>
  435. <if test=" null != parentTenantId and '' != parentTenantId">
  436. and `parent_tenant_id` = #{parentTenantId}
  437. </if>
  438. and id in(select r.id from (
  439. select id from wx_rent_contract where json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"'))
  440. and rent_shop_type=1 and status in(0,1) and status!=7)r)
  441. </update> -->
  442. <select id="selectRentContractByMerchantId" parameterType="com.iformall.domain.po.WxRentContract"
  443. resultType="com.iformall.domain.po.WxRentContract">
  444. select <include refid="allColumns"/> from wx_rent_contract
  445. where status in(2,3,4)
  446. and merchant_id = #{merchantId}
  447. </select>
  448. <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract"
  449. resultType="int">
  450. select count(1) from (
  451. select * from wx_rent_contract where contract_number=#{contractNumber}
  452. and status not in(5,6,7)
  453. <if test=" null != tenantId and '' != tenantId">
  454. and `tenant_id` = #{tenantId}
  455. </if>
  456. <if test=" null != parentTenantId and '' != parentTenantId">
  457. and `parent_tenant_id` = #{parentTenantId}
  458. </if>
  459. union
  460. select * from wx_rent_contract where contract_number=#{contractNumber}
  461. and apply_status in(1,2)
  462. <if test=" null != tenantId and '' != tenantId">
  463. and `tenant_id` = #{tenantId}
  464. </if>
  465. <if test=" null != parentTenantId and '' != parentTenantId">
  466. and `parent_tenant_id` = #{parentTenantId}
  467. </if>
  468. ) r
  469. <where>
  470. <if test="id!=null and id!=''">
  471. r.id!=#{id}
  472. </if>
  473. </where>
  474. </select>
  475. <!-- <select id="getShopType" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  476. select s.type
  477. from wx_rent_contract r
  478. left join wx_shop s on(s.id = r.`shop_id`)
  479. where r.id = #{id}
  480. </select> -->
  481. <resultMap id="contractMap" type="com.iformall.domain.vo.WxRentPropertyContractVo">
  482. <id column="id" property="id"/>
  483. <result column="tenant_id" property="tenantId"/>
  484. <result column="parent_tenant_id" property="parentTenantId"/>
  485. <result column="rent_id" property="rentId"/>
  486. <result column="property_id" property="propertyId"/>
  487. <result column="shop_name" property="shopName"/>
  488. <result column="merchant_name" property="merchantName"/>
  489. <result column="rent_info" property="rentInfo"/>
  490. <result column="rental_start_date" property="rentalStartDate"/>
  491. <result column="rental_end_date" property="rentalEndDate"/>
  492. <result column="rent_price" property="rentPrice"/>
  493. <result column="property_price" property="propertyPrice"/>
  494. <result column="type" property="type"/>
  495. <result column="status" property="status"/>
  496. <result column="apply_status" property="applyStatus"/>
  497. <result column="operation_type" property="operationType"/>
  498. <result column="rent_shop_type" property="rentShopType"/>
  499. <result column="merchant_id" property="merchantId"/>
  500. <result column="property_status" property="propertyStatus"/>
  501. <result column="rent_price_unit" property="rentPriceUnit"/>
  502. <result column="property_price_unit" property="propertyPriceUnit"/>
  503. <result column="bus_discount_time" property="busDiscountTime"/>
  504. <result column="bus_discount_ratio" property="busDiscountRatio"/>
  505. </resultMap>
  506. <select id="listContractVo" parameterType="com.iformall.domain.vo.WxRentPropertyContractVo" resultMap="contractMap">
  507. select rc.id,rc.tenant_id,rc.parent_tenant_id,rc.id as rent_id, pc.id as property_id, rc.merchant_name,rc.rental_start_date,rc.rental_end_date,rc.`status`,
  508. rc.price as rent_price,rc.contract_number,rc.shop_name,rc.type,rc.apply_status,
  509. rc.rent_shop_type,rc.rent_info,pc.price as property_price,rc.merchant_id,pc.`status` as property_status,
  510. rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit,
  511. rc.business_type businessType,rc.bus_discount_ratio,rc.bus_discount_time
  512. from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id
  513. <where>
  514. <if test=" null != tenantId and '' != tenantId">
  515. and rc.`tenant_id` = #{tenantId}
  516. </if>
  517. <if test=" null != parentTenantId and '' != parentTenantId">
  518. and rc.`parent_tenant_id` = #{parentTenantId}
  519. </if>
  520. <if test=" null != rentId and '' != rentId">
  521. and rc.`id` = #{rentId}
  522. </if>
  523. <if test=" null != propertyId and '' != propertyId">
  524. and pc.`id` = #{propertyId}
  525. </if>
  526. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like
  527. concat('%',#{merchantName},'%')
  528. </if>
  529. <if test=" null != shopNumber and shopNumber!=''">
  530. and (json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%') or rc.shop_name like concat('%',#{shopNumber},'%') )
  531. </if>
  532. <!-- <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  533. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  534. </if>
  535. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  536. and s.`shop_number` like concat('%',#{shopNumber},'%')
  537. </if> -->
  538. <if test=" null != status ">and rc.`status` = #{status}</if>
  539. <if test=" null != type ">and rc.`type` = #{type}</if>
  540. <if test=" null != rentShopType ">
  541. and rc.`rent_shop_type` = #{rentShopType}
  542. </if>
  543. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  544. <if test=" null != operationType ">and rc.`operation_type` = #{operationType}</if>
  545. <if test=" null != businessForRule and '' != businessForRule ">
  546. and rc.business_id in (${businessForRule})
  547. </if>
  548. <!-- <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule ">
  549. and rc.`id` in
  550. <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")">
  551. select id from wx_rent_contract where 1=1
  552. <if test=" null != tenantId and '' != tenantId">
  553. and `tenant_id` = #{tenantId}
  554. </if>
  555. <if test=" null != parentTenantId and '' != parentTenantId">
  556. and `parent_tenant_id` = #{parentTenantId}
  557. </if>
  558. and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select
  559. id from wx_shop where 1=1
  560. <if test=" null != tenantId and '' != tenantId">
  561. and `tenant_id` = #{tenantId}
  562. </if>
  563. <if test=" null != parentTenantId and '' != parentTenantId">
  564. and `parent_tenant_id` = #{parentTenantId}
  565. </if>
  566. and floor in (${floorForRule}))
  567. </foreach>
  568. </if> -->
  569. <!-- <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != floorForRule ">
  570. and rc.shop_id in (select id from wx_shop where 1=1
  571. <if test=" null != tenantId and '' != tenantId">
  572. and `tenant_id` = #{tenantId}
  573. </if>
  574. <if test=" null != parentTenantId and '' != parentTenantId">
  575. and `parent_tenant_id` = #{parentTenantId}
  576. </if>
  577. and floor in (${floorForRule}))
  578. </if> -->
  579. </where>
  580. <if test=" null != sortColumns">order by ${sortColumns}</if>
  581. <if test=" null == sortColumns">order by rc.createtime desc,rc.id desc</if>
  582. </select>
  583. <select id="getByBill" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
  584. select <include refid="allColumns"/> from wx_rent_contract
  585. where id in(
  586. select rent_contract_id from wx_bill_rent id = #{id}
  587. )
  588. </select>
  589. <select id="getShopCountMax" resultType="int">
  590. select max(json_length(rent_info)) from wx_rent_contract
  591. </select>
  592. <select id="queryContractByBus" resultType="hashmap" parameterType="com.iformall.domain.po.WxBusiness">
  593. select 1 type,c.`rental_start_date`,c.`rental_end_date`,c.id id from wx_merchant m left join wx_rent_contract c on(m.id = c.merchant_id)
  594. where m.business_id = #{id} and c.price is not null and c.`rental_start_date` is not null and c.`rental_end_date` is not null
  595. union all
  596. select 2 type,c.`rental_start_date`,c.`rental_end_date`,c.id id from wx_merchant m left join wx_property_contract c on(m.id = c.merchant_id)
  597. where m.business_id = #{id} and c.price is not null and c.`rental_start_date` is not null and c.`rental_end_date` is not null
  598. </select>
  599. <!-- <select id="selectRentContractByShopIds" resultType="com.iformall.domain.po.WxRentContract">
  600. SELECT rc.id,rc.rental_start_date,rc.rental_end_date,rc.`shop_id`,rc.`rent_shop_type`,rc.`rent_info` FROM
  601. `wx_rent_contract` rc
  602. WHERE rc.`status` IN (2,3,4) AND status!=7
  603. <if test=" null != tenantId and '' != tenantId">
  604. and `tenant_id` = #{tenantId}
  605. </if>
  606. <if test=" null != parentTenantId and '' != parentTenantId">
  607. and `parent_tenant_id` = #{parentTenantId}
  608. </if>
  609. AND ( (rc.`rent_shop_type`=2 AND rc.`shop_id` IN
  610. <foreach collection="shopIds" index="index" item="idItem" open="(" separator="," close=")">
  611. #{idItem}
  612. </foreach>
  613. )
  614. OR (rc.`rent_shop_type`=1 AND rc.`rent_info` REGEXP #{shopIdsRegexp})
  615. )
  616. </select> -->
  617. <!-- <select id="selectContractCountByShopId" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  618. SELECT count(*)
  619. FROM wx_rent_contract
  620. WHERE `status` = #{status} AND status!=7
  621. <if test=" null != tenantId and '' != tenantId">
  622. and `tenant_id` = #{tenantId}
  623. </if>
  624. <if test=" null != parentTenantId and '' != parentTenantId">
  625. and `parent_tenant_id` = #{parentTenantId}
  626. </if>
  627. AND (
  628. `rent_shop_type` = 1 AND
  629. json_contains(json_extract(rent_info, '$[*].shopId'), concat('"', #{shopId}, '"'))
  630. OR
  631. `rent_shop_type` = 2 AND `shop_id` = #{shopId}
  632. )
  633. </select> -->
  634. <!-- <select id="getContractByMerchant" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract">
  635. select * from wx_rent_contract where merchant_id = #{merchantId} and status=3
  636. </select> -->
  637. <select id="getCanApplyCount" resultType="Integer" parameterType="Long">
  638. select count(1) from wx_rent_contract where id != #{id} and (status=1 or (status=10 and apply_status=3) )
  639. </select>
  640. <select id="getMerchantIdsByStatuss" resultType="Long" parameterType="com.iformall.domain.po.WxRentContract">
  641. select distinct merchant_id from wx_rent_contract where 1=1
  642. <if test=" null != tenantId and '' != tenantId">
  643. and `tenant_id` = #{tenantId}
  644. </if>
  645. <if test=" null != parentTenantId and '' != parentTenantId">
  646. and `parent_tenant_id` = #{parentTenantId}
  647. </if>
  648. and status in
  649. <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
  650. #{statusItem}
  651. </foreach>
  652. </select>
  653. </mapper>