|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991 |
- <?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.WxBillAllMapper">
-
-
- <resultMap id="allVoResultMap" type="com.iformall.domain.vo.WxBillAllVo">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenantId" jdbcType="VARCHAR" property="tenantId" />
- <result column="parentTenantId" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="merchantId" jdbcType="INTEGER" property="merchantId" />
- <result column="shopId" jdbcType="INTEGER" property="shopId" />
-
- <result column="billTypeValue" jdbcType="INTEGER" property="billTypeValue"/>
- <result column="billType" jdbcType="VARCHAR" property="billType"/>
- <result column="needPay" jdbcType="BIGINT" property="needPay"/>
-
- <result column="merchantName" jdbcType="VARCHAR" property="merchantName" />
- <result column="rentShopType" jdbcType="INTEGER" property="rentShopType"/>
- <result column="receiveDate" jdbcType="TIMESTAMP" property="receiveDate" />
- <result column="expiredDay" jdbcType="INTEGER" property="expiredDay" />
- <result column="status" jdbcType="INTEGER" property="status" />
-
-
- <result column="receivePay" jdbcType="BIGINT" property="receivePay"/>
- <result column="owe" jdbcType="BIGINT" property="owe"/>
- <result column="pay" jdbcType="BIGINT" property="pay"/>
- <result column="payDate" jdbcType="TIMESTAMP" property="payDate" />
- <result column="starttime" jdbcType="TIMESTAMP" property="starttime" />
- <result column="endtime" jdbcType="TIMESTAMP" property="endtime" />
-
- <result column="shopNumber" jdbcType="VARCHAR" property="shopNumber"/>
- <result column="manager" jdbcType="VARCHAR" property="manager"/>
- <result column="managerPhone" jdbcType="VARCHAR" property="managerPhone"/>
-
- <result column="shopInfo" jdbcType="VARCHAR" property="shopInfo"/>
-
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="comments" property="comments"/>
-
- <result column="price_detail" property="priceDetail"/>
- <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
-
- <result column="freeze" property="freeze"/>
- <result column="late_pay_price" property="latePayPrice"/>
-
- <result column="service_charge_pay" property="serviceChargePay"/>
-
- </resultMap>
-
- <sql id = "billConditionSql" >
- <if test=" null != tenantId and '' != tenantId">
- and bill.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and bill.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != month and ''!=month">
- and date_format(bill.receive_date,'%Y-%m')=#{month}
- </if>
- <if test=" null != status ">and bill.`status` = #{status}</if>
- <if test=" null != rentShopType ">and bill.rent_shop_type = #{rentShopType}</if>
- <if test=" null != starttime and null!= endtime and '' != starttime and ''!= endtime ">
- and bill.receive_date between #{starttime} and #{endtime}
- </if>
- <if test=" null != merchantId and ''!=merchantId">
- and bill.merchant_id=#{merchantId}
- </if>
- <if test=" null != statusList ">
- and bill.`status` in
- <foreach collection="statusList" index="index" item="status" open="(" separator="," close=")">
- #{status}
- </foreach>
- </if>
-
- <if test=" null != freeze ">and bill.freeze = #{freeze}</if>
- <if test=" null != id ">and bill.id = #{id}</if>
-
- <if test=" null != merchantIdList ">
- and bill.`merchant_id` in
- <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
- #{merchantIdItem}
- </foreach>
- </if>
-
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- <if test=" null == sortColumns"> order by bill.receive_date,bill.id desc,bill.merchant_id,bill.status</if>
- </sql>
-
- <select id="listRentBill" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
- select id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租金' name,1 billTypeValue,'租金' billType,
- need_pay needPay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date payDate,expired_day expiredDay,status,starttime,
- endtime,rent_shop_type rentShopType,
- case when shop_info is null then '[]' else shop_info end shopInfo,
- comments,'' price_detail,updatetime,freeze,ifnull(late_pay_price,0) late_pay_price,service_charge_pay
- from wx_bill_rent bill
- where is_preview = 0
- <include refid="billConditionSql"/>
- </select>
-
- <select id="listRentDepositBill" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
- select id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租赁押金' name,2 billTypeValue,'租赁押金' billType,
- need_pay needPay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date payDate,expired_day expiredDay,status,starttime,
- endtime,rent_shop_type rentShopType,shop_info shopInfo,NULL comments,'' price_detail,updatetime,freeze,0 late_pay_price,0 service_charge_pay
- from wx_bill_rent_deposit bill
- where bill.`tenant_id` = #{tenantId}
- <include refid="billConditionSql"/>
- </select>
-
- <select id="listPropertyBill" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
- select id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'物业费' name,3 billTypeValue,'物业费' billType,
- need_pay needPay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date payDate,expired_day expiredDay,status,starttime,
- endtime,rent_shop_type rentShopType,case when shop_info is null then '[]' else shop_info end shopInfo,comments,'' price_detail,updatetime,
- freeze,ifnull(late_pay_price,0) late_pay_price,service_charge_pay
- from wx_bill_property bill
- where is_preview = 0
- <include refid="billConditionSql"/>
- </select>
-
- <select id="listPropertyDepositBill" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
- select id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'物业押金' name,4 billTypeValue,'物业押金' billType,
- need_pay needPay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date payDate,expired_day expiredDay,status,starttime,
- endtime,rent_shop_type rentShopType,shop_info shopInfo,NULL comments,'' price_detail,updatetime,freeze,0 late_pay_price,0 service_charge_pay
- from wx_bill_property_deposit bill
- where bill.`tenant_id` = #{tenantId}
- <include refid="billConditionSql"/>
- </select>
-
- <select id="listDailyBill" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
- select id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,case when type=1 then '水费' when type=2 then '电费' else '空调费' end name,
- case when type=1 then 5 when type=2 then 6 else 9 end billTypeValue,
- case when type=1 then '水费' when type=2 then '电费' else '空调费' end billType,
- 0 as needPay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date payDate,expired_day expiredDay,status,starttime,endtime,
- rent_shop_type rentShopType,'[]' shopInfo, NULL comments,price_detail,updatetime,freeze,0 late_pay_price,service_charge_pay
- from wx_bill_daily bill
- where bill.`tenant_id` = #{tenantId}
- <include refid="billConditionSql"/>
- </select>
-
- <select id="listOtherBill" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
- select id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,name,7 billTypeValue,concat('其他费用-',name) as billType,
- 0 as needPay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date payDate,expired_day expiredDay,status,starttime,endtime,
- rent_shop_type rentShopType,'[]' shopInfo,comments,'' price_detail,updatetime,freeze,0 late_pay_price,service_charge_pay
- from wx_bill_other bill
- where bill.`tenant_id` = #{tenantId}
- <include refid="billConditionSql"/>
- </select>
-
- <select id="listOtherDepositBill" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
- select id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,comments as name,8 billTypeValue,concat('其他押金-',comments) as
- billType,0 as needPay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date payDate,expired_day expiredDay,status,starttime,endtime,
- rent_shop_type rentShopType,'[]' shopInfo,comments,'' price_detail,updatetime,freeze,0 late_pay_price,service_charge_pay
- from wx_bill_other_deposit bill
- where bill.`tenant_id` = #{tenantId}
- <include refid="billConditionSql"/>
- </select>
-
- <select id="queryOweInfo" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
-
-
- select count(bill.id) owncount,IFNULL(sum(bill.owe),0) owe from (
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,1 bill_type_value,'租金'
- bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,2 bill_type_value,'租赁押金'
- bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
- wx_bill_rent_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,3 bill_type_value,'物业费'
- bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
- wx_bill_property where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,4 bill_type_value,'物业押金'
- bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
- wx_bill_property_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,5 bill_type_value,'水费' bill_type,0 as
- need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
- type=1
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,6 bill_type_value,'电费' bill_type,0 as
- need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
- type=2
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,9 bill_type_value,'空调费' bill_type,0 as
- need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
- type=3
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,7 bill_type_value,'其他费用' bill_type,0 as
- need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
- need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
- ) bill
- where bill.status=#{status}
- <if test=" null != tenantId and '' != tenantId">
- and bill.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and bill.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != starttime and null!= endtime ">
- and bill.receive_date between #{starttime} and #{endtime}
- </if>
- <if test=" null != month ">
- and date_format(bill.receive_date,'%Y-%m')=#{month}
- </if>
- <if test=" null != rentShopType ">
- and bill.rent_shop_type = #{rentShopType}
- </if>
- <if test=" null != billTypeList ">
- and bill.bill_type_value in
- <foreach collection="billTypeList" index="index" item="type" open="(" separator="," close=")">
- #{type}
- </foreach>
- </if>
-
- </select>
-
- <select id="queryPaidInfo" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
-
- select count(bill.id) paycount,IFNULL(sum(bill.pay),0) pay from (
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,1 bill_type_value,'租金'
- bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,2 bill_type_value,'租赁押金'
- bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
- wx_bill_rent_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,3 bill_type_value,'物业费'
- bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
- wx_bill_property where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,4 bill_type_value,'物业押金'
- bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
- wx_bill_property_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,5 bill_type_value,'水费' bill_type,0 as
- need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
- type=1
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,6 bill_type_value,'电费' bill_type,0 as
- need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
- type=2
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,9 bill_type_value,'空调费' bill_type,0 as
- need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
- type=3
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,7 bill_type_value,'其他费用' bill_type,0 as
- need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
- need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
- ) bill
- where bill.status=#{status}
- <if test=" null != tenantId and '' != tenantId">
- and bill.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and bill.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != starttime and null!= endtime ">
- and bill.receive_date between #{starttime} and #{endtime}
- </if>
- <if test=" null != month ">
- and date_format(bill.receive_date,'%Y-%m')=#{month}
- </if>
- <if test=" null != rentShopType ">
- and bill.rent_shop_type = #{rentShopType}
- </if>
- </select>
-
- <sql id = "billSql" >
- <if test=" null != id ">
- and bill.id=#{id}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and bill.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and bill.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != merchantId ">
- and bill.merchant_id=#{merchantId}
- </if>
- <if test=" null != statusList ">
- and bill.`status` in
- <foreach collection="statusList" index="index" item="status" open="(" separator="," close=")">
- #{status}
- </foreach>
- </if>
- <if test="null!=starttime and null!=endtime and ''!=starttime and ''!=endtime ">
- and DATE_FORMAT(bill.receive_date,'%Y-%m') between #{starttime} and #{endtime}
- </if>
- <if test=" null != status ">
- and bill.status=#{status}
- </if>
- <if test=" null != rentShopType ">
- and bill.rent_shop_type = #{rentShopType}
- </if>
- order by bill.merchant_id,bill.status desc,bill.receive_date desc
- </sql>
-
-
- <select id="listRentBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租金' name,1 billTypeValue,'租金' billType,
- need_pay needPay,receive_pay receivePay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) owe,
- receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,
- freeze,ifnull(late_pay_price,0) latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
-
- from wx_bill_rent bill
- where bill.is_preview = 0
- and rent_contract_id in (select id from wx_rent_contract where status in (2,3,4))
- <include refid="billSql"/>
- </select>
-
- <select id="listRentDepositBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
- select '' settle_number,id,merchant_id merchant_id,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租赁押金' name,2 billTypeValue,'租赁押金' billType,
- need_pay needPay,receive_pay receivePay,pay,(receive_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,
- status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,0 serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
-
- from wx_bill_rent_deposit bill
- where rent_contract_id in (select id from wx_rent_contract where status in (2,3,4))
- <include refid="billSql"/>
- </select>
-
- <select id="listPropertyBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'物业费' name,3 billTypeValue,'物业费' billType,
- need_pay needPay,receive_pay receivePay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) owe,receive_date receiveDate,pay_date payDate,
- DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,freeze,ifnull(late_pay_price,0) latePayPrice,
- service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
-
- from wx_bill_property bill
- where is_preview = 0
- and property_contract_id in (select id from wx_property_contract where status in(2,3,4))
- <include refid="billSql"/>
- </select>
-
- <select id="listPropertyDepositBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'物业押金' name,4 billTypeValue,'物业押金' billType,
- need_pay needPay,receive_pay receivePay,pay,(receive_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,
- endtime,rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,0 serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
-
- from wx_bill_property_deposit bill
- where property_contract_id in (select id from wx_property_contract where status in (2,3,4))
- <include refid="billSql"/>
- </select>
-
- <select id="listDailyBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,
- case when type=1 then '水费' when type=2 then '电费' else '空调费' end name,
- case when type=1 then 5 when type=2 then 6 else 9 end billTypeValue,
- case when type=1 then '水费' when type=2 then '电费' else '空调费' end billType, 0 as needPay,receive_pay receivePay,
- pay,(receive_pay+service_charge_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,
- rent_shop_type rentShopType,price_detail priceDetail,freeze,0 latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
-
- from wx_bill_daily bill where bill.merchant_id=#{merchantId}
- <include refid="billSql"/>
- </select>
-
- <select id="listOtherBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,name,7 billTypeValue,'其他费用' billType,0 as needPay,
- receive_pay receivePay,pay,(receive_pay+service_charge_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,'' starttime,'' endtime,
- rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
-
- from wx_bill_other bill where bill.merchant_id=#{merchantId}
- <include refid="billSql"/>
- </select>
-
- <select id="listOtherDepositBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,comments as name,8 billTypeValue,'其他押金' billType,
- 0 as needPay,receive_pay receivePay,pay,(receive_pay+service_charge_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,
- '' starttime,'' endtime,rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
-
- from wx_bill_other_deposit bill where bill.merchant_id=#{merchantId}
- <include refid="billSql"/>
- </select>
-
- <select id="listSettleBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
- select s.settle_number,s.id,s.merchant_id merchantId,'' shopId,s.tenant_id tenantId,parent_tenant_id parentTenantId,'结算单' name, 10 billTypeValue,'结算单' billType,0 needPay,
- settle_receive_pay receivePay,0 pay,0 owe,createtime receiveDate,'' pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,
- status,'' starttime,'' endtime,'' rentShopType,'' priceDetail, 0 freeze,0 latePayPrice,0 serviceChargePay
-
- from wx_bill_settle_schedule bill where bill.status >0
- <include refid="billSql"/>
- </select>
-
- <select id="detailRentBillData" resultType="hashmap" parameterType="Long">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租金' name,1 billTypeValue,'租金' billType,
- need_pay needPay,receive_pay receivePay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) owe,
- receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,
- freeze,ifnull(late_pay_price,0) latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
- from wx_bill_rent bill
- where bill.id = #{id}
- </select>
-
- <select id="detailRentDepositBillData" resultType="hashmap" parameterType="Long">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租赁押金' name,2 billTypeValue,'租赁押金' billType,
- need_pay needPay,receive_pay receivePay,pay,(receive_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,
- status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,0 serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
- from wx_bill_rent_deposit bill
- where bill.id = #{id}
- </select>
-
- <select id="detailPropertyBillData" resultType="hashmap" parameterType="Long">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'物业费' name,3 billTypeValue,'物业费' billType,
- need_pay needPay,receive_pay receivePay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) owe,receive_date receiveDate,pay_date payDate,
- DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,freeze,ifnull(late_pay_price,0) latePayPrice,
- service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
- from wx_bill_property bill
- where bill.id = #{id}
- </select>
-
- <select id="detailPropertyDepositBillData" resultType="hashmap" parameterType="Long">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'物业押金' name,4 billTypeValue,'物业押金' billType,
- need_pay needPay,receive_pay receivePay,pay,(receive_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,
- endtime,rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,0 serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
- from wx_bill_property_deposit bill
- where bill.id = #{id}
- </select>
-
- <select id="detailDailyBillData" resultType="hashmap" parameterType="Long">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,
- case when type=1 then '水费' when type=2 then '电费' else '空调费' end name,
- case when type=1 then 5 when type=2 then 6 else 9 end billTypeValue,
- case when type=1 then '水费' when type=2 then '电费' else '空调费' end billType, 0 as needPay,receive_pay receivePay,
- pay,(receive_pay+service_charge_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,
- rent_shop_type rentShopType,price_detail priceDetail,freeze,0 latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
- from wx_bill_daily bill where bill.id = #{id}
- </select>
-
- <select id="detailOtherBillData" resultType="hashmap" parameterType="Long">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,name,7 billTypeValue,'其他费用' billType,0 as needPay,
- receive_pay receivePay,pay,(receive_pay+service_charge_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,'' starttime,'' endtime,
- rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
- from wx_bill_other bill where bill.id = #{id}
- </select>
-
- <select id="detailOtherDepositBillData" resultType="hashmap" parameterType="Long">
- select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,comments as name,8 billTypeValue,'其他押金' billType,
- 0 as needPay,receive_pay receivePay,pay,(receive_pay+service_charge_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,
- '' starttime,'' endtime,rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
- from wx_bill_other_deposit bill where bill.id = #{id}
- </select>
-
- <select id="getWaitPayBill" resultType="hashmap">
- select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.receive_date receiveDate,
- bill.need_pay needPay,m.link_phone linkPhone,app.appname,m.email,bill.bill_type billType from (
- select bill.bill_type,bill.tenant_id,parent_tenant_id,bill.merchant_id,bill.receive_date,ifnull(sum(need_pay),0) need_pay from (
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_rent where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_rent_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_property where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_property_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=1
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=2
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=3
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_other
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_other_deposit
- ) bill
- where bill.status not in(3,5,6)
- group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.receive_date) bill
- left join wx_merchant m on bill.merchant_id=m.id
- left join (select tenant_id,parent_tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
- where m.status=1 and DATEDIFF(bill.receive_date,now())=m.bill_setting
- </select>
-
-
- <select id="getOweBill" resultType="hashmap">
- select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.owe,m.link_phone linkPhone,app.appname from (
- select bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,sum(owe) owe from (
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_rent where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_rent_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_property where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_property_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=1
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=2
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=3
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_other
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_other_deposit
- ) bill
- where DATEDIFF(bill.receive_date,now())<0 and bill.status not in(3,5,6)
- group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id) bill
- left join wx_merchant m on bill.merchant_id=m.id
- left join (select tenant_id,parent_tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
- where m.status=1
- </select>
-
- <select id="getWaitPayBillForEmail" resultType="hashmap">
- select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.receive_date receiveDate,
- bill.need_pay needPay,m.link_phone linkPhone,app.appname,m.email,bill.bill_type billType,ws.manager,ws.manager_phone managerPhone from (
- select bill.bill_type,bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.receive_date,ifnull(sum(need_pay),0) need_pay from (
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_rent where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_rent_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_property where is_preview = 0
- union
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_property_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=1
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=2
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=3
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_other
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_other_deposit
- ) bill
- where bill.status not in(3,5,6)
- group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.receive_date,bill.bill_type
- ) bill
- left join wx_merchant m on bill.merchant_id=m.id
- left join (select tenant_id,parent_tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
- left join wx_merchant_shop wms on wms.merchant_id = m.id
- left join wx_shop ws on wms.shop_id = ws.id
- where m.status=1 and DATEDIFF(bill.receive_date,now())=m.bill_setting
- </select>
-
- <select id="getOweBillForEmail" resultType="hashmap">
- select bill.tenant_id tenantId,bill.parent_tenant_id, parentTenantId,bill.merchant_id merchantId,bill.bill_type billType,bill.owe owe,m.link_phone managerPhone,m.`link_person` manager,m.email,app.appname,bill.receive_date receiveDate
- ,DATEDIFF(now(),bill.receive_date) expiredDay from (
- select bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.bill_type,sum(owe) owe,bill.receive_date,bill.expired_day from (
-
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_rent where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_rent_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_property where is_preview = 0
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type from wx_bill_property_deposit
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=1
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=2
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_daily where type=3
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_other
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
- from wx_bill_other_deposit
-
- ) bill
- where DATEDIFF(bill.receive_date,now())<0 and bill.status not in(3,5,6)
- group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.bill_type) bill
- left join wx_merchant m on bill.merchant_id=m.id
- left join (select tenant_id,parent_tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
- where m.status=1
- </select>
-
- <sql id="getOweBillAsPageConditions">
- and status !=6
- <if test="null != status ">
- and status = #{status}
- </if>
- <if test=" null != month and ''!=month">
- and date_format(receive_date,'%Y-%m')=#{month}
- </if>
- <if test=" null != starttime and ''!=starttime">
- and receive_date >= #{starttime}
- </if>
- <if test=" null != endtime and ''!=endtime">
- and receive_date <= #{endtime}
- </if>
- </sql>
-
- <select id="getOweBillAsPage" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
- select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.bill_type billType,
- m.link_phone managerPhone,m.`link_person` manager,m.email,
- bill.receive_date receiveDate,DATEDIFF(now(),bill.receive_date) expiredDay,
-
- round(bill.rentOwe/100,2) rentOwe,
- round(bill.propertyOwe/100,2) propertyOwe,
- round(bill.depositOwe/100,2) depositOwe,
- round(bill.otherOwe/100,2) otherOwe,
- round((bill.rentOwe+bill.propertyOwe+bill.depositOwe+bill.otherOwe)/100,2) totalOwe,
-
- <choose>
- <when test="1==filterHasPay">
- round((bill.rentReceivePay+bill.rentLatePay+bill.rentServiceChargePay-bill.rentPay)/100,2)
- rentReceivePay,
- round((bill.propertyReceivePay+bill.propertyLatePay+bill.propertyServiceChargePay-bill.propertyPay)/100,2)
- propertyReceivePay,
- round((bill.depositReceivePay+bill.depositLatePay+bill.depositServiceChargePay-bill.depositPay)/100,2)
- depositReceivePay,
- round((bill.otherReceivePay+bill.otherLatePay+bill.otherServiceChargePay-bill.otherPay)/100,2)
- otherReceivePay,
- round((bill.rentReceivePay+bill.propertyReceivePay+bill.depositReceivePay+bill.otherReceivePay
- +bill.rentLatePay+bill.propertyLatePay+bill.depositLatePay+bill.otherLatePay
- +bill.rentServiceChargePay+bill.propertyServiceChargePay+bill.depositServiceChargePay+bill.otherServiceChargePay
- -bill.rentPay-bill.propertyPay-bill.depositPay-bill.otherPay)/100,2) totalReceivePay
- </when>
- <otherwise>
- round((bill.rentReceivePay+bill.rentLatePay+bill.rentServiceChargePay)/100,2) rentReceivePay,
- round((bill.propertyReceivePay+bill.propertyLatePay+bill.propertyServiceChargePay)/100,2)
- propertyReceivePay,
- round((bill.depositReceivePay+bill.depositLatePay+bill.depositServiceChargePay)/100,2)
- depositReceivePay,
- round((bill.otherReceivePay+bill.otherLatePay+bill.otherServiceChargePay)/100,2) otherReceivePay,
- round((bill.rentReceivePay+bill.propertyReceivePay+bill.depositReceivePay
- +bill.otherReceivePay+bill.rentLatePay+bill.propertyLatePay+bill.depositLatePay
- +bill.otherLatePay+bill.rentServiceChargePay+bill.propertyServiceChargePay+bill.depositServiceChargePay+bill.otherServiceChargePay)/100,2)
- totalReceivePay
- </otherwise>
- </choose>
-
- from (
-
- select oweList.*,
- max(case oweList.bill_type when '租金' then oweList.owe else 0 end) rentOwe,
- max(case oweList.bill_type when '物业费' then oweList.owe else 0 end) propertyOwe,
- max(case oweList.bill_type when '欠缴押金' then oweList.owe else 0 end) depositOwe,
- max(case oweList.bill_type when '其他费用' then oweList.owe else 0 end) otherOwe,
-
- max(case oweList.bill_type when '租金' then oweList.receive_pay else 0 end) rentReceivePay,
- max(case oweList.bill_type when '物业费' then oweList.receive_pay else 0 end) propertyReceivePay,
- max(case oweList.bill_type when '欠缴押金' then oweList.receive_pay else 0 end) depositReceivePay,
- max(case oweList.bill_type when '其他费用' then oweList.receive_pay else 0 end) otherReceivePay,
-
- max(case oweList.bill_type when '租金' then oweList.pay else 0 end) rentPay,
- max(case oweList.bill_type when '物业费' then oweList.pay else 0 end) propertyPay,
- max(case oweList.bill_type when '欠缴押金' then oweList.pay else 0 end) depositPay,
- max(case oweList.bill_type when '其他费用' then oweList.pay else 0 end) otherPay,
-
- max(case oweList.bill_type when '租金' then oweList.latePayPrice else 0 end) rentLatePay,
- max(case oweList.bill_type when '物业费' then oweList.latePayPrice else 0 end) propertyLatePay,
- max(case oweList.bill_type when '欠缴押金' then oweList.latePayPrice else 0 end) depositLatePay,
- max(case oweList.bill_type when '其他费用' then oweList.latePayPrice else 0 end) otherLatePay,
-
- max(case oweList.bill_type when '租金' then oweList.serviceChargePay else 0 end) rentServiceChargePay,
- max(case oweList.bill_type when '物业费' then oweList.serviceChargePay else 0 end) propertyServiceChargePay,
- max(case oweList.bill_type when '欠缴押金' then oweList.serviceChargePay else 0 end) depositServiceChargePay,
- max(case oweList.bill_type when '其他费用' then oweList.serviceChargePay else 0 end) otherServiceChargePay
-
- from(
- select bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.bill_type,sum(owe)
- owe,bill.receive_date,bill.expired_day,sum(bill.receive_pay) receive_pay,sum(bill.pay)
- pay,sum(ifnull(bill.late_pay_price,0)) latePayPrice,sum(bill.service_charge_pay) serviceChargePay from (
-
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d')
- receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_rent
- where is_preview = 0
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <include refid="getOweBillAsPageConditions"/>
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_property where is_preview = 0
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <include refid="getOweBillAsPageConditions"/>
- union all
- select res.id,res.merchant_id,res.shop_id,res.tenant_id,res.parent_tenant_id,res.name,res.bill_type_value,res.bill_type,res.need_pay,
- res.receive_pay,res.pay,res.owe
- owe,res.receive_date,res.pay_date,res.expired_day,res.status,res.starttime,res.endtime,res.rent_shop_type,0
- late_pay_price,0 service_charge_pay from(
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'欠缴押金' name,2 bill_type_value,'欠缴押金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type,service_charge_pay from wx_bill_rent_deposit 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>
- <include refid="getOweBillAsPageConditions"/>
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'欠缴押金' name,4 bill_type_value,'欠缴押金'
- bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
- endtime,rent_shop_type,0 service_charge_pay from wx_bill_property_deposit 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>
- <include refid="getOweBillAsPageConditions"/>
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'欠缴押金' name,8 bill_type_value,'欠缴押金' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,
- pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay
- from wx_bill_other_deposit 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>
- <include refid="getOweBillAsPageConditions"/>
- ) res
- union all
- select res.id,res.merchant_id,res.shop_id,res.tenant_id,res.parent_tenant_id,res.name,res.bill_type_value,res.bill_type,res.need_pay,
- res.receive_pay,res.pay,res.owe
- owe,res.receive_date,res.pay_date,res.expired_day,res.status,res.starttime,res.endtime,res.rent_shop_type,0
- late_pay_price,service_charge_pay from(
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'其他费用' name,5 bill_type_value,'其他费用' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,
- expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay
- from wx_bill_daily where type in(1,2,3)
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <include refid="getOweBillAsPageConditions"/>
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'其他费用' name,7 bill_type_value,'其他费用' bill_type,0 as
- need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,
- expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay
- from wx_bill_other 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>
- <include refid="getOweBillAsPageConditions"/>
- ) res
-
- ) bill
- where bill.status not in(3,5,6)
- group by bill.merchant_id,bill.bill_type
-
- ) oweList group by oweList.merchant_id
-
- ) bill
- left join wx_merchant m on bill.merchant_id=m.id
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != merchantName and '' != merchantName">and m.name like concat('%', #{merchantName},'%')</if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- <if test=" null == sortColumns"> order by totalOwe desc </if>
- </select>
-
- <select id="getReceiveAndPayBillAsPage" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
-
- select tt.* from (
- select m.tenant_id,m.parent_tenant_id,m.id,m.name,ws.shop_number shopNumber,ws.type,m.link_person linkPerson,m.link_phone linkPhone,
- xb.title business,rc.rental_start_date rentalStartDate,rc.rental_end_date rentalEndDate,rc.rent_shop_type,
- ifnull(round(
- (select sum(bill.receive_pay)+sum(bill.late_pay_price)+sum(bill.receivePay) from (
- select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
- wx_bill_rent where is_preview = 0 and status not in(3,6)
- union all
- select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
- wx_bill_rent_deposit where status not in(3,6)
- union all
- select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
- wx_bill_property where is_preview = 0 and status not in(3,6)
- union all
- select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
- wx_bill_property_deposit where status not in(3,6)
- union all
- select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
- wx_bill_daily where type in(1,2,3) and status not in(3,6)
- union all
- select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
- wx_bill_other where status not in(3,6)
- union all
- select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
- wx_bill_other_deposit where status not in(3,6)
- ) bill where bill.merchant_id = m.id
- )/100,2),0) receivePay,
-
- ifnull(round(
- (select sum(ss.money) from (
- select subsidy money,merchant_id id from wx_merchant_subsidy where status = 0
- union all
- select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3
- union all
- select receive_pay money,merchant_id id from wx_bill_property_deposit where status = 3
- union all
- select receive_pay money,merchant_id id from wx_bill_other_deposit where status = 3
- )ss where ss.id = m.id
- )/100,2),0) payOut,
-
- (ifnull(round(
- (select sum(bill.receive_pay)+sum(bill.late_pay_price)+sum(bill.receivePay) from (
- select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
- wx_bill_rent
- where is_preview = 0 and status not in(3,6)
- union all
- select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
- wx_bill_rent_deposit where status not in(3,6)
- union all
- select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
- wx_bill_property where is_preview = 0 and status not in(3,6)
- union all
- select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
- wx_bill_property_deposit where status not in(3,6)
- union all
- select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
- wx_bill_daily where type in(1,2,3) and status not in(3,6)
- union all
- select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
- wx_bill_other where status not in(3,6)
- union all
- select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
- wx_bill_other_deposit where status not in(3,6)
- ) bill where bill.merchant_id = m.id
- )/100,2),0)-
- ifnull(round(
- (select sum(ss.money) from (
- select subsidy money,merchant_id id from wx_merchant_subsidy where order_type in(3,0) and status = 0
- union all
- select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3
- union all
- select receive_pay money,merchant_id id from wx_bill_property_deposit where status = 3
- union all
- select receive_pay money,merchant_id id from wx_bill_other_deposit where status = 3
- )ss where ss.id = m.id
- )/100,2),0)) balance
-
- from wx_merchant m
- left join (select ms.merchant_id,s.type,GROUP_CONCAT(s.shop_number) as shop_number
- from wx_merchant_shop ms inner join wx_shop s on ms.shop_id=s.id where ms.is_del=0
- group by ms.merchant_id) ws on m.id=ws.merchant_id
- left join wx_business xb on(m.business_id = xb.id)
- left join wx_rent_contract rc on(rc.merchant_id = m.id)
- where m.status=1
- ) tt where 1=1
-
- <if test=" null != tenantId and '' != tenantId">
- and tt.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and tt.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != merchantId"> and tt.id = #{merchantId} </if>
- <if test=" null != merchantName and ''!=merchantName">and tt.name like concat('%', #{merchantName},'%')</if>
- <if test=" null != rentShopType"> and tt.rent_shop_type = #{rentShopType} </if>
- and (receivePay >0 or payOut>0)
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- <if test=" null == sortColumns"> order by tt.id desc </if>
-
- <if test="null != limitStart and null != limitEnd">
- limit #{limitStart},#{limitEnd}
- </if>
- </select>
-
- <select id="allDepositList" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
- select bill.*
- from (
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 billTypeValue,'租赁押金'
- billType,need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze,0
- late_pay_price,0
- service_charge_pay
- from wx_bill_rent_deposit 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>
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 billTypeValue,'物业押金'
- billType,need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze,0
- late_pay_price,0
- service_charge_pay
- from wx_bill_property_deposit 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>
- union all
- select id,merchant_id,shop_id,tenant_id,parent_tenant_id,comments as name,8 billTypeValue,concat('其他押金-',comments) as
- billType,0 as need_pay,receive_pay receivePay,pay,owe,receive_date
- receiveDate,pay_date,expired_day,status,freeze,0
- late_pay_price,service_charge_pay
- from wx_bill_other_deposit 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>
- ) bill
- where 1=1
- <if test=" null != freeze"> and bill.freeze = #{freeze} </if>
- <if test=" null != status"> and bill.status = #{status} </if>
- <if test=" null != merchantId">and bill.merchant_id=#{merchantId}</if>
- </select>
-
- </mapper>
|