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

281 строка
15 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. </resultMap>
  48. <sql id="allColumns">
  49. `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,
  50. `tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`,
  51. `brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`link_person`,`link_phone`,
  52. `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`,
  53. `start_date`,`end_date`,
  54. `apply_status`,`bank_name`,`rent_shop_type`,`fix_start_date`,`fix_end_date`,
  55. `business_type`,`rent_info`, `file_names`
  56. </sql>
  57. <sql id="dynamicWhereConditions">
  58. where 1 = 1
  59. <if test=" null != id ">and `id` = #{id}</if>
  60. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  61. <if test=" null != price ">and `price` = #{price}</if>
  62. <if test=" null != rentalStartDate ">and `rental_start_date` = #{rentalStartDate}</if>
  63. <if test=" null != rentalEndDate ">and `rental_end_date` = #{rentalEndDate}</if>
  64. <if test=" null != signDate ">and `sign_date` = #{signDate}</if>
  65. <if test=" null != receivePeriod ">and `receive_period` = #{receivePeriod}</if>
  66. <if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if>
  67. <if test=" null != filepath ">and `filepath` = #{filepath}</if>
  68. <if test=" null != status ">and `status` = #{status}</if>
  69. <if test=" null != contractNumber ">and `contract_number` = #{contractNumber}</if>
  70. <if test=" null != deposit ">and `deposit` = #{deposit}</if>
  71. <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
  72. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  73. <if test=" null != merchantName ">and `merchant_name` = #{merchantName}</if>
  74. <if test=" null != brand ">and `brand` = #{brand}</if>
  75. <if test=" null != businessId ">and `business_id` = #{businessId}</if>
  76. <if test=" null != shopType ">and `shop_type` = #{shopType}</if>
  77. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  78. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  79. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  80. <if test=" null != linkPerson ">and `link_person` = #{linkPerson}</if>
  81. <if test=" null != linkPhone ">and `link_phone` = #{linkPhone}</if>
  82. <if test=" null != payAccount ">and `pay_account` = #{payAccount}</if>
  83. <if test=" null != filename ">and `filename` = #{filename}</if>
  84. <if test=" null != lease ">and `lease` = #{lease}</if>
  85. <if test=" null != type ">and `type` = #{type}</if>
  86. <if test=" null != startDate ">and `start_date` = #{startDate}</if>
  87. <if test=" null != endDate ">and `end_date` = #{endDate}</if>
  88. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  89. <if test=" null != ids ">
  90. and id in
  91. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  92. #{idItem}
  93. </foreach>
  94. </if>
  95. <if test=" null != sortColumns">order by ${sortColumns}</if>
  96. </sql>
  97. <select id="findList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  98. select
  99. <include refid="allColumns"/>
  100. from wx_rent_contract
  101. <include refid="dynamicWhereConditions"/>
  102. </select>
  103. <select id="queryRentContractData" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
  104. select rc.id,rc.merchant_name merchantName,rc.rental_start_date rentalStartDate,rc.rental_end_date rentalEndDate,rc.`status`,
  105. rc.price,rc.contract_number contractNumber,s.shop_number shopNumber,f.floor_name floorName,b.building_name buildingName,
  106. rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate,rc.merchant_id merchantId,rc.type,
  107. rc.start_date startDate,rc.end_date endDate,br.`name` brandName,rc.apply_status applyStatus,rc.bank_name
  108. bankName,rc.rent_shop_type rentShopType,rc.fix_start_date fixStartDate,rc.fix_end_date fixEndDate
  109. ,rc.business_type businessType,rc.adjust_period adjustPeriod,rc.rent_info rentInfo, rc.file_names fileNames
  110. from wx_rent_contract rc
  111. left join wx_shop s on rc.shop_id=s.id
  112. left join wx_mall_floor f on s.floor=f.id
  113. left join wx_mall_building b on s.building=b.id
  114. left join wx_brand br on rc.brand=br.id
  115. <where>
  116. rc.tenant_id=#{tenantId}
  117. <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like concat('%',#{merchantName},'%')</if>
  118. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
  119. and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
  120. </if>
  121. <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
  122. and s.`shop_number` like concat('%',#{shopNumber},'%')
  123. </if>
  124. <if test=" null != status ">and rc.`status` = #{status}</if>
  125. <if test=" null != shopId">and rc.`shop_id` = #{shopId}</if>
  126. <if test=" null != type ">and rc.`type` = #{type}</if>
  127. <if test=" null != rentShopType ">and rc.`rent_shop_type` = #{rentShopType}</if>
  128. </where>
  129. order by rc.id desc
  130. </select>
  131. <select id="queryRentContractWaitSignStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  132. select count(id) from wx_rent_contract where tenant_id=#{tenantId} and status=#{status}
  133. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  134. </select>
  135. <select id="queryRentContractEndSoonStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  136. select count(id) from wx_rent_contract where tenant_id=#{tenantId} and status=4
  137. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  138. </select>
  139. <select id="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  140. select count(id) from wx_rent_contract where tenant_id=#{tenantId} and status in (2,3,4)
  141. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  142. </select>
  143. <select id="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxRentContract">
  144. select count(id) from wx_rent_contract where tenant_id=#{tenantId} and status!=0 and status!=1 and status!=6 and
  145. status!=7
  146. and rental_end_date &lt;now()
  147. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  148. </select>
  149. <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxRentContract">
  150. 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()
  151. </update>
  152. <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  153. 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()
  154. </update>
  155. <update id="updateRentContractEndStatus" parameterType="com.iformall.domain.po.WxRentContract">
  156. 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()
  157. </update>
  158. <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxRentContract">
  159. 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
  160. </update>
  161. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract">
  162. update wx_rent_contract
  163. set apply_status=#{applyStatus}
  164. <if test=" null != businessType ">,business_type=#{businessType}</if>
  165. <if test=" null != status ">,status=#{status}</if>
  166. where id=#{id}
  167. </update>
  168. <update id="updateStatus" parameterType="com.iformall.domain.po.WxRentContract">
  169. update wx_rent_contract set status=#{status} where id=#{id}
  170. </update>
  171. <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxRentContract">
  172. update wx_rent_contract set status=#{status} where shop_id in (
  173. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE tenant_id = #{tenantId} and status in(2,3,4)
  174. )s) and status in(0,1) and status!=7 and tenant_id=#{tenantId} and rent_shop_type=2
  175. </update>
  176. <select id="getRentContractList" parameterType="com.iformall.domain.po.WxRentContract"
  177. resultType="com.iformall.domain.po.WxRentContract">
  178. select s.shop_id,s.shop_number,s.building_name building, s.floor_name floor,s.build_area,rc.* from (
  179. select s.id shop_id,ms.merchant_id,s.shop_number,b.building_name,f.floor_name,s.build_area
  180. from wx_shop s
  181. left join wx_mall_building b on s.building=b.id
  182. left join wx_mall_floor f on s.floor=f.id
  183. left join wx_merchant_shop ms on s.id=ms.shop_id
  184. where ms.is_del=0) s
  185. inner join (select * from wx_rent_contract where status in(2,3,4)) rc on s.merchant_id=rc.merchant_id
  186. where rc.tenant_id=#{tenantId}
  187. order by rc.id desc
  188. </select>
  189. <select id="updateStatusForUnsign" parameterType="com.iformall.domain.po.WxRentContract">
  190. update wx_rent_contract set status=1 where tenant_id=#{tenantId} and status=2 and merchant_id is null
  191. </select>
  192. <select id="getRentInvalidList" parameterType="com.iformall.domain.po.WxRentContract"
  193. resultType="com.iformall.domain.po.WxRentContract">
  194. select id from wx_rent_contract where shop_id in (
  195. select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE tenant_id = #{tenantId} and status in(2,3,4)
  196. )s) and status in(0,1) and status!=7 and tenant_id=#{tenantId} and apply_status=1
  197. </select>
  198. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  199. select count(*) from wx_rent_contract r,wx_bill_rent b
  200. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  201. </select>
  202. <select id="getMerchants" parameterType="com.iformall.domain.po.WxRentContract"
  203. resultType="com.iformall.domain.po.WxRentContract">
  204. select * from wx_rent_contract where status in(2,3,4)
  205. and merchant_id not in(select merchant_id from wx_property_contract where status in(2,3,4))
  206. <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if>
  207. </select>
  208. <select id="selectRentContractCountByShopId" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  209. 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)
  210. </select>
  211. <select id="selectRentContractByShopId" parameterType="com.iformall.domain.po.WxRentContract"
  212. resultType="com.iformall.domain.po.WxRentContract">
  213. select * from wx_rent_contract where tenant_id=#{tenantId} and json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and status=#{status} and rent_shop_type =1
  214. </select>
  215. <update id="updateInvalidContract" parameterType="com.iformall.domain.po.WxRentContract">
  216. update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and id in(select r.id from (
  217. select id from wx_rent_contract where json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"'))
  218. and rent_shop_type=1 and status in(0,1) and status!=7)r)
  219. </update>
  220. <select id="selectRentContractByMerchantId" parameterType="com.iformall.domain.po.WxRentContract"
  221. resultType="com.iformall.domain.po.WxRentContract">
  222. select * from wx_rent_contract
  223. where status in(2,3,4)
  224. and merchant_id = #{merchantId}
  225. </select>
  226. <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract"
  227. resultType="int">
  228. select count(*) from (
  229. select * from wx_rent_contract where tenant_id=#{tenantId}
  230. and contract_number=#{contractNumber}
  231. and status not in(5,6,7)
  232. union
  233. select * from wx_rent_contract where tenant_id=#{tenantId}
  234. and contract_number=#{contractNumber}
  235. and apply_status in(1,2)
  236. ) r
  237. <where>
  238. <if test="id!=null and id!=''">
  239. r.id!=#{id}
  240. </if>
  241. </where>
  242. </select>
  243. <select id="getShopType" parameterType="com.iformall.domain.po.WxRentContract" resultType="int">
  244. select s.type from wx_rent_contract r left join wx_shop s on(s.id = r.`shop_id`)
  245. where r.id = #{id}
  246. </select>
  247. </mapper>