123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659 |
- <?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.PayBaseAccountMapper">
- <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
- <!--@mbg.generated-->
- insert into pay_base_account(
- id,
- accountnumber,
- name,
- state,
- mobilephone,
- address,
- email,
- telephone,
- available_l1,
- available_l2,
- available_l3,
- available_l4,
- availableamount_1,
- availableamount_2,
- availableamount_3,
- availableamount_4,
- familysize,
- idcardno,
- idtype,
- resetaccumulatedtondate,
- create_by,
- create_date,
- update_by,
- update_date,
- remarks,
- del_flag,
- calculateway,
- waterproperty_id,
- site_id,
- customer_id)
- values
- <foreach collection="list" item="item" separator=",">
- (
- #{item.id},
- #{item.accountnumber},
- #{item.name},
- #{item.state},
- #{item.mobilephone},
- #{item.address},
- #{item.email},
- #{item.telephone},
- #{item.availableL1},
- #{item.availableL2},
- #{item.availableL3},
- #{item.availableL4},
- #{item.availableamount1},
- #{item.availableamount2},
- #{item.availableamount3},
- #{item.availableamount4},
- #{item.familysize},
- #{item.idcardno},
- #{item.idtype},
- #{item.resetaccumulatedtondate},
- #{item.createBy},
- #{item.createDate},
- #{item.updateBy},
- #{item.updateDate},
- #{item.remarks},
- #{item.delFlag},
- #{item.calculateway},
- #{item.waterpropertyId},
- #{item.siteId},
- #{item.customerId}
- )
- </foreach>
- </insert>
- <delete id="batchDel" >
- delete from pay_base_account where id in
- <foreach collection="accountIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </delete>
- <update id="update">
- update pay_base_account
- <set>
- <if test="payBaseAccount.accountnumber != null"> accountnumber=#{payBaseAccount.accountnumber,jdbcType=VARCHAR},</if>
- <if test="payBaseAccount.name != null">name=#{payBaseAccount.name,jdbcType=VARCHAR},</if>
- <if test="payBaseAccount.state != null">state=#{payBaseAccount.state,jdbcType=INTEGER},</if>
- <if test="payBaseAccount.mobilephone != null">mobilephone=#{payBaseAccount.mobilephone,jdbcType=VARCHAR},</if>
- <if test="payBaseAccount.address != null">address=#{payBaseAccount.address,jdbcType=VARCHAR},</if>
- <if test="payBaseAccount.email != null">email=#{payBaseAccount.email,jdbcType=VARCHAR},</if>
- <if test="payBaseAccount.telephone != null">telephone=#{payBaseAccount.telephone,jdbcType=VARCHAR},</if>
- <if test="payBaseAccount.availableL1 != null">available_l1=#{payBaseAccount.availableL1,jdbcType=DECIMAL},</if>
- <if test="payBaseAccount.availableL2 != null">available_l2=#{payBaseAccount.availableL2,jdbcType=DECIMAL},</if>
- <if test="payBaseAccount.availableL3 != null">available_l3=#{payBaseAccount.availableL3,jdbcType=DECIMAL},</if>
- <if test="payBaseAccount.availableL4 != null">available_l4=#{payBaseAccount.availableL4,jdbcType=DECIMAL},</if>
- <if test="payBaseAccount.availableamount1 != null">availableamount_1=#{payBaseAccount.availableamount1,jdbcType=DECIMAL},</if>
- <if test="payBaseAccount.availableamount2 != null">availableamount_2=#{payBaseAccount.availableamount2,jdbcType=DECIMAL},</if>
- <if test="payBaseAccount.availableamount3 != null">availableamount_3=#{payBaseAccount.availableamount3,jdbcType=DECIMAL},</if>
- <if test="payBaseAccount.availableamount4 != null">availableamount_4=#{payBaseAccount.availableamount4,jdbcType=DECIMAL},</if>
- <if test="payBaseAccount.familysize != null">familysize=#{payBaseAccount.familysize,jdbcType=INTEGER},</if>
- idcardno=#{payBaseAccount.idcardno,jdbcType=VARCHAR},
- idtype=#{payBaseAccount.idtype,jdbcType=INTEGER},
- <if test="payBaseAccount.resetaccumulatedtondate != null">resetaccumulatedtondate=#{payBaseAccount.resetaccumulatedtondate,jdbcType=TIMESTAMP},</if>
- <if test="payBaseAccount.updateBy != null">update_by=#{payBaseAccount.updateBy,jdbcType=BIGINT},</if>
- <if test="payBaseAccount.updateDate != null">update_date=#{payBaseAccount.updateDate,jdbcType=TIMESTAMP},</if>
- <if test="payBaseAccount.remarks != null">remarks=#{payBaseAccount.remarks,jdbcType=VARCHAR},</if>
- <if test="payBaseAccount.calculateway != null">calculateway=#{payBaseAccount.calculateway,jdbcType=INTEGER},</if>
- <if test="payBaseAccount.waterpropertyId != null">waterproperty_id=#{payBaseAccount.waterpropertyId,jdbcType=BIGINT}</if>
- </set>
- where id=#{payBaseAccount.id,jdbcType=BIGINT}
- </update>
- <select id="getAll" resultType="com.bz.smart_city.entity.pay.PayBaseAccount">
- select
- id,
- accountnumber,
- name,
- state,
- mobilephone,
- address,
- email,
- telephone,
- available_l1 as availableL1,
- available_l2 as availableL2,
- available_l3 as availableL3,
- available_l4 as availableL4,
- availableamount_1 as availableamount1,
- availableamount_2 as availableamount2,
- availableamount_3 as availableamount3,
- availableamount_4 as availableamount4,
- familysize,
- idcardno,
- idtype,
- resetaccumulatedtondate,
- create_by as createBy,
- create_date as createDate,
- update_by as updateBy,
- update_date updateDate,
- remarks,
- calculateway,
- waterproperty_id as waterpropertyId
- from pay_base_account
- where del_flag='0' and site_id=#{siteId} and customer_id=#{customerId}
- <if test="queryInfo != null">
- and (accountnumber like concat('%',#{value,jdbcType=VARCHAR} ,'%')
- or idcardno like concat('%',#{value,jdbcType=VARCHAR} ,'%')
- or telephone like concat('%',#{value,jdbcType=VARCHAR} ,'%')
- or address like concat('%',#{value,jdbcType=VARCHAR} ,'%')
- )
- </if>
- </select>
- <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
- insert into pay_base_account(
- accountnumber,
- name,
- state,
- mobilephone,
- address,
- email,
- telephone,
- available_l1,
- available_l2,
- available_l3,
- available_l4,
- availableamount_1,
- availableamount_2,
- availableamount_3,
- availableamount_4,
- familysize,
- idcardno,
- idtype,
- resetaccumulatedtondate,
- create_by,
- create_date,
- update_by,
- update_date,
- remarks,
- del_flag,
- calculateway,
- waterproperty_id,
- site_id,
- customer_id)
- values
- (
- #{payBaseAccount.accountnumber},
- #{payBaseAccount.name},
- #{payBaseAccount.state},
- #{payBaseAccount.mobilephone},
- #{payBaseAccount.address},
- #{payBaseAccount.email},
- #{payBaseAccount.telephone},
- #{payBaseAccount.availableL1},
- #{payBaseAccount.availableL2},
- #{payBaseAccount.availableL3},
- #{payBaseAccount.availableL4},
- #{payBaseAccount.availableamount1},
- #{payBaseAccount.availableamount2},
- #{payBaseAccount.availableamount3},
- #{payBaseAccount.availableamount4},
- #{payBaseAccount.familysize},
- #{payBaseAccount.idcardno},
- #{payBaseAccount.idtype},
- #{payBaseAccount.resetaccumulatedtondate,jdbcType=TIMESTAMP},
- #{payBaseAccount.createBy},
- #{payBaseAccount.createDate,jdbcType=TIMESTAMP},
- #{payBaseAccount.updateBy},
- #{payBaseAccount.updateDate,jdbcType=TIMESTAMP},
- #{payBaseAccount.remarks},
- #{payBaseAccount.delFlag},
- #{payBaseAccount.calculateway},
- #{payBaseAccount.waterpropertyId},
- #{payBaseAccount.siteId},
- #{payBaseAccount.customerId}
- )
- </insert>
- <!--<select id="findList" resultType="com.bz.smart_city.dto.pay.PayBaseAccountSelectDto">
- select
- (select count(1) from pay_base_customerandmeterrela pbc where pbc.account_id= pba.id and pbc.site_id=#{siteId} and pbc.customer_id=#{customerId}) AS waterNumber,
- IFNULL((select sum(payamount) from pay_amount_waterusedamount paw where paw.site_id=#{siteId} and paw.customer_id=#{customerId} and paw.account_id = pba.id and paw.year=#{year} and paw.month=#{month}),0) sumPayamount,
- psd2.label as stateName,
- psd2.value as state,
- (SELECT remaining from pay_pay_rechargeaccount
- where account_id=pba.id and site_id=#{siteId} and customer_id=#{customerId})
- -
- (select IFNULL(SUM(debt),0) debt from pay_pay_receivable where
- account_id=pba.id and debt <![CDATA[<>]]> 0 and site_id =#{siteId} and customer_id=#{customerId})
- as remaining,
- psd.label as idTypeName,
- pba.accountnumber,
- pba.name,
- pba.telephone,
- pba.idcardno,
- pba.address
- from pay_base_account pba
- left join pay_sys_dict psd on pba.idtype=psd.`value` and psd.type = '证件类型' and psd.site_id=#{siteId} and psd.customer_id=#{customerId}
- left join pay_base_customerandmeterrela ppr on pba.id=ppr.account_id and ppr.site_id=#{siteId} and ppr.customer_id=#{customerId}
- left join pay_sys_dict psd2 on pba.state = psd2.value and psd2.type='客户状态' and psd2.site_id=#{siteId} and psd2.customer_id=#{customerId}
- where pba.del_flag='0' and pba.site_id=#{siteId} and pba.customer_id=#{customerId}
- <if test="state != null and state != '' "> and psd2.value=#{state,jdbcType=VARCHAR}</if>
- <if test="queryInfo != null and queryInfo != ''">
- and (pba.accountnumber like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or pba.idcardno like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or pba.telephone like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or pba.address like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- )
- </if>
- <if test="programItemList != null and programItemList.size() > 0">
- and ( ppr.office_id is null
- <foreach collection="programItemList" item="item" open="or" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- ppr.${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- order by pba.create_date desc
- </select>-->
- <select id="findList" resultType="com.bz.smart_city.dto.pay.PayBaseAccountSelectDto">
- select
- IFNULL(cust.waterNumber,0) AS waterNumber,
- IFNULL(paw.sum_payamount,0) sumPayamount,
- pba.state as state,
- (select label from pay_sys_dict where value = pba.state and type='客户状态' and site_id = #{siteId} and customer_id = #{customerId}) stateName,
- dt.remaining ,
- (select label from pay_sys_dict where value = pba.idtype and type='证件类型' and site_id = #{siteId} and customer_id = #{customerId}) idTypeName,
- pba.accountnumber,
- pba.name,
- pba.telephone,
- pba.idcardno,
- pba.address
- from pay_base_account pba
- left join (
- select
- account_id,
- ifnull(sum(payamount),0) sum_payamount
- from pay_amount_waterusedamount
- where site_id = #{siteId} and customer_id = #{customerId} and year=#{year} and month=#{month}
- group by account_id
- ) paw on paw.account_id = pba.id
- left join (
- select
- rech.account_id
- ,IFNULL(max(rech.remaining),0) - IFNULL(sum(rece.debt),0) remaining
- from pay_pay_rechargeaccount rech
- left join pay_pay_receivable rece on rece.account_id=rech.account_id and rece.debt>0
- where rech.site_id = #{siteId} and rech.customer_id = #{customerId}
- group by rech.account_id
- ) dt on pba.id = dt.account_id
- left join (
- select account_id, count(1) waterNumber,max(office_id) office_id from pay_base_customerandmeterrela
- where site_id = #{siteId} and customer_id = #{customerId}
- <if test="programItemList != null and programItemList.size() > 0">
- and
- <foreach collection="programItemList" item="item" open="(" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- ${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- group by account_id
- ) cust on pba.id=cust.account_id
- where pba.del_flag='0' and pba.site_id=#{siteId} and pba.customer_id=#{customerId}
- <if test="state != null and state != '' "> and pba.state=#{state}</if>
- <if test="queryInfo != null and queryInfo != ''">
- and (pba.accountnumber like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or pba.idcardno like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or pba.telephone like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or pba.address like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- )
- </if>
- <if test="programItemList != null and programItemList.size() > 0">
- and
- ( cust.office_id is null
- <foreach collection="programItemList" item="item" open="or" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- cust.${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- <choose>
- <when test="sortColumn !=null and sortColumn != '' and sortOrder !=null and sortOrder != ''">
- ORDER BY ${sortColumn} ${sortOrder}
- </when>
- <otherwise>
- order by pba.create_date desc,pba.accountnumber DESC
- </otherwise>
- </choose>
- <!-- select
- cust.waterNumber AS waterNumber,
- IFNULL(
- (select sum(payamount) from pay_amount_waterusedamount paw
- where site_id = #{siteId} and customer_id = #{customerId} and paw.account_id = pba.id and paw.year=#{year} and paw.month=#{month}),0) sumPayamount,
- pba.state as state,
- (select label from pay_sys_dict where value = pba.state and type='客户状态' and site_id = #{siteId} and customer_id = #{customerId}) stateName,
- (
- SELECT remaining remaining from pay_pay_rechargeaccount
- where account_id=pba.id)
- -
- (select IFNULL(SUM(debt),0) debt from pay_pay_receivable where
- account_id=pba.id and debt > 0 )
- as remaining,
- (select label from pay_sys_dict where value = pba.idtype and type='证件类型' and site_id = #{siteId} and customer_id = #{customerId}) idTypeName,
- pba.accountnumber,
- pba.name,
- pba.telephone,
- pba.idcardno,
- pba.address
- from pay_base_account pba
- left join (
- select account_id, count(1) waterNumber,max(office_id) office_id from pay_base_customerandmeterrela
- where site_id = #{siteId} and customer_id = #{customerId}
- <if test="programItemList != null and programItemList.size() > 0">
- and
- <foreach collection="programItemList" item="item" open="(" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- ${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- group by account_id
- ) cust on pba.id=cust.account_id
- where pba.del_flag='0' and pba.site_id=#{siteId} and pba.customer_id=#{customerId}
- <if test="state != null and state != '' "> and pba.state=#{state}</if>
- <if test="queryInfo != null and queryInfo != ''">
- and (pba.accountnumber like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or pba.idcardno like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or pba.telephone like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or pba.address like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- )
- </if>
- <if test="programItemList != null and programItemList.size() > 0">
- and
- ( cust.office_id is null
- <foreach collection="programItemList" item="item" open="or" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- cust.${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- order by pba.create_date desc,pba.accountnumber DESC
- -->
- </select>
- <select id="findAccountnumberList" resultType="com.bz.smart_city.dto.pay.PayBaseAccountSelectAccountnumberDto">
- select
- (select IFNULL(sum(payamount),0) from pay_amount_waterusedamount paw where paw.site_id=#{siteId} and paw.customer_id=#{customerId} and paw.state = 2 and paw.accountnumber = pba.accountnumber) sumPayamount,
- #{payment} as sumPayment,
- psd2.label as stateName,
- (SELECT remaining from pay_pay_rechargeaccount
- where account_id=pba.id and site_id=#{siteId} and customer_id=#{customerId})
- -
- (select IFNULL(SUM(debt),0) debt from pay_pay_receivable where
- accountnumber=pba.accountnumber and debt <![CDATA[<>]]> 0 and site_id =#{siteId} and customer_id=#{customerId})
- as remaining,
- psd.label as idTypeName,
- pba.accountnumber,
- pba.name,
- pba.telephone,
- pba.idcardno,
- pba.address,
- pba.id as "accountId",
- pba.email,
- pbc.vatno
- from pay_base_account pba
- left join pay_sys_dict psd on pba.idtype=psd.`value` and psd.type='证件类型' and psd.site_id=#{siteId} and psd.customer_id=#{customerId}
- left join pay_pay_rechargeaccount ppr on pba.accountnumber=ppr.accountnumber and ppr.site_id=#{siteId} and ppr.customer_id=#{customerId}
- left join pay_sys_dict psd2 on pba.state = psd2.`value` and psd2.type='客户状态' and psd2.site_id=#{siteId} and psd2.customer_id=#{customerId}
- left join pay_base_customerandmeterrela pbc on pbc.account_id = pba.id
- where pba.accountnumber = #{queryInfo} and pba.site_id=#{siteId} and pba.customer_id=#{customerId}
- </select>
- <select id="getAccountPayment" resultType="decimal">
- select (
- (select IFNULL(SUM(ppra.remaining),0) from pay_pay_rechargeaccount ppra
- where ppra.accountnumber=#{accountnumber} and ppra.site_id=#{siteId} and ppra.customer_id=#{customerId})
- +
- (select IFNULL(sum(receivedamount),0) from pay_pay_received ppr
- where ppr.iscanceled=0 and ppr.canceledrecord_id is null and ppr.accountnumber=#{accountnumber} and ppr.site_id=#{siteId} and ppr.customer_id=#{customerId} )
- ) as payment
- </select>
- <select id="findMeterWaterInfo" resultType="com.bz.smart_city.dto.pay.PayBaseAccountWaterusedamountDto">
- select
- paw.metercode,
- paw.lastreading,
- paw.lastrecorddate,
- paw.reading,
- paw.recorddate,
- paw.amount,
- IFNULL(paw.payamount,0) as payamount,
- IFNULL(paw.payamount,0) as receivableAmount,
- paw.year as year,
- paw.month as month,
- CONCAT(CAST(paw.year AS CHAR),'年',CAST(paw.month AS CHAR),'月') credit,
- IFNULL(ppre.debt,0) debt
- from pay_amount_waterusedamount paw
- left join
- (select IFNULL(sum(ppr.debt),0) debt,ppr.month
- from pay_pay_receivable ppr
- where
- ppr.metercode=#{metercode}
- and ppr.year =#{year,jdbcType=INTEGER}
- and ppr.site_id=#{siteId}
- and ppr.customer_id=#{customerId}
- group by ppr.month) ppre on ppre.month = paw.month
- where
- paw.site_id=#{siteId}
- and paw.customer_id=#{customerId}
- and paw.year=#{year,jdbcType=INTEGER}
- and paw.metercode = #{metercode}
- order by paw.`month` DESC
- </select>
- <select id="findTransactionDetail" resultType="com.bz.smart_city.dto.pay.PayBaseAccountTransactionsDto">
- select
- ptrans.`name` as transactionInfo,
- ptrans.payseriesno,
- ptrans.transamount,
- ptrans.transtime,
- ptrans.transtypeLabel as transtypeName,
- ptrans.paywayLabel as paywayName,
- pagent.order_no orderNo
- from pay_pay_transactiondetails ptrans
- left join pay_pay_agenttransaction pagent on pagent.payseriesno = ptrans.payseriesno and pagent.site_id=#{siteId} and pagent.customer_id=#{customerId}
- where
- ptrans.accountnumber=#{accountnumber}
- and ptrans.`year`=#{year}
- and ptrans.site_id=#{siteId}
- and ptrans.customer_id=#{customerId}
- order by ptrans.create_date DESC
- </select>
- <select id="findWaterMeter" resultType="com.bz.smart_city.dto.pay.PayBaseAccountMeterDto">
- select
- pbc.opendate,
- pbc.metercode,
- psd.label AS housetypeName,
- psd2.label AS calculateway,
- pbw.name as waterpropertyName,
- device.water_meter_no as "metereleno"
- from pay_base_customerandmeterrela pbc
- LEFT JOIN pay_sys_dict psd on pbc.housetype = psd.value and psd.type='住房类型' and psd.site_id=#{siteId} and psd.customer_id=#{customerId}
- left join pay_sys_dict psd2 on pbc.calculateway = psd2.value and psd2.type='结算方式' and psd2.site_id=#{siteId} and psd2.customer_id=#{customerId}
- left join pay_base_waterproperty pbw on pbc.waterproperty_id = pbw.id and pbw.site_id=#{siteId} and pbw.customer_id=#{customerId}
- left join sc_device device on pbc.watermeter_id = device.id
- where pbc.accountnumber=#{accountnumber} and pbc.site_id=#{siteId} and pbc.customer_id=#{customerId}
- </select>
- <select id ="get" resultType="com.bz.smart_city.entity.pay.PayBaseAccount">
- select
- id,
- accountnumber,
- name,
- state,
- mobilephone,
- address,
- email,
- telephone,
- available_l1 as availableL1,
- available_l2 as availableL2,
- available_l3 as availableL3,
- available_l4 as availableL4,
- availableamount_1 as availableamount1,
- availableamount_2 as availableamount2,
- availableamount_3 as availableamount3,
- availableamount_4 as availableamount4,
- familysize,
- idcardno,
- idtype,
- resetaccumulatedtondate,
- create_by as createBy,
- create_date as createDate,
- update_by as updateBy,
- update_date updateDate,
- remarks,
- calculateway,
- waterproperty_id as waterpropertyId
- from pay_base_account
- where id = #{id}
- </select>
- <select id="findMeterInfo" resultType="com.bz.smart_city.entity.pay.PayMeter">
- select
- scd.water_meter_no as waterMeterNo,
- scd.metercode,
- scd.control_status,
- pba.address as address,
- scd.new_meter_start as initialData,
- scd.date_create as installDate,
- scd.device_model as deviceType,
- pba.accountnumber as accountnumber,
- pba.id as accountId,
- scd.id as deviceId,
- scd.curr_status state,
- (case scd.curr_status WHEN 2 then '已开户' when 1 then '待开户' else '待验收' end) stateName,
- IFNULL(rd.reading,0) as CurrData
- from sc_device scd
- left join pay_base_account pba on pba.id = scd.account_id and pba.site_id=#{siteId} and pba.customer_id=#{customerId}
- left join pay_base_customerandmeterrela ppr on ppr.metercode = scd.metercode and ppr.site_id=#{siteId} and ppr.customer_id=#{customerId}
- left join
- (SELECT a.watermeter_id,a.reading FROM pay_amount_waterusedamount_day AS a,
- (SELECT b.watermeter_id, MAX(b.read_date) AS read_date FROM pay_amount_waterusedamount_day AS b
- where b.reading is not null and b.customer_id=#{customerId} and b.site_id=#{siteId}
- GROUP BY b.watermeter_id)
- AS c WHERE a.watermeter_id=c.watermeter_id AND a.read_date = c.read_date) rd on rd.watermeter_id = scd.id
- where scd.customer_id = #{customerId} and scd.account_id is not null
- <if test="queryInfo != null and queryInfo != ''">
- and (
- scd.metercode like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or pba.accountnumber like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- or scd.water_meter_no like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
- )
- </if>
- <if test="address != null and address != ''">
- and pba.address like concat('%',#{address,jdbcType=VARCHAR} ,'%')
- </if>
- <if test="state != null and state != '' ">
- and IFNULL(scd.curr_status,0) = #{state,jdbcType=INTEGER}
- </if>
- <if test="programItemList != null and programItemList.size() > 0">
- and ( ppr.office_id is null
- <foreach collection="programItemList" item="item" open="or" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- ppr.${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- <choose>
- <when test="sortColumn !=null and sortColumn != '' and sortOrder !=null and sortOrder != ''">
- <if test="sortColumn = 'address'">
- ORDER BY pba.address
- </if>
- <if test="sortColumn != 'address'">
- ORDER BY ${sortColumn} ${sortOrder}
- </if>
- </when>
- <otherwise>
- order by scd.date_create DESC
- </otherwise>
- </choose>
- </select>
- <update id="updateAccountName">
- <if test="type !=null and type == 1">
- update pay_pay_received set accountname =#{accountname} where account_id =#{accountId}
- </if>
- <if test="type !=null and type == 2">
- update pay_pay_receivable set accountname =#{accountname} where account_id =#{accountId}
- </if>
- <if test="type !=null and type == 3">
- update pay_amount_waterusedamount set accountname =#{accountname} where account_id =#{accountId}
- </if>
- <if test="type !=null and type == 4">
- update pay_pay_transactiondetails set accountname =#{accountname} where account_id =#{accountId}
- </if>
- <if test="type != null and type == 5">
- update pay_pay_messagesendrecord set accountname =#{accountname} where account_id =#{accountId}
- </if>
- </update>
- <select id="getSynAccountInfo" resultType="com.bz.smart_city.dto.pay.SynAccountInfo">
- select
- a.accountnumber as "accountNumber"
- ,a.name as "accountName"
- ,a.mobilephone as "accountPhone"
- ,c.metercode as "fileNo"
- ,c.create_date as "createDate"
- from pay_base_customerandmeterrela c
- left join pay_base_account a on c.account_id=a.id
- <if test="createDate != null and createDate != ''">
- where DATE_FORMAT( c.create_date, "%Y%m%d" ) = #{createDate}
- </if>
- </select>
- <select id="findCommunityCount" resultType="integer">
- select COUNT(1) from pay_base_account where SUBSTR(accountnumber,1,3)=(select code from sc_community where id = #{communityId})
- </select>
- <update id="updateAccountAddr">
- update pay_base_account set address = #{address}
- where id = #{accountId}
- <if test="siteId != null "> and site_id = #{siteId}</if>
- <if test="customerId != null"> and customer_id = #{customerId}</if>
- </update>
- <update id="updateDeviceAddr">
- update sc_device set loc_desc = #{address}
- where account_id = #{accountId}
- <if test="customerId != null"> and customer_id = #{customerId}</if>
- </update>
- <select id="getCustIdAndSiteId" resultType="com.bz.smart_city.entity.pay.PayBaseAccount">
- select
- c.customer_id customerId,
- c.site_id siteId
- from pay_base_account c
- where
- c.customer_id is not null and c.site_id is not null
- group by c.customer_id, c.site_id
- </select>
- </mapper>
|