后台服务
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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