Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

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