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.
 
 
 
 
 

238 lines
13 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="INTEGER" 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. <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. </resultMap>
  46. <sql id="allColumns">
  47. `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,
  48. `sign_date`,`receive_period`,`tenant_id`,`filepath`,`status`,`contract_number`,
  49. `deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`,
  50. `shop_type`,`shop_id`,`updatetime`,`createtime`,`rent_area`,
  51. `link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`,
  52. `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio,`rent_info`,
  53. `file_names`,price_unit,rent_price,subject_name,rent_start_type
  54. </sql>
  55. <sql id="dynamicWhereConditions">
  56. where 1 = 1
  57. <if test=" null != id ">and `id` = #{id}</if>
  58. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  59. <if test=" null != price ">and `price` = #{price}</if>
  60. <if test=" null != rentalStartDate ">and `rental_start_date` = #{rentalStartDate}</if>
  61. <if test=" null != rentalEndDate ">and `rental_end_date` = #{rentalEndDate}</if>
  62. <if test=" null != signDate ">and `sign_date` = #{signDate}</if>
  63. <if test=" null != receivePeriod ">and `receive_period` = #{receivePeriod}</if>
  64. <if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if>
  65. <if test=" null != filepath ">and `filepath` = #{filepath}</if>
  66. <if test=" null != status ">and `status` = #{status}</if>
  67. <if test=" null != contractNumber ">and `contract_number` = #{contractNumber}</if>
  68. <if test=" null != deposit ">and `deposit` = #{deposit}</if>
  69. <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
  70. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  71. <if test=" null != merchantName ">and `merchant_name` = #{merchantName}</if>
  72. <if test=" null != brand ">and `brand` = #{brand}</if>
  73. <if test=" null != businessId ">and `business_id` = #{businessId}</if>
  74. <if test=" null != shopType ">and `shop_type` = #{shopType}</if>
  75. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  76. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  77. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  78. <if test=" null != rentArea ">and `rent_area` = #{rentArea}</if>
  79. <if test=" null != linkPerson ">and `link_person` = #{linkPerson}</if>
  80. <if test=" null != linkPhone ">and `link_phone` = #{linkPhone}</if>
  81. <if test=" null != payAccount ">and `pay_account` = #{payAccount}</if>
  82. <if test=" null != filename ">and `filename` = #{filename}</if>
  83. <if test=" null != lease ">and `lease` = #{lease}</if>
  84. <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
  85. <if test=" null != startDate ">and `start_date` = #{startDate}</if>
  86. <if test=" null != endDate ">and `end_date` = #{endDate}</if>
  87. <if test=" null != rentShopType">and `rent_shop_type` = #{rentShopType}</if>
  88. <if test=" null != ids ">
  89. and id in
  90. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  91. #{idItem}
  92. </foreach>
  93. </if>
  94. <if test=" null != sortColumns">order by ${sortColumns}</if>
  95. </sql>
  96. <select id="findList" parameterType="com.iformall.domain.po.WxPropertyContract" resultMap="BaseResultMap">
  97. select
  98. <include refid="allColumns"/>
  99. from wx_property_contract
  100. <include refid="dynamicWhereConditions"/>
  101. </select>
  102. <select id="queryPropertyContractData" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
  103. select rc.id,rc.merchant_name merchantName,rc.rental_start_date rentalStartDate,rc.rental_end_date
  104. rentalEndDate,rc.`status`,rc.price,rc.contract_number contractNumber,s.shop_number shopNumber,
  105. f.floor_name floorName,b.building_name buildingName,receive_period receivePeriod,
  106. rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate,
  107. start_date startDate,end_date endDate,rc.rent_contract_id rentContractId,br.`name` brandName,
  108. s.addr,rc.apply_status applyStatus,rc.adjust_period adjustPeriod,rc.business_type businessType,
  109. rc.adjust_ratio adjustRatio,rc.rent_info rentInfo, rc.file_names fileNames,rc.price_unit,rc.subject_name
  110. subjectName
  111. from wx_property_contract rc
  112. left join wx_shop s on rc.shop_id=s.id
  113. left join wx_mall_floor f on s.floor=f.id
  114. left join wx_mall_building b on s.building=b.id
  115. left join wx_brand br on rc.brand=br.id
  116. <where>
  117. <if test=" null != tenantId ">rc.tenant_id=#{tenantId}</if>
  118. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like
  119. concat('%',#{merchantName},'%')
  120. </if>
  121. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  122. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  123. </if>
  124. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  125. and s.`shop_number` like concat('%',#{shopNumber},'%')
  126. </if>
  127. <if test=" null != status ">and rc.`status` = #{status}</if>
  128. <if test=" null != rentContractId">and rc.`rent_contract_id` = #{rentContractId}</if>
  129. <if test=" null != id">and rc.`id` = #{id}</if>
  130. <if test=" null != rentShopType">and rc.`rent_shop_type` = #{rentShopType}</if>
  131. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  132. <if test=" null != building and ''!= building">and b.id = #{building}</if>
  133. <if test=" null != floor and ''!= floor">and f.id = #{floor}</if>
  134. </where>
  135. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  136. <if test=" null == sortColumns">order by rc.id desc</if>
  137. </select>
  138. <select id="queryRentContractWaitSignStatus" resultType="int"
  139. parameterType="com.iformall.domain.po.WxPropertyContract">
  140. select count(id) from wx_property_contract where tenant_id=#{tenantId} and status=#{status}
  141. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  142. </select>
  143. <select id="queryRentContractEndSoonStatus" resultType="int"
  144. parameterType="com.iformall.domain.po.WxPropertyContract">
  145. select count(id) from wx_property_contract where tenant_id=#{tenantId} and status=4
  146. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  147. </select>
  148. <select id="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxPropertyContract">
  149. select count(id) from wx_property_contract where tenant_id=#{tenantId} and status in (2,3,4)
  150. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  151. </select>
  152. <select id="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxPropertyContract">
  153. select count(id) from wx_property_contract where tenant_id=#{tenantId}
  154. and status!=1 and status!=6 and status!=7 and rental_end_date &lt;now()
  155. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  156. </select>
  157. <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  158. update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=5 and status!=6 and status!=7 and DATEDIFF(rental_end_date,now()) &lt;= 30 and rental_end_date > now()
  159. </update>
  160. <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  161. update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=5 and status!=6 and status!=7 and rental_start_date &lt;= now() and rental_end_date >= now()
  162. </update>
  163. <update id="updateRentContractEndStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  164. update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=5 and status!=6 and status!=7 and rental_end_date &lt;now()
  165. </update>
  166. <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  167. update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=7 and merchant_id is null
  168. </update>
  169. <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  170. update wx_property_contract set status=#{status} where shop_id in (
  171. 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
  172. )s) and merchant_id is null and tenant_id=#{tenantId}
  173. </update>
  174. <select id="getRentContractListByShop" parameterType="hashmap" resultType="com.iformall.domain.po.WxRentContract">
  175. select rc.* from wx_rent_contract rc
  176. where rc.status not in(0,1,5,6,7) and rc.tenant_id=#{tenantId}
  177. and rc.id not in (select pc.rent_contract_id from (
  178. select rent_contract_id from wx_property_contract where status not in(5,6,7) and tenant_id=#{tenantId}
  179. ) pc)
  180. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  181. </select>
  182. <select id="getRentContractListByPoint" parameterType="hashmap" resultType="com.iformall.domain.po.WxRentContract">
  183. select rc.*,s.shop_number from wx_rent_contract rc
  184. inner join wx_shop s on rc.shop_id=s.id
  185. where rc.status not in(0,1,5,6,7) and rc.tenant_id=#{tenantId}
  186. and rc.id not in (select pc.rent_contract_id from (
  187. select rent_contract_id from wx_property_contract where status not in(5,6,7) and tenant_id=#{tenantId}
  188. ) pc)
  189. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  190. </select>
  191. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  192. update wx_property_contract set apply_status=#{applyStatus}
  193. <if test=" null != businessType ">,business_type=#{businessType}</if>
  194. <if test=" null != status ">,status=#{status}</if>
  195. where id=#{id}
  196. </update>
  197. <update id="updateStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
  198. update wx_property_contract set status=#{status} where id=#{id}
  199. </update>
  200. <update id="updateStatusByRentContractId" parameterType="com.iformall.domain.po.WxPropertyContract">
  201. update wx_property_contract set status=#{status} where rent_contract_id=#{rentContractId}
  202. </update>
  203. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxPropertyContract" resultType="Long">
  204. select count(*) from wx_property_contract r,wx_bill_property b
  205. where b.property_contract_id = r.id and b.status = 1
  206. <if test=" null != id ">and r.id = #{id}</if>
  207. <if test=" null != rentContractId ">and r.rent_contract_id = #{rentContractId}</if>
  208. </select>
  209. <select id="findOneByRentId" parameterType="com.iformall.domain.po.WxRentContract" resultType="com.iformall.domain.po.WxPropertyContract">
  210. select * from wx_property_contract where rent_contract_id =#{id} order by createtime desc limit 1
  211. </select>
  212. </mapper>