Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

772 wiersze
36 KiB

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