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.
 
 
 
 
 

160 rivejä
9.2 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="filepath" jdbcType="VARCHAR" property="filepath"/>
  14. <result column="status" jdbcType="INTEGER" property="status"/>
  15. <result column="contract_number" jdbcType="VARCHAR" property="contractNumber"/>
  16. <result column="deposit" jdbcType="INTEGER" property="deposit"/>
  17. <result column="pay_date" jdbcType="INTEGER" property="payDate"/>
  18. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  19. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
  20. <result column="brand" jdbcType="VARCHAR" property="brand"/>
  21. <result column="business_id" jdbcType="BIGINT" property="businessId"/>
  22. <result column="shop_type" jdbcType="INTEGER" property="shopType"/>
  23. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  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. </resultMap>
  34. <sql id="allColumns">
  35. `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,`tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`rent_area`,`link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`
  36. </sql>
  37. <sql id="dynamicWhereConditions">
  38. where 1 = 1
  39. <if test=" null != id ">and `id` = #{id}</if>
  40. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  41. <if test=" null != price ">and `price` = #{price}</if>
  42. <if test=" null != rentalStartDate ">and `rental_start_date` = #{rentalStartDate}</if>
  43. <if test=" null != rentalEndDate ">and `rental_end_date` = #{rentalEndDate}</if>
  44. <if test=" null != signDate ">and `sign_date` = #{signDate}</if>
  45. <if test=" null != receivePeriod ">and `receive_period` = #{receivePeriod}</if>
  46. <if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if>
  47. <if test=" null != filepath ">and `filepath` = #{filepath}</if>
  48. <if test=" null != status ">and `status` = #{status}</if>
  49. <if test=" null != contractNumber ">and `contract_number` = #{contractNumber}</if>
  50. <if test=" null != deposit ">and `deposit` = #{deposit}</if>
  51. <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
  52. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  53. <if test=" null != merchantName ">and `merchant_name` = #{merchantName}</if>
  54. <if test=" null != brand ">and `brand` = #{brand}</if>
  55. <if test=" null != businessId ">and `business_id` = #{businessId}</if>
  56. <if test=" null != shopType ">and `shop_type` = #{shopType}</if>
  57. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  58. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  59. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  60. <if test=" null != rentArea ">and `rent_area` = #{rentArea}</if>
  61. <if test=" null != linkPerson ">and `link_person` = #{linkPerson}</if>
  62. <if test=" null != linkPhone ">and `link_phone` = #{linkPhone}</if>
  63. <if test=" null != payAccount ">and `pay_account` = #{payAccount}</if>
  64. <if test=" null != filename ">and `filename` = #{filename}</if>
  65. <if test=" null != lease ">and `lease` = #{lease}</if>
  66. <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
  67. <if test=" null != ids ">
  68. and id in
  69. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  70. #{idItem}
  71. </foreach>
  72. </if>
  73. <if test=" null != sortColumns">order by ${sortColumns}</if>
  74. </sql>
  75. <select id="findList" parameterType="com.iformall.domain.po.WxPropertyContract" resultMap="BaseResultMap">
  76. select
  77. <include refid="allColumns"/>
  78. from wx_property_contract
  79. <include refid="dynamicWhereConditions"/>
  80. </select>
  81. <select id="queryPropertyContractData" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
  82. select rc.id,rc.merchant_name merchantName,rc.rental_start_date rentalStartDate,rc.rental_end_date
  83. rentalEndDate,rc.`status`,
  84. rc.price,rc.contract_number contractNumber,s.shop_number shopNumber,f.floor_name floorName,b.building_name
  85. buildingName,
  86. rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate
  87. from wx_property_contract rc
  88. left join wx_shop s on rc.shop_id=s.id
  89. left join wx_mall_floor f on s.floor=f.id
  90. left join wx_mall_building b on s.building=b.id
  91. <where>
  92. rc.tenant_id=#{tenantId}
  93. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like
  94. concat('%',#{merchantName},'%')
  95. </if>
  96. <if test=" null != shopNumber and shopNumber!=''">and s.`shop_number` like concat('%',#{shopNumber},'%')
  97. </if>
  98. <if test=" null != status ">and rc.`status` = #{status}</if>
  99. <if test=" null != rentContractId">and rc.`rent_contract_id` = #{rentContractId}</if>
  100. <if test=" null != id">and rc.`id` = #{id}</if>
  101. </where>
  102. order by rc.id desc
  103. </select>
  104. <select id="queryRentContractWaitSignStatus" resultType="int"
  105. parameterType="com.iformall.domain.po.WxPropertyContract">
  106. select count(id) from wx_property_contract where tenant_id=#{tenantId} and status=#{status}
  107. </select>
  108. <select id="queryRentContractEndSoonStatus" resultType="int"
  109. parameterType="com.iformall.domain.po.WxPropertyContract">
  110. select count(id) from wx_property_contract where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and DATEDIFF(rental_end_date,now()) &lt;= 30 and rental_end_date > now()
  111. </select>
  112. <select id="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxPropertyContract">
  113. select count(id) from wx_property_contract where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and rental_start_date &lt;= now() and rental_end_date >= now()
  114. </select>
  115. <select id="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxPropertyContract">
  116. select count(id) from wx_property_contract where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and rental_end_date &lt;now()
  117. </select>
  118. <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  119. update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and DATEDIFF(rental_end_date,now()) &lt;= 30 and rental_end_date > now()
  120. </update>
  121. <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  122. update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and rental_start_date &lt;= now() and rental_end_date >= now()
  123. </update>
  124. <update id="updateRentContractEndStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  125. update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and rental_end_date &lt;now()
  126. </update>
  127. <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  128. update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=7 and merchant_id is null
  129. </update>
  130. <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  131. update wx_property_contract set status=#{status} where shop_id in (
  132. select s.shop_id from (SELECT shop_id FROM wx_property_contract WHERE tenant_id = #{tenantId} and merchant_id is not null and status!=6
  133. )s) and merchant_id is null and tenant_id=#{tenantId}
  134. </update>
  135. <select id="getRentContractList" parameterType="hashmap" resultType="com.iformall.domain.po.WxRentContract">
  136. select rc.*,s.shop_number from wx_rent_contract rc inner join wx_shop s on rc.shop_id=s.id
  137. where rc.status not in(1,5,6,7) and rc.tenant_id=#{tenantId}
  138. and rc.id not in (select pc.rent_contract_id from (
  139. select rent_contract_id from wx_property_contract where status not in(1,5,6,7) and tenant_id=#{tenantId}
  140. ) pc)
  141. </select>
  142. </mapper>