|
- <?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.WxPropertyContractMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPropertyContract">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
- <result column="price" jdbcType="INTEGER" 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="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="filepath" jdbcType="VARCHAR" property="filepath"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="contract_number" jdbcType="VARCHAR" property="contractNumber"/>
- <result column="deposit" jdbcType="INTEGER" property="deposit"/>
- <result column="pay_date" jdbcType="INTEGER" property="payDate"/>
- <result column="is_del" jdbcType="INTEGER" property="isDel"/>
- <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
- <result column="brand" jdbcType="VARCHAR" property="brand"/>
- <result column="business_id" jdbcType="BIGINT" property="businessId"/>
- <result column="shop_type" jdbcType="INTEGER" property="shopType"/>
- <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
- <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
- <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
- <result column="rent_area" jdbcType="VARCHAR" property="rentArea"/>
- <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="filename" jdbcType="VARCHAR" property="filename"/>
- <result column="lease" jdbcType="INTEGER" property="lease"/>
- <result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,`tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`rent_area`,`link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
- <if test=" null != id ">and `id` = #{id}</if>
- <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
- <if test=" null != price ">and `price` = #{price}</if>
- <if test=" null != rentalStartDate ">and `rental_start_date` = #{rentalStartDate}</if>
- <if test=" null != rentalEndDate ">and `rental_end_date` = #{rentalEndDate}</if>
- <if test=" null != signDate ">and `sign_date` = #{signDate}</if>
- <if test=" null != receivePeriod ">and `receive_period` = #{receivePeriod}</if>
- <if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if>
- <if test=" null != filepath ">and `filepath` = #{filepath}</if>
- <if test=" null != status ">and `status` = #{status}</if>
- <if test=" null != contractNumber ">and `contract_number` = #{contractNumber}</if>
- <if test=" null != deposit ">and `deposit` = #{deposit}</if>
- <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
- <if test=" null != isDel ">and `is_del` = #{isDel}</if>
- <if test=" null != merchantName ">and `merchant_name` = #{merchantName}</if>
- <if test=" null != brand ">and `brand` = #{brand}</if>
- <if test=" null != businessId ">and `business_id` = #{businessId}</if>
- <if test=" null != shopType ">and `shop_type` = #{shopType}</if>
- <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
- <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
- <if test=" null != createtime ">and `createtime` = #{createtime}</if>
- <if test=" null != rentArea ">and `rent_area` = #{rentArea}</if>
- <if test=" null != linkPerson ">and `link_person` = #{linkPerson}</if>
- <if test=" null != linkPhone ">and `link_phone` = #{linkPhone}</if>
- <if test=" null != payAccount ">and `pay_account` = #{payAccount}</if>
- <if test=" null != filename ">and `filename` = #{filename}</if>
- <if test=" null != lease ">and `lease` = #{lease}</if>
- <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</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.WxPropertyContract" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_property_contract
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="queryPropertyContractData" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
- select rc.id,rc.merchant_name merchantName,rc.rental_start_date rentalStartDate,rc.rental_end_date
- rentalEndDate,rc.`status`,
- rc.price,rc.contract_number contractNumber,s.shop_number shopNumber,f.floor_name floorName,b.building_name
- buildingName,
- rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate
- from wx_property_contract rc
- left join wx_shop s on rc.shop_id=s.id
- left join wx_mall_floor f on s.floor=f.id
- left join wx_mall_building b on s.building=b.id
- <where>
- rc.tenant_id=#{tenantId}
- <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like
- concat('%',#{merchantName},'%')
- </if>
- <if test=" null != shopNumber and shopNumber!=''">and s.`shop_number` like concat('%',#{shopNumber},'%')
- </if>
- <if test=" null != status ">and rc.`status` = #{status}</if>
- <if test=" null != rentContractId">and rc.`rent_contract_id` = #{rentContractId}</if>
- <if test=" null != id">and rc.`id` = #{id}</if>
- </where>
- order by rc.id desc
- </select>
-
- <select id="queryRentContractWaitSignStatus" resultType="int"
- parameterType="com.iformall.domain.po.WxPropertyContract">
- select count(id) from wx_property_contract where tenant_id=#{tenantId} and status=#{status}
- </select>
-
- <select id="queryRentContractEndSoonStatus" resultType="int"
- parameterType="com.iformall.domain.po.WxPropertyContract">
- select count(id) from wx_property_contract where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and DATEDIFF(rental_end_date,now()) <= 30 and rental_end_date > now()
- </select>
-
- <select id="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxPropertyContract">
- select count(id) from wx_property_contract where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and rental_start_date <= now() and rental_end_date >= now()
- </select>
-
- <select id="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxPropertyContract">
- select count(id) from wx_property_contract where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and rental_end_date <now()
- </select>
-
- <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
- update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and DATEDIFF(rental_end_date,now()) <= 30 and rental_end_date > now()
- </update>
-
- <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
- update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and rental_start_date <= now() and rental_end_date >= now()
- </update>
-
- <update id="updateRentContractEndStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
- update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=6 and status!=7 and rental_end_date <now()
- </update>
-
- <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
- update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=7 and merchant_id is null
- </update>
-
- <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
- update wx_property_contract set status=#{status} where shop_id in (
- select s.shop_id from (SELECT shop_id FROM wx_property_contract WHERE tenant_id = #{tenantId} and merchant_id is not null and status!=6
- )s) and merchant_id is null and tenant_id=#{tenantId}
- </update>
-
- <select id="getRentContractList" parameterType="hashmap" resultType="com.iformall.domain.po.WxRentContract">
- select rc.*,s.shop_number from wx_rent_contract rc inner join wx_shop s on rc.shop_id=s.id
- where rc.status not in(1,5,6,7) and rc.tenant_id=#{tenantId}
- and rc.id not in (select pc.rent_contract_id from (
- select rent_contract_id from wx_property_contract where status not in(1,5,6,7) and tenant_id=#{tenantId}
- ) pc)
-
- </select>
-
-
- </mapper>
|