財務對賬-資金統計

來源:互聯網
上載者:User

標籤:


select dtime1,SUM(fkje) as fkje,
(select sum(borrow_amount) from yyd_borrow_borrowinfo where (status=10 or status=20) and loandate<=tongjitb.dtime1
--張亮修改,是否屬於內部使用者11.5

) sumFKJE,
(select sum(amount) from yyd_Account_moneyrecord where state=1 and (moneytype=‘儲值‘ or moneytype=‘線下儲值‘) and paytime<=tongjitb.dtime1
--張亮修改,是否屬於內部使用者11.5

) sumCZJE
,SUM(czje) as czje,
SUM(txje) as txje,
(select sum(amount) from yyd_Account_moneyrecord where state=1 and (moneytype=‘提現‘or moneytype=‘線下提現‘) and createtime<=tongjitb.dtime1
--張亮修改,是否屬於內部使用者11.5

) sumTXJE,
SUM(ptje) as ptje,
(select sum(jfmoney) from HUR_PlatFormFinanceDetail where feeDate<=dtime1 and fType=3
--張亮修改,是否屬於內部使用者11.5

) sumPTJE,
SUM(lxje) as lxje,
(select sum(repay_Amount) from yyd_borrow_repayrecord where repaytype=‘利息‘ and repay_time<=tongjitb.dtime1
--張亮修改,是否屬於內部使用者11.5

)sumLXJE,
SUM(sxfje) as sxfje,
(select SUM( amount *( case recharge_type when ‘chinapaywap‘ then 0.01 when ‘chinapay_b2c‘ then 0.005 when ‘0‘ then 0.005 else 0 end) )from YYD_Account_RechargeRecord where state=1 and createtime<=dtime1
--張亮修改,是否屬於內部使用者11.5

)sumSXFJE,
--(select ISNULL(usableamount,0)+ISNULL(withdrawing,0) from (select sum(usableamount) usableamount,(select SUM(amount) from YYD_Account_MoneyRecord where (moneytype=‘提現‘ or moneytype=‘線下提現‘) and state=0
----張亮修改,是否屬於內部使用者11.5

--) withdrawing from hur_accountinfo_balance where CONVERT(datetime,period)=CONVERT(datetime,dtime1)
----張亮修改,是否屬於內部使用者11.5

--) data) UsableTotal,

--2016-07-14修改備兌總金額:UsableTotal =可用餘額+凍結(UsableAmount+FrozenAmount)
(select sum(ISNULL(UsableAmount,0)+ISNULL(FrozenAmount,0)) as ddd from hur_accountinfo_balance
where CONVERT(datetime,period)=CONVERT(datetime,dtime1)) as UsableTotal,

 

--(select sum(balanceamount) from hur_accountinfo_balance where CONVERT(datetime,period)=CONVERT(datetime,dtime1)
----張亮修改,是否屬於內部使用者11.5
--) balanceAmount,
--2016-07-14修改--賬戶餘額:balanceAmount = 可用餘額總金額(UsableAmount)
(select sum(UsableAmount) from hur_accountinfo_balance where CONVERT(datetime,period)=CONVERT(datetime,dtime1)
) balanceAmount,


