Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

572 wiersze
32 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="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  7. <result column="shop_type_sub" jdbcType="VARCHAR" property="shopTypeSub"/>
  8. <result column="lease_purpose" jdbcType="VARCHAR" property="leasePurpose"/>
  9. <result column="contractual_rules" jdbcType="VARCHAR" property="contractualRules"/>
  10. <result column="delivery_date" jdbcType="TIMESTAMP" property="deliveryDate"/>
  11. <result column="delivery_grace_period" jdbcType="INTEGER" property="deliveryGracePeriod"/>
  12. <result column="opening_date" jdbcType="TIMESTAMP" property="openingDate"/>
  13. <result column="business_hours" jdbcType="VARCHAR" property="businessHours"/>
  14. <result column="scope_metre" jdbcType="INTEGER" property="scopeMetre"/>
  15. <result column="decimal_size" jdbcType="INTEGER" property="decimalSize"/>
  16. <result column="price" jdbcType="VARCHAR" property="price"/>
  17. <result column="rental_start_date" jdbcType="TIMESTAMP" property="rentalStartDate"/>
  18. <result column="rental_end_date" jdbcType="TIMESTAMP" property="rentalEndDate"/>
  19. <result column="sign_date" jdbcType="TIMESTAMP" property="signDate"/>
  20. <result column="receive_period" jdbcType="INTEGER" property="receivePeriod"/>
  21. <result column="receive_period_unit" jdbcType="INTEGER" property="receivePeriodUnit"/>
  22. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  23. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  24. <result column="filepath" jdbcType="VARCHAR" property="filepath"/>
  25. <result column="status" jdbcType="INTEGER" property="status"/>
  26. <result column="contract_number" jdbcType="VARCHAR" property="contractNumber"/>
  27. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  28. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  29. <result column="first_party_bank_info" jdbcType="VARCHAR" property="firstPartyBankInfo"/>
  30. <result column="second_party_bank_info" jdbcType="VARCHAR" property="secondPartyBankInfo"/>
  31. <result column="second_party_tax_info" jdbcType="VARCHAR" property="secondPartyTaxInfo"/>
  32. <result column="property_name" jdbcType="VARCHAR" property="propertyName"/>
  33. <result column="property_fee" jdbcType="VARCHAR" property="propertyFee"/>
  34. <result column="fee_cycle" jdbcType="INTEGER" property="feeCycle"/>
  35. <result column="water_fee" jdbcType="VARCHAR" property="waterFee"/>
  36. <result column="electricity_fees" jdbcType="VARCHAR" property="electricityFees"/>
  37. <result column="deposit" jdbcType="VARCHAR" property="deposit"/>
  38. <!--<result column="deposit_info" jdbcType="VARCHAR" property="depositInfo"/>-->
  39. <result column="cashtype_content_lsit" jdbcType="VARCHAR" property="cashtypeContentLsit"/>
  40. <result column="cashtype_lsit" jdbcType="VARCHAR" property="cashtypeLsit"/>
  41. <result column="pay_date" jdbcType="INTEGER" property="payDate"/>
  42. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  43. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
  44. <result column="brand" jdbcType="VARCHAR" property="brand"/>
  45. <result column="business_id" jdbcType="INTEGER" property="businessId"/>
  46. <result column="shop_type" jdbcType="INTEGER" property="shopType"/>
  47. <result column="shop_type_str" jdbcType="VARCHAR" property="shopTypeStr"/>
  48. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
  49. <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
  50. <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/>
  51. <result column="link_phone" jdbcType="VARCHAR" property="linkPhone"/>
  52. <result column="pay_account" jdbcType="VARCHAR" property="payAccount"/>
  53. <result column="link_address" jdbcType="VARCHAR" property="linkAddress"/>
  54. <result column="filename" jdbcType="VARCHAR" property="filename"/>
  55. <result column="lease" jdbcType="INTEGER" property="lease"/>
  56. <result column="type" jdbcType="INTEGER" property="type"/>
  57. <result column="revenue" jdbcType="VARCHAR" property="revenue"/>
  58. <result column="revenue_ratio" jdbcType="INTEGER" property="revenueRatio"/>
  59. <result column="revenue_ratio_way" jdbcType="INTEGER" property="revenueRatioWay"/>
  60. <result column="revenue_ratio_set" jdbcType="VARCHAR" property="revenueRatioSet"/>
  61. <result column="adjust_ratio" jdbcType="VARCHAR" property="adjustRatio"/>
  62. <result column="adjust_period" jdbcType="INTEGER" property="adjustPeriod"/>
  63. <result column="pay_ratio" jdbcType="INTEGER" property="payRatio"/>
  64. <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/>
  65. <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/>
  66. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  67. <result column="bank_name" jdbcType="VARCHAR" property="bankName"/>
  68. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  69. <result column="fix_start_date" property="fixStartDate"/>
  70. <result column="fix_end_date" property="fixEndDate"/>
  71. <result column="business_type" property="businessType"/>
  72. <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
  73. <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
  74. <result column="price_unit" property="priceUnit"/>
  75. <result column="rent_price" property="rentPrice"/>
  76. <result column="other_rent_price_info" jdbcType="VARCHAR" property="otherRentPriceInfo"/>
  77. <result column="subject_name" property="subjectName"/>
  78. <result column="rent_start_type" property="rentStartType"/>
  79. <result column="type" jdbcType="INTEGER" property="type"/>
  80. <result column="revenue" jdbcType="INTEGER" property="revenue"/>
  81. <result column="adjust_ratio" jdbcType="VARCHAR" property="adjustRatio"/>
  82. <result column="adjust_period" jdbcType="INTEGER" property="adjustPeriod"/>
  83. <result column="pay_ratio" jdbcType="INTEGER" property="payRatio"/>
  84. <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/>
  85. <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/>
  86. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  87. <result column="bank_name" jdbcType="VARCHAR" property="bankName"/>
  88. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  89. <result column="fix_start_date" property="fixStartDate"/>
  90. <result column="fix_end_date" property="fixEndDate"/>
  91. <result column="business_type" property="businessType"/>
  92. <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
  93. <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
  94. <result column="subject_name" property="subjectName"/>
  95. <result column="rent_start_type" property="rentStartType"/>
  96. <result column="shop_name" property="shopName"/>
  97. <result column="from_id" property="fromId"/>
  98. <result column="rent_input_way" property="rentInputWay"/>
  99. <result column="adjust_ratio_way" property="adjustRatioWay"/>
  100. <result column="operation_type" property="operationType"/>
  101. <result column="late_pay_ratio" property="latePayRatio"/>
  102. <result column="late_pay_day" property="latePayDay"/>
  103. <result column="bus_discount_ratio" property="busDiscountRatio"/>
  104. <result column="end_contract_time" jdbcType="TIMESTAMP" property="endContractTime"/>
  105. <result column="bussiness_management_fee" jdbcType="VARCHAR" property="bussinessManagementFee"/>
  106. <result column="bussiness_management_fee_ratio_way" jdbcType="INTEGER" property="bussinessManagementFeeRatioWay"/>
  107. <result column="bussiness_management_fee_ratio" jdbcType="VARCHAR" property="bussinessManagementFeeRatio"/>
  108. <result column="operating_management_fee" jdbcType="VARCHAR" property="operatingManagementFee"/>
  109. <result column="operating_management_fee_ratio_way" jdbcType="INTEGER" property="operatingManagementFeeRatioWay"/>
  110. <result column="operating_management_fee_ratio" jdbcType="VARCHAR" property="operatingManagementFeeRatio"/>
  111. <result column="out_date_notify_days" jdbcType="INTEGER" property="outDateNotifyDays"/>
  112. <result column="out_date_notify_phone" jdbcType="VARCHAR" property="outDateNotifyPhone"/>
  113. <result column="design_file" jdbcType="VARCHAR" property="designFile"/>
  114. <result column="price_detail" jdbcType="VARCHAR" property="priceDetail"/>
  115. <result column="day_price_calcute" jdbcType="INTEGER" property="dayPriceCalcute"/>
  116. <result column="month_average_days" jdbcType="INTEGER" property="monthAverageDays"/>
  117. <result column="revenue_fixed_rent_price" jdbcType="INTEGER" property="revenueFixedRentPrice"/>
  118. <result column="revenue_rent_price" jdbcType="VARCHAR" property="revenueRentPrice"/>
  119. <result column="revenue_jumps_remark" jdbcType="VARCHAR" property="revenueJumpsRemark"/>
  120. <result column="free_period_remark" jdbcType="VARCHAR" property="freePeriodRemark"/>
  121. </resultMap>
  122. <sql id="allColumns">
  123. `id`,`merchant_id`,
  124. `shop_type_sub`,`lease_purpose`,`contractual_rules`,`delivery_date`,`delivery_grace_period`,`opening_date`,`business_hours`,`scope_metre`,
  125. `decimal_size`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,`receive_period_unit`,
  126. `tenant_id`,`parent_tenant_id`,`filepath`,`status`,`contract_number`,`price_detail`,`create_by`,`update_by`,
  127. `first_party_bank_info`,`second_party_bank_info`,`second_party_tax_info`,`day_price_calcute`,
  128. `property_name`,`property_fee`,`fee_cycle`,`water_fee`,`electricity_fees`,`month_average_days`,`free_period_remark`,
  129. `deposit`,cashtype_content_lsit,cashtype_lsit,`pay_date`,`is_del`,`merchant_name`,`revenue_jumps_remark`,
  130. `brand`,`business_id`,`shop_type`,`shop_type_str`,`updatetime`,`createtime`,`link_person`,`link_phone`,`link_address`,
  131. `pay_account`,`filename`,`lease`,`type`,`revenue`,`revenue_ratio`,`revenue_ratio_way`,`revenue_ratio_set`,`adjust_ratio`,`adjust_period`,`pay_ratio`,
  132. `start_date`,`end_date`,`shop_name`,`from_id`,`end_contract_time`,`revenue_fixed_rent_price`,`revenue_rent_price`,
  133. `apply_status`,`bank_name`,`rent_shop_type`,`fix_start_date`,`fix_end_date`,
  134. `business_type`,`rent_info`, `file_names`,price_unit,rent_price,other_rent_price_info,`subject_name`,rent_start_type,
  135. `rent_input_way`,`adjust_ratio_way`,`operation_type`,late_pay_ratio,late_pay_day,bus_discount_ratio,
  136. bussiness_management_fee,bussiness_management_fee_ratio_way,bussiness_management_fee_ratio,
  137. operating_management_fee,operating_management_fee_ratio_way,operating_management_fee_ratio,out_date_notify_days,out_date_notify_phone,design_file
  138. </sql>
  139. <sql id="dynamicWhereConditions">
  140. where 1 = 1
  141. <if test=" null != id ">and `id` = #{id}</if>
  142. <if test=" null != fromId ">and `from_id` = #{fromId}</if>
  143. <if test=" null != merchantId and '' != merchantId">and `merchant_id` = #{merchantId}</if>
  144. <if test=" null != price and '' != price">and `price` = #{price}</if>
  145. <if test=" null != rentalStartDate and '' != rentalStartDate">and `rental_start_date` = #{rentalStartDate}</if>
  146. <if test=" null != rentalEndDate and '' != rentalEndDate">and `rental_end_date` = #{rentalEndDate}</if>
  147. <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>
  148. <if test=" null != signDate and '' != signDate">and `sign_date` = #{signDate}</if>
  149. <if test=" null != receivePeriod and '' != receivePeriod">and `receive_period` = #{receivePeriod}</if>
  150. <if test=" null != receivePeriodUnit and '' != receivePeriodUnit">and `receive_period_unit` = #{receivePeriodUnit}</if>
  151. <if test=" null != tenantId and '' != tenantId">
  152. and `tenant_id` = #{tenantId}
  153. </if>
  154. <if test=" null != parentTenantId and '' != parentTenantId">
  155. and `parent_tenant_id` = #{parentTenantId}
  156. </if>
  157. <if test=" null != filepath and '' != filepath">and `filepath` = #{filepath}</if>
  158. <if test=" null != status and '' != status">and `status` = #{status}</if>
  159. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  160. <if test=" null != contractNumber and '' != contractNumber">and `contract_number` = #{contractNumber}</if>
  161. <if test=" null != deposit and '' != deposit">and `deposit` = #{deposit}</if>
  162. <if test=" null != payDate and '' != payDate">and `pay_date` = #{payDate}</if>
  163. <if test=" null != isDel and '' != isDel">and `is_del` = #{isDel}</if>
  164. <if test=" null != merchantName and '' != merchantName">and `merchant_name` like concat('%', #{merchantName},'%') </if>
  165. <if test=" null != brand and '' != brand">and `brand` = #{brand}</if>
  166. <if test=" null != businessId and '' != businessId">and `business_id` = #{businessId}</if>
  167. <if test=" null != shopType and '' != shopType">and `shop_type` = #{shopType}</if>
  168. <if test=" null != updatetime and '' != updatetime">and `updatetime` = #{updatetime}</if>
  169. <if test=" null != createtime and '' != createtime">and `createtime` = #{createtime}</if>
  170. <if test=" null != linkPerson and '' != linkPerson">and `link_person` = #{linkPerson}</if>
  171. <if test=" null != linkPhone and '' != linkPhone">and `link_phone` = #{linkPhone}</if>
  172. <if test=" null != payAccount and '' != payAccount">and `pay_account` = #{payAccount}</if>
  173. <if test=" null != filename and '' != filename">and `filename` = #{filename}</if>
  174. <if test=" null != lease and '' != lease">and `lease` = #{lease}</if>
  175. <if test=" null != type and '' != type">and `type` = #{type}</if>
  176. <if test=" null != startDate and '' != startDate">and `start_date` = #{startDate}</if>
  177. <if test=" null != endDate and '' != endDate">and `end_date` = #{endDate}</if>
  178. <if test=" null != rentShopType and '' != rentShopType">and `rent_shop_type` = #{rentShopType}</if>
  179. <if test=" null != operationType and '' != operationType">and `operation_type` = #{operationType}</if>
  180. <if test=" null != queryShopId and '' != queryShopId">and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{queryShopId},'"'))</if>
  181. <if test=" null != dayPriceCalcute ">and `day_price_calcute` = #{dayPriceCalcute}</if>
  182. <if test=" null != monthAverageDays ">and `month_average_days` = #{monthAverageDays}</if>
  183. <if test=" null != revenueFixedRentPrice ">and `revenue_fixed_rent_price` = #{revenueFixedRentPrice}</if>
  184. <if test=" null != shopNumber and shopNumber!=''">
  185. and shop_name like concat('%',#{shopNumber},'%')
  186. </if>
  187. <if test=" null != businessForRule and '' != businessForRule ">
  188. and business_id in (${businessForRule})
  189. </if>
  190. <if test=" null != merchantIds ">
  191. and merchant_id in
  192. <foreach collection="merchantIds" index="index" item="mItem" open="(" separator="," close=")">
  193. #{mItem}
  194. </foreach>
  195. </if>
  196. <if test=" null != statuss ">
  197. and status in
  198. <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
  199. #{statusItem}
  200. </foreach>
  201. </if>
  202. <if test=" null != typeList ">
  203. and type in
  204. <foreach collection="typeList" index="index" item="typeItem" open="(" separator="," close=")">
  205. #{typeItem}
  206. </foreach>
  207. </if>
  208. <if test=" null != ids ">
  209. and id in
  210. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  211. #{idItem}
  212. </foreach>
  213. </if>
  214. <if test=" null != sortColumns">order by ${sortColumns}</if>
  215. </sql>
  216. <select id="findList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  217. select
  218. <include refid="allColumns"/>
  219. from wx_rent_contract
  220. <include refid="dynamicWhereConditions"/>
  221. </select>
  222. <select id="findCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="java.lang.Long">
  223. select count(id)
  224. from wx_rent_contract
  225. where status=#{status}
  226. <if test=" null != tenantId and '' != tenantId">
  227. and `tenant_id` = #{tenantId}
  228. </if>
  229. <if test=" null != parentTenantId and '' != parentTenantId">
  230. and `parent_tenant_id` = #{parentTenantId}
  231. </if>
  232. <if test=" null != rentShopType ">
  233. and rent_shop_type = #{rentShopType}
  234. </if>
  235. </select>
  236. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract">
  237. update wx_rent_contract
  238. set apply_status=#{applyStatus}
  239. <if test=" null != businessType ">,business_type=#{businessType}</if>
  240. <if test=" null != status ">,status=#{status}</if>
  241. where id=#{id}
  242. </update>
  243. <update id="updateStatus" parameterType="com.iformall.domain.po.WxRentContract">
  244. update wx_rent_contract set status=#{status} where id=#{id}
  245. </update>
  246. <select id="updateStatusForUnsign" parameterType="com.iformall.domain.po.WxRentContract">
  247. update wx_rent_contract set status=1 where status=2 and merchant_id is null
  248. <if test=" null != tenantId and '' != tenantId">
  249. and `tenant_id` = #{tenantId}
  250. </if>
  251. <if test=" null != parentTenantId and '' != parentTenantId">
  252. and `parent_tenant_id` = #{parentTenantId}
  253. </if>
  254. </select>
  255. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  256. select count(1) from wx_rent_contract r,wx_all_bill b
  257. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  258. </select>
  259. <select id="getMerchants" parameterType="com.iformall.domain.po.WxRentContract"
  260. resultType="com.iformall.domain.po.WxRentContract">
  261. select <include refid="allColumns"/> from wx_rent_contract where status in(2,3,4)
  262. and merchant_id not in(select merchant_id from wx_property_contract where status in(2,3,4))
  263. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  264. </select>
  265. <select id="selectRentContractCountByShopId" parameterType="java.util.Map" resultType="int">
  266. select count(1) from wx_rent_contract where 1=1
  267. <if test=" null != tenantId and '' != tenantId">
  268. and `tenant_id` = #{tenantId}
  269. </if>
  270. <if test=" null != parentTenantId and '' != parentTenantId">
  271. and `parent_tenant_id` = #{parentTenantId}
  272. </if>
  273. and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{shopId},'"')) and status in (2,3,4)
  274. <if test="id!=null">
  275. and id!=#{id}
  276. </if>
  277. </select>
  278. <select id="selectRentContractByShopId" parameterType="com.iformall.domain.po.WxRentContract"
  279. resultType="com.iformall.domain.po.WxRentContract">
  280. select <include refid="allColumns"/> from wx_rent_contract
  281. where 1=1
  282. <if test=" null != tenantId and '' != tenantId">
  283. and `tenant_id` = #{tenantId}
  284. </if>
  285. <if test=" null != parentTenantId and '' != parentTenantId">
  286. and `parent_tenant_id` = #{parentTenantId}
  287. </if>
  288. and json_contains(json_extract(rent_info,'$[*].id'),concat('"',${shopId},'"')) and rent_shop_type =1
  289. <if test=" null != status ">and status=#{status} and status!=7</if>
  290. </select>
  291. <select id="selectRentContractByMerchantId" parameterType="com.iformall.domain.po.WxRentContract"
  292. resultType="com.iformall.domain.po.WxRentContract">
  293. select <include refid="allColumns"/> from wx_rent_contract
  294. where status in(2,3,4)
  295. and merchant_id = #{merchantId}
  296. </select>
  297. <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract"
  298. resultType="int">
  299. select count(1) from (
  300. select * from wx_rent_contract where contract_number=#{contractNumber}
  301. and status not in(5,6,7)
  302. <if test=" null != tenantId and '' != tenantId">
  303. and `tenant_id` = #{tenantId}
  304. </if>
  305. <if test=" null != parentTenantId and '' != parentTenantId">
  306. and `parent_tenant_id` = #{parentTenantId}
  307. </if>
  308. union
  309. select * from wx_rent_contract where contract_number=#{contractNumber}
  310. and apply_status in(1,2)
  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. ) r
  318. <where>
  319. <if test="id!=null and id!=''">
  320. r.id!=#{id}
  321. </if>
  322. </where>
  323. </select>
  324. <resultMap id="contractMap" type="com.iformall.domain.vo.WxRentPropertyContractVo">
  325. <id column="id" property="id"/>
  326. <result column="tenant_id" property="tenantId"/>
  327. <result column="parent_tenant_id" property="parentTenantId"/>
  328. <result column="rent_id" property="rentId"/>
  329. <result column="property_id" property="propertyId"/>
  330. <result column="shop_name" property="shopName"/>
  331. <result column="merchant_name" property="merchantName"/>
  332. <result column="rent_info" property="rentInfo"/>
  333. <result column="rental_start_date" property="rentalStartDate"/>
  334. <result column="rental_end_date" property="rentalEndDate"/>
  335. <result column="rent_price" property="rentPrice"/>
  336. <result column="price_detail" property="priceDetail"/>
  337. <result column="property_price" property="propertyPrice"/>
  338. <result column="type" property="type"/>
  339. <result column="status" property="status"/>
  340. <result column="apply_status" property="applyStatus"/>
  341. <result column="operation_type" property="operationType"/>
  342. <result column="rent_shop_type" property="rentShopType"/>
  343. <result column="merchant_id" property="merchantId"/>
  344. <result column="property_status" property="propertyStatus"/>
  345. <result column="rent_price_unit" property="rentPriceUnit"/>
  346. <result column="property_price_unit" property="propertyPriceUnit"/>
  347. <result column="bus_discount_ratio" property="busDiscountRatio"/>
  348. <result column="day_price_calcute" property="dayPriceCalcute"/>
  349. <result column="month_average_days" property="monthAverageDays"/>
  350. <result column="revenue_fixed_rent_price" jdbcType="INTEGER" property="revenueFixedRentPrice"/>
  351. <result column="revenue_rent_price" jdbcType="VARCHAR" property="revenueRentPrice"/>
  352. <result column="revenue_jumps_remark" jdbcType="VARCHAR" property="revenueJumpsRemark"/>
  353. <result column="free_period_remark" jdbcType="VARCHAR" property="freePeriodRemark"/>
  354. </resultMap>
  355. <select id="listContractVo" parameterType="com.iformall.domain.vo.WxRentPropertyContractVo" resultMap="contractMap">
  356. select rc.id,rc.tenant_id,rc.parent_tenant_id,rc.id as rent_id, pc.id as property_id, rc.merchant_name,rc.rental_start_date,rc.rental_end_date,rc.`status`,
  357. rc.price as rent_price,rc.contract_number,rc.shop_name,rc.type,rc.apply_status,rc.price_detail,rc.revenue_fixed_rent_price,rc.revenue_rent_price,
  358. rc.rent_shop_type,rc.rent_info,pc.price as property_price,rc.merchant_id,pc.`status` as property_status,
  359. rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit,rc.day_price_calcute,rc.free_period_remark,
  360. rc.business_type businessType,rc.bus_discount_ratio,rc.month_average_days,rc.revenue_jumps_remark
  361. from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id
  362. <where>
  363. <if test=" null != tenantId and '' != tenantId">
  364. and rc.`tenant_id` = #{tenantId}
  365. </if>
  366. <if test=" null != parentTenantId and '' != parentTenantId">
  367. and rc.`parent_tenant_id` = #{parentTenantId}
  368. </if>
  369. <if test=" null != contractNumber and '' != contractNumber">
  370. and rc.`contract_number` = #{contractNumber}
  371. </if>
  372. <if test=" null != rentId and '' != rentId">
  373. and rc.`id` = #{rentId}
  374. </if>
  375. <if test=" null != propertyId and '' != propertyId">
  376. and pc.`id` = #{propertyId}
  377. </if>
  378. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like
  379. concat('%',#{merchantName},'%')
  380. </if>
  381. <if test=" null != shopNumber and shopNumber!=''">
  382. and (json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%') or rc.shop_name like concat('%',#{shopNumber},'%') )
  383. </if>
  384. <!-- <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  385. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  386. </if>
  387. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  388. and s.`shop_number` like concat('%',#{shopNumber},'%')
  389. </if> -->
  390. <if test=" null != status ">and rc.`status` = #{status}</if>
  391. <if test=" null != type ">and rc.`type` = #{type}</if>
  392. <if test=" null != rentShopType ">
  393. and rc.`rent_shop_type` = #{rentShopType}
  394. </if>
  395. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  396. <if test=" null != operationType ">and rc.`operation_type` = #{operationType}</if>
  397. <if test=" null != dayPriceCalcute ">and rc.`day_price_calcute` = #{dayPriceCalcute}</if>
  398. <if test=" null != monthAverageDays ">and rc.`month_average_days` = #{monthAverageDays}</if>
  399. <if test=" null != businessForRule and '' != businessForRule ">
  400. and rc.business_id in (${businessForRule})
  401. </if>
  402. <if test=" null != merchantIds ">
  403. and rc.merchant_id in
  404. <foreach collection="merchantIds" index="index" item="mItem" open="(" separator="," close=")">
  405. #{mItem}
  406. </foreach>
  407. </if>
  408. </where>
  409. <if test=" null != sortColumns">order by ${sortColumns}</if>
  410. <if test=" null == sortColumns">order by rc.createtime desc,rc.id desc</if>
  411. </select>
  412. <select id="getByBill" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  413. select <include refid="allColumns"/> from wx_rent_contract
  414. where id in(
  415. select rent_contract_id from wx_all_bill id = #{id}
  416. )
  417. </select>
  418. <select id="getShopCountMax" resultType="int">
  419. select max(json_length(rent_info)) from wx_rent_contract
  420. </select>
  421. <select id="queryContractByBus" resultType="hashmap" parameterType="com.iformall.domain.po.WxBusiness">
  422. select 1 type,c.`rental_start_date`,c.`rental_end_date`,c.id id from wx_merchant m left join wx_rent_contract c on(m.id = c.merchant_id)
  423. where m.business_id = #{id} and c.price is not null and c.`rental_start_date` is not null and c.`rental_end_date` is not null
  424. union all
  425. select 2 type,c.`rental_start_date`,c.`rental_end_date`,c.id id from wx_merchant m left join wx_property_contract c on(m.id = c.merchant_id)
  426. where m.business_id = #{id} and c.price is not null and c.`rental_start_date` is not null and c.`rental_end_date` is not null
  427. </select>
  428. <select id="getCanApplyCount" resultType="Integer" parameterType="Long">
  429. select count(1) from wx_rent_contract where id != #{id} and (status=1 or (status=10 and apply_status=3) )
  430. </select>
  431. <select id="getMerchantIdsByStatuss" resultType="Long" parameterType="com.iformall.domain.po.WxRentContract">
  432. select distinct merchant_id from wx_rent_contract where `tenant_id` = #{tenantId} and merchant_id is not null
  433. <if test=" null != parentTenantId and '' != parentTenantId">
  434. and `parent_tenant_id` = #{parentTenantId}
  435. </if>
  436. and status in
  437. <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
  438. #{statusItem}
  439. </foreach>
  440. </select>
  441. <select id="findRentByShop" parameterType="Long" resultType="hashmap">
  442. select
  443. rc.`id`,rc.`merchant_id`,
  444. rc.`shop_type_sub`,rc.`lease_purpose`,rc.`contractual_rules`,rc.`delivery_date`,rc.`delivery_grace_period`,rc.`opening_date`,rc.`business_hours`,rc.`scope_metre`,
  445. rc.`price`,rc.rent_area,rc.`rental_start_date`,rc.`rental_end_date`,rc.`sign_date`,rc.`receive_period`, rc.`receive_period_unit`,
  446. rc.`tenant_id`,rc.`parent_tenant_id`,rc.`filepath`,rc.`status`,rc.`contract_number`,rc.`price_detail`,rc.`create_by`,rc.`update_by`,
  447. rc.`first_party_bank_info`,rc.`second_party_bank_info`,rc.`second_party_tax_info`,rc.`free_period_remark`,
  448. rc.`property_name`,rc.`property_fee`,rc.`fee_cycle`,rc.`water_fee`,rc.`electricity_fees`,
  449. rc.`deposit`,rc.cashtype_content_lsit,rc.cashtype_lsit,rc.`pay_date`,rc.`is_del`,rc.`merchant_name`,
  450. rc.`brand`,rc.`business_id`,rc.`shop_type`,rc.`shop_type_str`,rc.`updatetime`,rc.`createtime`,rc.`link_person`,rc.`link_phone`,rc.`link_address`,
  451. rc.`pay_account`,rc.`filename`,rc.`lease`,rc.`type`,rc.`revenue`,rc.`revenue_ratio`,rc.`revenue_ratio_way`,rc.`revenue_ratio_set`,rc.`adjust_ratio`,rc.`adjust_period`,rc.`pay_ratio`,
  452. rc.`start_date`,rc.`end_date`,rc.`shop_name`,rc.`from_id`,`rc.end_contract_time`,rc.`revenue_jumps_remark`,
  453. rc.`apply_status`,rc.`bank_name`,rc.`rent_shop_type`,rc.`fix_start_date`,rc.`fix_end_date`,
  454. rc.`business_type`,rc.`rent_info`, rc.`file_names`,rc.price_unit,rent_price,rc.other_rent_price_info,rc.`subject_name`,rc.rent_start_type,
  455. rc.`rent_input_way`,rc.`adjust_ratio_way`,rc.`operation_type`,rc.late_pay_ratio,rc.late_pay_day,rc.bus_discount_ratio,
  456. rc.bussiness_management_fee,rc.bussiness_management_fee_ratio_way,rc.bussiness_management_fee_ratio,
  457. rc.operating_management_fee,rc.operating_management_fee_ratio_way,rc.operating_management_fee_ratio,rc.out_date_notify_days,rc.out_date_notify_phone
  458. from wx_shop s
  459. left join wx_merchant_shop ms on ms.shop_id=s.id and ms.is_del=0
  460. left join wx_merchant m on ms.merchant_id=m.id
  461. left join wx_rent_contract rc on rc.merchant_id = m.id and rc.is_del=0
  462. where s.`id` = #{shopId}
  463. and rc.`status` in (2,3)
  464. and rc.`rental_start_date` &lt;= now() and rc.rental_end_date >= now()
  465. order by rc.`updatetime` desc;
  466. </select>
  467. <select id="currentValidByMerchantId" parameterType="com.iformall.domain.po.WxRentContract" resultType="hashmap">
  468. select
  469. rc.`id`,rc.`merchant_id`,
  470. rc.`shop_type_sub`,rc.`lease_purpose`,rc.`contractual_rules`,rc.`delivery_date`,rc.`delivery_grace_period`,rc.`opening_date`,rc.`business_hours`,rc.`scope_metre`,
  471. rc.`price`,rc.rent_area,rc.`rental_start_date`,rc.`rental_end_date`,rc.`sign_date`,rc.`receive_period`, rc.`receive_period_unit`,
  472. rc.`tenant_id`,rc.`parent_tenant_id`,rc.`filepath`,rc.`status`,rc.`contract_number`,rc.`price_detail`,rc.`create_by`,rc.`update_by`,
  473. rc.`first_party_bank_info`,rc.`second_party_bank_info`,rc.`second_party_tax_info`,rc.`revenue_jumps_remark`,
  474. rc.`property_name`,rc.`property_fee`,rc.`fee_cycle`,rc.`water_fee`,rc.`electricity_fees`,rc.`free_period_remark`,
  475. rc.`deposit`,rc.cashtype_content_lsit,rc.cashtype_lsit,rc.`pay_date`,rc.`is_del`,rc.`merchant_name`,
  476. rc.`brand`,rc.`business_id`,rc.`shop_type`,rc.`shop_type_str`,rc.`updatetime`,rc.`createtime`,rc.`link_person`,rc.`link_phone`,rc.`link_address`,
  477. rc.`pay_account`,rc.`filename`,rc.`lease`,rc.`type`,rc.`revenue`,rc.`revenue_ratio`,rc.`revenue_ratio_way`,rc.`revenue_ratio_set`,rc.`adjust_ratio`,rc.`adjust_period`,rc.`pay_ratio`,
  478. rc.`start_date`,rc.`end_date`,rc.`shop_name`,rc.`from_id`,rc.`end_contract_time`,
  479. rc.`apply_status`,rc.`bank_name`,rc.`rent_shop_type`,rc.`fix_start_date`,rc.`fix_end_date`,
  480. rc.`business_type`,rc.`rent_info`, rc.`file_names`,rc.price_unit,rent_price,rc.other_rent_price_info,rc.`subject_name`,rc.rent_start_type,
  481. rc.`rent_input_way`,rc.`adjust_ratio_way`,rc.`operation_type`,rc.late_pay_ratio,rc.late_pay_day,rc.bus_discount_ratio,
  482. rc.bussiness_management_fee,rc.bussiness_management_fee_ratio_way,rc.bussiness_management_fee_ratio,
  483. rc.operating_management_fee,rc.operating_management_fee_ratio_way,rc.operating_management_fee_ratio,rc.out_date_notify_days,rc.out_date_notify_phone
  484. from wx_rent_contract rc
  485. where rc.is_del = 0
  486. <if test=" null != tenantId and '' != tenantId">
  487. and rc.`tenant_id` = #{tenantId}
  488. </if>
  489. <if test=" null != parentTenantId and '' != parentTenantId">
  490. and rc.`parent_tenant_id` = #{parentTenantId}
  491. </if>
  492. and rc.`merchant_id` = #{merchantId}
  493. <if test=" null != shopNumber and shopNumber!=''">
  494. and rc.shop_name like concat('%',#{shopNumber},'%')
  495. </if>
  496. and rc.`rental_start_date` &lt;= now() and rc.rental_end_date >= now()
  497. <if test=" null != statuss ">
  498. and rc.`status` in
  499. <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
  500. #{statusItem}
  501. </foreach>
  502. </if>
  503. </select>
  504. <select id="getUsedRentShopIds" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  505. SELECT distinct shop_id FROM wx_rent_contract WHERE status in(1,2,3,4,8)
  506. and rent_shop_type=2
  507. <if test=" null != tenantId and '' != tenantId">
  508. and `tenant_id` = #{tenantId}
  509. </if>
  510. <if test=" null != parentTenantId and '' != parentTenantId">
  511. and `parent_tenant_id` = #{parentTenantId}
  512. </if>
  513. </select>
  514. <update id = "setEndContractTime" parameterType="com.iformall.domain.po.WxRentContract" >
  515. update wx_rent_contract set end_contract_time = #{endContractTime} where id = #{id}
  516. </update>
  517. <select id = "findToEndContractList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  518. select
  519. <include refid="allColumns"/>
  520. from wx_rent_contract
  521. where `tenant_id` = #{tenantId} and status = 3 and end_contract_time &lt;= now();
  522. </select>
  523. </mapper>