Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Biz.Finances.V2.0
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶然
Kivii.Biz.Finances.V2.0
Commits
92abc61e
Commit
92abc61e
authored
Mar 25, 2022
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
1e6f17ca
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
0 deletions
+115
-0
RestfulInvoice.Debit.cs
Src/Transforms/RestfulInvoice.Debit.cs
+1
-0
RestfulPayment.Accept.cs
Src/Transforms/RestfulPayment.Accept.cs
+21
-0
RestfulStatistic.cs
Src/Transforms/RestfulStatistic.cs
+93
-0
No files found.
Src/Transforms/RestfulInvoice.Debit.cs
View file @
92abc61e
...
...
@@ -100,6 +100,7 @@ namespace Kivii.Finances.Transforms
if
(
item
.
OnlyProperties
.
Count
>
0
)
{
conn
.
UpdateOnly
(
item
);
item
.
RemoveAllOnlyProperties
();
rtns
.
Results
.
Add
(
item
);
}
}
...
...
Src/Transforms/RestfulPayment.Accept.cs
View file @
92abc61e
...
...
@@ -34,9 +34,15 @@ namespace Kivii.Finances.Transforms
var
typeCashs
=
Items
.
Where
(
o
=>
o
.
Type
==
PaymentType
.
Cash
).
ToList
();
var
typePoss
=
Items
.
Where
(
o
=>
o
.
Type
==
PaymentType
.
Pos
).
ToList
();
var
serialNumbers
=
typeBanks
.
ConvertAll
(
o
=>
o
.
SerialNumber
);
serialNumbers
.
AddRange
(
typeCashs
.
ConvertAll
(
o
=>
o
.
SerialNumber
));
serialNumbers
.
AddRange
(
typePoss
.
ConvertAll
(
o
=>
o
.
SerialNumber
));
serialNumbers
.
RemoveAll
(
o
=>
o
.
IsNullOrEmpty
());
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Payment
>();
var
accountBalance
=
CurrencyUnit
.
CNY
.
GetBalanceAccount
();
var
existPayments
=
conn
.
Select
<
Payment
>(
o
=>
Sql
.
In
(
o
.
SerialNumber
,
serialNumbers
));
var
allAccountDetails
=
new
List
<
AccountDetail
>();
var
allAcceptPayments
=
new
List
<
Payment
>();
var
allAcceptPays
=
new
List
<
Pay
>();
...
...
@@ -46,6 +52,11 @@ namespace Kivii.Finances.Transforms
{
foreach
(
var
item
in
typeBanks
)
{
if
(!
existPayments
.
IsNullOrEmpty
())
{
var
exist
=
existPayments
.
FirstOrDefault
(
o
=>
o
.
SerialNumber
==
item
.
SerialNumber
);
if
(
exist
!=
null
)
continue
;
}
if
(
item
.
Amount
<=
0
)
continue
;
//Account account = null;
//if (item.PayerAccountKvid != Guid.Empty) account = accounts.FirstOrDefault(o => o.Kvid == item.PayerAccountKvid);
...
...
@@ -87,6 +98,11 @@ namespace Kivii.Finances.Transforms
if
(
cashAccount
==
null
)
throw
new
Exception
(
"未找到当前登录人的现金账户!"
);
foreach
(
var
item
in
typeCashs
)
{
if
(!
existPayments
.
IsNullOrEmpty
())
{
var
exist
=
existPayments
.
FirstOrDefault
(
o
=>
o
.
SerialNumber
==
item
.
SerialNumber
);
if
(
exist
!=
null
)
continue
;
}
if
(
item
.
Amount
<=
0
)
continue
;
var
itemKvid
=
Guid
.
NewGuid
();
item
.
AmountInvoice
=
0
;
...
...
@@ -123,6 +139,11 @@ namespace Kivii.Finances.Transforms
if
(
posAccount
==
null
)
throw
new
Exception
(
"未找到当前登录人的刷卡账户!"
);
foreach
(
var
item
in
typePoss
)
{
if
(!
existPayments
.
IsNullOrEmpty
())
{
var
exist
=
existPayments
.
FirstOrDefault
(
o
=>
o
.
SerialNumber
==
item
.
SerialNumber
);
if
(
exist
!=
null
)
continue
;
}
if
(
item
.
Amount
<=
0
)
continue
;
var
itemKvid
=
Guid
.
NewGuid
();
item
.
AmountInvoice
=
0
;
...
...
Src/Transforms/RestfulStatistic.cs
View file @
92abc61e
...
...
@@ -154,15 +154,108 @@ namespace Kivii.Finances.Transforms
}
}
[
Api
(
Description
=
"到账统计"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
PaymentStatistic
:
RestfulExecution
<
Payment
>
{
#
region
QueryArgs
public
virtual
int
?
Skip
{
get
;
set
;
}
public
virtual
int
?
Take
{
get
;
set
;
}
public
virtual
string
OrderBy
{
get
;
set
;
}
public
string
OrderByDesc
{
get
;
set
;
}
public
virtual
string
Include
{
get
;
set
;
}
public
virtual
string
Fields
{
get
;
set
;
}
public
string
QueryKeys
{
get
;
set
;
}
public
string
QueryValues
{
get
;
set
;
}
#
endregion
public
DateTime
BeginTime
{
get
;
set
;
}
public
DateTime
EndTime
{
get
;
set
;
}
public
OwnerType
OwnerType
{
get
;
set
;
}
=
OwnerType
.
Unsupport
;
public
bool
?
IsPayee
{
get
;
set
;
}
//查收款还是付款
public
bool
?
Used
{
get
;
set
;
}
//到账是否已被使用
public
bool
?
Invoiced
{
get
;
set
;
}
//到账是否开票
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
int
monthDay
=
DateTime
.
DaysInMonth
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
);
if
(
BeginTime
==
DateTime
.
MinValue
)
BeginTime
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
1
);
if
(
EndTime
==
DateTime
.
MinValue
)
EndTime
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
monthDay
);
BeginTime
=
DateTime
.
Parse
(
BeginTime
.
ToString
(
"yyyy-MM-dd"
));
EndTime
=
DateTime
.
Parse
(
EndTime
.
ToString
(
"yyyy-MM-dd"
));
if
(
EndTime
<
BeginTime
)
throw
new
Exception
(
"查询结束日期不可小于开始日期!"
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Payment
>();
var
dynamicParams
=
Request
.
GetRequestParams
();
var
autoQuery
=
Request
.
TryResolve
<
IAutoQueryDb
>();
autoQuery
.
IncludeTotal
=
true
;
var
request
=
new
RestfulQuery
<
Payment
>();
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
WeChat
,
PaymentType
.
Cash
,
PaymentType
.
AliPay
,
PaymentType
.
Pos
,
PaymentType
.
Split
,
PaymentType
.
Refund
,
PaymentType
.
UnBiz
));
if
(
OwnerType
==
OwnerType
.
Organization
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
OrganizationKvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Department
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
DepartmentKvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Member
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
Kvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
IsPayee
!=
null
)
{
var
queryAccount
=
conn
.
From
<
Account
>();
queryAccount
.
Where
(
o
=>
o
.
OrganizationKvid
==
KiviiContext
.
CurrentMember
.
OrganizationKvid
&&
Sql
.
In
(
o
.
Type
,
AccountType
.
Balance
,
AccountType
.
Cash
,
AccountType
.
Pos
));
queryAccount
.
Select
(
o
=>
o
.
Kvid
);
if
(
IsPayee
.
Value
)
sqlExpress
.
And
(
o
=>
(
Sql
.
In
(
o
.
PayerAccountKvid
,
queryAccount
)));
//收款
else
sqlExpress
.
And
(
o
=>
Sql
.
In
(
o
.
PayeeAccountKvid
,
queryAccount
));
//付款
}
if
(
Used
!=
null
)
{
if
(
Used
.
Value
)
sqlExpress
.
And
(
o
=>
o
.
AmountUsed
==
o
.
Amount
);
else
sqlExpress
.
And
(
o
=>
o
.
AmountUsed
<
o
.
Amount
);
}
if
(
Invoiced
!=
null
)
{
if
(
Invoiced
.
Value
)
sqlExpress
.
And
(
o
=>
o
.
AmountInvoice
==
o
.
Amount
);
else
sqlExpress
.
And
(
o
=>
o
.
AmountInvoice
<
o
.
Amount
);
}
var
results
=
autoQuery
.
Execute
(
Request
,
conn
,
request
,
sqlExpress
);
var
rtns
=
new
StatisticResponse
<
Payment
>();
rtns
.
PopulateWith
(
results
);
rtns
.
TotalAmount
=
rtns
.
Results
.
Where
(
o
=>
o
.
Amount
>=
0
).
Sum
(
o
=>
o
.
Amount
);
rtns
.
TotalQuantity
=
rtns
.
Results
.
Where
(
o
=>
o
.
Amount
>=
0
).
Count
();
rtns
.
TotalAmountInvoice
=
rtns
.
Results
.
Where
(
o
=>
o
.
Amount
>=
0
&&
o
.
AmountInvoice
>
0
).
Sum
(
o
=>
o
.
AmountInvoice
);
rtns
.
TotalQuantityInvoice
=
rtns
.
Results
.
Where
(
o
=>
o
.
Amount
>=
0
&&
o
.
AmountInvoice
==
o
.
Amount
).
Count
();
rtns
.
TotalAmountUsed
=
rtns
.
Results
.
Where
(
o
=>
o
.
Amount
>=
0
&&
o
.
AmountUsed
>
0
).
Sum
(
o
=>
o
.
AmountUsed
);
rtns
.
TotalQuantityUsed
=
rtns
.
Results
.
Where
(
o
=>
o
.
Amount
>=
0
&&
o
.
AmountUsed
==
o
.
Amount
).
Count
();
return
rtns
;
}
}
public
class
StatisticResponse
<
T
>:
RestfulQueryResponse
<
T
>
{
public
decimal
TotalAmount
{
get
;
set
;
}
public
decimal
TotalAmountInvoice
{
get
;
set
;
}
public
decimal
TotalAmountUsed
{
get
;
set
;
}
public
decimal
TotalAmountPayment
{
get
;
set
;
}
public
decimal
TotalAmountUnpaid
{
get
;
set
;
}
public
decimal
TotalAmountOffset
{
get
;
set
;
}
public
decimal
TotalQuantity
{
get
;
set
;
}
public
decimal
TotalQuantityInvoice
{
get
;
set
;
}
public
decimal
TotalQuantityUsed
{
get
;
set
;
}
public
decimal
TotalQuantityPayment
{
get
;
set
;
}
public
decimal
TotalQuantityUnpaid
{
get
;
set
;
}
public
decimal
TotalQuantityOffset
{
get
;
set
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment