Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

679 lignes
32 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="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`,`updatetime`,`createtime`,`link_person`,`link_phone`,
  83. `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`,
  84. `start_date`,`end_date`,`shop_name`,
  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 != updatetime ">and `updatetime` = #{updatetime}</if>
  115. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  116. <if test=" null != linkPerson ">and `link_person` = #{linkPerson}</if>
  117. <if test=" null != linkPhone ">and `link_phone` = #{linkPhone}</if>
  118. <if test=" null != payAccount ">and `pay_account` = #{payAccount}</if>
  119. <if test=" null != filename ">and `filename` = #{filename}</if>
  120. <if test=" null != lease ">and `lease` = #{lease}</if>
  121. <if test=" null != type ">and `type` = #{type}</if>
  122. <if test=" null != startDate ">and `start_date` = #{startDate}</if>
  123. <if test=" null != endDate ">and `end_date` = #{endDate}</if>
  124. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  125. <if test=" null != operationType ">and `operation_type` = #{operationType}</if>
  126. <if test=" null != ids ">
  127. and id in
  128. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  129. #{idItem}
  130. </foreach>
  131. </if>
  132. <if test=" null != sortColumns">order by ${sortColumns}</if>
  133. </sql>
  134. <select id="findList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  135. select
  136. <include refid="allColumns"/>
  137. from wx_rent_contract
  138. <include refid="dynamicWhereConditions"/>
  139. </select>
  140. <!-- 需要修改 -->
  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="queryRentContractCountByStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  217. select count(1) 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 ">and rent_shop_type = #{rentShopType}</if>
  225. </select>
  226. <!-- <select id="queryRentContractWaitSignStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  227. select count(id) 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 ">
  235. and rent_shop_type = #{rentShopType}
  236. </if>
  237. </select> -->
  238. <!-- <select id="queryRentContractEndSoonStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  239. select count(id) from wx_rent_contract where status=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="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  249. select count(id) from wx_rent_contract where status in (2,3,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="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  259. 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()
  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. <!-- <update id="updateRentContractEndSoonStatus" 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 DATEDIFF(rental_end_date,now()) &lt;= 30 and rental_end_date > now()
  277. </update> -->
  278. <!-- <update id="updateRentContractPaidStatus" 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_start_date &lt;= now() and rental_end_date >= now()
  287. </update> -->
  288. <!-- <update id="updateRentContractEndStatus" 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_end_date &lt;now()
  297. </update> -->
  298. <!-- <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxRentContract">
  299. update wx_rent_contract set status=#{status} where status not in(0,5,6,7)
  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 merchant_id is null
  307. </update> -->
  308. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract">
  309. update wx_rent_contract
  310. set apply_status=#{applyStatus}
  311. <if test=" null != businessType ">,business_type=#{businessType}</if>
  312. <if test=" null != status ">,status=#{status}</if>
  313. where id=#{id}
  314. </update>
  315. <update id="updateStatus" parameterType="com.iformall.domain.po.WxRentContract">
  316. update wx_rent_contract set status=#{status} where id=#{id}
  317. </update>
  318. <!-- <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  319. update wx_rent_contract set status=#{status} where shop_id in (
  320. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE status in(2,3,4)
  321. <if test=" null != tenantId and '' != tenantId">
  322. and `tenant_id` = #{tenantId}
  323. </if>
  324. <if test=" null != parentTenantId and '' != parentTenantId">
  325. and `parent_tenant_id` = #{parentTenantId}
  326. </if>
  327. )s) and status in(0,1) and status!=7 and rent_shop_type=2
  328. </update> -->
  329. <!-- <select id="getRentContractList" parameterType="com.iformall.domain.po.WxRentContract"
  330. resultType="com.iformall.domain.po.WxRentContract">
  331. select s.shop_id,s.shop_number,s.building_name building, s.floor_name floor,s.build_area,rc.* from (
  332. select s.id shop_id,ms.merchant_id,s.shop_number,b.building_name,f.floor_name,s.build_area,s.floor,s.building
  333. from wx_shop s
  334. left join wx_mall_building b on s.building=b.id
  335. left join wx_mall_floor f on s.floor=f.id
  336. left join wx_merchant_shop ms on s.id=ms.shop_id
  337. where ms.is_del=0) s
  338. inner join (select * from wx_rent_contract where status in(2,3,4)) rc on s.merchant_id=rc.merchant_id
  339. where 1=1
  340. <if test=" null != tenantId and '' != tenantId">
  341. and rc.`tenant_id` = #{tenantId}
  342. </if>
  343. <if test=" null != parentTenantId and '' != parentTenantId">
  344. and rc.`parent_tenant_id` = #{parentTenantId}
  345. </if>
  346. <if test=" null != shopNumber and ''!=shopNumber">
  347. and s.shop_number like concat('%', #{shopNumber},'%')
  348. </if>
  349. <if test=" null != floor and ''!=floor">
  350. and s.floor = #{floor}
  351. </if>
  352. <if test=" null != building and ''!=building">
  353. and s.building = #{building}
  354. </if>
  355. order by rc.id desc
  356. </select> -->
  357. <select id="updateStatusForUnsign" parameterType="com.iformall.domain.po.WxRentContract">
  358. update wx_rent_contract set status=1 where status=2 and merchant_id is null
  359. <if test=" null != tenantId and '' != tenantId">
  360. and `tenant_id` = #{tenantId}
  361. </if>
  362. <if test=" null != parentTenantId and '' != parentTenantId">
  363. and `parent_tenant_id` = #{parentTenantId}
  364. </if>
  365. </select>
  366. <!-- <select id="getRentInvalidList" parameterType="com.iformall.domain.po.WxRentContract"
  367. resultType="com.iformall.domain.po.WxRentContract">
  368. select id from wx_rent_contract where shop_id in (
  369. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE status in(2,3,4)
  370. <if test=" null != tenantId and '' != tenantId">
  371. and `tenant_id` = #{tenantId}
  372. </if>
  373. <if test=" null != parentTenantId and '' != parentTenantId">
  374. and `parent_tenant_id` = #{parentTenantId}
  375. </if>
  376. )s) and status in(0,1) and status!=7 and apply_status=1
  377. <if test=" null != tenantId and '' != tenantId">
  378. and `tenant_id` = #{tenantId}
  379. </if>
  380. <if test=" null != parentTenantId and '' != parentTenantId">
  381. and `parent_tenant_id` = #{parentTenantId}
  382. </if>
  383. </select> -->
  384. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  385. select count(1) from wx_rent_contract r,wx_bill_rent b
  386. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  387. </select>
  388. <select id="getMerchants" parameterType="com.iformall.domain.po.WxRentContract"
  389. resultType="com.iformall.domain.po.WxRentContract">
  390. select <include refid="allColumns"/> from wx_rent_contract where status in(2,3,4)
  391. and merchant_id not in(select merchant_id from wx_property_contract where status in(2,3,4))
  392. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  393. </select>
  394. <select id="selectRentContractCountByShopId" parameterType="java.util.Map" resultType="int">
  395. select count(1) from wx_rent_contract where 1=1
  396. <if test=" null != tenantId and '' != tenantId">
  397. and `tenant_id` = #{tenantId}
  398. </if>
  399. <if test=" null != parentTenantId and '' != parentTenantId">
  400. and `parent_tenant_id` = #{parentTenantId}
  401. </if>
  402. and json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and status in (2,3,4)
  403. <if test="id!=null">
  404. and id!=#{id}
  405. </if>
  406. </select>
  407. <select id="selectRentContractByShopId" parameterType="com.iformall.domain.po.WxRentContract"
  408. resultType="com.iformall.domain.po.WxRentContract">
  409. select <include refid="allColumns"/> from wx_rent_contract
  410. where 1=1
  411. <if test=" null != tenantId and '' != tenantId">
  412. and `tenant_id` = #{tenantId}
  413. </if>
  414. <if test=" null != parentTenantId and '' != parentTenantId">
  415. and `parent_tenant_id` = #{parentTenantId}
  416. </if>
  417. and json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and rent_shop_type =1
  418. <if test=" null != status ">and status=#{status} and status!=7</if>
  419. </select>
  420. <update id="updateInvalidContract" parameterType="com.iformall.domain.po.WxRentContract">
  421. update wx_rent_contract set status=#{status}
  422. where 1=1
  423. <if test=" null != tenantId and '' != tenantId">
  424. and `tenant_id` = #{tenantId}
  425. </if>
  426. <if test=" null != parentTenantId and '' != parentTenantId">
  427. and `parent_tenant_id` = #{parentTenantId}
  428. </if>
  429. and id in(select r.id from (
  430. select id from wx_rent_contract where json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"'))
  431. and rent_shop_type=1 and status in(0,1) and status!=7)r)
  432. </update>
  433. <select id="selectRentContractByMerchantId" parameterType="com.iformall.domain.po.WxRentContract"
  434. resultType="com.iformall.domain.po.WxRentContract">
  435. select <include refid="allColumns"/> from wx_rent_contract
  436. where status in(2,3,4)
  437. and merchant_id = #{merchantId}
  438. </select>
  439. <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract"
  440. resultType="int">
  441. select count(1) from (
  442. select * from wx_rent_contract where contract_number=#{contractNumber}
  443. and status not in(5,6,7)
  444. <if test=" null != tenantId and '' != tenantId">
  445. and `tenant_id` = #{tenantId}
  446. </if>
  447. <if test=" null != parentTenantId and '' != parentTenantId">
  448. and `parent_tenant_id` = #{parentTenantId}
  449. </if>
  450. union
  451. select * from wx_rent_contract where contract_number=#{contractNumber}
  452. and apply_status in(1,2)
  453. <if test=" null != tenantId and '' != tenantId">
  454. and `tenant_id` = #{tenantId}
  455. </if>
  456. <if test=" null != parentTenantId and '' != parentTenantId">
  457. and `parent_tenant_id` = #{parentTenantId}
  458. </if>
  459. ) r
  460. <where>
  461. <if test="id!=null and id!=''">
  462. r.id!=#{id}
  463. </if>
  464. </where>
  465. </select>
  466. <!-- <select id="getShopType" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  467. select s.type
  468. from wx_rent_contract r
  469. left join wx_shop s on(s.id = r.`shop_id`)
  470. where r.id = #{id}
  471. </select> -->
  472. <resultMap id="contractMap" type="com.iformall.domain.vo.WxRentPropertyContractVo">
  473. <id column="id" property="id"/>
  474. <result column="contract_number" property="contractNumber"/>
  475. <result column="shop_number" property="shopNumber"/>
  476. <result column="merchant_name" property="merchantName"/>
  477. <result column="rent_info" property="rentInfo"/>
  478. <result column="rental_start_date" property="rentalStartDate"/>
  479. <result column="rental_end_date" property="rentalEndDate"/>
  480. <result column="rent_price" property="rentPrice"/>
  481. <result column="property_price" property="propertyPrice"/>
  482. <result column="type" property="type"/>
  483. <result column="status" property="status"/>
  484. <result column="apply_status" property="applyStatus"/>
  485. <result column="operation_type" property="operationType"/>
  486. <result column="rent_shop_type" property="rentShopType"/>
  487. <result column="merchant_id" property="merchantId"/>
  488. <result column="property_status" property="propertyStatus"/>
  489. <result column="rent_price_unit" property="rentPriceUnit"/>
  490. <result column="property_price_unit" property="propertyPriceUnit"/>
  491. <result column="bus_discount_time" property="busDiscountTime"/>
  492. <result column="bus_discount_ratio" property="busDiscountRatio"/>
  493. </resultMap>
  494. <!-- <select id="listContractVo" parameterType="com.iformall.domain.vo.WxRentPropertyContractVo" resultMap="contractMap">
  495. select rc.id,rc.merchant_name,rc.rental_start_date,rc.rental_end_date,rc.`status`,
  496. rc.price as rent_price,rc.contract_number,s.shop_number,rc.type,rc.apply_status,
  497. rc.rent_shop_type,rc.rent_info,pc.price as property_price,rc.merchant_id,pc.`status` as property_status,
  498. rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit,
  499. rc.business_type businessType,rc.bus_discount_ratio,rc.bus_discount_time
  500. from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id
  501. left join wx_shop s on rc.shop_id=s.id
  502. <where>
  503. <if test=" null != tenantId and '' != tenantId">
  504. and rc.`tenant_id` = #{tenantId}
  505. </if>
  506. <if test=" null != parentTenantId and '' != parentTenantId">
  507. and rc.`parent_tenant_id` = #{parentTenantId}
  508. </if>
  509. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like
  510. concat('%',#{merchantName},'%')
  511. </if>
  512. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  513. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  514. </if>
  515. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  516. and s.`shop_number` like concat('%',#{shopNumber},'%')
  517. </if>
  518. <if test=" null != status ">and rc.`status` = #{status}</if>
  519. <if test=" null != type ">and rc.`type` = #{type}</if>
  520. <if test=" null != rentShopType ">
  521. and rc.`rent_shop_type` = #{rentShopType}
  522. </if>
  523. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  524. <if test=" null != operationType ">and rc.`operation_type` = #{operationType}</if>
  525. <if test=" null != businessForRule and '' != businessForRule ">
  526. and rc.business_id in (${businessForRule})
  527. </if>
  528. <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule ">
  529. and rc.`id` in
  530. <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")">
  531. select id from wx_rent_contract where 1=1
  532. <if test=" null != tenantId and '' != tenantId">
  533. and `tenant_id` = #{tenantId}
  534. </if>
  535. <if test=" null != parentTenantId and '' != parentTenantId">
  536. and `parent_tenant_id` = #{parentTenantId}
  537. </if>
  538. and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select
  539. id from wx_shop where 1=1
  540. <if test=" null != tenantId and '' != tenantId">
  541. and `tenant_id` = #{tenantId}
  542. </if>
  543. <if test=" null != parentTenantId and '' != parentTenantId">
  544. and `parent_tenant_id` = #{parentTenantId}
  545. </if>
  546. and floor in (${floorForRule}))
  547. </foreach>
  548. </if>
  549. <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != floorForRule ">
  550. and rc.shop_id in (select id from wx_shop where 1=1
  551. <if test=" null != tenantId and '' != tenantId">
  552. and `tenant_id` = #{tenantId}
  553. </if>
  554. <if test=" null != parentTenantId and '' != parentTenantId">
  555. and `parent_tenant_id` = #{parentTenantId}
  556. </if>
  557. and floor in (${floorForRule}))
  558. </if>
  559. </where>
  560. <if test=" null != sortColumns">order by ${sortColumns}</if>
  561. <if test=" null == sortColumns">order by rc.createtime desc,rc.id desc</if>
  562. </select> -->
  563. <select id="getByBill" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
  564. select <include refid="allColumns"/> from wx_rent_contract
  565. where id in(
  566. select rent_contract_id from wx_bill_rent id = #{id}
  567. )
  568. </select>
  569. <select id="getShopCountMax" resultType="int">
  570. select max(json_length(rent_info)) from wx_rent_contract
  571. </select>
  572. <select id="queryContractByBus" resultType="hashmap" parameterType="com.iformall.domain.po.WxBusiness">
  573. 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)
  574. 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
  575. union all
  576. 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)
  577. 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
  578. </select>
  579. <!-- <select id="selectRentContractByShopIds" resultType="com.iformall.domain.po.WxRentContract">
  580. SELECT rc.id,rc.rental_start_date,rc.rental_end_date,rc.`shop_id`,rc.`rent_shop_type`,rc.`rent_info` FROM
  581. `wx_rent_contract` rc
  582. WHERE rc.`status` IN (2,3,4) AND status!=7
  583. <if test=" null != tenantId and '' != tenantId">
  584. and `tenant_id` = #{tenantId}
  585. </if>
  586. <if test=" null != parentTenantId and '' != parentTenantId">
  587. and `parent_tenant_id` = #{parentTenantId}
  588. </if>
  589. AND ( (rc.`rent_shop_type`=2 AND rc.`shop_id` IN
  590. <foreach collection="shopIds" index="index" item="idItem" open="(" separator="," close=")">
  591. #{idItem}
  592. </foreach>
  593. )
  594. OR (rc.`rent_shop_type`=1 AND rc.`rent_info` REGEXP #{shopIdsRegexp})
  595. )
  596. </select> -->
  597. <!-- <select id="selectContractCountByShopId" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  598. SELECT count(*)
  599. FROM wx_rent_contract
  600. WHERE `status` = #{status} AND status!=7
  601. <if test=" null != tenantId and '' != tenantId">
  602. and `tenant_id` = #{tenantId}
  603. </if>
  604. <if test=" null != parentTenantId and '' != parentTenantId">
  605. and `parent_tenant_id` = #{parentTenantId}
  606. </if>
  607. AND (
  608. `rent_shop_type` = 1 AND
  609. json_contains(json_extract(rent_info, '$[*].shopId'), concat('"', #{shopId}, '"'))
  610. OR
  611. `rent_shop_type` = 2 AND `shop_id` = #{shopId}
  612. )
  613. </select> -->
  614. <select id="searchMerchantByname" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
  615. 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
  616. </select>
  617. <select id="getByMerchantId" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract">
  618. select * from wx_rent_contract where merchant_id = #{merchantId} and status in (3,5) ORDER BY rental_end_date DESC limit 1
  619. </select>
  620. <select id="getAllContractBymerchantId" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract">
  621. select * from wx_rent_contract where merchant_id = #{merchantId} ORDER BY rental_end_date
  622. </select>
  623. <select id="getContractByMerchant" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract">
  624. select * from wx_rent_contract where merchant_id = #{merchantId} and status=3
  625. </select>
  626. </mapper>