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
c.businessstate = 1 and c.site_id=#{siteId} and c.customer_id=#{customerId}
and c.accountnumber=#{accountnumber}
and c.metercode =#{metercode}
and c.account_id =#{accountId}
limit 1
update pay_pay_receivable set
debt=#{debt}
,update_date=#{updateDate}
,update_by = #{updateBy}
where id=#{id}
update pay_pay_rechargeaccount set
remaining=#{remaining}
,update_by=#{updateBy}
,update_date=#{updateDate}
where id=#{id}
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
and account_id=#{accountId}
and id in
#{item}
order by a.year asc,a.month asc,a.feetype asc
select
YEAR,
MONTH
from pay_base_closingaccountinfo
where site_id=#{siteId} and customer_id=#{customerId}
order by YEAR desc , MONTH desc
limit 1
call updateAccountState(#{accountId});
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}
c.businessstate=1 and c.site_id=#{siteId}
and c.id= #{id}
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},'%')
)
and
c.${item.dimensionCode} = #{item.dimensionValue}
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
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
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
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
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
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
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
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
a.type = 2
and a.account_id=#{accountId}
and a.year = #{year}
order by a.create_date desc
select
waterproperty_id as "id"
from pay_base_customerandmeterrela
where account_id =#{id}
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
a.accountnumber = #{queryValue}
a.mobilephone= #{queryValue}
a.idcardno= #{queryValue}
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
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
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
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
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
#{item}
)
group by cs.customer_no, r.account_id ,d.id ,d.water_meter_no ,d.water_meter_no,d.metercode ,d.control_status
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
delete from pay_control_valve
where device_id in
#{item}
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}
and action = #{action}
and condition_id in
#{item}