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.
 
 
 
 
 

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