|
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.iformall.mapper.WxRentContractMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxRentContract">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="customers_id" jdbcType="BIGINT" property="customersId"/>
- <result column="decimal_size" jdbcType="INTEGER" property="decimalSize"/>
- <result column="rental_start_date" jdbcType="TIMESTAMP" property="rentalStartDate"/>
- <result column="rental_end_date" jdbcType="TIMESTAMP" property="rentalEndDate"/>
- <result column="sign_date" jdbcType="TIMESTAMP" property="signDate"/>
- <result column="filepath" jdbcType="VARCHAR" property="filepath"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="contract_number" jdbcType="VARCHAR" property="contractNumber"/>
- <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
- <result column="create_by" jdbcType="BIGINT" property="createBy"/>
- <result column="create_by_name" jdbcType="VARCHAR" property="createByName"/>
- <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
- <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
- <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/>
- <result column="cashtype_content_lsit" jdbcType="VARCHAR" property="cashtypeContentLsit"/>
- <result column="is_del" jdbcType="INTEGER" property="isDel"/>
- <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/>
- <result column="link_phone" jdbcType="VARCHAR" property="linkPhone"/>
- <result column="link_address" jdbcType="VARCHAR" property="linkAddress"/>
- <result column="lease" jdbcType="INTEGER" property="lease"/>
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
- <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
- <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
- <result column="from_id" property="fromId"/>
- <result column="end_contract_time" jdbcType="TIMESTAMP" property="endContractTime"/>
- <result column="design_file" jdbcType="VARCHAR" property="designFile"/>
- <result column="day_price_calcute" jdbcType="INTEGER" property="dayPriceCalcute"/>
- <result column="month_average_days" jdbcType="INTEGER" property="monthAverageDays"/>
- <result column="shop_id_str" jdbcType="VARCHAR" property="shopIdStr"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="orgin_id" jdbcType="BIGINT" property="orginId"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`customers_id`,`tenant_id`,`parent_tenant_id`,
- `decimal_size`,`rental_start_date`,`rental_end_date`,`sign_date`,
- `filepath`,`status`,`contract_number`,`create_by`,`update_by`,
- `day_price_calcute`,`month_average_days`,
- cashtype_content_lsit,`is_del`,
- `updatetime`,`createtime`,`link_person`,`link_phone`,`link_address`,
- `lease`,`type`,
- `from_id`,`end_contract_time`,
- `apply_status`,`create_by_name`,`update_by_name`,
- `rent_info`, `file_names`,
- shop_id_str,
- design_file,remark,orgin_id
- </sql>
-
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
- <if test=" null != id ">and `id` = #{id}</if>
- <if test=" null != fromId ">and `from_id` = #{fromId}</if>
- <if test=" null != orginId ">and `orgin_id` = #{orginId}</if>
- <if test=" null != customersId ">and `customers_id` = #{customersId}</if>
- <if test=" null != rentalStartDate and '' != rentalStartDate">and `rental_start_date` = #{rentalStartDate}</if>
- <if test=" null != rentalEndDate and '' != rentalEndDate">and `rental_end_date` = #{rentalEndDate}</if>
- <if test=" null != useStartTime and null != useEndTime">
- and (
- (`rental_start_date` <= #{useStartTime} and rental_end_date > #{useStartTime})
- or
- (`rental_start_date` >= #{useStartTime} and rental_start_date < #{useEndTime})
- )
- </if>
- <if test=" null != signDate and '' != signDate">and `sign_date` = #{signDate}</if>
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != filepath and '' != filepath">and `filepath` = #{filepath}</if>
- <if test=" null != status and '' != status">and `status` = #{status}</if>
- <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
- <if test=" null != contractNumber and '' != contractNumber">and `contract_number` = #{contractNumber}</if>
- <if test=" null != isDel and '' != isDel">and `is_del` = #{isDel}</if>
- <if test=" null != updatetime and '' != updatetime">and `updatetime` = #{updatetime}</if>
- <if test=" null != createtime and '' != createtime">and `createtime` = #{createtime}</if>
- <if test=" null != linkPerson and '' != linkPerson">and `link_person` = #{linkPerson}</if>
- <if test=" null != linkPhone and '' != linkPhone">and `link_phone` = #{linkPhone}</if>
- <if test=" null != lease and '' != lease">and `lease` = #{lease}</if>
- <if test=" null != type and '' != type">and `type` = #{type}</if>
- <if test=" null != queryShopId and '' != queryShopId">and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{queryShopId},'"'))</if>
- <if test=" null != dayPriceCalcute ">and `day_price_calcute` = #{dayPriceCalcute}</if>
- <if test=" null != monthAverageDays ">and `month_average_days` = #{monthAverageDays}</if>
- <if test=" null != mainContract ">and `orgin_id` is null</if>
- <if test=" null != queryShopId">
- and concat(',',shop_id_str,',') like concat('%,',#{queryShopId},',%')
- </if>
-
- <if test=" null != customersIdList ">
- and customers_id in
- <foreach collection="customersIdList" index="index" item="cusItem" open="(" separator="," close=")">
- #{cusItem}
- </foreach>
- </if>
-
- <if test=" null != statuss ">
- and status in
- <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")">
- #{statusItem}
- </foreach>
- </if>
- <if test=" null != typeList ">
- and type in
- <foreach collection="typeList" index="index" item="typeItem" open="(" separator="," close=")">
- #{typeItem}
- </foreach>
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_rent_contract
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="findIdList" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
- select id
- from wx_rent_contract
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="findCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="java.lang.Long">
- select count(id)
- from wx_rent_contract
- where status=#{status}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
- <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract">
- update wx_rent_contract
- set apply_status=#{applyStatus}
- <if test=" null != status ">,status=#{status}</if>
- where id=#{id}
- </update>
-
- <update id="updateStatus" parameterType="com.iformall.domain.po.WxRentContract">
- update wx_rent_contract set status=#{status} where id=#{id}
- </update>
-
- <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
- select count(1) from wx_rent_contract r,wx_all_bill b
- where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
- </select>
-
- <select id="selectRentContractCountByShopId" parameterType="java.util.Map" resultType="int">
- select count(1) from wx_rent_contract where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{shopId},'"')) and status in (2,3,4)
- <if test="id!=null">
- and id!=#{id}
- </if>
- </select>
-
- <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract"
- resultType="int">
- select count(1) from (
- select * from wx_rent_contract where contract_number=#{contractNumber}
- and status not in(5,6,7)
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- union
- select * from wx_rent_contract where contract_number=#{contractNumber}
- and apply_status in(1,2)
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- ) r
- <where>
- <if test="id!=null and id!=''">
- r.id!=#{id}
- </if>
- </where>
- </select>
-
- <select id="getByBill" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
- select <include refid="allColumns"/> from wx_rent_contract
- where id in(
- select rent_contract_id from wx_all_bill id = #{id}
- )
- </select>
-
- <select id="getShopCountMax" resultType="int">
- select max(json_length(rent_info)) from wx_rent_contract
- </select>
-
- <select id="getCanApplyCount" resultType="Integer" parameterType="Long">
- select count(1) from wx_rent_contract where id != #{id} and (status=1 or (status=10 and apply_status=3) )
- </select>
-
- <select id="getUsedRentShopIds" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
- SELECT distinct shop_id FROM wx_rent_contract WHERE status in(1,2,3,4,8)
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
- <update id = "setEndContractTime" parameterType="com.iformall.domain.po.WxRentContract" >
- update wx_rent_contract set end_contract_time = #{endContractTime} where id = #{id}
- </update>
-
- <select id = "findToEndContractList" parameterType="com.iformall.domain.po.WxRentContract" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_rent_contract
- where `tenant_id` = #{tenantId} and status = 3 and end_contract_time <= now();
- </select>
-
- <update id="copyValidDeleteContract" parameterType="java.util.Map">
- insert into wx_rent_contract_valid_delete select * from wx_rent_contract where id = #{id} and `tenant_id` = #{tenantId}
- </update>
-
- <delete id="deleteContract" parameterType="java.util.Map">
- delete from wx_rent_contract where `tenant_id` = #{tenantId} and id = #{id}
- </delete>
-
- <update id = "updateContractId" parameterType="java.util.Map" >
- update wx_rent_contract set id = #{newId},orgin_id = null, where id = #{oldId} and `tenant_id` = #{tenantId}
- </update>
-
- </mapper>
|