Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

667 строки
31 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. <if test=" null != tenantId and '' != tenantId">
  157. and rc.`tenant_id` = #{tenantId}
  158. </if>
  159. <if test=" null != parentTenantId and '' != parentTenantId">
  160. and rc.`parent_tenant_id` = #{parentTenantId}
  161. </if>
  162. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like concat('%',#{merchantName},'%')</if>
  163. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  164. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  165. </if>
  166. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  167. and s.`shop_number` like concat('%',#{shopNumber},'%')
  168. </if>
  169. <if test=" null != status ">and rc.`status` = #{status}</if>
  170. <if test=" null != shopId">and rc.`shop_id` = #{shopId}</if>
  171. <if test=" null != type ">and rc.`type` = #{type}</if>
  172. <if test=" null != rentShopType ">and rc.`rent_shop_type` = #{rentShopType}</if>
  173. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  174. <if test=" null != building and ''!= building">and b.id = #{building}</if>
  175. <if test=" null != floor and ''!= floor">and f.id = #{floor}</if>
  176. <if test=" null != operationType ">and `operation_type` = #{operationType}</if>
  177. <if test=" null != businessForRule and '' != businessForRule ">
  178. and rc.business_id in (${businessForRule})
  179. </if>
  180. <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule ">
  181. and rc.`id` in
  182. <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")">
  183. select id from wx_rent_contract where 1=1
  184. <if test=" null != tenantId and '' != tenantId">
  185. and `tenant_id` = #{tenantId}
  186. </if>
  187. <if test=" null != parentTenantId and '' != parentTenantId">
  188. and `parent_tenant_id` = #{parentTenantId}
  189. </if>
  190. and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select
  191. id from wx_shop where 1=1
  192. <if test=" null != tenantId and '' != tenantId">
  193. and `tenant_id` = #{tenantId}
  194. </if>
  195. <if test=" null != parentTenantId and '' != parentTenantId">
  196. and `parent_tenant_id` = #{parentTenantId}
  197. </if>
  198. and floor in (${floorForRule}))
  199. </foreach>
  200. </if>
  201. <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != floorForRule ">
  202. and rc.shop_id in (select id from wx_shop where 1=1
  203. <if test=" null != tenantId and '' != tenantId">
  204. and `tenant_id` = #{tenantId}
  205. </if>
  206. <if test=" null != parentTenantId and '' != parentTenantId">
  207. and `parent_tenant_id` = #{parentTenantId}
  208. </if>
  209. and floor in (${floorForRule}))
  210. </if>
  211. <if test=" null != merchantId">and rc.`merchant_id` = #{merchantId}</if>
  212. </where>
  213. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  214. <if test=" null == sortColumns"> order by rc.createtime desc,rc.id desc </if>
  215. </select>
  216. <select id="queryRentContractWaitSignStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  217. select count(id) from wx_rent_contract where status=#{status}
  218. <if test=" null != tenantId and '' != tenantId">
  219. and `tenant_id` = #{tenantId}
  220. </if>
  221. <if test=" null != parentTenantId and '' != parentTenantId">
  222. and `parent_tenant_id` = #{parentTenantId}
  223. </if>
  224. <if test=" null != rentShopType ">
  225. and rent_shop_type = #{rentShopType}
  226. </if>
  227. </select>
  228. <select id="queryRentContractEndSoonStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  229. select count(id) from wx_rent_contract where status=4
  230. <if test=" null != tenantId and '' != tenantId">
  231. and `tenant_id` = #{tenantId}
  232. </if>
  233. <if test=" null != parentTenantId and '' != parentTenantId">
  234. and `parent_tenant_id` = #{parentTenantId}
  235. </if>
  236. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  237. </select>
  238. <select id="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  239. select count(id) from wx_rent_contract where status in (2,3,4)
  240. <if test=" null != tenantId and '' != tenantId">
  241. and `tenant_id` = #{tenantId}
  242. </if>
  243. <if test=" null != parentTenantId and '' != parentTenantId">
  244. and `parent_tenant_id` = #{parentTenantId}
  245. </if>
  246. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  247. </select>
  248. <select id="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  249. 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()
  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. <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxRentContract">
  259. update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8)
  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. and DATEDIFF(rental_end_date,now()) &lt;= 30 and rental_end_date > now()
  267. </update>
  268. <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  269. update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8)
  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. and rental_start_date &lt;= now() and rental_end_date >= now()
  277. </update>
  278. <update id="updateRentContractEndStatus" 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 rental_end_date &lt;now()
  287. </update>
  288. <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxRentContract">
  289. update wx_rent_contract set status=#{status} where status not in(0,5,6,7)
  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 merchant_id is null
  297. </update>
  298. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract">
  299. update wx_rent_contract
  300. set apply_status=#{applyStatus}
  301. <if test=" null != businessType ">,business_type=#{businessType}</if>
  302. <if test=" null != status ">,status=#{status}</if>
  303. where id=#{id}
  304. </update>
  305. <update id="updateStatus" parameterType="com.iformall.domain.po.WxRentContract">
  306. update wx_rent_contract set status=#{status} where id=#{id}
  307. </update>
  308. <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  309. update wx_rent_contract set status=#{status} where shop_id in (
  310. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE status in(2,3,4)
  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. )s) and status in(0,1) and status!=7 and rent_shop_type=2
  318. <if test=" null != tenantId and '' != tenantId">
  319. and `tenant_id` = #{tenantId}
  320. </if>
  321. <if test=" null != parentTenantId and '' != parentTenantId">
  322. and `parent_tenant_id` = #{parentTenantId}
  323. </if>
  324. </update>
  325. <select id="getRentContractList" parameterType="com.iformall.domain.po.WxRentContract"
  326. resultType="com.iformall.domain.po.WxRentContract">
  327. select s.shop_id,s.shop_number,s.building_name building, s.floor_name floor,s.build_area,rc.* from (
  328. select s.id shop_id,ms.merchant_id,s.shop_number,b.building_name,f.floor_name,s.build_area,s.floor,s.building
  329. from wx_shop s
  330. left join wx_mall_building b on s.building=b.id
  331. left join wx_mall_floor f on s.floor=f.id
  332. left join wx_merchant_shop ms on s.id=ms.shop_id
  333. where ms.is_del=0) s
  334. inner join (select * from wx_rent_contract where status in(2,3,4)) rc on s.merchant_id=rc.merchant_id
  335. where 1=1
  336. <if test=" null != tenantId and '' != tenantId">
  337. and rc.`tenant_id` = #{tenantId}
  338. </if>
  339. <if test=" null != parentTenantId and '' != parentTenantId">
  340. and rc.`parent_tenant_id` = #{parentTenantId}
  341. </if>
  342. <if test=" null != shopNumber and ''!=shopNumber">
  343. and s.shop_number like concat('%', #{shopNumber},'%')
  344. </if>
  345. <if test=" null != floor and ''!=floor">
  346. and s.floor = #{floor}
  347. </if>
  348. <if test=" null != building and ''!=building">
  349. and s.building = #{building}
  350. </if>
  351. order by rc.id desc
  352. </select>
  353. <select id="updateStatusForUnsign" parameterType="com.iformall.domain.po.WxRentContract">
  354. update wx_rent_contract set status=1 where status=2 and merchant_id is null
  355. <if test=" null != tenantId and '' != tenantId">
  356. and `tenant_id` = #{tenantId}
  357. </if>
  358. <if test=" null != parentTenantId and '' != parentTenantId">
  359. and `parent_tenant_id` = #{parentTenantId}
  360. </if>
  361. </select>
  362. <select id="getRentInvalidList" parameterType="com.iformall.domain.po.WxRentContract"
  363. resultType="com.iformall.domain.po.WxRentContract">
  364. select id from wx_rent_contract where shop_id in (
  365. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE status in(2,3,4)
  366. <if test=" null != tenantId and '' != tenantId">
  367. and `tenant_id` = #{tenantId}
  368. </if>
  369. <if test=" null != parentTenantId and '' != parentTenantId">
  370. and `parent_tenant_id` = #{parentTenantId}
  371. </if>
  372. )s) and status in(0,1) and status!=7 and apply_status=1
  373. <if test=" null != tenantId and '' != tenantId">
  374. and `tenant_id` = #{tenantId}
  375. </if>
  376. <if test=" null != parentTenantId and '' != parentTenantId">
  377. and `parent_tenant_id` = #{parentTenantId}
  378. </if>
  379. </select>
  380. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  381. select count(*) from wx_rent_contract r,wx_bill_rent b
  382. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  383. </select>
  384. <select id="getMerchants" parameterType="com.iformall.domain.po.WxRentContract"
  385. resultType="com.iformall.domain.po.WxRentContract">
  386. select * from wx_rent_contract where status in(2,3,4)
  387. and merchant_id not in(select merchant_id from wx_property_contract where status in(2,3,4))
  388. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  389. </select>
  390. <select id="selectRentContractCountByShopId" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  391. select count(*) from wx_rent_contract where 1=1
  392. <if test=" null != tenantId and '' != tenantId">
  393. and `tenant_id` = #{tenantId}
  394. </if>
  395. <if test=" null != parentTenantId and '' != parentTenantId">
  396. and `parent_tenant_id` = #{parentTenantId}
  397. </if>
  398. and json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and status in (2,3,4)
  399. <if test="id!=null">
  400. and id!=#{id}
  401. </if>
  402. </select>
  403. <select id="selectRentContractByShopId" parameterType="com.iformall.domain.po.WxRentContract"
  404. resultType="com.iformall.domain.po.WxRentContract">
  405. select * from wx_rent_contract
  406. where 1=1
  407. <if test=" null != tenantId and '' != tenantId">
  408. and `tenant_id` = #{tenantId}
  409. </if>
  410. <if test=" null != parentTenantId and '' != parentTenantId">
  411. and `parent_tenant_id` = #{parentTenantId}
  412. </if>
  413. and json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and rent_shop_type =1
  414. <if test=" null != status ">and status=#{status} and status!=7</if>
  415. </select>
  416. <update id="updateInvalidContract" parameterType="com.iformall.domain.po.WxRentContract">
  417. update wx_rent_contract set status=#{status}
  418. where 1=1
  419. <if test=" null != tenantId and '' != tenantId">
  420. and `tenant_id` = #{tenantId}
  421. </if>
  422. <if test=" null != parentTenantId and '' != parentTenantId">
  423. and `parent_tenant_id` = #{parentTenantId}
  424. </if>
  425. and id in(select r.id from (
  426. select id from wx_rent_contract where json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"'))
  427. and rent_shop_type=1 and status in(0,1) and status!=7)r)
  428. </update>
  429. <select id="selectRentContractByMerchantId" parameterType="com.iformall.domain.po.WxRentContract"
  430. resultType="com.iformall.domain.po.WxRentContract">
  431. select * from wx_rent_contract
  432. where status in(2,3,4)
  433. and merchant_id = #{merchantId}
  434. </select>
  435. <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract"
  436. resultType="int">
  437. select count(*) from (
  438. select * from wx_rent_contract where contract_number=#{contractNumber}
  439. and status not in(5,6,7)
  440. <if test=" null != tenantId and '' != tenantId">
  441. and `tenant_id` = #{tenantId}
  442. </if>
  443. <if test=" null != parentTenantId and '' != parentTenantId">
  444. and `parent_tenant_id` = #{parentTenantId}
  445. </if>
  446. union
  447. select * from wx_rent_contract where contract_number=#{contractNumber}
  448. and apply_status in(1,2)
  449. <if test=" null != tenantId and '' != tenantId">
  450. and `tenant_id` = #{tenantId}
  451. </if>
  452. <if test=" null != parentTenantId and '' != parentTenantId">
  453. and `parent_tenant_id` = #{parentTenantId}
  454. </if>
  455. ) r
  456. <where>
  457. <if test="id!=null and id!=''">
  458. r.id!=#{id}
  459. </if>
  460. </where>
  461. </select>
  462. <select id="getShopType" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  463. select s.type
  464. from wx_rent_contract r
  465. left join wx_shop s on(s.id = r.`shop_id`)
  466. where r.id = #{id}
  467. </select>
  468. <resultMap id="contractMap" type="com.iformall.domain.vo.WxRentPropertyContractVo">
  469. <id column="id" property="id"/>
  470. <result column="contract_number" property="contractNumber"/>
  471. <result column="shop_number" property="shopNumber"/>
  472. <result column="merchant_name" property="merchantName"/>
  473. <result column="rent_info" property="rentInfo"/>
  474. <result column="rental_start_date" property="rentalStartDate"/>
  475. <result column="rental_end_date" property="rentalEndDate"/>
  476. <result column="rent_price" property="rentPrice"/>
  477. <result column="property_price" property="propertyPrice"/>
  478. <result column="type" property="type"/>
  479. <result column="status" property="status"/>
  480. <result column="apply_status" property="applyStatus"/>
  481. <result column="operation_type" property="operationType"/>
  482. <result column="rent_shop_type" property="rentShopType"/>
  483. <result column="merchant_id" property="merchantId"/>
  484. <result column="property_status" property="propertyStatus"/>
  485. <result column="rent_price_unit" property="rentPriceUnit"/>
  486. <result column="property_price_unit" property="propertyPriceUnit"/>
  487. <result column="bus_discount_time" property="busDiscountTime"/>
  488. <result column="bus_discount_ratio" property="busDiscountRatio"/>
  489. </resultMap>
  490. <select id="listContractVo" parameterType="com.iformall.domain.vo.WxRentPropertyContractVo" resultMap="contractMap">
  491. select rc.id,rc.merchant_name,rc.rental_start_date,rc.rental_end_date,rc.`status`,
  492. rc.price as rent_price,rc.contract_number,s.shop_number,rc.type,rc.apply_status,
  493. rc.rent_shop_type,rc.rent_info,pc.price as property_price,rc.merchant_id,pc.`status` as property_status,
  494. rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit,
  495. rc.business_type businessType,rc.bus_discount_ratio,rc.bus_discount_time
  496. from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id
  497. left join wx_shop s on rc.shop_id=s.id
  498. <where>
  499. <if test=" null != tenantId and '' != tenantId">
  500. and rc.`tenant_id` = #{tenantId}
  501. </if>
  502. <if test=" null != parentTenantId and '' != parentTenantId">
  503. and rc.`parent_tenant_id` = #{parentTenantId}
  504. </if>
  505. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like
  506. concat('%',#{merchantName},'%')
  507. </if>
  508. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  509. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  510. </if>
  511. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  512. and s.`shop_number` like concat('%',#{shopNumber},'%')
  513. </if>
  514. <if test=" null != status ">and rc.`status` = #{status}</if>
  515. <if test=" null != type ">and rc.`type` = #{type}</if>
  516. <if test=" null != rentShopType ">
  517. and rc.`rent_shop_type` = #{rentShopType}
  518. </if>
  519. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  520. <if test=" null != operationType ">and rc.`operation_type` = #{operationType}</if>
  521. <if test=" null != businessForRule and '' != businessForRule ">
  522. and rc.business_id in (${businessForRule})
  523. </if>
  524. <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule ">
  525. and rc.`id` in
  526. <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")">
  527. select id from wx_rent_contract where 1=1
  528. <if test=" null != tenantId and '' != tenantId">
  529. and `tenant_id` = #{tenantId}
  530. </if>
  531. <if test=" null != parentTenantId and '' != parentTenantId">
  532. and `parent_tenant_id` = #{parentTenantId}
  533. </if>
  534. and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select
  535. id from wx_shop where 1=1
  536. <if test=" null != tenantId and '' != tenantId">
  537. and `tenant_id` = #{tenantId}
  538. </if>
  539. <if test=" null != parentTenantId and '' != parentTenantId">
  540. and `parent_tenant_id` = #{parentTenantId}
  541. </if>
  542. and floor in (${floorForRule}))
  543. </foreach>
  544. </if>
  545. <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != floorForRule ">
  546. and rc.shop_id in (select id from wx_shop where 1=1
  547. <if test=" null != tenantId and '' != tenantId">
  548. and `tenant_id` = #{tenantId}
  549. </if>
  550. <if test=" null != parentTenantId and '' != parentTenantId">
  551. and `parent_tenant_id` = #{parentTenantId}
  552. </if>
  553. and floor in (${floorForRule}))
  554. </if>
  555. </where>
  556. <if test=" null != sortColumns">order by ${sortColumns}</if>
  557. <if test=" null == sortColumns">order by rc.createtime desc,rc.id desc</if>
  558. </select>
  559. <select id="getByBill" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
  560. select * from wx_rent_contract
  561. where id in(
  562. select rent_contract_id from wx_bill_rent id = #{id}
  563. )
  564. </select>
  565. <select id="getShopCountMax" resultType="int">
  566. select max(json_length(rent_info)) from wx_rent_contract
  567. </select>
  568. <select id="queryContractByBus" resultType="hashmap" parameterType="com.iformall.domain.po.WxBusiness">
  569. 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)
  570. 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
  571. union all
  572. 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)
  573. 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
  574. </select>
  575. <select id="selectRentContractByShopIds" resultType="com.iformall.domain.po.WxRentContract">
  576. SELECT rc.id,rc.rental_start_date,rc.rental_end_date,rc.`shop_id`,rc.`rent_shop_type`,rc.`rent_info` FROM
  577. `wx_rent_contract` rc
  578. WHERE rc.`status` IN (2,3,4) AND status!=7
  579. <if test=" null != tenantId and '' != tenantId">
  580. and `tenant_id` = #{tenantId}
  581. </if>
  582. <if test=" null != parentTenantId and '' != parentTenantId">
  583. and `parent_tenant_id` = #{parentTenantId}
  584. </if>
  585. AND ( (rc.`rent_shop_type`=2 AND rc.`shop_id` IN
  586. <foreach collection="shopIds" index="index" item="idItem" open="(" separator="," close=")">
  587. #{idItem}
  588. </foreach>
  589. )
  590. OR (rc.`rent_shop_type`=1 AND rc.`rent_info` REGEXP #{shopIdsRegexp})
  591. )
  592. </select>
  593. <select id="selectContractCountByShopId" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  594. SELECT count(*)
  595. FROM wx_rent_contract
  596. WHERE `status` = #{status} AND status!=7
  597. <if test=" null != tenantId and '' != tenantId">
  598. and `tenant_id` = #{tenantId}
  599. </if>
  600. <if test=" null != parentTenantId and '' != parentTenantId">
  601. and `parent_tenant_id` = #{parentTenantId}
  602. </if>
  603. AND (
  604. `rent_shop_type` = 1 AND
  605. json_contains(json_extract(rent_info, '$[*].shopId'), concat('"', #{shopId}, '"'))
  606. OR
  607. `rent_shop_type` = 2 AND `shop_id` = #{shopId}
  608. )
  609. </select>
  610. <select id="searchMerchantByname" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
  611. select merchant_id,merchant_name from wx_rent_contract where tenant_id = #{tenantId} and merchant_name like concat('%',#{merchantName},'%') and rent_shop_type = #{rentShopType} and status in (3,5) and merchant_id not in (select merchant_id from wx_rent_contract where status=9) ORDER BY merchant_name
  612. </select>
  613. <select id="getByMerchantId" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract">
  614. select * from wx_rent_contract where merchant_id = #{merchantId} and status in (3,5) ORDER BY rental_end_date DESC limit 1
  615. </select>
  616. <select id="getAllContractBymerchantId" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract">
  617. select * from wx_rent_contract where merchant_id = #{merchantId} ORDER BY rental_end_date
  618. </select>
  619. </mapper>