123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- alter proc Query_Finance
- @OrderCount int output,
- @ReceiptCount int output,
- @Oreder1 int output,
- @Oreder2 int output,
- @Oreder3 int output,
- @Oreder4 int output,
- @OtherReceipts int output,
- @Payout int output,
- @OtherSalary int output,
- @MemberReceipts int output,
- @GrossReceipts int output,
- @NetReceipt int output
- as
- begin
- select @OrderCount = count(distinct id) from dindanbukuan where 0=datediff(day,date,getdate())
- select @ReceiptCount = count(id) from dindanbukuan where 0=datediff(day,date,getdate())
- select @Oreder1 = sum(convert(int,money)) from dindanbukuan where 0=datediff(day,date,getdate()) and bz='预约收款'
- select @Oreder2 = sum(convert(int,money)) from dindanbukuan where 0=datediff(day,date,getdate()) and bz='预约补款'
- select @Oreder3 = sum(convert(int,money)) from dindanbukuan where 0=datediff(day,date,getdate()) and bz not in('预约收款','预约补款')
- select @Oreder4 = sum(convert(int,money)) from dindanbukuan where 0=datediff(day,date,getdate()) and paytype = '储值卡扣款'
- select @OtherReceipts = sum(convert(float,money)) from singleincome where 0=datediff(day,dat,getdate()) and sale2type is null
- select @Payout = sum(convert(float,money)) from gudingfeiyong where 0=datediff(day,dat,getdate())
- select @OtherSalary = sum(convert(float,money)) from singleincomemoneyview where 0=datediff(day,date,getdate())
- select @MemberReceipts = sum(convert(float,money)) from memberview where 0=datediff(day,date,getdate())
- set @GrossReceipts = 0
- if @Oreder1 is not null
- begin
- set @GrossReceipts = @GrossReceipts + @Oreder1
- end
- if @Oreder2 is not null
- begin
- set @GrossReceipts = @GrossReceipts + @Oreder2
- end
- if @Oreder3 is not null
- begin
- set @GrossReceipts = @GrossReceipts + @Oreder3
- end
- if @Oreder4 is not null
- begin
- set @GrossReceipts = @GrossReceipts - @Oreder4
- end
- if @OtherReceipts is not null
- begin
- set @GrossReceipts = @GrossReceipts + @OtherReceipts
- end
- if @OtherSalary is not null
- begin
- set @GrossReceipts = @GrossReceipts + @OtherSalary
- end
- set @NetReceipt = (@GrossReceipts - @Payout)
- end
|