25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

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