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.
 
 
 
 
 

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