Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

399 righe
19 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.WxPropertyContractMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPropertyContract">
  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="rent_area" jdbcType="VARCHAR" property="rentArea"/>
  27. <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/>
  28. <result column="link_phone" jdbcType="VARCHAR" property="linkPhone"/>
  29. <result column="pay_account" jdbcType="VARCHAR" property="payAccount"/>
  30. <result column="filename" jdbcType="VARCHAR" property="filename"/>
  31. <result column="lease" jdbcType="INTEGER" property="lease"/>
  32. <result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/>
  33. <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/>
  34. <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/>
  35. <result column="apply_status" property="applyStatus"/>
  36. <result column="adjust_period" jdbcType="INTEGER" property="adjustPeriod"/>
  37. <result column="business_type" property="businessType"/>
  38. <result column="adjust_ratio" property="adjustRatio"/>
  39. <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
  40. <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
  41. <result column="price_unit" property="priceUnit"/>
  42. <result column="rent_price" property="rentPrice"/>
  43. <result column="subject_name" property="subjectName"/>
  44. <result column="rent_start_type" property="rentStartType"/>
  45. <result column="operation_type" property="operationType"/>
  46. <result column="late_pay_ratio" property="latePayRatio"/>
  47. <result column="late_pay_day" property="latePayDay"/>
  48. </resultMap>
  49. <sql id="allColumns">
  50. `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,
  51. `sign_date`,`receive_period`,`tenant_id`,`parent_tenant_id`,`filepath`,`status`,`contract_number`,
  52. `deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`,
  53. `shop_type`,`updatetime`,`createtime`,`rent_area`,
  54. `link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`,
  55. `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio,`rent_info`,
  56. `file_names`,price_unit,rent_price,subject_name,rent_start_type,`operation_type`,late_pay_ratio,late_pay_day
  57. </sql>
  58. <sql id="dynamicWhereConditions">
  59. where 1 = 1
  60. <if test=" null != id ">and `id` = #{id}</if>
  61. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  62. <if test=" null != price ">and `price` = #{price}</if>
  63. <if test=" null != rentalStartDate ">and `rental_start_date` = #{rentalStartDate}</if>
  64. <if test=" null != rentalEndDate ">and `rental_end_date` = #{rentalEndDate}</if>
  65. <if test=" null != signDate ">and `sign_date` = #{signDate}</if>
  66. <if test=" null != receivePeriod ">and `receive_period` = #{receivePeriod}</if>
  67. <if test=" null != tenantId and '' != tenantId">
  68. and `tenant_id` = #{tenantId}
  69. </if>
  70. <if test=" null != parentTenantId and '' != parentTenantId">
  71. and `parent_tenant_id` = #{parentTenantId}
  72. </if>
  73. <if test=" null != filepath ">and `filepath` = #{filepath}</if>
  74. <if test=" null != status ">and `status` = #{status}</if>
  75. <if test=" null != contractNumber ">and `contract_number` = #{contractNumber}</if>
  76. <if test=" null != deposit ">and `deposit` = #{deposit}</if>
  77. <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
  78. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  79. <if test=" null != merchantName and '' != merchantName ">and `merchant_name` like concat('%', #{merchantName},'%') </if>
  80. <if test=" null != brand ">and `brand` = #{brand}</if>
  81. <if test=" null != businessId ">and `business_id` = #{businessId}</if>
  82. <if test=" null != shopType ">and `shop_type` = #{shopType}</if>
  83. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  84. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  85. <if test=" null != rentArea ">and `rent_area` = #{rentArea}</if>
  86. <if test=" null != linkPerson ">and `link_person` = #{linkPerson}</if>
  87. <if test=" null != linkPhone ">and `link_phone` = #{linkPhone}</if>
  88. <if test=" null != payAccount ">and `pay_account` = #{payAccount}</if>
  89. <if test=" null != filename ">and `filename` = #{filename}</if>
  90. <if test=" null != lease ">and `lease` = #{lease}</if>
  91. <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
  92. <if test=" null != startDate ">and `start_date` = #{startDate}</if>
  93. <if test=" null != endDate ">and `end_date` = #{endDate}</if>
  94. <if test=" null != rentShopType">and `rent_shop_type` = #{rentShopType}</if>
  95. <if test=" null != operationType ">and `operation_type` = #{operationType}</if>
  96. <if test=" null != ids ">
  97. and id in
  98. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  99. #{idItem}
  100. </foreach>
  101. </if>
  102. <if test=" null != sortColumns">order by ${sortColumns}</if>
  103. </sql>
  104. <select id="findList" parameterType="com.iformall.domain.po.WxPropertyContract" resultMap="BaseResultMap">
  105. select
  106. <include refid="allColumns"/>
  107. from wx_property_contract
  108. <include refid="dynamicWhereConditions"/>
  109. </select>
  110. <!-- <select id="queryPropertyContractData" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
  111. select rc.id,rc.merchant_name merchantName,rc.rental_start_date rentalStartDate,rc.rental_end_date
  112. rentalEndDate,rc.`status`,rc.price,rc.contract_number contractNumber,s.shop_number shopNumber,
  113. f.floor_name floorName,b.building_name buildingName,receive_period receivePeriod,
  114. rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate,
  115. start_date startDate,end_date endDate,rc.rent_contract_id rentContractId,br.`name` brandName,
  116. s.addr,rc.apply_status applyStatus,rc.adjust_period adjustPeriod,rc.business_type businessType,
  117. rc.adjust_ratio adjustRatio,rc.rent_info rentInfo, rc.file_names fileNames,rc.price_unit,rc.subject_name
  118. subjectName
  119. from wx_property_contract rc
  120. left join wx_shop s on rc.shop_id=s.id
  121. left join wx_mall_floor f on s.floor=f.id
  122. left join wx_mall_building b on s.building=b.id
  123. left join wx_brand br on rc.brand=br.id
  124. <where>
  125. <if test=" null != tenantId and '' != tenantId">
  126. and rc.`tenant_id` = #{tenantId}
  127. </if>
  128. <if test=" null != parentTenantId and '' != parentTenantId">
  129. and rc.`parent_tenant_id` = #{parentTenantId}
  130. </if>
  131. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like
  132. concat('%',#{merchantName},'%')
  133. </if>
  134. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  135. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  136. </if>
  137. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  138. and s.`shop_number` like concat('%',#{shopNumber},'%')
  139. </if>
  140. <if test=" null != status ">and rc.`status` = #{status}</if>
  141. <if test=" null != rentContractId">and rc.`rent_contract_id` = #{rentContractId}</if>
  142. <if test=" null != id">and rc.`id` = #{id}</if>
  143. <if test=" null != rentShopType">and rc.`rent_shop_type` = #{rentShopType}</if>
  144. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  145. <if test=" null != building and ''!= building">and b.id = #{building}</if>
  146. <if test=" null != floor and ''!= floor">and f.id = #{floor}</if>
  147. <if test=" null != operationType ">and `operation_type` = #{operationType}</if>
  148. <if test=" null != businessForRule and '' != businessForRule ">
  149. and rc.business_id in (${businessForRule})
  150. </if>
  151. <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule ">
  152. and rc.`id` in
  153. <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")">
  154. select id from wx_property_contract where 1=1
  155. <if test=" null != tenantId and '' != tenantId">
  156. and `tenant_id` = #{tenantId}
  157. </if>
  158. <if test=" null != parentTenantId and '' != parentTenantId">
  159. and `parent_tenant_id` = #{parentTenantId}
  160. </if>
  161. and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select
  162. id from wx_shop where 1=1
  163. <if test=" null != tenantId and '' != tenantId">
  164. and `tenant_id` = #{tenantId}
  165. </if>
  166. <if test=" null != parentTenantId and '' != parentTenantId">
  167. and `parent_tenant_id` = #{parentTenantId}
  168. </if>
  169. and floor in (${floorForRule}))
  170. </foreach>
  171. </if>
  172. <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != floorForRule ">
  173. and rc.shop_id in (select id from wx_shop where 1=1
  174. <if test=" null != tenantId and '' != tenantId">
  175. and `tenant_id` = #{tenantId}
  176. </if>
  177. <if test=" null != parentTenantId and '' != parentTenantId">
  178. and `parent_tenant_id` = #{parentTenantId}
  179. </if>
  180. and floor in (${floorForRule}))
  181. </if>
  182. </where>
  183. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  184. <if test=" null == sortColumns">order by rc.createtime desc,rc.id desc</if>
  185. </select> -->
  186. <select id="queryRentContractWaitSignStatus" resultType="int"
  187. parameterType="com.iformall.domain.po.WxPropertyContract">
  188. select count(id) from wx_property_contract where status=#{status}
  189. <if test=" null != tenantId and '' != tenantId">
  190. and `tenant_id` = #{tenantId}
  191. </if>
  192. <if test=" null != parentTenantId and '' != parentTenantId">
  193. and `parent_tenant_id` = #{parentTenantId}
  194. </if>
  195. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  196. </select>
  197. <select id="queryRentContractEndSoonStatus" resultType="int"
  198. parameterType="com.iformall.domain.po.WxPropertyContract">
  199. select count(id) from wx_property_contract where status=4
  200. <if test=" null != tenantId and '' != tenantId">
  201. and `tenant_id` = #{tenantId}
  202. </if>
  203. <if test=" null != parentTenantId and '' != parentTenantId">
  204. and `parent_tenant_id` = #{parentTenantId}
  205. </if>
  206. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  207. </select>
  208. <select id="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxPropertyContract">
  209. select count(id) from wx_property_contract where status in (2,3,4)
  210. <if test=" null != tenantId and '' != tenantId">
  211. and `tenant_id` = #{tenantId}
  212. </if>
  213. <if test=" null != parentTenantId and '' != parentTenantId">
  214. and `parent_tenant_id` = #{parentTenantId}
  215. </if>
  216. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  217. </select>
  218. <select id="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxPropertyContract">
  219. select count(id) from wx_property_contract where status!=1 and status!=6 and status!=7 and rental_end_date &lt;now()
  220. <if test=" null != tenantId and '' != tenantId">
  221. and `tenant_id` = #{tenantId}
  222. </if>
  223. <if test=" null != parentTenantId and '' != parentTenantId">
  224. and `parent_tenant_id` = #{parentTenantId}
  225. </if>
  226. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  227. </select>
  228. <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  229. update wx_property_contract set status=#{status} where status!=1 and status!=5 and status!=6 and status!=7
  230. <if test=" null != tenantId and '' != tenantId">
  231. and `tenant_id` = #{tenantId}
  232. </if>
  233. <if test=" null != parentTenantId and '' != parentTenantId">
  234. and `parent_tenant_id` = #{parentTenantId}
  235. </if>
  236. and DATEDIFF(rental_end_date,now()) &lt;= 30 and rental_end_date > now()
  237. </update>
  238. <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  239. update wx_property_contract set status=#{status} where status!=1 and status!=5 and status!=6 and status!=7
  240. <if test=" null != tenantId and '' != tenantId">
  241. and `tenant_id` = #{tenantId}
  242. </if>
  243. <if test=" null != parentTenantId and '' != parentTenantId">
  244. and `parent_tenant_id` = #{parentTenantId}
  245. </if>
  246. and rental_start_date &lt;= now() and rental_end_date >= now()
  247. </update>
  248. <update id="updateRentContractEndStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  249. update wx_property_contract set status=#{status} where status!=1 and status!=5 and status!=6 and status!=7
  250. <if test=" null != tenantId and '' != tenantId">
  251. and `tenant_id` = #{tenantId}
  252. </if>
  253. <if test=" null != parentTenantId and '' != parentTenantId">
  254. and `parent_tenant_id` = #{parentTenantId}
  255. </if>
  256. and rental_end_date &lt;now()
  257. </update>
  258. <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  259. update wx_property_contract set status=#{status} where status!=7
  260. <if test=" null != tenantId and '' != tenantId">
  261. and `tenant_id` = #{tenantId}
  262. </if>
  263. <if test=" null != parentTenantId and '' != parentTenantId">
  264. and `parent_tenant_id` = #{parentTenantId}
  265. </if>
  266. and merchant_id is null
  267. </update>
  268. <!-- <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  269. update wx_property_contract set status=#{status} where shop_id in (
  270. select s.shop_id from (SELECT shop_id FROM wx_property_contract WHERE merchant_id is not null and status!=6
  271. <if test=" null != tenantId and '' != tenantId">
  272. and `tenant_id` = #{tenantId}
  273. </if>
  274. <if test=" null != parentTenantId and '' != parentTenantId">
  275. and `parent_tenant_id` = #{parentTenantId}
  276. </if>
  277. )s) and merchant_id is null
  278. <if test=" null != tenantId and '' != tenantId">
  279. and `tenant_id` = #{tenantId}
  280. </if>
  281. <if test=" null != parentTenantId and '' != parentTenantId">
  282. and `parent_tenant_id` = #{parentTenantId}
  283. </if>
  284. </update> -->
  285. <!-- <select id="getRentContractListByShop" parameterType="hashmap" resultType="com.iformall.domain.po.WxRentContract">
  286. select rc.* from wx_rent_contract rc
  287. where rc.status not in(0,1,5,6,7,8)
  288. <if test=" null != tenantId and '' != tenantId">
  289. and rc.`tenant_id` = #{tenantId}
  290. </if>
  291. <if test=" null != parentTenantId and '' != parentTenantId">
  292. and rc.`parent_tenant_id` = #{parentTenantId}
  293. </if>
  294. and rc.id not in (select pc.rent_contract_id from (
  295. select rent_contract_id from wx_property_contract where status not in(5,6,7)
  296. <if test=" null != tenantId and '' != tenantId">
  297. and `tenant_id` = #{tenantId}
  298. </if>
  299. <if test=" null != parentTenantId and '' != parentTenantId">
  300. and `parent_tenant_id` = #{parentTenantId}
  301. </if>
  302. ) pc)
  303. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  304. </select> -->
  305. <!-- <select id="getRentContractListByPoint" parameterType="hashmap" resultType="com.iformall.domain.po.WxRentContract">
  306. select rc.*,s.shop_number from wx_rent_contract rc
  307. inner join wx_shop s on rc.shop_id=s.id
  308. where rc.status not in(0,1,5,6,7,8)
  309. <if test=" null != tenantId and '' != tenantId">
  310. and rc.`tenant_id` = #{tenantId}
  311. </if>
  312. <if test=" null != parentTenantId and '' != parentTenantId">
  313. and rc.`parent_tenant_id` = #{parentTenantId}
  314. </if>
  315. and rc.id not in (select pc.rent_contract_id from (
  316. select rent_contract_id from wx_property_contract where status not in(5,6,7)
  317. <if test=" null != tenantId and '' != tenantId">
  318. and `tenant_id` = #{tenantId}
  319. </if>
  320. <if test=" null != parentTenantId and '' != parentTenantId">
  321. and `parent_tenant_id` = #{parentTenantId}
  322. </if>
  323. ) pc)
  324. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  325. </select> -->
  326. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  327. update wx_property_contract set apply_status=#{applyStatus}
  328. <if test=" null != businessType ">,business_type=#{businessType}</if>
  329. <if test=" null != status ">,status=#{status}</if>
  330. where id=#{id}
  331. </update>
  332. <update id="updateApplyStatusByRentContractId" parameterType="com.iformall.domain.po.WxPropertyContract">
  333. update wx_property_contract set apply_status=#{applyStatus}
  334. <if test=" null != businessType ">,business_type=#{businessType}</if>
  335. <if test=" null != status ">,status=#{status}</if>
  336. where rent_contract_id=#{rentContractId}
  337. </update>
  338. <update id="updateStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  339. update wx_property_contract set status=#{status} where id=#{id}
  340. </update>
  341. <update id="updateStatusByRentContractId" parameterType="com.iformall.domain.po.WxPropertyContract">
  342. update wx_property_contract set status=#{status} where rent_contract_id=#{rentContractId}
  343. </update>
  344. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxPropertyContract" resultType="Long">
  345. select count(*) from wx_property_contract r,wx_bill_property b
  346. where b.property_contract_id = r.id and b.status = 1
  347. <if test=" null != id ">and r.id = #{id}</if>
  348. <if test=" null != rentContractId ">and r.rent_contract_id = #{rentContractId}</if>
  349. </select>
  350. <select id="findOneByRentId" parameterType="com.iformall.domain.po.WxRentContract" resultType="com.iformall.domain.po.WxPropertyContract">
  351. select * from wx_property_contract where rent_contract_id =#{id} order by createtime desc limit 1
  352. </select>
  353. <select id="getByBill" parameterType="com.iformall.domain.po.WxBillProperty" resultMap="BaseResultMap">
  354. select * from wx_property_contract where id in(
  355. select property_contract_id from wx_bill_property id = #{id}
  356. )
  357. </select>
  358. <update id="endContract" parameterType="com.iformall.domain.po.WxPropertyContract">
  359. update wx_property_contract set status=#{status},updatetime = #{updatetime} where rent_contract_id =#{rentContractId}
  360. <if test=" null != statuss ">
  361. and status in
  362. <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
  363. #{statusItem}
  364. </foreach>
  365. </if>
  366. </update>
  367. </mapper>