后台服务
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.

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