123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- <?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.PayPayReceivedMapper">
- <select id="findListByPayseriesno" resultType="com.bz.smart_city.dto.pay.PayPayReceivedListDto">
- select
- CONCAT(rece.year,'年',LPAD(rece.month, 2, 0),'月',(select label from pay_sys_dict where type = '收费类型' and site_id = #{siteId} and customer_id =#{customerId} and value = rece.feetype)) as "name",
- rece.accountnumber as "accountnumber",
- rece.accountname as "accountname",
- rece.id as "id",
- rece.account_id as "accountId",
- rece.customerandmeterrela_id as "customerandmeterrelaId",
- rece.office_id as "officeId",
- rece.meter_id as "meterId",
- rece.metercode as "metercode",
- rece.receivable_id as "receivableId",
- rece.waterproperty_id as "waterpropertyId",
- rece.payamount as "payamount",
- rece.watertype as "watertype",
- groy.name as "watertypename",
- 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.payseriesno as "payseriesno",
- rece.receivedamount as "receivedamount",
- (select label from pay_sys_dict where type = '支付方式' and value = rece.payway and site_id = #{siteId} and customer_id =#{customerId}) as "paywayname",
- rece.create_date as "transtime",
- (select label from pay_sys_dict where type = '交易状态' and value = rece.state and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
- rece.state as "state",
- users.name as "createbyname",
- (select name from sc_user where id = rece.cancelperson) as "cancelperson",
- rece.canceltime as "canceltime",
- rece.year as "year",
- rece.month as "month"
- from pay_pay_received rece
- left join pay_base_waterproperty pro on rece.waterproperty_id = pro.id
- left join pay_base_watercategory groy on groy.id = pro.category_id
- left join sc_user users on users.id = rece.create_by
- <where>
- <if test="siteId != null">
- and rece.site_id=#{siteId}
- </if>
- <if test="customerId != null">
- and rece.customer_id=#{customerId}
- </if>
- <if test="payseriesno != null">
- and rece.payseriesno =#{payseriesno}
- </if>
- <if test="year != null">
- and rece.year =#{year}
- </if>
- <if test="month != null">
- and rece.month =#{month}
- </if>
- <if test="accountnumber != null">
- and rece.accountnumber =#{accountnumber}
- </if>
- <if test="beginDate != null">
- and rece.create_date >=#{beginDate}
- </if>
- <if test="endDate != null">
- and rece.create_date <=#{endDate}
- </if>
- <if test="state != null">
- and rece.state =#{state}
- </if>
- <if test="payway != null">
- and rece.payway =#{payway}
- </if>
- order by rece.create_date desc
- </where>
- </select>
- <select id="findTotalList" resultType="com.bz.smart_city.dto.pay.PayPayReceivedListDto">
- select
- CONCAT(rece.year,'年',LPAD(rece.month, 2, 0),'月费用') as "name",
- rece.accountnumber as "accountnumber",
- rece.accountname as "accountname",
- max(groy.name) as "watertypename",
- '' as "ladderlevelname",
- rece.payseriesno as "payseriesno",
- sum(rece.receivedamount) as "receivedamount",
- max(rece.state) as "state",
- min(rece.payway) as "payway",
- (select label from pay_sys_dict where type = '支付方式' and value = min(rece.payway) and site_id = #{siteId} and customer_id =#{customerId}) as "paywayname",
- (select label from pay_sys_dict where type = '交易状态' and value = max(rece.state) and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
- max(users.name) as "createbyname",
- max(rece.create_date) as "transtime",
- max(rece.invoice_id) as "invoiceId",
- rece.year as "year",
- rece.month as "month"
- from pay_pay_received rece
- left join pay_base_waterproperty pro on rece.waterproperty_id = pro.id
- left join pay_base_watercategory groy on groy.id = pro.category_id
- left join sc_user users on users.id = rece.create_by
- <where>
- <if test="siteId != null">
- and rece.site_id=#{siteId}
- </if>
- <if test="customerId != null">
- and rece.customer_id=#{customerId}
- </if>
- <if test="year != null">
- rece.`year`=#{year}
- </if>
- <if test="accountId != null">
- rece.account_id=#{accountId}
- </if>
- <if test="condition != null">
- and
- (
- CONCAT(rece.year,'年',LPAD(rece.month, 2, 0),'月费用') like concat('%',#{condition},'%')
- or rece.accountnumber like concat('%',#{condition},'%')
- or rece.accountname like concat('%',#{condition},'%')
- )
- </if>
- <if test="beginDate != null">
- and rece.create_date >=#{beginDate}
- </if>
- <if test="endDate != null">
- and rece.create_date <=#{endDate}
- </if>
- <if test="state != null">
- and rece.state =#{state}
- </if>
- <if test="payway != null">
- and rece.payway =#{payway}
- </if>
- <if test="programItems != null and programItems.size() != 0">
- and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- rece.office_id = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- group by rece.accountnumber,rece.accountname,rece.year,rece.month,rece.payseriesno
- order by max(rece.create_date) desc
- </where>
- </select>
- <insert id="insert" parameterType="com.bz.smart_city.entity.pay.PayPayReceived" useGeneratedKeys="true" keyProperty="id">
- insert into pay_pay_received
- (
- site_id,
- customer_id,
- create_date,
- create_by,
- update_date,
- update_by,
- remarks,
- del_flag,
- name,
- account_id,
- accountname,
- accountnumber,
- customerandmeterrela_id,
- office_id,
- invoice_id,
- iscanceled,
- meter_id,
- metercode,
- payway,
- receivable_id,
- receivedamount,
- state,
- payseriesno,
- waterproperty_id,
- price,
- payamount,
- feetype,
- ladderlevel,
- year,
- month,
- isrefund,
- watertype,
- canceledrecord_id,
- canceltime,
- cancelperson
- )
- values
- (
- #{siteId},
- #{customerId},
- #{createDate},
- #{createBy},
- #{updateDate},
- #{updateBy},
- #{remarks},
- #{delFlag},
- #{name},
- #{accountId},
- #{accountname},
- #{accountnumber},
- #{customerandmeterrelaId},
- #{officeId},
- #{invoiceId},
- #{iscanceled},
- #{meterId},
- #{metercode},
- #{payway},
- #{receivableId},
- #{receivedamount},
- #{state},
- #{payseriesno},
- #{waterpropertyId},
- #{price},
- #{payamount},
- #{feetype},
- #{ladderlevel},
- #{year},
- #{month},
- #{isrefund},
- #{watertype},
- #{canceledrecordId},
- #{canceltime},
- #{cancelperson}
- )
- </insert>
- <select id="getReceivdePaySeriesno" resultType="com.bz.smart_city.dto.pay.PayPayReceivedDto">
- select * from pay_pay_received where id =#{id}
- </select>
- <select id="findBySeriesno" resultType="com.bz.smart_city.dto.pay.PayPayReceivedDto">
- select
- rece.id as "id",
- rece.name as "name",
- rece.account_id as "accountId",
- rece.accountname as "accountname",
- rece.accountnumber as "accountnumber",
- rece.customerandmeterrela_id as "customerandmeterrelaId",
- rece.cheque_id as "chequeId",
- rece.office_id as "officeId",
- rece.invoice_id as "invoiceId",
- rece.iscanceled as "iscanceled",
- rece.meter_id as "meterId",
- rece.metercode as "metercode",
- rece.payway as "payway",
- rece.receivable_id as "receivableId",
- rece.receivedamount as "receivedamount",
- rece.state as "state",
- rece.payseriesno as "payseriesno",
- rece.waterproperty_id as "waterpropertyId",
- rece.price as "price",
- rece.payamount as "payamount",
- rece.feetype as "feetype",
- rece.ladderlevel as "ladderlevel",
- rece.year as "year",
- rece.month as "month",
- rece.isrefund as "isrefund",
- rece.watertype as "watertype",
- rece.canceledrecord_id as "canceledrecordId",
- rece.cancelperson as "cancelperson",
- rece.canceltime as "canceltime",
- rece.create_by as "createBy",
- rece.create_date as "createDate",
- rece.update_by as "updateBy",
- rece.update_date as "updateDate",
- rece.remarks as "remarks",
- rece.del_flag as "delFlag",
- rece.site_id as "siteId",
- rece.customer_id as "customerId"
- from pay_pay_received rece
- <where>
- rece.canceledrecord_id is null and rece.state=1
- <if test="siteId != null">
- and rece.site_id =#{siteId}
- </if>
- <if test="customerId != null">
- and rece.customer_id =#{customerId}
- </if>
- <if test="payseriesno != null" >
- and rece.payseriesno =#{payseriesno}
- </if>
- </where>
- </select>
- <!-- 取消实收时回退应收欠费 -->
- <update id="updateDebtById">
- update pay_pay_receivable set debt= debt+#{debt}, update_date=now()
- where id=#{id}
- </update>
- <update id="updateReceived">
- update pay_pay_received set iscanceled =#{iscanceled},cancelperson=#{cancelperson},canceltime=#{canceltime},state=#{state} where id=#{id}
- </update>
- <update id="updateReceivedCancel">
- update pay_pay_agenttransaction set state=4 where payseriesno = #{payseriesno}and site_id= #{siteId} and customer_id= #{customerId}
- </update>
- <update id="cancelCheckAgentPayseriesno">
- update pay_pay_checkbalance set state=4
- where out_trade_no =(select order_no from pay_pay_agenttransaction where payseriesno=#{payseriesno} and site_id= #{siteId} and customer_id= #{customerId})
- </update>
- <update id="update">
- update pay_pay_received
- <set>
- <if test="iscanceled != null">
- iscanceled =#{iscanceled},
- </if>
- <if test="cancelperson != null">
- cancelperson =#{cancelperson},
- </if>
- <if test="canceltime != null">
- canceltime =#{canceltime},
- </if>
- <if test="state != null">
- state =#{state},
- </if>
- <if test="updateBy != null">
- update_by =#{updateBy},
- </if>
- <if test="updateDate != null">
- update_date =#{updateDate}
- </if>
- </set>
- <where>
- <if test="id != null">
- id =#{id}
- </if>
- </where>
- </update>
- <select id="findInvoiceReceivedByPayseriesno" resultType="com.bz.smart_city.dto.pay.PayReceivedInvoiceDto">
- select
- rece.payseriesno as "payseriesno",
- rece.create_date as "createDate",
- rece.ladderlevel as "ladderlevel",
- rece.payway as "payway",
- dict2.label as "paywayname",
- sum(rece.receivedamount) as "receivedamount",
- rece.price as "price",
- rece.feetype as "feetype" ,
- dict.label as "feetypename"
- from pay_pay_received rece
- inner join pay_sys_dict dict on dict.type="收费类型" and dict.`value`= rece.feetype
- inner join pay_sys_dict dict2 on dict2.type="支付方式" and dict2.`value`= rece.payway
- where rece.canceledrecord_id is null and rece.iscanceled =0 and rece.receivedamount>0
- #and rece.payseriesno= #{payseriesno}
- and rece.site_id = #{siteId}
- and rece.customer_id = #{customerId}
- group by rece.payseriesno,rece.create_date,rece.ladderlevel,rece.payway,dict2.label,rece.price,rece.feetype,dict.label
- </select>
- </mapper>
|