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.
 
 
 
 
 

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