123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507 |
- <?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="," 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",
- device.control_status as "valveStatus"
- 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 c.watermeter_id=device.id 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>
- <select id="selectBankPayfeeAccountInfo" resultType="com.bz.smart_city.dto.pay.payfee.BankPayfeeAccountInfo">
- select
- a.name as "accountName"
- ,a.accountnumber as "accountCode"
- ,a.address as "address"
- ,a.mobilephone as "phone"
- ,a.idcardno as "idCardNo"
- ,IFNULL(r.debt,0) as "debt"
- ,IFNULL(h.remaining,0) as "prepayAmount"
- from pay_base_account a
- left join pay_pay_rechargeaccount h on a.id=h.account_id
- left join (
- select
- account_id
- ,sum(debt) debt
- from pay_pay_receivable
- group by account_id
- ) r on r.account_id =a.id
- where
- <if test="queryType != null and queryType == '01'">
- a.accountnumber = #{queryValue}
- </if>
- <if test="queryType != null and queryType == '02'">
- a.mobilephone= #{queryValue}
- </if>
- <if test="queryType != null and queryType == '03'">
- a.idcardno= #{queryValue}
- </if>
- </select>
- <select id="selectPayAgentbranchInfo" resultType="com.bz.smart_city.entity.pay.PayPayAgentbranch">
- select
- id
- ,paykey
- ,code
- ,name
- ,type
- ,appid
- ,appsecret
- ,mchid
- ,site_id as "siteId"
- ,customer_id as "customerId"
- from pay_pay_agentbranch
- where del_flag = 0 and `code`=#{code} and customer_id =#{customerId}
- </select>
- <select id="selectAgenttransaction" resultType="com.bz.smart_city.dto.pay.PayAgenttransactionDto">
- select
- a.accountnumber as "accountnumber",
- a.accountname as "accountname",
- a.agentbranch_id as "agentbranchId",
- a.agent_name as "agentName",
- a.agent_code as "agentCode",
- a.amount as "amount",
- a.state as "state",
- a.transtime as "transtime",
- a.payseriesno as "payseriesno",
- a.order_no as "orderNo",
- a.id as "id",
- a.site_id as "siteId",
- a.customer_id as "customerId",
- a.create_date as "createDate",
- a.create_by as "createBy",
- a.update_date as "updateDate",
- a.update_by as "updateBy",
- a.remarks as "remarks",
- a.del_flag as "delFlag"
- from pay_pay_agenttransaction a
- where a.order_no = #{orderNo}
- </select>
- <select id="getDeviceValveState" resultType="com.bz.smart_city.dto.pay.payfee.PayValveStateInfo">
- select
- d.account_id as "accountId"
- ,d.id as "meterId"
- ,d.water_meter_no as "eleno"
- ,ifnull(d.water_meter_no,d.metercode )as "metercode"
- ,d.control_status as "valveState"
- ,(select sum(debt) from pay_pay_receivable where debt>0 and account_id=#{accountId}) as "debt"
- ,cs.customer_no as "customerNo"
- ,r.remaining
- from sc_device d
- left join pay_base_customerandmeterrela c on c.watermeter_id=d.id
- left join pay_pay_rechargeaccount r on r.account_id = c.account_id
- left join sc_customer cs on cs.id=d.customer_id
- where c.account_id=#{accountId}
- </select>
- <select id="getDeviceValveStateByAccountId" resultType="com.bz.smart_city.dto.pay.payfee.PayValveStateInfo">
- select
- d.account_id as "accountId"
- ,d.id as "meterId"
- ,d.water_meter_no as "eleno"
- ,ifnull(d.water_meter_no,d.metercode )as "metercode"
- ,d.control_status as "valveState"
- ,(select sum(debt) from pay_pay_receivable where debt>0 and account_id=#{accountId}) as "debt"
- ,cs.customer_no as "customerNo"
- from sc_device d
- left join pay_base_customerandmeterrela c on c.watermeter_id=d.id
- left join sc_customer cs on cs.id=d.customer_id
- where c.account_id=#{accountId}
- </select>
- <select id="getDeviceValveStateByAmount" resultType="com.bz.smart_city.dto.pay.payfee.PayValveStateInfo">
- select
- r.account_id as "accountId"
- ,d.id as "meterId"
- ,d.water_meter_no as "eleno"
- ,ifnull(d.water_meter_no,d.metercode )as "metercode"
- ,d.control_status as "valveState"
- ,cs.customer_no as "customerNo"
- ,sum(debt) debt
- from pay_pay_receivable r
- left join sc_device d on d.id=r.meter_id
- left join sc_customer cs on cs.id=d.customer_id
- where debt > 0
- and r.account_id in (
- select account_id
- from pay_amount_waterusedamount
- where id in
- <foreach collection="list" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- )
- group by cs.customer_no, r.account_id ,d.id ,d.water_meter_no ,d.water_meter_no,d.metercode ,d.control_status
- </select>
- <select id="getDeviceValveStateByRecord" resultType="com.bz.smart_city.dto.pay.payfee.PayValveStateInfo">
- select
- v.control_rule_id as "controlRuleId"
- ,c.account_id as "accountId"
- ,d.id as "meterId"
- ,d.water_meter_no as "eleno"
- ,ifnull(d.water_meter_no,d.metercode )as "metercode"
- ,d.control_status as "valveState"
- ,cs.customer_no as "customerNo"
- ,v.control_state as "operation"
- ,d.site_id as "siteId"
- ,d.customer_id as "customerId"
- from pay_control_valve v
- left join sc_device d on d.id=v.device_id
- left join pay_base_customerandmeterrela c on c.watermeter_id =d.id
- left join sc_customer cs on cs.id=d.customer_id
- </select>
- <delete id="deleteControlValveInfoByDevice">
- delete from pay_control_valve
- where device_id in
- <foreach collection="list" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </delete>
- <select id="getValveRulesByType" resultType="com.bz.smart_city.entity.pay.PayControlRule">
- select
- id as "id"
- ,condition_id as "conditionId"
- ,operator as "operator"
- ,value as "value"
- ,action as "action"
- from pay_control_rule
- where `disable` = 0 and site_id = #{siteId} and customer_id = #{customer}
- <if test="action != null">and action = #{action} </if>
- <if test="types != null and types.size() > 0">
- and condition_id in
- <foreach collection="types" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </select>
- </mapper>
|