123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532 |
- <?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.PayTransactiondetailsMapper">
- <insert id="insert" >
- insert into pay_pay_transactiondetails
- (
- site_id,
- customer_id,
- create_date,
- create_by,
- update_date,
- update_by,
- remarks,
- del_flag,
- name,
- accountnumber,
- accountname,
- account_id,
- metercode,
- meter_id,
- canceledrecord_id,
- canceltime,
- cancelperson,
- received_id,
- payseriesno,
- office_id,
- transamount,
- transtime,
- transtype,
- invoice_id,
- iscanceled,
- payway,
- remaining,
- lastrecreamaing,
- state,
- year,
- month,
- transtypeLabel,
- paywayLabel
- )
- values(
- #{siteId},
- #{customerId},
- #{createDate},
- #{createBy},
- #{updateDate},
- #{updateBy},
- #{remarks},
- #{delFlag},
- #{name},
- #{accountnumber},
- #{accountname},
- #{accountId},
- #{metercode},
- #{meterId},
- #{canceledrecordId},
- #{canceltime},
- #{cancelperson},
- #{receivedId},
- #{payseriesno},
- #{officeId},
- #{transamount},
- #{transtime},
- #{transtype},
- #{invoiceId},
- #{iscanceled},
- #{payway},
- #{remaining},
- #{lastrecreamaing},
- #{state},
- #{year},
- #{month},
- #{transtypeLabel},
- #{paywayLabel}
- )
- </insert>
- <insert id="batchInsert">
- insert into pay_pay_transactiondetails
- (
- site_id,
- customer_id,
- create_date,
- create_by,
- update_date,
- update_by,
- remarks,
- del_flag,
- name,
- accountnumber,
- accountname,
- account_id,
- metercode,
- meter_id,
- canceledrecord_id,
- canceltime,
- cancelperson,
- received_id,
- payseriesno,
- office_id,
- transamount,
- transtime,
- transtype,
- invoice_id,
- iscanceled,
- payway,
- remaining,
- lastrecreamaing,
- state,
- year,
- month,
- transtypeLabel,
- paywayLabel
- )
- values
- <foreach collection="list" item="item" separator=",">
- (
- #{item.siteId},
- #{item.customerId},
- #{item.createDate},
- #{item.createBy},
- #{item.updateDate},
- #{item.updateBy},
- #{item.remarks},
- #{item.delFlag},
- #{item.name},
- #{item.accountnumber},
- #{item.accountname},
- #{item.accountId},
- #{item.metercode},
- #{item.meterId},
- #{item.canceledrecordId},
- #{item.canceltime},
- #{item.cancelperson},
- #{item.receivedId},
- #{item.payseriesno},
- #{item.officeId},
- #{item.transamount},
- #{item.transtime},
- #{item.transtype},
- #{item.invoiceId},
- #{item.iscanceled},
- #{item.payway},
- #{item.remaining},
- #{item.lastrecreamaing},
- #{item.state},
- #{item.year},
- #{item.month},
- #{item.transtypeLabel},
- #{item.paywayLabel}
- )
- </foreach>
- </insert>
- <sql id="mainColumnInfo">
- 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",
- a.name as "name",
- a.accountnumber as "accountnumber",
- a.accountname as "accountname",
- a.account_id as "accountId",
- a.metercode as "metercode",
- a.meter_id as "meterId",
- a.canceledrecord_id as "canceledrecordId",
- a.canceltime as "canceltime",
- a.cancelperson as "cancelperson",
- a.received_id as "receivedId",
- a.payseriesno as "payseriesno",
- a.office_id as "officeId",
- a.transamount as "transamount",
- a.transtime as "transtime",
- a.transtype as "transtype",
- a.invoice_id as "invoiceId",
- a.iscanceled as "iscanceled",
- a.payway as "payway",
- a.remaining as "remaining",
- a.lastrecreamaing as "lastrecreamaing",
- a.state as "state",
- a.year as "year",
- a.month AS "month",
- a.transtypeLabel as "transtypeLabel",
- a.paywayLabel as "paywayLabel"
- </sql>
- <select id="findList" resultType="com.bz.smart_city.dto.pay.PayTransactiondetails">
- select
- <include refid="mainColumnInfo" />
- ,u.name as "cancelpersonName"
- ,agent.order_no as "orderNo"
- from pay_pay_transactiondetails a
- left join sc_user u on a.cancelperson=u.id
- left join pay_pay_agenttransaction agent on a.payseriesno=agent.payseriesno and a.site_id=agent.site_id and a.customer_id=agent.customer_id
- <where>
- <if test="siteId != null">
- and a.site_id=#{siteId}
- </if>
- <if test="customerId != null">
- and a.customer_id=#{customerId}
- </if>
- <if test="name != null and name != ''">
- and a.name like concat('%',#{name},'%')
- </if>
- <if test="transtype != null">
- and a.transtype =#{transtype}
- </if>
- <if test="payway != null">
- and a.payway = #{payway}
- </if>
- <if test="beginTime != null">
- and a.transtime >= #{beginTime}
- </if>
- <if test="endTime != null">
- and a.transtime <= #{endTime}
- </if>
- <if test="accountnumber != null and accountnumber != ''">
- and a.accountnumber = #{accountnumber}
- </if>
- <if test="year != null">
- and a.year = #{year}
- </if>
- <if test="programItems != null and programItems.size() != 0">
- and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- a.${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- </where>
- order by a.create_date desc
- <!--<if test="sortColumn != null and sortColumn != ''">
- <if test="sortOrder != null and sortOrder != ''">
- order by ${sortColumn} ${sortOrder}
- </if>
- </if>-->
- </select>
- <select id="findByid" resultType="com.bz.smart_city.dto.pay.PayTransactiondetails">
- select
- <include refid="mainColumnInfo"/>
- from pay_pay_transactiondetails a
- where id= #{id}
- </select>
- <update id="updateCancelInfo">
- update pay_pay_transactiondetails
- set
- iscanceled = #{iscanceled},
- canceltime = #{canceltime},
- cancelperson =#{cancelperson},
- update_by = #{updateBy},
- update_date= #{updateDate}
- where id= #{id}
- </update>
- <select id="findBySeriesno" resultType="com.bz.smart_city.dto.pay.PayTransactiondetails">
- select
- <include refid="mainColumnInfo" />
- ,u.name as "cancelpersonName"
- ,agent.order_no as "orderNo"
- from pay_pay_transactiondetails a
- left join sc_user u on a.cancelperson=u.id
- left join pay_pay_agenttransaction agent on a.payseriesno=agent.payseriesno and a.site_id=agent.site_id and a.customer_id=agent.customer_id
- <where>
- <if test="siteId != null">
- and a.site_id=#{siteId}
- </if>
- <if test="customerId != null">
- and a.customer_id=#{customerId}
- </if>
- <if test="payseriesno != null">
- and a.payseriesno =#{payseriesno}
- </if>
- <if test="programItems != null and programItems.size() != 0">
- and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- a.${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- </where>
- </select>
- <update id="updateLastRecreamaing">
- update pay_pay_transactiondetails set lastrecreamaing= #{lastrecreamaing} where payseriesno =#{payseriesno}
- </update>
-
- <select id="selectTransactionList" resultType="com.bz.smart_city.dto.pay.PayTransactiondetailsDto">
- select
- t.pname as "name"
- ,t.accountnumber
- ,t.accountname
- ,t.payseriesno
- ,t.iscanceled
- ,canceltime
- ,cancelperson
- ,u.name as "cancelpersonName"
- ,t.transtime
- ,t.transamount
- ,t.payway
- ,t.invoiceId
- ,dict.label as"paywayLabel"
- ,t.transtype
- ,t.transtypeLabel
- ,pa.order_no as "orderNo"
- from
- (
- select
- accountnumber
- ,accountname
- ,payseriesno
- ,CONCAT(
- accountname
- ,accountnumber
- ,(
- case when max(iscanceled) = 1 then '取消实收'else
- (case when max(transtype) = 1 then '充值' else
- (case when min(payway) = 5 then '扣费'else
- '缴费'
- end )
- end)
- end)
- ) pname
- ,max(iscanceled) iscanceled
- ,max(canceltime) canceltime
- ,max(cancelperson) cancelperson
- ,min(transtime) transtime
- ,sum(transamount) transamount
- ,min(payway) payway
- ,max(transtype) transtype
- ,max(invoiceId) as "invoiceId"
- ,case when max(transtype) = 1 then '充值'
- else (case when min(payway) = 5 then '扣费' else '缴费' end ) end transtypeLabel
- from (
- select accountnumber
- ,accountname
- ,payseriesno
- ,min(transtime) transtime
- ,sum(transamount ) transamount
- ,max(payway) payway ,1 "transtype"
- ,max(iscanceled) iscanceled
- ,max(canceltime) canceltime
- ,max(cancelperson) cancelperson
- ,max(invoice_id) as "invoiceId"
- from pay_pay_transactiondetails
- where canceledrecord_id is null and payway !=5 and transtype!=2
- and site_id=#{siteId} and customer_id = #{customerId}
- <if test="beginTime != null">
- and transtime >= #{beginTime}
- </if>
- <if test="endTime != null">
- and transtime <= #{endTime}
- </if>
- <if test="year != null">
- and year = #{year }
- </if>
- <if test="month != null">
- and month = #{month}
- </if>
- <if test="accountnumber != null and accountnumber !=''">
- and accountnumber = #{accountnumber}
- </if>
- <if test="accountId != null and accountId !=''">
- and account_id = #{accountId}
- </if>
- <if test="programItems != null and programItems.size() != 0">
- and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- ${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- group by accountnumber,accountname,payseriesno
- union all
- select accountnumber,accountname,payseriesno
- ,min(create_date) transtime
- ,sum(receivedamount) transamount
- ,min(payway) payway, 0 "transtype"
- ,max(iscanceled) iscanceled
- ,max(canceltime) canceltime
- ,max(cancelperson) cancelperson
- ,max(invoice_id) as "invoiceId"
- from pay_pay_received
- where canceledrecord_id is null and payway !=5
- and site_id=#{siteId} and customer_id = #{customerId}
- <if test="beginTime != null">
- and create_date >= #{beginTime}
- </if>
- <if test="endTime != null">
- and create_date <= #{endTime}
- </if>
- <if test="year != null">
- and year = #{year }
- </if>
- <if test="month != null">
- and month = #{month}
- </if>
- <if test="accountnumber != null and accountnumber !=''">
- and accountnumber = #{accountnumber}
- </if>
- <if test="accountId != null and accountId !=''">
- and account_id = #{accountId}
- </if>
- <if test="programItems != null and programItems.size() != 0">
- and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- ${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- group by accountnumber,accountname,payseriesno
- ) a
- group by accountnumber,accountname,payseriesno
- ) t
- left join pay_pay_agenttransaction pa on pa.payseriesno=t.payseriesno and pa.site_id=#{siteId} and pa.customer_id = #{customerId}
- left join pay_sys_dict dict on dict.type='支付方式' and dict.value=t.payway and dict.site_id=#{siteId} and dict.customer_id = #{customerId}
- left join sc_user u on u.id=t.cancelperson
- <where>
- <if test="name != null and name !=''">
- and pname like concat('%',#{name},'%')
- </if>
- <if test="transtypeLabel != null and transtypeLabel != ''">
- and transtypeLabel = #{transtypeLabel}
- </if>
- <if test="payway != null ">
- and payway = #{payway}
- </if>
- <if test="agentbranchId != null">
- and pa.agentbranch_id = #{agentbranchId}
- </if>
- </where>
- order by t.transtime desc
- </select>
- <select id="selectTransactionListForAgenttrans" resultType="com.bz.smart_city.dto.pay.PayTransactiondetailsDto">
- select
- CONCAT(
- a.accountname
- ,a.accountnumber
- ,(case when ifnull(r.iscanceled,t.iscanceled)=1 then '取消实收' else ifnull(ifnull(r.transtypeLabel,t.transtypeLabel),'') end)
- )as "name"
- ,a.accountnumber
- ,a.accountname
- ,a.payseriesno
- ,a.transtime transtime
- ,a.amount transamount
- ,a.order_no as "orderNo"
- ,ab.type as "payway"
- ,dict.label as"paywayLabel"
- ,ifnull(r.invoiceId,t.invoiceId) invoiceId
- ,ifnull(r.iscanceled,t.iscanceled) iscanceled
- ,ifnull(r.canceltime,t.canceltime) canceltime
- ,ifnull(r.cancelperson,t.cancelperson) cancelperson
- ,u.name as "cancelpersonName"
- ,ifnull(r.transtype,t.transtype) transtype
- ,ifnull(r.transtypeLabel,t.transtypeLabel) transtypeLabel
- from pay_pay_agenttransaction a
- left join pay_pay_agentbranch ab on a.agentbranch_id =ab.id and ab.site_id=#{siteId} and ab.customer_id = #{customerId}
- left join pay_sys_dict dict on dict.type='支付方式' and dict.value= ab.type and dict.site_id=#{siteId} and dict.customer_id = #{customerId}
- left join (
- select
- office_id, payseriesno
- ,1 as transtype
- ,'充值' transtypeLabel
- ,min(payway) payway
- ,max(invoice_id) as "invoiceId"
- ,max(iscanceled) iscanceled
- ,min(canceltime) canceltime
- ,min(cancelperson) cancelperson
- from pay_pay_transactiondetails
- where canceledrecord_id is null and payway !=5 and transtype!=2
- and site_id=#{siteId} and customer_id = #{customerId}
- group by office_id, payseriesno
- ) t on t.payseriesno = a.payseriesno
- LEFT JOIN (
- SELECT
- office_id,payseriesno
- ,0 as transtype
- ,'缴费' transtypeLabel
- ,min(payway) payway
- ,max(invoice_id) as "invoiceId"
- ,max(iscanceled) iscanceled
- ,min(canceltime) canceltime
- ,min(cancelperson) cancelperson
- from pay_pay_received
- where canceledrecord_id is null and payway !=5
- and site_id=#{siteId} and customer_id = #{customerId}
- group by office_id,payseriesno
- ) r on r.payseriesno = a.payseriesno
- left join sc_user u on ifnull(r.cancelperson,t.cancelperson) = u.id
- where a.state != 0 and a.state != 4 and a.site_id=#{siteId} and a.customer_id = #{customerId}
- <if test="name != null and name != ''">
- and CONCAT(
- a.accountname
- ,a.accountnumber
- ,(case when ifnull(r.iscanceled,t.iscanceled)=1 then '取消实收' else ifnull(ifnull(r.transtypeLabel,t.transtypeLabel),'') end)
- ) like concat('%',#{name},'%')
- </if>
- <if test="transtype != null">
- and ifnull(r.transtype,t.transtype) = #{transtype}
- </if>
- <if test="payway != null">
- and ab.type= #{payway}
- </if>
- <if test="beginTime != null">
- and a.transtime>=#{beginTime}
- </if>
- <if test="endTime != null">
- and a.transtime <= #{endTime}
- </if>
- <if test="agentbranchId !=null">
- and ab.id=#{agentbranchId}
- </if>
- order by a.transtime desc
- </select>
- </mapper>
|