|
- <?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.WxBillPropertyMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillProperty">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="property_contract_id" jdbcType="INTEGER" property="propertyContractId" />
- <result column="receive_pay" jdbcType="BIGINT" property="receivePay"/>
- <result column="pay" jdbcType="BIGINT" property="pay"/>
- <result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate" />
- <result column="pay_date" jdbcType="TIMESTAMP" property="payDate" />
- <result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
- <result column="expired_day" jdbcType="INTEGER" property="expiredDay" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="owe" jdbcType="BIGINT" property="owe"/>
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="is_del" jdbcType="INTEGER" property="isDel" />
- <result column="need_pay" jdbcType="BIGINT" property="needPay"/>
- <result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
- <result column="user_id" jdbcType="INTEGER" property="userId" />
- <result column="shop_id" jdbcType="INTEGER" property="shopId" />
- <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
- <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
- <result column="revenue" jdbcType="BIGINT" property="revenue"/>
- <result column="late_pay_ratio" jdbcType="INTEGER" property="latePayRatio"/>
- <result column="late_pay_time" jdbcType="TIMESTAMP" property="latePayTime"/>
- <result column="late_pay_price" jdbcType="BIGINT" property="latePayPrice"/>
- <result column="period" jdbcType="INTEGER" property="period"/>
- <result column="is_preview" property="isPreview"/>
- <result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/>
- <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
- <result column="late_pay_status" jdbcType="INTEGER" property="latePayStatus"/>
- <result column="comments" jdbcType="VARCHAR" property="comments"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`property_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,
- `createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`,
- `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,
- `revenue`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,`period`,`is_preview`,`shop_info`,
- `pay_way`,`late_pay_status`,`comments`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1=1
- <if test=" null != id "> and `id` = #{id} </if>
- <if test=" null != propertyContractId "> and `property_contract_id` = #{propertyContractId} </if>
- <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
- <if test=" null != pay "> and `pay` = #{pay} </if>
- <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
- <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
- <if test=" null != createtime "> and `createtime` = #{createtime} </if>
- <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
- <if test=" null != tenantId "> and `tenant_id` = #{tenantId} </if>
- <if test=" null != owe "> and `owe` = #{owe} </if>
- <if test=" null != status "> and `status` = #{status} </if>
- <if test=" null != isDel "> and `is_del` = #{isDel} </if>
- <if test=" null != needPay "> and `need_pay` = #{needPay} </if>
- <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
- <if test=" null != userId "> and `user_id` = #{userId} </if>
- <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
- <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
- <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
- <if test=" null != isPreview ">and is_preview = #{isPreview}</if>
- <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
- <if test=" null != latePayStatus ">and `late_pay_status` = #{latePayStatus}</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.WxBillProperty" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_bill_property
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="queryBillPropertyList" parameterType="com.iformall.domain.po.WxBillProperty" resultType="hashmap">
- select br.`id`,br.`receive_pay` receivePay,
- case when br.status=1 then br.`pay` else 0 end pay
- ,br.`receive_date` receiveDate,
- br.`pay_date` payDate,br.`createtime`,br.`expired_day` expiredDay,
- case when br.status=1 then br.owe else 0 end owe
- ,br.`status`,
- br.`need_pay` needPay,m.`name` merchantName,s.shop_number shopNumber,br.`updatetime`,
- br.`merchant_id` merchantId,br.`rent_shop_type` rentShopType,br.`period`,
- br.`revenue`,br.`late_pay_ratio` latePayRatio,br.`late_pay_time` latePayTime,
- br.`property_contract_id` propertyContractId,d.receive_pay deposit,case when br.late_pay_status=2
- then (case when br.late_pay_time is null then 0
- else FLOOR(DATEDIFF(now(),br.late_pay_time)*br.late_pay_ratio/10000*br.owe)end)
- else br.late_pay_price end latePayPrice,
- (select max(period) from wx_bill_property where property_contract_id=br.property_contract_id)
- allPeriod,d.`status` depositStatus,br.`shop_info` shopInfo,br.pay_way payWay,br.late_pay_status latePayStatus,
- br.`comments`,br.starttime,br.endtime
- from wx_bill_property br left join wx_merchant m on br.merchant_id=m.id
- left join wx_shop s on br.shop_id=s.id
- left join wx_bill_property_deposit d on br.property_contract_id=d.property_contract_id
- <where>
- br.is_preview = 0
- <if test=" null != id ">and br.`id` = #{id}</if>
- <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
- <if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if>
- <if test=" null != tenantId ">and br.`tenant_id` = #{tenantId}</if>
- <if test=" null != status ">and br.`status` = #{status}</if>
- <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
- <if test=" null != starttime and null!=endtime ">and br.`receive_date` between #{starttime} and #{endtime}</if>
- <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
- <if test=" null != propertyContractId ">and br.`property_contract_id` = #{propertyContractId}</if>
- <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
- <if test=" null != latePayStatus ">and br.`late_pay_status` = #{latePayStatus}</if>
- <if test=" null != latePayStatus ">and br.`late_pay_status` = #{latePayStatus}</if>
- <if test=" null != depositStatus ">and d.`status` = #{depositStatus}</if>
- </where>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- </select>
-
- <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
- select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property
- where tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate} and is_preview = 0
- group by tenant_id
- </select>
-
-
- <select id="queryPayInfoTotal" resultType="hashmap" parameterType="hashmap">
- select round(sum(receive_pay)/100,2) receivepay,round(sum(pay)/100,2) pay,tenant_id from wx_bill_property
- where tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate} and is_preview = 0
- </select>
-
-
- <select id="queryOweInfo" resultType="hashmap" parameterType="hashmap">
- select IFNULL(round(sum(owe)/100,2),0) owe,tenant_id from wx_bill_property
- where status = 1 and tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate} and is_preview = 0
- </select>
-
- <update id="updateNotPaidStatus" parameterType="hashmap">
- update wx_bill_property set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
- where tenant_id=#{tenantId} and status!=#{paid} and status != 6 and DATEDIFF(now(),receive_date)>0
- </update>
-
- <update id="updateWaitPayStatus" parameterType="hashmap">
- update wx_bill_property set status=#{waitPay} where id in(
- select a.id from (select br.id,rc.receive_period,br.property_contract_id,br.receive_date from wx_bill_property br
- left join wx_property_contract rc on br.property_contract_id=rc.id
- where br.tenant_id=#{tenantId} and br.status!=#{paid} and br.status != 6 and now() < br.receive_date
- and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
- </update>
-
-
- <update id="updateInvalidStatus" parameterType="com.iformall.domain.po.WxBillProperty">
- update wx_bill_property set status = 6 where property_contract_id = #{propertyContractId}
- and status in(4,2)
- </update>
-
- <update id="updateInvalidStatusByRent" parameterType="com.iformall.domain.po.WxRentContract">
- update wx_bill_property set status = 6 where property_contract_id in
- (select id from wx_property_contract where rent_contract_id = #{id})
- and status != 3
- </update>
-
- <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxPropertyContract">
- delete from wx_bill_property where property_contract_id = #{id}
- </delete>
-
- <update id="update" parameterType="com.iformall.domain.po.WxBillProperty">
- update wx_bill_property set updatetime = now()
- <if test=" null != receivePay ">,receive_pay = #{receivePay},owe=#{receivePay}</if>
- <if test=" null != comments ">,comments = #{comments}</if>
- <if test=" null != receiveDate ">,receive_date = #{receiveDate}</if>
- <if test="0 == receivePay or 0l == receivePay">,status = 3,pay_date=now()</if>
- where id = #{id}
- </update>
-
- <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxBillProperty">
- update wx_bill_property set is_preview = #{isPreview},merchant_id = #{merchantId}
- where property_contract_id = #{propertyContractId}
- </update>
-
-
- <select id="oweBillCount" parameterType="java.lang.Long" resultType="java.lang.Long">
- select count(br.id) from wx_bill_property br,wx_property_contract c
- where c.id = br.property_contract_id and br.status = 1 and c.id = #{contractId}
- </select>
- </mapper>
|