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

356 rivejä
19 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="filepath" jdbcType="VARCHAR" property="filepath"/>
  14. <result column="status" jdbcType="INTEGER" property="status"/>
  15. <result column="contract_number" jdbcType="VARCHAR" property="contractNumber"/>
  16. <result column="deposit" jdbcType="INTEGER" property="deposit"/>
  17. <result column="pay_date" jdbcType="INTEGER" property="payDate"/>
  18. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  19. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
  20. <result column="brand" jdbcType="VARCHAR" property="brand"/>
  21. <result column="business_id" jdbcType="INTEGER" property="businessId"/>
  22. <result column="shop_type" jdbcType="INTEGER" property="shopType"/>
  23. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  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"/>
  51. <result column="rent_input_way" property="rentInputWay"/>
  52. <result column="adjust_ratio_way" property="adjustRatioWay"/>
  53. <result column="operation_type" property="operationType"/>
  54. <result column="late_pay_ratio" property="latePayRatio"/>
  55. <result column="late_pay_day" property="latePayDay"/>
  56. </resultMap>
  57. <sql id="allColumns">
  58. `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,
  59. `tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`,
  60. `brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`link_person`,`link_phone`,
  61. `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`,
  62. `start_date`,`end_date`,
  63. `apply_status`,`bank_name`,`rent_shop_type`,`fix_start_date`,`fix_end_date`,
  64. `business_type`,`rent_info`, `file_names`,price_unit,rent_price,`subject_name`,rent_start_type,
  65. `rent_input_way`,`adjust_ratio_way`,`operation_type`,late_pay_ratio,late_pay_day
  66. </sql>
  67. <sql id="dynamicWhereConditions">
  68. where 1 = 1
  69. <if test=" null != id ">and `id` = #{id}</if>
  70. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  71. <if test=" null != price ">and `price` = #{price}</if>
  72. <if test=" null != rentalStartDate ">and `rental_start_date` = #{rentalStartDate}</if>
  73. <if test=" null != rentalEndDate ">and `rental_end_date` = #{rentalEndDate}</if>
  74. <if test=" null != signDate ">and `sign_date` = #{signDate}</if>
  75. <if test=" null != receivePeriod ">and `receive_period` = #{receivePeriod}</if>
  76. <if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if>
  77. <if test=" null != filepath ">and `filepath` = #{filepath}</if>
  78. <if test=" null != status ">and `status` = #{status}</if>
  79. <if test=" null != contractNumber ">and `contract_number` = #{contractNumber}</if>
  80. <if test=" null != deposit ">and `deposit` = #{deposit}</if>
  81. <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
  82. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  83. <if test=" null != merchantName ">and `merchant_name` = #{merchantName}</if>
  84. <if test=" null != brand ">and `brand` = #{brand}</if>
  85. <if test=" null != businessId ">and `business_id` = #{businessId}</if>
  86. <if test=" null != shopType ">and `shop_type` = #{shopType}</if>
  87. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  88. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  89. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  90. <if test=" null != linkPerson ">and `link_person` = #{linkPerson}</if>
  91. <if test=" null != linkPhone ">and `link_phone` = #{linkPhone}</if>
  92. <if test=" null != payAccount ">and `pay_account` = #{payAccount}</if>
  93. <if test=" null != filename ">and `filename` = #{filename}</if>
  94. <if test=" null != lease ">and `lease` = #{lease}</if>
  95. <if test=" null != type ">and `type` = #{type}</if>
  96. <if test=" null != startDate ">and `start_date` = #{startDate}</if>
  97. <if test=" null != endDate ">and `end_date` = #{endDate}</if>
  98. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  99. <if test=" null != operationType ">and `operation_type` = #{operationType}</if>
  100. <if test=" null != ids ">
  101. and id in
  102. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  103. #{idItem}
  104. </foreach>
  105. </if>
  106. <if test=" null != sortColumns">order by ${sortColumns}</if>
  107. </sql>
  108. <select id="findList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  109. select
  110. <include refid="allColumns"/>
  111. from wx_rent_contract
  112. <include refid="dynamicWhereConditions"/>
  113. </select>
  114. <select id="queryRentContractData" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
  115. select rc.id,rc.merchant_name merchantName,rc.rental_start_date rentalStartDate,rc.rental_end_date rentalEndDate,rc.`status`,
  116. rc.price,rc.contract_number contractNumber,s.shop_number shopNumber,f.floor_name floorName,b.building_name buildingName,
  117. rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate,rc.merchant_id merchantId,rc.type,
  118. rc.start_date startDate,rc.end_date endDate,br.`name` brandName,rc.apply_status applyStatus,rc.bank_name
  119. bankName,rc.rent_shop_type rentShopType,rc.fix_start_date fixStartDate,rc.fix_end_date fixEndDate
  120. ,rc.business_type businessType,rc.adjust_period adjustPeriod,rc.rent_info rentInfo, rc.file_names
  121. fileNames,rc.price_unit,rc.subject_name subjectName,rc.`rent_input_way` rentInputWay,rc.`adjust_ratio_way`
  122. adjustRatioWay
  123. from wx_rent_contract rc
  124. left join wx_shop s on rc.shop_id=s.id
  125. left join wx_mall_floor f on s.floor=f.id
  126. left join wx_mall_building b on s.building=b.id
  127. left join wx_brand br on rc.brand=br.id
  128. <where>
  129. rc.tenant_id=#{tenantId}
  130. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like concat('%',#{merchantName},'%')</if>
  131. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  132. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  133. </if>
  134. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  135. and s.`shop_number` like concat('%',#{shopNumber},'%')
  136. </if>
  137. <if test=" null != status ">and rc.`status` = #{status}</if>
  138. <if test=" null != shopId">and rc.`shop_id` = #{shopId}</if>
  139. <if test=" null != type ">and rc.`type` = #{type}</if>
  140. <if test=" null != rentShopType ">and rc.`rent_shop_type` = #{rentShopType}</if>
  141. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  142. <if test=" null != building and ''!= building">and b.id = #{building}</if>
  143. <if test=" null != floor and ''!= floor">and f.id = #{floor}</if>
  144. <if test=" null != operationType ">and `operation_type` = #{operationType}</if>
  145. </where>
  146. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  147. <if test=" null == sortColumns"> order by rc.createtime desc,rc.id desc </if>
  148. </select>
  149. <select id="queryRentContractWaitSignStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  150. select count(id) from wx_rent_contract where tenant_id=#{tenantId} and status=#{status}
  151. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  152. </select>
  153. <select id="queryRentContractEndSoonStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  154. select count(id) from wx_rent_contract where tenant_id=#{tenantId} and status=4
  155. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  156. </select>
  157. <select id="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  158. select count(id) from wx_rent_contract where tenant_id=#{tenantId} and status in (2,3,4)
  159. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  160. </select>
  161. <select id="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  162. select count(id) from wx_rent_contract where tenant_id=#{tenantId} and status!=0 and status!=1 and status!=6 and
  163. status!=7
  164. and rental_end_date &lt;now()
  165. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  166. </select>
  167. <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxRentContract">
  168. update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and status!=0 and status!=5 and status!=1 and status!=6 and status!=7 and DATEDIFF(rental_end_date,now()) &lt;= 30 and rental_end_date > now()
  169. </update>
  170. <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  171. update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and status!=0 and status!=1 and status!=5 and status!=6 and status!=7 and rental_start_date &lt;= now() and rental_end_date >= now()
  172. </update>
  173. <update id="updateRentContractEndStatus" parameterType="com.iformall.domain.po.WxRentContract">
  174. update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and status!=0 and status!=1 and status!=5 and status!=6 and status!=7 and rental_end_date &lt;now()
  175. </update>
  176. <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxRentContract">
  177. update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and status!=0 and status!=5 and status!=6 and status!=7 and merchant_id is null
  178. </update>
  179. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract">
  180. update wx_rent_contract
  181. set apply_status=#{applyStatus}
  182. <if test=" null != businessType ">,business_type=#{businessType}</if>
  183. <if test=" null != status ">,status=#{status}</if>
  184. where id=#{id}
  185. </update>
  186. <update id="updateStatus" parameterType="com.iformall.domain.po.WxRentContract">
  187. update wx_rent_contract set status=#{status} where id=#{id}
  188. </update>
  189. <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  190. update wx_rent_contract set status=#{status} where shop_id in (
  191. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE tenant_id = #{tenantId} and status in(2,3,4)
  192. )s) and status in(0,1) and status!=7 and tenant_id=#{tenantId} and rent_shop_type=2
  193. </update>
  194. <select id="getRentContractList" parameterType="com.iformall.domain.po.WxRentContract"
  195. resultType="com.iformall.domain.po.WxRentContract">
  196. select s.shop_id,s.shop_number,s.building_name building, s.floor_name floor,s.build_area,rc.* from (
  197. select s.id shop_id,ms.merchant_id,s.shop_number,b.building_name,f.floor_name,s.build_area
  198. from wx_shop s
  199. left join wx_mall_building b on s.building=b.id
  200. left join wx_mall_floor f on s.floor=f.id
  201. left join wx_merchant_shop ms on s.id=ms.shop_id
  202. where ms.is_del=0) s
  203. inner join (select * from wx_rent_contract where status in(2,3,4)) rc on s.merchant_id=rc.merchant_id
  204. where rc.tenant_id=#{tenantId}
  205. order by rc.id desc
  206. </select>
  207. <select id="updateStatusForUnsign" parameterType="com.iformall.domain.po.WxRentContract">
  208. update wx_rent_contract set status=1 where tenant_id=#{tenantId} and status=2 and merchant_id is null
  209. </select>
  210. <select id="getRentInvalidList" parameterType="com.iformall.domain.po.WxRentContract"
  211. resultType="com.iformall.domain.po.WxRentContract">
  212. select id from wx_rent_contract where shop_id in (
  213. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE tenant_id = #{tenantId} and status in(2,3,4)
  214. )s) and status in(0,1) and status!=7 and tenant_id=#{tenantId} and apply_status=1
  215. </select>
  216. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  217. select count(*) from wx_rent_contract r,wx_bill_rent b
  218. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  219. </select>
  220. <select id="getMerchants" parameterType="com.iformall.domain.po.WxRentContract"
  221. resultType="com.iformall.domain.po.WxRentContract">
  222. select * from wx_rent_contract where status in(2,3,4)
  223. and merchant_id not in(select merchant_id from wx_property_contract where status in(2,3,4))
  224. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  225. </select>
  226. <select id="selectRentContractCountByShopId" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  227. select count(*) from wx_rent_contract where tenant_id=#{tenantId} and json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and status in (2,3,4)
  228. <if test="id!=null">
  229. and id!=#{id}
  230. </if>
  231. </select>
  232. <select id="selectRentContractByShopId" parameterType="com.iformall.domain.po.WxRentContract"
  233. resultType="com.iformall.domain.po.WxRentContract">
  234. select * from wx_rent_contract where tenant_id=#{tenantId} and
  235. json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and rent_shop_type =1
  236. <if test=" null != status ">and status=#{status} and status!=7</if>
  237. </select>
  238. <update id="updateInvalidContract" parameterType="com.iformall.domain.po.WxRentContract">
  239. update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and id in(select r.id from (
  240. select id from wx_rent_contract where json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"'))
  241. and rent_shop_type=1 and status in(0,1) and status!=7)r)
  242. </update>
  243. <select id="selectRentContractByMerchantId" parameterType="com.iformall.domain.po.WxRentContract"
  244. resultType="com.iformall.domain.po.WxRentContract">
  245. select * from wx_rent_contract
  246. where status in(2,3,4)
  247. and merchant_id = #{merchantId}
  248. </select>
  249. <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract"
  250. resultType="int">
  251. select count(*) from (
  252. select * from wx_rent_contract where tenant_id=#{tenantId}
  253. and contract_number=#{contractNumber}
  254. and status not in(5,6,7)
  255. union
  256. select * from wx_rent_contract where tenant_id=#{tenantId}
  257. and contract_number=#{contractNumber}
  258. and apply_status in(1,2)
  259. ) r
  260. <where>
  261. <if test="id!=null and id!=''">
  262. r.id!=#{id}
  263. </if>
  264. </where>
  265. </select>
  266. <select id="getShopType" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  267. select s.type from wx_rent_contract r left join wx_shop s on(s.id = r.`shop_id`)
  268. where r.id = #{id}
  269. </select>
  270. <resultMap id="contractMap" type="com.iformall.domain.vo.WxRentPropertyContractVo">
  271. <id column="id" property="id"/>
  272. <result column="contract_number" property="contractNumber"/>
  273. <result column="shop_number" property="shopNumber"/>
  274. <result column="merchant_name" property="merchantName"/>
  275. <result column="rent_info" property="rentInfo"/>
  276. <result column="rental_start_date" property="rentalStartDate"/>
  277. <result column="rental_end_date" property="rentalEndDate"/>
  278. <result column="rent_price" property="rentPrice"/>
  279. <result column="property_price" property="propertyPrice"/>
  280. <result column="type" property="type"/>
  281. <result column="status" property="status"/>
  282. <result column="apply_status" property="applyStatus"/>
  283. <result column="operation_type" property="operationType"/>
  284. <result column="rent_shop_type" property="rentShopType"/>
  285. <result column="merchant_id" property="merchantId"/>
  286. <result column="property_status" property="propertyStatus"/>
  287. <result column="rent_price_unit" property="rentPriceUnit"/>
  288. <result column="property_price_unit" property="propertyPriceUnit"/>
  289. </resultMap>
  290. <select id="listContractVo" parameterType="com.iformall.domain.vo.WxRentPropertyContractVo" resultMap="contractMap">
  291. select rc.id,rc.merchant_name,rc.rental_start_date,rc.rental_end_date,rc.`status`,
  292. rc.price as rent_price,rc.contract_number,s.shop_number,rc.type,rc.apply_status,
  293. rc.rent_shop_type,rc.rent_info,pc.price as property_price,rc.merchant_id,pc.`status` as property_status,
  294. rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit
  295. from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id
  296. left join wx_shop s on rc.shop_id=s.id
  297. <where>
  298. rc.tenant_id=#{tenantId}
  299. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like
  300. concat('%',#{merchantName},'%')
  301. </if>
  302. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  303. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  304. </if>
  305. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  306. and s.`shop_number` like concat('%',#{shopNumber},'%')
  307. </if>
  308. <if test=" null != status ">and rc.`status` = #{status}</if>
  309. <if test=" null != type ">and rc.`type` = #{type}</if>
  310. <if test=" null != rentShopType ">and rc.`rent_shop_type` = #{rentShopType}</if>
  311. <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
  312. <if test=" null != operationType ">and rc.`operation_type` = #{operationType}</if>
  313. </where>
  314. <if test=" null != sortColumns">order by ${sortColumns}</if>
  315. <if test=" null == sortColumns">order by rc.createtime desc,rc.id desc</if>
  316. </select>
  317. </mapper>