|
- <?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="agile_type" jdbcType="INTEGER" property="agileType"/>
- <result column="customers_id" jdbcType="BIGINT" property="customersId"/>
- <result column="decimal_size" jdbcType="INTEGER" property="decimalSize"/>
- <result column="price" jdbcType="VARCHAR" property="price"/>
- <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="receive_period" jdbcType="INTEGER" property="receivePeriod"/>
- <result column="receive_period_unit" jdbcType="INTEGER" property="receivePeriodUnit"/>
- <result column="pay_period_rate" jdbcType="INTEGER" property="payPeriodRate"/>
- <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="deposit" jdbcType="VARCHAR" property="deposit"/>
- <result column="cashtype_content_lsit" jdbcType="VARCHAR" property="cashtypeContentLsit"/>
- <result column="cashtype_lsit" jdbcType="VARCHAR" property="cashtypeLsit"/>
- <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="pay_account" jdbcType="VARCHAR" property="payAccount"/>
- <result column="link_address" jdbcType="VARCHAR" property="linkAddress"/>
- <result column="filename" jdbcType="VARCHAR" property="filename"/>
- <result column="lease" jdbcType="INTEGER" property="lease"/>
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="revenue" jdbcType="VARCHAR" property="revenue"/>
- <result column="revenue_ratio" jdbcType="INTEGER" property="revenueRatio"/>
- <result column="revenue_ratio_way" jdbcType="INTEGER" property="revenueRatioWay"/>
- <result column="revenue_ratio_set" jdbcType="VARCHAR" property="revenueRatioSet"/>
- <result column="adjust_ratio" jdbcType="VARCHAR" property="adjustRatio"/>
- <result column="adjust_period" jdbcType="INTEGER" property="adjustPeriod"/>
- <result column="pay_ratio" jdbcType="INTEGER" property="payRatio"/>
- <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/>
- <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/>
- <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
- <result column="bank_name" jdbcType="VARCHAR" property="bankName"/>
- <result column="fix_start_date" property="fixStartDate"/>
- <result column="fix_end_date" property="fixEndDate"/>
- <result column="business_type" property="businessType"/>
- <result column="rent_info" jdbcType="VARCHAR" property="rentInfo"/>
- <result column="file_names" jdbcType="VARCHAR" property="fileNames"/>
- <result column="price_unit" property="priceUnit"/>
- <result column="rent_price" property="rentPrice"/>
- <result column="other_rent_price_info" jdbcType="VARCHAR" property="otherRentPriceInfo"/>
- <result column="subject_name" property="subjectName"/>
- <result column="rent_start_type" property="rentStartType"/>
- <result column="from_id" property="fromId"/>
- <result column="rent_input_way" property="rentInputWay"/>
- <result column="adjust_ratio_way" property="adjustRatioWay"/>
- <result column="operation_type" property="operationType"/>
- <result column="late_pay_ratio" property="latePayRatio"/>
- <result column="late_pay_day" property="latePayDay"/>
- <result column="end_contract_time" jdbcType="TIMESTAMP" property="endContractTime"/>
- <result column="bussiness_management_fee" jdbcType="VARCHAR" property="bussinessManagementFee"/>
- <result column="bussiness_management_fee_ratio_way" jdbcType="INTEGER" property="bussinessManagementFeeRatioWay"/>
- <result column="bussiness_management_fee_ratio" jdbcType="VARCHAR" property="bussinessManagementFeeRatio"/>
- <result column="operating_management_fee" jdbcType="VARCHAR" property="operatingManagementFee"/>
- <result column="operating_management_fee_ratio_way" jdbcType="INTEGER" property="operatingManagementFeeRatioWay"/>
- <result column="operating_management_fee_ratio" jdbcType="VARCHAR" property="operatingManagementFeeRatio"/>
- <result column="out_date_notify_days" jdbcType="INTEGER" property="outDateNotifyDays"/>
- <result column="out_date_notify_phone" jdbcType="VARCHAR" property="outDateNotifyPhone"/>
- <result column="design_file" jdbcType="VARCHAR" property="designFile"/>
- <result column="price_detail" jdbcType="VARCHAR" property="priceDetail"/>
- <result column="day_price_calcute" jdbcType="INTEGER" property="dayPriceCalcute"/>
- <result column="month_average_days" jdbcType="INTEGER" property="monthAverageDays"/>
- <result column="revenue_fixed_rent_price" jdbcType="INTEGER" property="revenueFixedRentPrice"/>
- <result column="revenue_rent_price" jdbcType="VARCHAR" property="revenueRentPrice"/>
- <result column="revenue_jumps_remark" jdbcType="VARCHAR" property="revenueJumpsRemark"/>
- <result column="free_period_remark" jdbcType="VARCHAR" property="freePeriodRemark"/>
- <result column="first_bill_date_start" jdbcType="TIMESTAMP" property="firstBillDateStart"/>
- <result column="first_bill_date_end" jdbcType="TIMESTAMP" property="firstBillDateEnd"/>
- <result column="first_bill_receive_date" jdbcType="TIMESTAMP" property="firstBillReceiveDate"/>
- <result column="shop_id_str" jdbcType="VARCHAR" property="shopIdStr"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`agile_type`,`customers_id`,`tenant_id`,`parent_tenant_id`,
- `decimal_size`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,`receive_period_unit`,
- `filepath`,`status`,`contract_number`,`price_detail`,`create_by`,`update_by`,
- `day_price_calcute`,`first_bill_date_start`,`first_bill_date_end`,`month_average_days`,`free_period_remark`,
- `deposit`,cashtype_content_lsit,cashtype_lsit,`is_del`,`revenue_jumps_remark`,
- `updatetime`,`createtime`,`link_person`,`link_phone`,`link_address`,
- `pay_account`,`filename`,`lease`,`type`,`revenue`,`revenue_ratio`,`revenue_ratio_way`,`revenue_ratio_set`,`adjust_ratio`,`adjust_period`,`pay_ratio`,
- `start_date`,`end_date`,`from_id`,`end_contract_time`,`revenue_fixed_rent_price`,`revenue_rent_price`,
- `apply_status`,`bank_name`,`fix_start_date`,`fix_end_date`,`pay_period_rate`,`create_by_name`,`update_by_name`,
- `business_type`,`rent_info`, `file_names`,price_unit,rent_price,other_rent_price_info,`subject_name`,rent_start_type,
- `rent_input_way`,`adjust_ratio_way`,`operation_type`,late_pay_ratio,late_pay_day,first_bill_receive_date,
- bussiness_management_fee,bussiness_management_fee_ratio_way,bussiness_management_fee_ratio,shop_id_str,
- operating_management_fee,operating_management_fee_ratio_way,operating_management_fee_ratio,out_date_notify_days,out_date_notify_phone,design_file
- </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 != agileType">and `agile_type` = #{agileType}</if>
- <if test=" null != customersId ">and `customers_id` = #{customersId}</if>
- <if test=" null != price and '' != price">and `price` = #{price}</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 != outDateNofity ">and out_date_notify_phone is not null and out_date_notify_phone != '' and out_date_notify_days is not null and out_date_notify_days > 0 </if>
- <if test=" null != signDate and '' != signDate">and `sign_date` = #{signDate}</if>
- <if test=" null != receivePeriod and '' != receivePeriod">and `receive_period` = #{receivePeriod}</if>
- <if test=" null != receivePeriodUnit and '' != receivePeriodUnit">and `receive_period_unit` = #{receivePeriodUnit}</if>
- <if test=" null != payPeriodRate and '' != payPeriodRate">and `pay_period_rate` = #{payPeriodRate}</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 != deposit and '' != deposit">and `deposit` = #{deposit}</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 != payAccount and '' != payAccount">and `pay_account` = #{payAccount}</if>
- <if test=" null != filename and '' != filename">and `filename` = #{filename}</if>
- <if test=" null != lease and '' != lease">and `lease` = #{lease}</if>
- <if test=" null != type and '' != type">and `type` = #{type}</if>
- <if test=" null != startDate and '' != startDate">and `start_date` = #{startDate}</if>
- <if test=" null != endDate and '' != endDate">and `end_date` = #{endDate}</if>
- <if test=" null != operationType and '' != operationType">and `operation_type` = #{operationType}</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 != revenueFixedRentPrice ">and `revenue_fixed_rent_price` = #{revenueFixedRentPrice}</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="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 != businessType ">,business_type=#{businessType}</if>
- <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>
-
- <resultMap id="contractMap" type="com.iformall.domain.vo.WxRentPropertyContractVo">
- <id column="id" property="id"/>
- <result column="tenant_id" property="tenantId"/>
- <result column="parent_tenant_id" property="parentTenantId"/>
- <result column="customers_id" jdbcType="BIGINT" property="customersId"/>
- <result column="rent_id" property="rentId"/>
- <result column="property_id" property="propertyId"/>
- <result column="rent_info" property="rentInfo"/>
- <result column="rental_start_date" property="rentalStartDate"/>
- <result column="rental_end_date" property="rentalEndDate"/>
- <result column="rent_price" property="rentPrice"/>
- <result column="price_detail" property="priceDetail"/>
- <result column="property_price" property="propertyPrice"/>
- <result column="type" property="type"/>
- <result column="status" property="status"/>
- <result column="apply_status" property="applyStatus"/>
- <result column="operation_type" property="operationType"/>
- <result column="property_status" property="propertyStatus"/>
- <result column="rent_price_unit" property="rentPriceUnit"/>
- <result column="property_price_unit" property="propertyPriceUnit"/>
- <result column="day_price_calcute" property="dayPriceCalcute"/>
- <result column="month_average_days" property="monthAverageDays"/>
- <result column="revenue_fixed_rent_price" jdbcType="INTEGER" property="revenueFixedRentPrice"/>
- <result column="revenue_rent_price" jdbcType="VARCHAR" property="revenueRentPrice"/>
- <result column="revenue_jumps_remark" jdbcType="VARCHAR" property="revenueJumpsRemark"/>
- <result column="free_period_remark" jdbcType="VARCHAR" property="freePeriodRemark"/>
- <result column="first_bill_date_start" jdbcType="TIMESTAMP" property="firstBillDateStart"/>
- <result column="first_bill_date_end" jdbcType="TIMESTAMP" property="firstBillDateEnd"/>
- </resultMap>
-
-
- <select id="listContractVo" parameterType="com.iformall.domain.vo.WxRentPropertyContractVo" resultMap="contractMap">
- select rc.id,rc.tenant_id,rc.parent_tenant_id,rc.customers_id,rc.id as rent_id, pc.id as property_id, rc.rental_start_date,rc.rental_end_date,rc.`status`,
- rc.price as rent_price,rc.contract_number,rc.type,rc.apply_status,rc.price_detail,rc.revenue_fixed_rent_price,rc.revenue_rent_price,
- rc.rent_info,pc.price as property_price,pc.`status` as property_status,
- rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit,rc.day_price_calcute,rc.free_period_remark,
- rc.business_type businessType,rc.month_average_days,rc.revenue_jumps_remark,rc.first_bill_date_start,rc.first_bill_date_end
- from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id
- <where>
- <if test=" null != tenantId and '' != tenantId">
- and rc.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and rc.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != contractNumber and '' != contractNumber">
- and rc.`contract_number` = #{contractNumber}
- </if>
- <if test=" null != rentId and '' != rentId">
- and rc.`id` = #{rentId}
- </if>
- <if test=" null != propertyId and '' != propertyId">
- and pc.`id` = #{propertyId}
- </if>
- <if test=" null != customersIdList ">
- and rc.customers_id in
- <foreach collection="customersIdList" index="index" item="cusItem" open="(" separator="," close=")">
- #{cusItem}
- </foreach>
- </if>
-
- <!-- <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1">
- and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%')
- </if>
- <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==2">
- and s.`shop_number` like concat('%',#{shopNumber},'%')
- </if> -->
- <if test=" null != status ">and rc.`status` = #{status}</if>
- <if test=" null != type ">and rc.`type` = #{type}</if>
- <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if>
- <if test=" null != operationType ">and rc.`operation_type` = #{operationType}</if>
- <if test=" null != dayPriceCalcute ">and rc.`day_price_calcute` = #{dayPriceCalcute}</if>
- <if test=" null != monthAverageDays ">and rc.`month_average_days` = #{monthAverageDays}</if>
- <if test=" null != ids ">
- and rc.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </where>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- <if test=" null == sortColumns">order by rc.createtime desc,rc.id desc</if>
- </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>
-
- </mapper>
|