(select sum(repay_amount) from YYD_Borrow_RepayRecord where repay_time>=dtime1 and repaytype=‘本金‘ ) DSBJAmount
--待收本金
from
(select CONVERT(datetime, ISNULL(ISNULL(ISNULL(tt1.dt1,(ISNULL(tt1.dt2,tt1.dt3))),tt1.dt5),tt1.dt6)) as dtime1 ,tt1.fkje,tt1.czje,tt1.txje,tt1.ptje,tt1.lxje,tt1.sxfje from
(
select * from
(
--標的詳情主表(放款金額)
select SUM (borrow_amount) as fkje,convert(nvarchar(10),loandate,120) dt1 from YYD_Borrow_BorrowInfo
--張亮修改,是否屬於內部使用者11.5

group by convert(nvarchar(10),loandate,120)
) as zb
full join
--平台費
(
select sum(jfmoney) ptje,convert(nvarchar(10),feeDate,120) feeDate from HUR_PlatFormFinanceDetail where ftype=3
--張亮修改,是否屬於內部使用者11.5

group by convert(nvarchar(10),feeDate,120)
)
as pt
on pt.feeDate=zb.dt1
full join
(---儲值金額
select convert(nvarchar(10),paytime,120) dt2,SUM(amount) czje from YYD_Account_MoneyRecord where (moneytype=‘儲值‘ or moneytype=‘線下儲值‘) and state=1
--張亮修改,是否屬於內部使用者11.5

group by convert(nvarchar(10),paytime,120)
) as cz
on zb.dt1=cz.dt2
full join
----開始其他的表合并
(
--手續約表
select convert(nvarchar(10),createtime,120) dt6, SUM( amount *( case recharge_type when ‘chinapaywap‘ then 0.01 when ‘chinapay_b2c‘ then 0.005 when ‘0‘ then 0.005 else 0 end) ) as sxfje from YYD_Account_RechargeRecord
where state=1
--張亮修改,是否屬於內部使用者11.5

group by convert(nvarchar(10),createtime,120)
) as sxf on zb.dt1=sxf.dt6
full join
(
--提現表
select convert(nvarchar(10),createtime,120) dt3,SUM(amount) txje from YYD_Account_MoneyRecord where (moneytype=‘提現‘ or moneytype=‘線下提現‘) and state=1
--張亮修改,是否屬於內部使用者11.5

group by convert(nvarchar(10),createtime,120)
) as tx on zb.dt1=tx.dt3
full join
(
--利息表
select convert(nvarchar(10),repay_time,120) dt5,SUM(repay_amount) lxje from YYD_Borrow_RepayRecord where status=1 and repaytype=‘利息‘
--張亮修改,是否屬於內部使用者11.5

group by convert(nvarchar(10),repay_time,120)
) as lx on zb.dt1=lx.dt5
)as tt1
) as tongjitb

group by dtime1 order by dtime1 desc

 


--注釋說明對應的欄位如下:
--備兌金額:UsableTotal =可用+凍結(UsableAmount+FrozenAmount)
--賬戶餘額:balanceAmount = 可用餘額總金額(UsableAmount)
--待收本金:DSBJAmount




--(select ISNULL(usableamount,0)+ISNULL(withdrawing,0) from
--(select sum(usableamount) usableamount,(select SUM(amount) from YYD_Account_MoneyRecord
--where (moneytype=‘提現‘ or moneytype=‘線下提現‘) and state=0
--)
-- withdrawing from hur_accountinfo_balance where CONVERT(datetime,period)=CONVERT(datetime,‘2016-07-13 00:00:00.000‘)
--) data) UsableTotal


-- select * from hur_accountinfo_balance order by ID desc

-- select UsableAmount+FrozenAmount from(
-- (select SUM(UsableAmount) as UsableAmount from hur_accountinfo_balance
-- where CONVERT(datetime,period)=CONVERT(datetime,‘2015-10-15 00:00:00.000‘)) sss2,
-- (select SUM(FrozenAmount) as FrozenAmount from hur_accountinfo_balance
-- where CONVERT(datetime,period)=CONVERT(datetime,‘2015-10-15 00:00:00.000‘)) sss
--)

-- select sum(ISNULL(UsableAmount,0)+ISNULL(FrozenAmount,0)) as ddd from hur_accountinfo_balance where CONVERT(datetime,period)=CONVERT(datetime,‘2015-10-15 00:00:00.000‘)


-- select ss=ISNULL(UsableAmount,0)+ISNULL(FrozenAmount,0) from hur_accountinfo_balance


-- select sum(ISNULL(UsableAmount,0)+ISNULL(FrozenAmount,0)) as ddd from hur_accountinfo_balance

-- select sum(UsableAmount) as balanceAmount from hur_accountinfo_balance where CONVERT(datetime,period)=CONVERT(datetime,‘2015-10-15 00:00:00.000‘)

財務對賬-資金統計

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.