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.
 
 
 
 
 

378 lines
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.WxRentContractMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxRentContract">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  8. <result column="agile_type" jdbcType="INTEGER" property="agileType"/>
  9. <result column="customers_id" jdbcType="BIGINT" property="customersId"/>
  10. <result column="decimal_size" jdbcType="INTEGER" property="decimalSize"/>
  11. <result column="price" jdbcType="VARCHAR" property="price"/>
  12. <result column="rental_start_date" jdbcType="TIMESTAMP" property="rentalStartDate"/>
  13. <result column="rental_end_date" jdbcType="TIMESTAMP" property="rentalEndDate"/>
  14. <result column="sign_date" jdbcType="TIMESTAMP" property="signDate"/>
  15. <result column="receive_period" jdbcType="INTEGER" property="receivePeriod"/>
  16. <result column="receive_period_unit" jdbcType="INTEGER" property="receivePeriodUnit"/>
  17. <result column="pay_period_rate" jdbcType="INTEGER" property="payPeriodRate"/>
  18. <result column="filepath" jdbcType="VARCHAR" property="filepath"/>
  19. <result column="status" jdbcType="INTEGER" property="status"/>
  20. <result column="contract_number" jdbcType="VARCHAR" property="contractNumber"/>
  21. <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
  22. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  23. <result column="create_by_name" jdbcType="VARCHAR" property="createByName"/>
  24. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
  25. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  26. <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/>
  27. <result column="deposit" jdbcType="VARCHAR" property="deposit"/>
  28. <result column="cashtype_content_lsit" jdbcType="VARCHAR" property="cashtypeContentLsit"/>
  29. <result column="cashtype_lsit" jdbcType="VARCHAR" property="cashtypeLsit"/>
  30. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  31. <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/>
  32. <result column="link_phone" jdbcType="VARCHAR" property="linkPhone"/>
  33. <result column="pay_account" jdbcType="VARCHAR" property="payAccount"/>
  34. <result column="link_address" jdbcType="VARCHAR" property="linkAddress"/>
  35. <result column="filename" jdbcType="VARCHAR" property="filename"/>
  36. <result column="lease" jdbcType="INTEGER" property="lease"/>
  37. <result column="type" jdbcType="INTEGER" property="type"/>
  38. <result column="revenue" jdbcType="VARCHAR" property="revenue"/>
  39. <result column="revenue_ratio" jdbcType="INTEGER" property="revenueRatio"/>
  40. <result column="revenue_ratio_way" jdbcType="INTEGER" property="revenueRatioWay"/>
  41. <result column="revenue_ratio_set" jdbcType="VARCHAR" property="revenueRatioSet"/>
  42. <result column="adjust_ratio" jdbcType="VARCHAR" property="adjustRatio"/>
  43. <result column="adjust_period" jdbcType="INTEGER" property="adjustPeriod"/>
  44. <result column="pay_ratio" jdbcType="INTEGER" property="payRatio"/>
  45. <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/>
  46. <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/>
  47. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  48. <result column="bank_name" jdbcType="VARCHAR" property="bankName"/>
  49. <result column="fix_start_date" property="fixStartDate"/>
  50. <result column="fix_end_date" property="fixEndDate"/>
  51. <result column="business_type" property="businessType"/>
  52. <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
  53. <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
  54. <result column="price_unit" property="priceUnit"/>
  55. <result column="rent_price" property="rentPrice"/>
  56. <result column="other_rent_price_info" jdbcType="VARCHAR" property="otherRentPriceInfo"/>
  57. <result column="subject_name" property="subjectName"/>
  58. <result column="rent_start_type" property="rentStartType"/>
  59. <result column="from_id" property="fromId"/>
  60. <result column="rent_input_way" property="rentInputWay"/>
  61. <result column="adjust_ratio_way" property="adjustRatioWay"/>
  62. <result column="operation_type" property="operationType"/>
  63. <result column="late_pay_ratio" property="latePayRatio"/>
  64. <result column="late_pay_day" property="latePayDay"/>
  65. <result column="end_contract_time" jdbcType="TIMESTAMP" property="endContractTime"/>
  66. <result column="bussiness_management_fee" jdbcType="VARCHAR" property="bussinessManagementFee"/>
  67. <result column="bussiness_management_fee_ratio_way" jdbcType="INTEGER" property="bussinessManagementFeeRatioWay"/>
  68. <result column="bussiness_management_fee_ratio" jdbcType="VARCHAR" property="bussinessManagementFeeRatio"/>
  69. <result column="operating_management_fee" jdbcType="VARCHAR" property="operatingManagementFee"/>
  70. <result column="operating_management_fee_ratio_way" jdbcType="INTEGER" property="operatingManagementFeeRatioWay"/>
  71. <result column="operating_management_fee_ratio" jdbcType="VARCHAR" property="operatingManagementFeeRatio"/>
  72. <result column="out_date_notify_days" jdbcType="INTEGER" property="outDateNotifyDays"/>
  73. <result column="out_date_notify_phone" jdbcType="VARCHAR" property="outDateNotifyPhone"/>
  74. <result column="design_file" jdbcType="VARCHAR" property="designFile"/>
  75. <result column="price_detail" jdbcType="VARCHAR" property="priceDetail"/>
  76. <result column="day_price_calcute" jdbcType="INTEGER" property="dayPriceCalcute"/>
  77. <result column="month_average_days" jdbcType="INTEGER" property="monthAverageDays"/>
  78. <result column="revenue_fixed_rent_price" jdbcType="INTEGER" property="revenueFixedRentPrice"/>
  79. <result column="revenue_rent_price" jdbcType="VARCHAR" property="revenueRentPrice"/>
  80. <result column="revenue_jumps_remark" jdbcType="VARCHAR" property="revenueJumpsRemark"/>
  81. <result column="free_period_remark" jdbcType="VARCHAR" property="freePeriodRemark"/>
  82. <result column="first_bill_date_start" jdbcType="TIMESTAMP" property="firstBillDateStart"/>
  83. <result column="first_bill_date_end" jdbcType="TIMESTAMP" property="firstBillDateEnd"/>
  84. <result column="first_bill_receive_date" jdbcType="TIMESTAMP" property="firstBillReceiveDate"/>
  85. <result column="shop_id_str" jdbcType="VARCHAR" property="shopIdStr"/>
  86. </resultMap>
  87. <sql id="allColumns">
  88. `id`,`agile_type`,`customers_id`,`tenant_id`,`parent_tenant_id`,
  89. `decimal_size`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,`receive_period_unit`,
  90. `filepath`,`status`,`contract_number`,`price_detail`,`create_by`,`update_by`,
  91. `day_price_calcute`,`first_bill_date_start`,`first_bill_date_end`,`month_average_days`,`free_period_remark`,
  92. `deposit`,cashtype_content_lsit,cashtype_lsit,`is_del`,`revenue_jumps_remark`,
  93. `updatetime`,`createtime`,`link_person`,`link_phone`,`link_address`,
  94. `pay_account`,`filename`,`lease`,`type`,`revenue`,`revenue_ratio`,`revenue_ratio_way`,`revenue_ratio_set`,`adjust_ratio`,`adjust_period`,`pay_ratio`,
  95. `start_date`,`end_date`,`from_id`,`end_contract_time`,`revenue_fixed_rent_price`,`revenue_rent_price`,
  96. `apply_status`,`bank_name`,`fix_start_date`,`fix_end_date`,`pay_period_rate`,`create_by_name`,`update_by_name`,
  97. `business_type`,`rent_info`, `file_names`,price_unit,rent_price,other_rent_price_info,`subject_name`,rent_start_type,
  98. `rent_input_way`,`adjust_ratio_way`,`operation_type`,late_pay_ratio,late_pay_day,first_bill_receive_date,
  99. bussiness_management_fee,bussiness_management_fee_ratio_way,bussiness_management_fee_ratio,shop_id_str,
  100. operating_management_fee,operating_management_fee_ratio_way,operating_management_fee_ratio,out_date_notify_days,out_date_notify_phone,design_file
  101. </sql>
  102. <sql id="dynamicWhereConditions">
  103. where 1 = 1
  104. <if test=" null != id ">and `id` = #{id}</if>
  105. <if test=" null != fromId ">and `from_id` = #{fromId}</if>
  106. <if test=" null != agileType">and `agile_type` = #{agileType}</if>
  107. <if test=" null != customersId ">and `customers_id` = #{customersId}</if>
  108. <if test=" null != price and '' != price">and `price` = #{price}</if>
  109. <if test=" null != rentalStartDate and '' != rentalStartDate">and `rental_start_date` = #{rentalStartDate}</if>
  110. <if test=" null != rentalEndDate and '' != rentalEndDate">and `rental_end_date` = #{rentalEndDate}</if>
  111. <if test=" null != outDateNofity ">and out_date_notify_phone is not null and out_date_notify_phone != '' and out_date_notify_days is not null and out_date_notify_days &gt; 0 </if>
  112. <if test=" null != signDate and '' != signDate">and `sign_date` = #{signDate}</if>
  113. <if test=" null != receivePeriod and '' != receivePeriod">and `receive_period` = #{receivePeriod}</if>
  114. <if test=" null != receivePeriodUnit and '' != receivePeriodUnit">and `receive_period_unit` = #{receivePeriodUnit}</if>
  115. <if test=" null != payPeriodRate and '' != payPeriodRate">and `pay_period_rate` = #{payPeriodRate}</if>
  116. <if test=" null != tenantId and '' != tenantId">
  117. and `tenant_id` = #{tenantId}
  118. </if>
  119. <if test=" null != parentTenantId and '' != parentTenantId">
  120. and `parent_tenant_id` = #{parentTenantId}
  121. </if>
  122. <if test=" null != filepath and '' != filepath">and `filepath` = #{filepath}</if>
  123. <if test=" null != status and '' != status">and `status` = #{status}</if>
  124. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  125. <if test=" null != contractNumber and '' != contractNumber">and `contract_number` = #{contractNumber}</if>
  126. <if test=" null != deposit and '' != deposit">and `deposit` = #{deposit}</if>
  127. <if test=" null != isDel and '' != isDel">and `is_del` = #{isDel}</if>
  128. <if test=" null != updatetime and '' != updatetime">and `updatetime` = #{updatetime}</if>
  129. <if test=" null != createtime and '' != createtime">and `createtime` = #{createtime}</if>
  130. <if test=" null != linkPerson and '' != linkPerson">and `link_person` = #{linkPerson}</if>
  131. <if test=" null != linkPhone and '' != linkPhone">and `link_phone` = #{linkPhone}</if>
  132. <if test=" null != payAccount and '' != payAccount">and `pay_account` = #{payAccount}</if>
  133. <if test=" null != filename and '' != filename">and `filename` = #{filename}</if>
  134. <if test=" null != lease and '' != lease">and `lease` = #{lease}</if>
  135. <if test=" null != type and '' != type">and `type` = #{type}</if>
  136. <if test=" null != startDate and '' != startDate">and `start_date` = #{startDate}</if>
  137. <if test=" null != endDate and '' != endDate">and `end_date` = #{endDate}</if>
  138. <if test=" null != operationType and '' != operationType">and `operation_type` = #{operationType}</if>
  139. <if test=" null != queryShopId and '' != queryShopId">and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{queryShopId},'"'))</if>
  140. <if test=" null != dayPriceCalcute ">and `day_price_calcute` = #{dayPriceCalcute}</if>
  141. <if test=" null != monthAverageDays ">and `month_average_days` = #{monthAverageDays}</if>
  142. <if test=" null != revenueFixedRentPrice ">and `revenue_fixed_rent_price` = #{revenueFixedRentPrice}</if>
  143. <if test=" null != queryShopId">
  144. and concat(',',shop_id_str,',') like concat('%,',#{queryShopId},',%')
  145. </if>
  146. <if test=" null != customersIdList ">
  147. and customers_id in
  148. <foreach collection="customersIdList" index="index" item="cusItem" open="(" separator="," close=")">
  149. #{cusItem}
  150. </foreach>
  151. </if>
  152. <if test=" null != statuss ">
  153. and status in
  154. <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
  155. #{statusItem}
  156. </foreach>
  157. </if>
  158. <if test=" null != typeList ">
  159. and type in
  160. <foreach collection="typeList" index="index" item="typeItem" open="(" separator="," close=")">
  161. #{typeItem}
  162. </foreach>
  163. </if>
  164. <if test=" null != ids ">
  165. and id in
  166. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  167. #{idItem}
  168. </foreach>
  169. </if>
  170. <if test=" null != sortColumns">order by ${sortColumns}</if>
  171. </sql>
  172. <select id="findList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  173. select
  174. <include refid="allColumns"/>
  175. from wx_rent_contract
  176. <include refid="dynamicWhereConditions"/>
  177. </select>
  178. <select id="findCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="java.lang.Long">
  179. select count(id)
  180. from wx_rent_contract
  181. where status=#{status}
  182. <if test=" null != tenantId and '' != tenantId">
  183. and `tenant_id` = #{tenantId}
  184. </if>
  185. <if test=" null != parentTenantId and '' != parentTenantId">
  186. and `parent_tenant_id` = #{parentTenantId}
  187. </if>
  188. </select>
  189. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract">
  190. update wx_rent_contract
  191. set apply_status=#{applyStatus}
  192. <if test=" null != businessType ">,business_type=#{businessType}</if>
  193. <if test=" null != status ">,status=#{status}</if>
  194. where id=#{id}
  195. </update>
  196. <update id="updateStatus" parameterType="com.iformall.domain.po.WxRentContract">
  197. update wx_rent_contract set status=#{status} where id=#{id}
  198. </update>
  199. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  200. select count(1) from wx_rent_contract r,wx_all_bill b
  201. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  202. </select>
  203. <select id="selectRentContractCountByShopId" parameterType="java.util.Map" resultType="int">
  204. select count(1) from wx_rent_contract where 1=1
  205. <if test=" null != tenantId and '' != tenantId">
  206. and `tenant_id` = #{tenantId}
  207. </if>
  208. <if test=" null != parentTenantId and '' != parentTenantId">
  209. and `parent_tenant_id` = #{parentTenantId}
  210. </if>
  211. and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{shopId},'"')) and status in (2,3,4)
  212. <if test="id!=null">
  213. and id!=#{id}
  214. </if>
  215. </select>
  216. <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract"
  217. resultType="int">
  218. select count(1) from (
  219. select * from wx_rent_contract where contract_number=#{contractNumber}
  220. and status not in(5,6,7)
  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. union
  228. select * from wx_rent_contract where contract_number=#{contractNumber}
  229. and apply_status in(1,2)
  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. ) r
  237. <where>
  238. <if test="id!=null and id!=''">
  239. r.id!=#{id}
  240. </if>
  241. </where>
  242. </select>
  243. <resultMap id="contractMap" type="com.iformall.domain.vo.WxRentPropertyContractVo">
  244. <id column="id" property="id"/>
  245. <result column="tenant_id" property="tenantId"/>
  246. <result column="parent_tenant_id" property="parentTenantId"/>
  247. <result column="customers_id" jdbcType="BIGINT" property="customersId"/>
  248. <result column="rent_id" property="rentId"/>
  249. <result column="property_id" property="propertyId"/>
  250. <result column="rent_info" property="rentInfo"/>
  251. <result column="rental_start_date" property="rentalStartDate"/>
  252. <result column="rental_end_date" property="rentalEndDate"/>
  253. <result column="rent_price" property="rentPrice"/>
  254. <result column="price_detail" property="priceDetail"/>
  255. <result column="property_price" property="propertyPrice"/>
  256. <result column="type" property="type"/>
  257. <result column="status" property="status"/>
  258. <result column="apply_status" property="applyStatus"/>
  259. <result column="operation_type" property="operationType"/>
  260. <result column="property_status" property="propertyStatus"/>
  261. <result column="rent_price_unit" property="rentPriceUnit"/>
  262. <result column="property_price_unit" property="propertyPriceUnit"/>
  263. <result column="day_price_calcute" property="dayPriceCalcute"/>
  264. <result column="month_average_days" property="monthAverageDays"/>
  265. <result column="revenue_fixed_rent_price" jdbcType="INTEGER" property="revenueFixedRentPrice"/>
  266. <result column="revenue_rent_price" jdbcType="VARCHAR" property="revenueRentPrice"/>
  267. <result column="revenue_jumps_remark" jdbcType="VARCHAR" property="revenueJumpsRemark"/>
  268. <result column="free_period_remark" jdbcType="VARCHAR" property="freePeriodRemark"/>
  269. <result column="first_bill_date_start" jdbcType="TIMESTAMP" property="firstBillDateStart"/>
  270. <result column="first_bill_date_end" jdbcType="TIMESTAMP" property="firstBillDateEnd"/>
  271. </resultMap>
  272. <select id="listContractVo" parameterType="com.iformall.domain.vo.WxRentPropertyContractVo" resultMap="contractMap">
  273. select rc.id,rc.tenant_id,rc.parent_tenant_id,rc.customers_id,rc.id as rent_id, pc.id as property_id, rc.rental_start_date,rc.rental_end_date,rc.`status`,
  274. rc.price as rent_price,rc.contract_number,rc.type,rc.apply_status,rc.price_detail,rc.revenue_fixed_rent_price,rc.revenue_rent_price,
  275. rc.rent_info,pc.price as property_price,pc.`status` as property_status,
  276. rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit,rc.day_price_calcute,rc.free_period_remark,
  277. rc.business_type businessType,rc.month_average_days,rc.revenue_jumps_remark,rc.first_bill_date_start,rc.first_bill_date_end
  278. from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id
  279. <where>
  280. <if test=" null != tenantId and '' != tenantId">
  281. and rc.`tenant_id` = #{tenantId}
  282. </if>
  283. <if test=" null != parentTenantId and '' != parentTenantId">
  284. and rc.`parent_tenant_id` = #{parentTenantId}
  285. </if>
  286. <if test=" null != contractNumber and '' != contractNumber">
  287. and rc.`contract_number` = #{contractNumber}
  288. </if>
  289. <if test=" null != rentId and '' != rentId">
  290. and rc.`id` = #{rentId}
  291. </if>
  292. <if test=" null != propertyId and '' != propertyId">
  293. and pc.`id` = #{propertyId}
  294. </if>
  295. <if test=" null != customersIdList ">
  296. and rc.customers_id in
  297. <foreach collection="customersIdList" index="index" item="cusItem" open="(" separator="," close=")">
  298. #{cusItem}
  299. </foreach>
  300. </if>
  301. <!-- <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  302. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  303. </if>
  304. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  305. and s.`shop_number` like concat('%',#{shopNumber},'%')
  306. </if> -->
  307. <if test=" null != status ">and rc.`status` = #{status}</if>
  308. <if test=" null != type ">and rc.`type` = #{type}</if>
  309. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  310. <if test=" null != operationType ">and rc.`operation_type` = #{operationType}</if>
  311. <if test=" null != dayPriceCalcute ">and rc.`day_price_calcute` = #{dayPriceCalcute}</if>
  312. <if test=" null != monthAverageDays ">and rc.`month_average_days` = #{monthAverageDays}</if>
  313. <if test=" null != ids ">
  314. and rc.id in
  315. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  316. #{idItem}
  317. </foreach>
  318. </if>
  319. </where>
  320. <if test=" null != sortColumns">order by ${sortColumns}</if>
  321. <if test=" null == sortColumns">order by rc.createtime desc,rc.id desc</if>
  322. </select>
  323. <select id="getByBill" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  324. select <include refid="allColumns"/> from wx_rent_contract
  325. where id in(
  326. select rent_contract_id from wx_all_bill id = #{id}
  327. )
  328. </select>
  329. <select id="getShopCountMax" resultType="int">
  330. select max(json_length(rent_info)) from wx_rent_contract
  331. </select>
  332. <select id="getCanApplyCount" resultType="Integer" parameterType="Long">
  333. select count(1) from wx_rent_contract where id != #{id} and (status=1 or (status=10 and apply_status=3) )
  334. </select>
  335. <select id="getUsedRentShopIds" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  336. SELECT distinct shop_id FROM wx_rent_contract WHERE status in(1,2,3,4,8)
  337. <if test=" null != tenantId and '' != tenantId">
  338. and `tenant_id` = #{tenantId}
  339. </if>
  340. <if test=" null != parentTenantId and '' != parentTenantId">
  341. and `parent_tenant_id` = #{parentTenantId}
  342. </if>
  343. </select>
  344. <update id = "setEndContractTime" parameterType="com.iformall.domain.po.WxRentContract" >
  345. update wx_rent_contract set end_contract_time = #{endContractTime} where id = #{id}
  346. </update>
  347. <select id = "findToEndContractList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  348. select
  349. <include refid="allColumns"/>
  350. from wx_rent_contract
  351. where `tenant_id` = #{tenantId} and status = 3 and end_contract_time &lt;= now();
  352. </select>
  353. </mapper>