123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- <?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.bz.smart_city.dao.pay.PayFeeMapper">
- <select id="getCustomInfoByMeterOrAccount" resultType="com.bz.smart_city.dto.pay.PayCustomRechargeDto">
- select
- c.id as "customId",
- c.accountnumber as "accountnumber",
- c.accountname as "accountname",
- c.account_id as "accountId",
- c.metercode as "metercode",
- c.watermeter_id as "watermeterId",
- c.office_id as "officeId",
- rech.id as "rechargeId",
- rech.remaining as "remaining"
- from pay_base_customerandmeterrela c
- left join pay_pay_rechargeaccount rech on rech.account_id=c.account_id
- <where>
- c.businessstate = 1 and c.site_id=#{siteId} and c.customer_id=#{customerId}
- <if test="accountnumber != null and accountnumber != '' ">
- and c.accountnumber=#{accountnumber}
- </if>
- <if test="metercode != null and metercode != '' ">
- and c.metercode =#{metercode}
- </if>
- <if test="accountId != null and accountId != '' ">
- and c.account_id =#{accountId}
- </if>
- </where>
- limit 1
- </select>
- <update id="updatePayReceivable">
- update pay_pay_receivable set
- debt=#{debt}
- ,update_date=#{updateDate}
- ,update_by = #{updateBy}
- where id=#{id}
- </update>
- <update id="updateRechargeaccount">
- update pay_pay_rechargeaccount set
- remaining=#{remaining}
- ,update_by=#{updateBy}
- ,update_date=#{updateDate}
- where id=#{id}
- </update>
- <select id="getReceivable" resultType="com.bz.smart_city.entity.pay.PayReceivable">
- select
- a.id as "id",
- a.account_id as "accountId",
- a.accountname as "accountname",
- a.accountnumber as "accountnumber",
- a.customerandmeterrela_id as "customerandmeterrelaId",
- a.meter_id as "meterId",
- a.metercode as "metercode",
- a.payamount as "payamount",
- a.waterbasicprice as "waterbasicprice",
- a.feetype as "feetype",
- a.waterproperty_id as "waterpropertyId",
- a.office_id as "officeId",
- a.watertype as "watertype",
- a.ladderlevel as "ladderlevel",
- a.debt as "debt"
- from pay_pay_receivable a
- where site_id=#{siteId} and customer_id=#{customerId}
- and debt >0
- <if test="accountId != null">
- and account_id=#{accountId}
- </if>
- <if test="list != null and list.size() != 0">
- and id in
- <foreach collection="list" item="item" open="(" separator=" or " close=")">
- #{item}
- </foreach>
- </if>
- order by a.year asc,a.month asc,a.feetype asc
- </select>
- <select id="getLastClosingAccount" resultType="com.bz.smart_city.entity.pay.BaseClosingAccountInfo">
- select
- YEAR,
- MONTH
- from pay_base_closingaccountinfo
- where site_id=#{siteId} and customer_id=#{customerId}
- order by YEAR desc , MONTH desc
- limit 1
- </select>
- <update id="updateAccountState">
- call updateAccountState(#{accountId});
- </update>
- <select id="findPayfeeAccountInfo" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeAccountInfoDto">
- select
- c.id as "custId",
- a.id as "accountId",
- c.accountnumber,
- c.accountname,
- a.mobilephone,
- a.address,
- a.idcardno,
- c.vatno,
- a.email,
- c.opendate,
- c.metercode,
- c.watermeter_id as "watermeterId",
- (select label from pay_sys_dict where type='住房类型' and `value`=c.housetype and site_id=#{siteId}
- and customer_id=#{customerId}) as "housetype",
- (select label from pay_sys_dict where type='结算方式' and `value`=c.calculateway and site_id=#{siteId}
- and customer_id=#{customerId}) as "calculateway",
- p.id as "waterPropertyId",
- p.name as "waterPropertyName",
- device.water_meter_no as "metereleno"
- from pay_base_customerandmeterrela c
- left join pay_base_account a on c.account_id=a.id
- left join pay_base_waterproperty p on c.waterProperty_id=p.id
- inner join sc_device device on device.metercode = c.metercode and device.customer_id =#{customerId}
- <where>
- c.businessstate=1 and c.site_id=#{siteId}
- <if test="id != null and id != ''">
- and c.id= #{id}
- </if>
- <if test="condition != null and condition != ''">
- and( c.accountname like concat('%',#{condition},'%')
- or c.accountnumber like concat('%',#{condition},'%')
- or a.mobilephone like concat('%',#{condition},'%')
- or a.address like concat('%',#{condition},'%')
- or device.water_meter_no like concat('%',#{condition},'%')
- )
- </if>
- <if test="programItems != null and programItems.size() != 0">
- and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- c.${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- </where>
- </select>
- <select id="getPayfeeDetaileBill" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeDetaileBill">
- select
- IFNULL(sum(r.debt),0) debt ,
- (case when (IFNULL(sum(r.debt),0)-IFNULL(max(remaining ),0)) <=0 then 0
- else (IFNULL(sum(r.debt),0)-IFNULL(max(remaining ),0) )end) as "receivableFee",
- IFNULL(max(remaining),0)-IFNULL(sum(r.debt),0) as "waterFee",
- IFNULL(max(remaining),0) as "remaining"
- from pay_pay_rechargeaccount a
- left join pay_pay_receivable r on a.account_id=r.account_id
- where a.account_id = #{accountId}
- </select>
- <select id="getPayfeeDetailed" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeDetailed">
- select
- r.account_id as "accountId",
- IFNULL(sum(case when r.feetype=1 then r.debt else 0 end),0) waterFee1,
- IFNULL(sum(case when r.feetype=2 then r.debt else 0 end),0) waterFee2,
- IFNULL(sum(case when r.feetype=3 then r.debt else 0 end),0) waterFee3,
- IFNULL(sum(case when r.feetype=4 then r.debt else 0 end),0) waterFee4,
- IFNULL(sum(case when r.feetype=5 then r.debt else 0 end),0) waterFee5,
- IFNULL(sum(case when r.feetype=6 then r.debt else 0 end),0) waterFee6
- from pay_pay_rechargeaccount a
- left join pay_pay_receivable r on a.account_id=r.account_id
- where a.account_id=#{accountId}
- group by a.account_id
- </select>
- <select id="getPayreceivableDebt" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeReceivableInfo">
- select
- account_id as "accountId",
- accountnumber,
- accountname,
- year,
- month,
- CONCAT(rece.year,'年',LPAD(rece.month, 2, 0),'月费用') as "name",
- sum(rece.debt) as "debt",
- "--" as "ladderlevelname",
- null as "price",
- max(rece.payamount) as "payamount",
- sum(rece.receivablefee) as "receivablefee",
- max(rece.create_date) as "createDate"
- from pay_pay_receivable rece
- where rece.debt > 0
- and rece.account_id=#{accountId}
- and `year`=#{year}
- group by account_id,accountnumber,accountname,`year`,`month`
- order by max(rece.create_date) desc
- </select>
- <select id="getPayreceivableDebtDetailed" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeReceivableInfo">
- select
- account_id as "accountId",
- accountnumber,
- accountname,
- year,
- month,
- rece.payitemname as "name",
- rece.debt as "debt",
- (case when rece.ladderlevel = 1 then '一阶'
- when rece.ladderlevel = 2 then '二阶'
- when rece.ladderlevel = 3 then '三阶'
- when rece.ladderlevel = 4 then '四阶'
- else '' end) as "ladderlevelname",
- rece.waterbasicprice as "price",
- rece.payamount,
- rece.receivablefee,
- rece.create_date
- from pay_pay_receivable rece
- where rece.debt > 0
- and rece.account_id=#{accountId}
- and `year`=#{year} and `month`=#{month}
- order by rece.create_date desc
- </select>
- <select id="getPayreceivedDetailed" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeReceivedInfo">
- select
- accountnumber,
- accountname,
- name as "name",
- (case when ladderlevel = 1 then '一阶'
- when ladderlevel = 2 then '二阶'
- when ladderlevel = 3 then '三阶'
- when ladderlevel = 4 then '四阶'
- else '' end) as "ladderlevelname",
- receivedamount,
- reced.payway as "payway",
- create_date as "createDate",
- iscanceled,
- (select name from sc_user where id = reced.cancelperson) as "cancelperson",
- canceltime,
- invoice_id as "invoiceId"
- from pay_pay_received reced
- where account_id=#{accountId}
- and `year`=#{year} and `month` = #{month} and payseriesno=#{payseriesno}
- order by create_date desc
- </select>
- <select id="getPayreceived" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeReceivedInfo">
- select
- account_id as "accountId",
- accountnumber,
- accountname,
- `year`,`month`,
- CONCAT(year,'年',LPAD(month, 2, 0),'月费用') as "name" ,
- '--'as "ladderlevelname",
- payseriesno as "payseriesno",
- sum(receivedamount) as "receivedamount",
- (case when min(reced.payway) != 5 then min(reced.payway) else max(reced.payway) end ) as "payway",
- max(reced.state) as "state",
- (select label from pay_sys_dict where type = '支付方式' and value =
- (case when min(reced.payway) != 5 then min(reced.payway) else max(reced.payway) end )
- and site_id = #{siteId} and customer_id =#{customerId}) as "paywayname",
- (select label from pay_sys_dict where type = '交易状态' and value = max(reced.state) and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
- max(invoice_id) as "invoiceId",
- max(iscanceled) as "iscanceled",
- (select name from sc_user where id= max(reced.cancelperson)) as "cancelperson",
- max(canceltime) as "canceltime",
- max(create_date) as "createDate",
- max(canceledrecord_id) as "canceledrecordId",
- ifnull(max(isprint),0) as "isprint"
- from pay_pay_received reced
- where
- account_id=#{accountId}
- and `year`=#{year}
- group by account_id,accountnumber,accountname,`year`,`month`,payseriesno
- order by max(create_date) desc
- </select>
- <select id="getWaterusedamount" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeWaterusedamount">
- select
- a.metercode AS "metercode",
- a.lastreading AS "lastreading",
- a.lastrecorddate AS "lastrecorddate",
- a.reading AS "reading",
- a.recorddate AS "recorddate",
- a.amount AS "amount",
- a.payamount AS "payamount",
- CONCAT(a.`year`,'年',LPAD(a.month, 2, 0),'月') as "closingName",
- (select label from pay_sys_dict where type = '水量状态' and value = a.state and site_id = #{siteId} and customer_id = #{customerId}) stateLabel,
- (case when a.state = 2 then '是' else '否' end ) isReceivable
- from pay_amount_waterusedamount a
- where a.`year`=#{year} and a.account_id=#{accountId}
- order by a.year desc ,a.month desc
- </select>
- <select id="getPayinvoiceInfo" resultType="com.bz.smart_city.dto.pay.PayInvoiceDto">
- select
- a.id,
- a.invoiceno as "invoiceno",
- a.account_id as "accountId",
- a.accountnumber as "accountnumber",
- a.accountname as "accountname",
- a.invoiceamount as "invoiceamount",
- a.state as "state",
- (select label from pay_sys_dict where type = '票据状态' and value = a.state and site_id = #{siteId} and customer_id = #{customerId}) stateLabel,
- a.create_date as "createDate",
- (select name from sc_user where id=a.create_by) as "createByName",
- a.canceltime as "canceltime",
- (select name from sc_user where id=a.cancelperson) as "cancelpersonName"
- from pay_pay_invoice a
- <where>
- a.type = 2
- <if test="accountId != null">
- and a.account_id=#{accountId}
- </if>
- <if test="year != null">
- and a.year = #{year}
- </if>
- </where>
- order by a.create_date desc
- </select>
- <select id="getWaterPropertyId" resultType="java.math.BigInteger">
- select
- waterproperty_id as "id"
- from pay_base_customerandmeterrela
- where account_id =#{id}
- </select>
- </mapper>
|