You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

705 lines
33 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="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
  25. <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
  26. <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/>
  27. <result column="link_phone" jdbcType="VARCHAR" property="linkPhone"/>
  28. <result column="pay_account" jdbcType="VARCHAR" property="payAccount"/>
  29. <result column="filename" jdbcType="VARCHAR" property="filename"/>
  30. <result column="lease" jdbcType="INTEGER" property="lease"/>
  31. <result column="type" jdbcType="INTEGER" property="type"/>
  32. <result column="revenue" jdbcType="INTEGER" property="revenue"/>
  33. <result column="adjust_ratio" jdbcType="VARCHAR" property="adjustRatio"/>
  34. <result column="adjust_period" jdbcType="INTEGER" property="adjustPeriod"/>
  35. <result column="pay_ratio" jdbcType="INTEGER" property="payRatio"/>
  36. <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/>
  37. <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/>
  38. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  39. <result column="bank_name" jdbcType="VARCHAR" property="bankName"/>
  40. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  41. <result column="fix_start_date" property="fixStartDate"/>
  42. <result column="fix_end_date" property="fixEndDate"/>
  43. <result column="business_type" property="businessType"/>
  44. <result column="receive_period" property="receivePeriod"/>
  45. <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
  46. <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
  47. <result column="price_unit" property="priceUnit"/>
  48. <result column="rent_price" property="rentPrice"/>
  49. <result column="subject_name" property="subjectName"/>
  50. <result column="rent_start_type" property="rentStartType"/><result column="type" jdbcType="INTEGER" property="type"/>
  51. <result column="revenue" jdbcType="INTEGER" property="revenue"/>
  52. <result column="adjust_ratio" jdbcType="VARCHAR" property="adjustRatio"/>
  53. <result column="adjust_period" jdbcType="INTEGER" property="adjustPeriod"/>
  54. <result column="pay_ratio" jdbcType="INTEGER" property="payRatio"/>
  55. <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/>
  56. <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/>
  57. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  58. <result column="bank_name" jdbcType="VARCHAR" property="bankName"/>
  59. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  60. <result column="fix_start_date" property="fixStartDate"/>
  61. <result column="fix_end_date" property="fixEndDate"/>
  62. <result column="business_type" property="businessType"/>
  63. <result column="receive_period" property="receivePeriod"/>
  64. <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
  65. <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
  66. <result column="price_unit" property="priceUnit"/>
  67. <result column="rent_price" property="rentPrice"/>
  68. <result column="subject_name" property="subjectName"/>
  69. <result column="rent_start_type" property="rentStartType"/>
  70. <result column="shop_name" property="shopName"/>
  71. <result column="from_id" property="fromId"/>
  72. <result column="rent_input_way" property="rentInputWay"/>
  73. <result column="adjust_ratio_way" property="adjustRatioWay"/>
  74. <result column="operation_type" property="operationType"/>
  75. <result column="late_pay_ratio" property="latePayRatio"/>
  76. <result column="late_pay_day" property="latePayDay"/>
  77. <result column="bus_discount_ratio" property="busDiscountRatio"/>
  78. <result column="bus_discount_time" property="busDiscountTime"/>
  79. </resultMap>
  80. <sql id="allColumns">
  81. `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,
  82. `tenant_id`,`parent_tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`,
  83. `brand`,`business_id`,`shop_type`,`updatetime`,`createtime`,`link_person`,`link_phone`,
  84. `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`,
  85. `start_date`,`end_date`,`shop_name`,`from_id`,
  86. `apply_status`,`bank_name`,`rent_shop_type`,`fix_start_date`,`fix_end_date`,
  87. `business_type`,`rent_info`, `file_names`,price_unit,rent_price,`subject_name`,rent_start_type,
  88. `rent_input_way`,`adjust_ratio_way`,`operation_type`,late_pay_ratio,late_pay_day,bus_discount_ratio,bus_discount_time
  89. </sql>
  90. <sql id="dynamicWhereConditions">
  91. where 1 = 1
  92. <if test=" null != id ">and `id` = #{id}</if>
  93. <if test=" null != fromId ">and `from_id` = #{fromId}</if>
  94. <if test=" null != merchantId and '' != merchantId">and `merchant_id` = #{merchantId}</if>
  95. <if test=" null != price and '' != price">and `price` = #{price}</if>
  96. <if test=" null != rentalStartDate and '' != rentalStartDate">and `rental_start_date` = #{rentalStartDate}</if>
  97. <if test=" null != rentalEndDate and '' != rentalEndDate">and `rental_end_date` = #{rentalEndDate}</if>
  98. <if test=" null != signDate and '' != signDate">and `sign_date` = #{signDate}</if>
  99. <if test=" null != receivePeriod and '' != receivePeriod">and `receive_period` = #{receivePeriod}</if>
  100. <if test=" null != tenantId and '' != tenantId">
  101. and `tenant_id` = #{tenantId}
  102. </if>
  103. <if test=" null != parentTenantId and '' != parentTenantId">
  104. and `parent_tenant_id` = #{parentTenantId}
  105. </if>
  106. <if test=" null != filepath and '' != filepath">and `filepath` = #{filepath}</if>
  107. <if test=" null != status and '' != status">and `status` = #{status}</if>
  108. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  109. <if test=" null != contractNumber and '' != contractNumber">and `contract_number` = #{contractNumber}</if>
  110. <if test=" null != deposit and '' != deposit">and `deposit` = #{deposit}</if>
  111. <if test=" null != payDate and '' != payDate">and `pay_date` = #{payDate}</if>
  112. <if test=" null != isDel and '' != isDel">and `is_del` = #{isDel}</if>
  113. <if test=" null != merchantName and '' != merchantName">and `merchant_name` like concat('%', #{merchantName},'%') </if>
  114. <if test=" null != brand and '' != brand">and `brand` = #{brand}</if>
  115. <if test=" null != businessId and '' != businessId">and `business_id` = #{businessId}</if>
  116. <if test=" null != shopType and '' != shopType">and `shop_type` = #{shopType}</if>
  117. <if test=" null != updatetime and '' != updatetime">and `updatetime` = #{updatetime}</if>
  118. <if test=" null != createtime and '' != createtime">and `createtime` = #{createtime}</if>
  119. <if test=" null != linkPerson and '' != linkPerson">and `link_person` = #{linkPerson}</if>
  120. <if test=" null != linkPhone and '' != linkPhone">and `link_phone` = #{linkPhone}</if>
  121. <if test=" null != payAccount and '' != payAccount">and `pay_account` = #{payAccount}</if>
  122. <if test=" null != filename and '' != filename">and `filename` = #{filename}</if>
  123. <if test=" null != lease and '' != lease">and `lease` = #{lease}</if>
  124. <if test=" null != type and '' != type">and `type` = #{type}</if>
  125. <if test=" null != startDate and '' != startDate">and `start_date` = #{startDate}</if>
  126. <if test=" null != endDate and '' != endDate">and `end_date` = #{endDate}</if>
  127. <if test=" null != rentShopType and '' != rentShopType">and `rent_shop_type` = #{rentShopType}</if>
  128. <if test=" null != operationType and '' != operationType">and `operation_type` = #{operationType}</if>
  129. <if test=" null != queryShopId and '' != queryShopId">and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{queryShopId},'"'))</if>
  130. <if test=" null != statuss ">
  131. and status in
  132. <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
  133. #{statusItem}
  134. </foreach>
  135. </if>
  136. <if test=" null != ids ">
  137. and id in
  138. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  139. #{idItem}
  140. </foreach>
  141. </if>
  142. <if test=" null != sortColumns">order by ${sortColumns}</if>
  143. </sql>
  144. <select id="findList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  145. select
  146. <include refid="allColumns"/>
  147. from wx_rent_contract
  148. <include refid="dynamicWhereConditions"/>
  149. </select>
  150. <!-- 需要修改 -->
  151. <!-- <select id="queryRentContractData" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
  152. select rc.id,rc.merchant_name merchantName,rc.rental_start_date rentalStartDate,rc.rental_end_date rentalEndDate,rc.`status`,
  153. rc.price,rc.contract_number contractNumber,s.shop_number shopNumber,f.floor_name floorName,b.building_name buildingName,
  154. rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate,rc.merchant_id merchantId,rc.type,
  155. rc.start_date startDate,rc.end_date endDate,br.`name` brandName,rc.apply_status applyStatus,rc.bank_name
  156. bankName,rc.rent_shop_type rentShopType,rc.fix_start_date fixStartDate,rc.fix_end_date fixEndDate
  157. ,rc.business_type businessType,rc.adjust_period adjustPeriod,rc.rent_info rentInfo, rc.file_names
  158. fileNames,rc.price_unit,rc.subject_name subjectName,rc.`rent_input_way` rentInputWay,rc.`adjust_ratio_way`
  159. adjustRatioWay,rc.bus_discount_ratio,rc.bus_discount_time
  160. from wx_rent_contract rc
  161. left join wx_shop s on rc.shop_id=s.id
  162. left join wx_mall_floor f on s.floor=f.id
  163. left join wx_mall_building b on s.building=b.id
  164. left join wx_brand br on rc.brand=br.id
  165. <where>
  166. <if test=" null != tenantId and '' != tenantId">
  167. and rc.`tenant_id` = #{tenantId}
  168. </if>
  169. <if test=" null != parentTenantId and '' != parentTenantId">
  170. and rc.`parent_tenant_id` = #{parentTenantId}
  171. </if>
  172. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like concat('%',#{merchantName},'%')</if>
  173. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  174. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  175. </if>
  176. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  177. and s.`shop_number` like concat('%',#{shopNumber},'%')
  178. </if>
  179. <if test=" null != status ">and rc.`status` = #{status}</if>
  180. <if test=" null != shopId">and rc.`shop_id` = #{shopId}</if>
  181. <if test=" null != type ">and rc.`type` = #{type}</if>
  182. <if test=" null != rentShopType ">and rc.`rent_shop_type` = #{rentShopType}</if>
  183. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  184. <if test=" null != building and ''!= building">and b.id = #{building}</if>
  185. <if test=" null != floor and ''!= floor">and f.id = #{floor}</if>
  186. <if test=" null != operationType ">and `operation_type` = #{operationType}</if>
  187. <if test=" null != businessForRule and '' != businessForRule ">
  188. and rc.business_id in (${businessForRule})
  189. </if>
  190. <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule ">
  191. and rc.`id` in
  192. <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")">
  193. select id from wx_rent_contract where 1=1
  194. <if test=" null != tenantId and '' != tenantId">
  195. and `tenant_id` = #{tenantId}
  196. </if>
  197. <if test=" null != parentTenantId and '' != parentTenantId">
  198. and `parent_tenant_id` = #{parentTenantId}
  199. </if>
  200. and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select
  201. id from wx_shop where 1=1
  202. <if test=" null != tenantId and '' != tenantId">
  203. and `tenant_id` = #{tenantId}
  204. </if>
  205. <if test=" null != parentTenantId and '' != parentTenantId">
  206. and `parent_tenant_id` = #{parentTenantId}
  207. </if>
  208. and floor in (${floorForRule}))
  209. </foreach>
  210. </if>
  211. <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != floorForRule ">
  212. and rc.shop_id in (select id from wx_shop where 1=1
  213. <if test=" null != tenantId and '' != tenantId">
  214. and `tenant_id` = #{tenantId}
  215. </if>
  216. <if test=" null != parentTenantId and '' != parentTenantId">
  217. and `parent_tenant_id` = #{parentTenantId}
  218. </if>
  219. and floor in (${floorForRule}))
  220. </if>
  221. <if test=" null != merchantId">and rc.`merchant_id` = #{merchantId}</if>
  222. </where>
  223. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  224. <if test=" null == sortColumns"> order by rc.createtime desc,rc.id desc </if>
  225. </select> -->
  226. <select id="queryRentContractCountByStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  227. select count(1) from wx_rent_contract where status=#{status}
  228. <if test=" null != tenantId and '' != tenantId">
  229. and `tenant_id` = #{tenantId}
  230. </if>
  231. <if test=" null != parentTenantId and '' != parentTenantId">
  232. and `parent_tenant_id` = #{parentTenantId}
  233. </if>
  234. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  235. </select>
  236. <!-- <select id="queryRentContractWaitSignStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  237. select count(id) from wx_rent_contract where status=#{status}
  238. <if test=" null != tenantId and '' != tenantId">
  239. and `tenant_id` = #{tenantId}
  240. </if>
  241. <if test=" null != parentTenantId and '' != parentTenantId">
  242. and `parent_tenant_id` = #{parentTenantId}
  243. </if>
  244. <if test=" null != rentShopType ">
  245. and rent_shop_type = #{rentShopType}
  246. </if>
  247. </select> -->
  248. <!-- <select id="queryRentContractEndSoonStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  249. select count(id) from wx_rent_contract where status=4
  250. <if test=" null != tenantId and '' != tenantId">
  251. and `tenant_id` = #{tenantId}
  252. </if>
  253. <if test=" null != parentTenantId and '' != parentTenantId">
  254. and `parent_tenant_id` = #{parentTenantId}
  255. </if>
  256. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  257. </select> -->
  258. <!-- <select id="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  259. select count(id) from wx_rent_contract where status in (2,3,4)
  260. <if test=" null != tenantId and '' != tenantId">
  261. and `tenant_id` = #{tenantId}
  262. </if>
  263. <if test=" null != parentTenantId and '' != parentTenantId">
  264. and `parent_tenant_id` = #{parentTenantId}
  265. </if>
  266. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  267. </select> -->
  268. <!-- <select id="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  269. 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()
  270. <if test=" null != tenantId and '' != tenantId">
  271. and `tenant_id` = #{tenantId}
  272. </if>
  273. <if test=" null != parentTenantId and '' != parentTenantId">
  274. and `parent_tenant_id` = #{parentTenantId}
  275. </if>
  276. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  277. </select> -->
  278. <!-- <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxRentContract">
  279. update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8)
  280. <if test=" null != tenantId and '' != tenantId">
  281. and `tenant_id` = #{tenantId}
  282. </if>
  283. <if test=" null != parentTenantId and '' != parentTenantId">
  284. and `parent_tenant_id` = #{parentTenantId}
  285. </if>
  286. and DATEDIFF(rental_end_date,now()) &lt;= 30 and rental_end_date > now()
  287. </update> -->
  288. <!-- <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  289. update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8)
  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. and rental_start_date &lt;= now() and rental_end_date >= now()
  297. </update> -->
  298. <!-- <update id="updateRentContractEndStatus" parameterType="com.iformall.domain.po.WxRentContract">
  299. update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8)
  300. <if test=" null != tenantId and '' != tenantId">
  301. and `tenant_id` = #{tenantId}
  302. </if>
  303. <if test=" null != parentTenantId and '' != parentTenantId">
  304. and `parent_tenant_id` = #{parentTenantId}
  305. </if>
  306. and rental_end_date &lt;now()
  307. </update> -->
  308. <!-- <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxRentContract">
  309. update wx_rent_contract set status=#{status} where status not in(0,5,6,7)
  310. <if test=" null != tenantId and '' != tenantId">
  311. and `tenant_id` = #{tenantId}
  312. </if>
  313. <if test=" null != parentTenantId and '' != parentTenantId">
  314. and `parent_tenant_id` = #{parentTenantId}
  315. </if>
  316. and merchant_id is null
  317. </update> -->
  318. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract">
  319. update wx_rent_contract
  320. set apply_status=#{applyStatus}
  321. <if test=" null != businessType ">,business_type=#{businessType}</if>
  322. <if test=" null != status ">,status=#{status}</if>
  323. where id=#{id}
  324. </update>
  325. <update id="updateStatus" parameterType="com.iformall.domain.po.WxRentContract">
  326. update wx_rent_contract set status=#{status} where id=#{id}
  327. </update>
  328. <!-- <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  329. update wx_rent_contract set status=#{status} where shop_id in (
  330. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE status in(2,3,4)
  331. <if test=" null != tenantId and '' != tenantId">
  332. and `tenant_id` = #{tenantId}
  333. </if>
  334. <if test=" null != parentTenantId and '' != parentTenantId">
  335. and `parent_tenant_id` = #{parentTenantId}
  336. </if>
  337. )s) and status in(0,1) and status!=7 and rent_shop_type=2
  338. </update> -->
  339. <!-- <select id="getRentContractList" parameterType="com.iformall.domain.po.WxRentContract"
  340. resultType="com.iformall.domain.po.WxRentContract">
  341. select s.shop_id,s.shop_number,s.building_name building, s.floor_name floor,s.build_area,rc.* from (
  342. select s.id shop_id,ms.merchant_id,s.shop_number,b.building_name,f.floor_name,s.build_area,s.floor,s.building
  343. from wx_shop s
  344. left join wx_mall_building b on s.building=b.id
  345. left join wx_mall_floor f on s.floor=f.id
  346. left join wx_merchant_shop ms on s.id=ms.shop_id
  347. where ms.is_del=0) s
  348. inner join (select * from wx_rent_contract where status in(2,3,4)) rc on s.merchant_id=rc.merchant_id
  349. where 1=1
  350. <if test=" null != tenantId and '' != tenantId">
  351. and rc.`tenant_id` = #{tenantId}
  352. </if>
  353. <if test=" null != parentTenantId and '' != parentTenantId">
  354. and rc.`parent_tenant_id` = #{parentTenantId}
  355. </if>
  356. <if test=" null != shopNumber and ''!=shopNumber">
  357. and s.shop_number like concat('%', #{shopNumber},'%')
  358. </if>
  359. <if test=" null != floor and ''!=floor">
  360. and s.floor = #{floor}
  361. </if>
  362. <if test=" null != building and ''!=building">
  363. and s.building = #{building}
  364. </if>
  365. order by rc.id desc
  366. </select> -->
  367. <select id="updateStatusForUnsign" parameterType="com.iformall.domain.po.WxRentContract">
  368. update wx_rent_contract set status=1 where status=2 and merchant_id is null
  369. <if test=" null != tenantId and '' != tenantId">
  370. and `tenant_id` = #{tenantId}
  371. </if>
  372. <if test=" null != parentTenantId and '' != parentTenantId">
  373. and `parent_tenant_id` = #{parentTenantId}
  374. </if>
  375. </select>
  376. <!-- <select id="getRentInvalidList" parameterType="com.iformall.domain.po.WxRentContract"
  377. resultType="com.iformall.domain.po.WxRentContract">
  378. select id from wx_rent_contract where shop_id in (
  379. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE status in(2,3,4)
  380. <if test=" null != tenantId and '' != tenantId">
  381. and `tenant_id` = #{tenantId}
  382. </if>
  383. <if test=" null != parentTenantId and '' != parentTenantId">
  384. and `parent_tenant_id` = #{parentTenantId}
  385. </if>
  386. )s) and status in(0,1) and status!=7 and apply_status=1
  387. <if test=" null != tenantId and '' != tenantId">
  388. and `tenant_id` = #{tenantId}
  389. </if>
  390. <if test=" null != parentTenantId and '' != parentTenantId">
  391. and `parent_tenant_id` = #{parentTenantId}
  392. </if>
  393. </select> -->
  394. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  395. select count(1) from wx_rent_contract r,wx_bill_rent b
  396. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  397. </select>
  398. <select id="getMerchants" parameterType="com.iformall.domain.po.WxRentContract"
  399. resultType="com.iformall.domain.po.WxRentContract">
  400. select <include refid="allColumns"/> from wx_rent_contract where status in(2,3,4)
  401. and merchant_id not in(select merchant_id from wx_property_contract where status in(2,3,4))
  402. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  403. </select>
  404. <select id="selectRentContractCountByShopId" parameterType="java.util.Map" resultType="int">
  405. select count(1) from wx_rent_contract where 1=1
  406. <if test=" null != tenantId and '' != tenantId">
  407. and `tenant_id` = #{tenantId}
  408. </if>
  409. <if test=" null != parentTenantId and '' != parentTenantId">
  410. and `parent_tenant_id` = #{parentTenantId}
  411. </if>
  412. and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{shopId},'"')) and status in (2,3,4)
  413. <if test="id!=null">
  414. and id!=#{id}
  415. </if>
  416. </select>
  417. <select id="selectRentContractByShopId" parameterType="com.iformall.domain.po.WxRentContract"
  418. resultType="com.iformall.domain.po.WxRentContract">
  419. select <include refid="allColumns"/> from wx_rent_contract
  420. where 1=1
  421. <if test=" null != tenantId and '' != tenantId">
  422. and `tenant_id` = #{tenantId}
  423. </if>
  424. <if test=" null != parentTenantId and '' != parentTenantId">
  425. and `parent_tenant_id` = #{parentTenantId}
  426. </if>
  427. and json_contains(json_extract(rent_info,'$[*].id'),concat('"',${shopId},'"')) and rent_shop_type =1
  428. <if test=" null != status ">and status=#{status} and status!=7</if>
  429. </select>
  430. <!-- <update id="updateInvalidContract" parameterType="com.iformall.domain.po.WxRentContract">
  431. update wx_rent_contract set status=#{status}
  432. where 1=1
  433. <if test=" null != tenantId and '' != tenantId">
  434. and `tenant_id` = #{tenantId}
  435. </if>
  436. <if test=" null != parentTenantId and '' != parentTenantId">
  437. and `parent_tenant_id` = #{parentTenantId}
  438. </if>
  439. and id in(select r.id from (
  440. select id from wx_rent_contract where json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"'))
  441. and rent_shop_type=1 and status in(0,1) and status!=7)r)
  442. </update> -->
  443. <select id="selectRentContractByMerchantId" parameterType="com.iformall.domain.po.WxRentContract"
  444. resultType="com.iformall.domain.po.WxRentContract">
  445. select <include refid="allColumns"/> from wx_rent_contract
  446. where status in(2,3,4)
  447. and merchant_id = #{merchantId}
  448. </select>
  449. <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract"
  450. resultType="int">
  451. select count(1) from (
  452. select * from wx_rent_contract where contract_number=#{contractNumber}
  453. and status not in(5,6,7)
  454. <if test=" null != tenantId and '' != tenantId">
  455. and `tenant_id` = #{tenantId}
  456. </if>
  457. <if test=" null != parentTenantId and '' != parentTenantId">
  458. and `parent_tenant_id` = #{parentTenantId}
  459. </if>
  460. union
  461. select * from wx_rent_contract where contract_number=#{contractNumber}
  462. and apply_status in(1,2)
  463. <if test=" null != tenantId and '' != tenantId">
  464. and `tenant_id` = #{tenantId}
  465. </if>
  466. <if test=" null != parentTenantId and '' != parentTenantId">
  467. and `parent_tenant_id` = #{parentTenantId}
  468. </if>
  469. ) r
  470. <where>
  471. <if test="id!=null and id!=''">
  472. r.id!=#{id}
  473. </if>
  474. </where>
  475. </select>
  476. <!-- <select id="getShopType" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  477. select s.type
  478. from wx_rent_contract r
  479. left join wx_shop s on(s.id = r.`shop_id`)
  480. where r.id = #{id}
  481. </select> -->
  482. <resultMap id="contractMap" type="com.iformall.domain.vo.WxRentPropertyContractVo">
  483. <id column="id" property="id"/>
  484. <result column="tenant_id" property="tenantId"/>
  485. <result column="parent_tenant_id" property="parentTenantId"/>
  486. <result column="rent_id" property="rentId"/>
  487. <result column="property_id" property="propertyId"/>
  488. <result column="shop_name" property="shopName"/>
  489. <result column="merchant_name" property="merchantName"/>
  490. <result column="rent_info" property="rentInfo"/>
  491. <result column="rental_start_date" property="rentalStartDate"/>
  492. <result column="rental_end_date" property="rentalEndDate"/>
  493. <result column="rent_price" property="rentPrice"/>
  494. <result column="property_price" property="propertyPrice"/>
  495. <result column="type" property="type"/>
  496. <result column="status" property="status"/>
  497. <result column="apply_status" property="applyStatus"/>
  498. <result column="operation_type" property="operationType"/>
  499. <result column="rent_shop_type" property="rentShopType"/>
  500. <result column="merchant_id" property="merchantId"/>
  501. <result column="property_status" property="propertyStatus"/>
  502. <result column="rent_price_unit" property="rentPriceUnit"/>
  503. <result column="property_price_unit" property="propertyPriceUnit"/>
  504. <result column="bus_discount_time" property="busDiscountTime"/>
  505. <result column="bus_discount_ratio" property="busDiscountRatio"/>
  506. </resultMap>
  507. <select id="listContractVo" parameterType="com.iformall.domain.vo.WxRentPropertyContractVo" resultMap="contractMap">
  508. 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`,
  509. rc.price as rent_price,rc.contract_number,rc.shop_name,rc.type,rc.apply_status,
  510. rc.rent_shop_type,rc.rent_info,pc.price as property_price,rc.merchant_id,pc.`status` as property_status,
  511. rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit,
  512. rc.business_type businessType,rc.bus_discount_ratio,rc.bus_discount_time
  513. from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id
  514. <where>
  515. <if test=" null != tenantId and '' != tenantId">
  516. and rc.`tenant_id` = #{tenantId}
  517. </if>
  518. <if test=" null != parentTenantId and '' != parentTenantId">
  519. and rc.`parent_tenant_id` = #{parentTenantId}
  520. </if>
  521. <if test=" null != rentId and '' != rentId">
  522. and rc.`id` = #{rentId}
  523. </if>
  524. <if test=" null != propertyId and '' != propertyId">
  525. and pc.`id` = #{propertyId}
  526. </if>
  527. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like
  528. concat('%',#{merchantName},'%')
  529. </if>
  530. <if test=" null != shopNumber and shopNumber!=''">
  531. and (json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%') or rc.shop_name like concat('%',#{shopNumber},'%') )
  532. </if>
  533. <!-- <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  534. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  535. </if>
  536. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  537. and s.`shop_number` like concat('%',#{shopNumber},'%')
  538. </if> -->
  539. <if test=" null != status ">and rc.`status` = #{status}</if>
  540. <if test=" null != type ">and rc.`type` = #{type}</if>
  541. <if test=" null != rentShopType ">
  542. and rc.`rent_shop_type` = #{rentShopType}
  543. </if>
  544. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  545. <if test=" null != operationType ">and rc.`operation_type` = #{operationType}</if>
  546. <if test=" null != businessForRule and '' != businessForRule ">
  547. and rc.business_id in (${businessForRule})
  548. </if>
  549. <!-- <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule ">
  550. and rc.`id` in
  551. <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")">
  552. select id from wx_rent_contract where 1=1
  553. <if test=" null != tenantId and '' != tenantId">
  554. and `tenant_id` = #{tenantId}
  555. </if>
  556. <if test=" null != parentTenantId and '' != parentTenantId">
  557. and `parent_tenant_id` = #{parentTenantId}
  558. </if>
  559. and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select
  560. id from wx_shop where 1=1
  561. <if test=" null != tenantId and '' != tenantId">
  562. and `tenant_id` = #{tenantId}
  563. </if>
  564. <if test=" null != parentTenantId and '' != parentTenantId">
  565. and `parent_tenant_id` = #{parentTenantId}
  566. </if>
  567. and floor in (${floorForRule}))
  568. </foreach>
  569. </if> -->
  570. <!-- <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != floorForRule ">
  571. and rc.shop_id in (select id from wx_shop where 1=1
  572. <if test=" null != tenantId and '' != tenantId">
  573. and `tenant_id` = #{tenantId}
  574. </if>
  575. <if test=" null != parentTenantId and '' != parentTenantId">
  576. and `parent_tenant_id` = #{parentTenantId}
  577. </if>
  578. and floor in (${floorForRule}))
  579. </if> -->
  580. </where>
  581. <if test=" null != sortColumns">order by ${sortColumns}</if>
  582. <if test=" null == sortColumns">order by rc.createtime desc,rc.id desc</if>
  583. </select>
  584. <select id="getByBill" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
  585. select <include refid="allColumns"/> from wx_rent_contract
  586. where id in(
  587. select rent_contract_id from wx_bill_rent id = #{id}
  588. )
  589. </select>
  590. <select id="getShopCountMax" resultType="int">
  591. select max(json_length(rent_info)) from wx_rent_contract
  592. </select>
  593. <select id="queryContractByBus" resultType="hashmap" parameterType="com.iformall.domain.po.WxBusiness">
  594. 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)
  595. 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
  596. union all
  597. 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)
  598. 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
  599. </select>
  600. <!-- <select id="selectRentContractByShopIds" resultType="com.iformall.domain.po.WxRentContract">
  601. SELECT rc.id,rc.rental_start_date,rc.rental_end_date,rc.`shop_id`,rc.`rent_shop_type`,rc.`rent_info` FROM
  602. `wx_rent_contract` rc
  603. WHERE rc.`status` IN (2,3,4) AND status!=7
  604. <if test=" null != tenantId and '' != tenantId">
  605. and `tenant_id` = #{tenantId}
  606. </if>
  607. <if test=" null != parentTenantId and '' != parentTenantId">
  608. and `parent_tenant_id` = #{parentTenantId}
  609. </if>
  610. AND ( (rc.`rent_shop_type`=2 AND rc.`shop_id` IN
  611. <foreach collection="shopIds" index="index" item="idItem" open="(" separator="," close=")">
  612. #{idItem}
  613. </foreach>
  614. )
  615. OR (rc.`rent_shop_type`=1 AND rc.`rent_info` REGEXP #{shopIdsRegexp})
  616. )
  617. </select> -->
  618. <!-- <select id="selectContractCountByShopId" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  619. SELECT count(*)
  620. FROM wx_rent_contract
  621. WHERE `status` = #{status} AND status!=7
  622. <if test=" null != tenantId and '' != tenantId">
  623. and `tenant_id` = #{tenantId}
  624. </if>
  625. <if test=" null != parentTenantId and '' != parentTenantId">
  626. and `parent_tenant_id` = #{parentTenantId}
  627. </if>
  628. AND (
  629. `rent_shop_type` = 1 AND
  630. json_contains(json_extract(rent_info, '$[*].shopId'), concat('"', #{shopId}, '"'))
  631. OR
  632. `rent_shop_type` = 2 AND `shop_id` = #{shopId}
  633. )
  634. </select> -->
  635. <!-- <select id="getContractByMerchant" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract">
  636. select * from wx_rent_contract where merchant_id = #{merchantId} and status=3
  637. </select> -->
  638. <select id="getCanApplyCount" resultType="Integer" parameterType="Long">
  639. select count(1) from wx_rent_contract where id != #{id} and (status=1 or (status=10 and apply_status=3) )
  640. </select>
  641. <select id="getMerchantIdsByStatuss" resultType="Long" parameterType="com.iformall.domain.po.WxRentContract">
  642. select distinct merchant_id from wx_rent_contract where 1=1
  643. <if test=" null != tenantId and '' != tenantId">
  644. and `tenant_id` = #{tenantId}
  645. </if>
  646. <if test=" null != parentTenantId and '' != parentTenantId">
  647. and `parent_tenant_id` = #{parentTenantId}
  648. </if>
  649. and status in
  650. <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
  651. #{statusItem}
  652. </foreach>
  653. </select>
  654. </mapper>