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.
 
 
 
 
 

260 lines
11 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="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  8. <result column="customers_id" jdbcType="BIGINT" property="customersId"/>
  9. <result column="decimal_size" jdbcType="INTEGER" property="decimalSize"/>
  10. <result column="rental_start_date" jdbcType="TIMESTAMP" property="rentalStartDate"/>
  11. <result column="rental_end_date" jdbcType="TIMESTAMP" property="rentalEndDate"/>
  12. <result column="sign_date" jdbcType="TIMESTAMP" property="signDate"/>
  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="createtime" jdbcType="TIMESTAMP" property="createtime"/>
  17. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  18. <result column="create_by_name" jdbcType="VARCHAR" property="createByName"/>
  19. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
  20. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  21. <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/>
  22. <result column="cashtype_content_lsit" jdbcType="VARCHAR" property="cashtypeContentLsit"/>
  23. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  24. <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/>
  25. <result column="link_phone" jdbcType="VARCHAR" property="linkPhone"/>
  26. <result column="link_address" jdbcType="VARCHAR" property="linkAddress"/>
  27. <result column="lease" jdbcType="INTEGER" property="lease"/>
  28. <result column="type" jdbcType="INTEGER" property="type"/>
  29. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  30. <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
  31. <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
  32. <result column="from_id" property="fromId"/>
  33. <result column="end_contract_time" jdbcType="TIMESTAMP" property="endContractTime"/>
  34. <result column="design_file" jdbcType="VARCHAR" property="designFile"/>
  35. <result column="day_price_calcute" jdbcType="INTEGER" property="dayPriceCalcute"/>
  36. <result column="month_average_days" jdbcType="INTEGER" property="monthAverageDays"/>
  37. <result column="shop_id_str" jdbcType="VARCHAR" property="shopIdStr"/>
  38. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  39. <result column="orgin_id" jdbcType="BIGINT" property="orginId"/>
  40. </resultMap>
  41. <sql id="allColumns">
  42. `id`,`customers_id`,`tenant_id`,`parent_tenant_id`,
  43. `decimal_size`,`rental_start_date`,`rental_end_date`,`sign_date`,
  44. `filepath`,`status`,`contract_number`,`create_by`,`update_by`,
  45. `day_price_calcute`,`month_average_days`,
  46. cashtype_content_lsit,`is_del`,
  47. `updatetime`,`createtime`,`link_person`,`link_phone`,`link_address`,
  48. `lease`,`type`,
  49. `from_id`,`end_contract_time`,
  50. `apply_status`,`create_by_name`,`update_by_name`,
  51. `rent_info`, `file_names`,
  52. shop_id_str,
  53. design_file,remark,orgin_id
  54. </sql>
  55. <sql id="dynamicWhereConditions">
  56. where 1 = 1
  57. <if test=" null != id ">and `id` = #{id}</if>
  58. <if test=" null != fromId ">and `from_id` = #{fromId}</if>
  59. <if test=" null != orginId ">and `orgin_id` = #{orginId}</if>
  60. <if test=" null != customersId ">and `customers_id` = #{customersId}</if>
  61. <if test=" null != rentalStartDate and '' != rentalStartDate">and `rental_start_date` = #{rentalStartDate}</if>
  62. <if test=" null != rentalEndDate and '' != rentalEndDate">and `rental_end_date` = #{rentalEndDate}</if>
  63. <if test=" null != useStartTime and null != useEndTime">
  64. and (
  65. (`rental_start_date` &lt;= #{useStartTime} and rental_end_date &gt; #{useStartTime})
  66. or
  67. (`rental_start_date` &gt;= #{useStartTime} and rental_start_date &lt; #{useEndTime})
  68. )
  69. </if>
  70. <if test=" null != signDate and '' != signDate">and `sign_date` = #{signDate}</if>
  71. <if test=" null != tenantId and '' != tenantId">
  72. and `tenant_id` = #{tenantId}
  73. </if>
  74. <if test=" null != parentTenantId and '' != parentTenantId">
  75. and `parent_tenant_id` = #{parentTenantId}
  76. </if>
  77. <if test=" null != filepath and '' != filepath">and `filepath` = #{filepath}</if>
  78. <if test=" null != status and '' != status">and `status` = #{status}</if>
  79. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  80. <if test=" null != contractNumber and '' != contractNumber">and `contract_number` = #{contractNumber}</if>
  81. <if test=" null != isDel and '' != isDel">and `is_del` = #{isDel}</if>
  82. <if test=" null != updatetime and '' != updatetime">and `updatetime` = #{updatetime}</if>
  83. <if test=" null != createtime and '' != createtime">and `createtime` = #{createtime}</if>
  84. <if test=" null != linkPerson and '' != linkPerson">and `link_person` = #{linkPerson}</if>
  85. <if test=" null != linkPhone and '' != linkPhone">and `link_phone` = #{linkPhone}</if>
  86. <if test=" null != lease and '' != lease">and `lease` = #{lease}</if>
  87. <if test=" null != type and '' != type">and `type` = #{type}</if>
  88. <if test=" null != queryShopId and '' != queryShopId">and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{queryShopId},'"'))</if>
  89. <if test=" null != dayPriceCalcute ">and `day_price_calcute` = #{dayPriceCalcute}</if>
  90. <if test=" null != monthAverageDays ">and `month_average_days` = #{monthAverageDays}</if>
  91. <if test=" null != mainContract ">and `orgin_id` is null</if>
  92. <if test=" null != queryShopId">
  93. and concat(',',shop_id_str,',') like concat('%,',#{queryShopId},',%')
  94. </if>
  95. <if test=" null != customersIdList ">
  96. and customers_id in
  97. <foreach collection="customersIdList" index="index" item="cusItem" open="(" separator="," close=")">
  98. #{cusItem}
  99. </foreach>
  100. </if>
  101. <if test=" null != statuss ">
  102. and status in
  103. <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
  104. #{statusItem}
  105. </foreach>
  106. </if>
  107. <if test=" null != typeList ">
  108. and type in
  109. <foreach collection="typeList" index="index" item="typeItem" open="(" separator="," close=")">
  110. #{typeItem}
  111. </foreach>
  112. </if>
  113. <if test=" null != ids ">
  114. and id in
  115. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  116. #{idItem}
  117. </foreach>
  118. </if>
  119. <if test=" null != sortColumns">order by ${sortColumns}</if>
  120. </sql>
  121. <select id="findList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  122. select
  123. <include refid="allColumns"/>
  124. from wx_rent_contract
  125. <include refid="dynamicWhereConditions"/>
  126. </select>
  127. <select id="findIdList" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  128. select id
  129. from wx_rent_contract
  130. <include refid="dynamicWhereConditions"/>
  131. </select>
  132. <select id="findCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="java.lang.Long">
  133. select count(id)
  134. from wx_rent_contract
  135. where status=#{status}
  136. <if test=" null != tenantId and '' != tenantId">
  137. and `tenant_id` = #{tenantId}
  138. </if>
  139. <if test=" null != parentTenantId and '' != parentTenantId">
  140. and `parent_tenant_id` = #{parentTenantId}
  141. </if>
  142. </select>
  143. <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract">
  144. update wx_rent_contract
  145. set apply_status=#{applyStatus}
  146. <if test=" null != status ">,status=#{status}</if>
  147. where id=#{id}
  148. </update>
  149. <update id="updateStatus" parameterType="com.iformall.domain.po.WxRentContract">
  150. update wx_rent_contract set status=#{status} where id=#{id}
  151. </update>
  152. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  153. select count(1) from wx_rent_contract r,wx_all_bill b
  154. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  155. </select>
  156. <select id="selectRentContractCountByShopId" parameterType="java.util.Map" resultType="int">
  157. select count(1) from wx_rent_contract where 1=1
  158. <if test=" null != tenantId and '' != tenantId">
  159. and `tenant_id` = #{tenantId}
  160. </if>
  161. <if test=" null != parentTenantId and '' != parentTenantId">
  162. and `parent_tenant_id` = #{parentTenantId}
  163. </if>
  164. and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{shopId},'"')) and status in (2,3,4)
  165. <if test="id!=null">
  166. and id!=#{id}
  167. </if>
  168. </select>
  169. <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract"
  170. resultType="int">
  171. select count(1) from (
  172. select * from wx_rent_contract where contract_number=#{contractNumber}
  173. and status not in(5,6,7)
  174. <if test=" null != tenantId and '' != tenantId">
  175. and `tenant_id` = #{tenantId}
  176. </if>
  177. <if test=" null != parentTenantId and '' != parentTenantId">
  178. and `parent_tenant_id` = #{parentTenantId}
  179. </if>
  180. union
  181. select * from wx_rent_contract where contract_number=#{contractNumber}
  182. and apply_status in(1,2)
  183. <if test=" null != tenantId and '' != tenantId">
  184. and `tenant_id` = #{tenantId}
  185. </if>
  186. <if test=" null != parentTenantId and '' != parentTenantId">
  187. and `parent_tenant_id` = #{parentTenantId}
  188. </if>
  189. ) r
  190. <where>
  191. <if test="id!=null and id!=''">
  192. r.id!=#{id}
  193. </if>
  194. </where>
  195. </select>
  196. <select id="getByBill" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  197. select <include refid="allColumns"/> from wx_rent_contract
  198. where id in(
  199. select rent_contract_id from wx_all_bill id = #{id}
  200. )
  201. </select>
  202. <select id="getShopCountMax" resultType="int">
  203. select max(json_length(rent_info)) from wx_rent_contract
  204. </select>
  205. <select id="getCanApplyCount" resultType="Integer" parameterType="Long">
  206. select count(1) from wx_rent_contract where id != #{id} and (status=1 or (status=10 and apply_status=3) )
  207. </select>
  208. <select id="getUsedRentShopIds" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  209. SELECT distinct shop_id FROM wx_rent_contract WHERE status in(1,2,3,4,8)
  210. <if test=" null != tenantId and '' != tenantId">
  211. and `tenant_id` = #{tenantId}
  212. </if>
  213. <if test=" null != parentTenantId and '' != parentTenantId">
  214. and `parent_tenant_id` = #{parentTenantId}
  215. </if>
  216. </select>
  217. <update id = "setEndContractTime" parameterType="com.iformall.domain.po.WxRentContract" >
  218. update wx_rent_contract set end_contract_time = #{endContractTime} where id = #{id}
  219. </update>
  220. <select id = "findToEndContractList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
  221. select
  222. <include refid="allColumns"/>
  223. from wx_rent_contract
  224. where `tenant_id` = #{tenantId} and status = 3 and end_contract_time &lt;= now();
  225. </select>
  226. <update id="copyValidDeleteContract" parameterType="java.util.Map">
  227. insert into wx_rent_contract_valid_delete select * from wx_rent_contract where id = #{id} and `tenant_id` = #{tenantId}
  228. </update>
  229. <delete id="deleteContract" parameterType="java.util.Map">
  230. delete from wx_rent_contract where `tenant_id` = #{tenantId} and id = #{id}
  231. </delete>
  232. <update id = "updateContractId" parameterType="java.util.Map" >
  233. update wx_rent_contract set id = #{newId},orgin_id = null, where id = #{oldId} and `tenant_id` = #{tenantId}
  234. </update>
  235. </mapper>