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
864227ae
Commit
864227ae
authored
Nov 10, 2022
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
6d1a150c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
28 deletions
+66
-28
PaymentExtension.cs
Src/Extensions/PaymentExtension.cs
+4
-4
RestfulAccount.cs
Src/Transforms/RestfulAccount.cs
+4
-1
RestfulInvoiceApply.Apply.cs
Src/Transforms/RestfulInvoiceApply.Apply.cs
+4
-1
RestfulPayment.Split.cs
Src/Transforms/RestfulPayment.Split.cs
+28
-4
RestfulPayment.UnBiz.Refund.cs
Src/Transforms/RestfulPayment.UnBiz.Refund.cs
+8
-4
RestfulPayment.cs
Src/Transforms/RestfulPayment.cs
+2
-2
RestfulSettlement.cs
Src/Transforms/RestfulSettlement.cs
+16
-12
RestfulStatistic.cs
Src/Transforms/RestfulStatistic.cs
+0
-0
No files found.
Src/Extensions/PaymentExtension.cs
View file @
864227ae
...
@@ -344,7 +344,7 @@ namespace Kivii.Finances
...
@@ -344,7 +344,7 @@ namespace Kivii.Finances
/// <param name="ownerKvid"></param>
/// <param name="ownerKvid"></param>
/// <param name="ownerName"></param>
/// <param name="ownerName"></param>
/// <returns></returns>
/// <returns></returns>
public
static
Payment
BizSplit
(
this
Payment
payment
,
decimal
amountSplit
,
Guid
?
ownerKvid
=
null
,
string
ownerName
=
null
,
IDbConnection
conn
=
null
)
public
static
Payment
BizSplit
(
this
Payment
payment
,
decimal
amountSplit
,
string
remark
=
null
,
Guid
?
ownerKvid
=
null
,
string
ownerName
=
null
,
IDbConnection
conn
=
null
)
{
{
payment
.
ThrowIfNull
(
$"传入payment参数为空"
);
payment
.
ThrowIfNull
(
$"传入payment参数为空"
);
if
(
payment
.
Type
!=
PaymentType
.
Bank
)
throw
new
Exception
(
"非银行到账不可以认领!"
);
if
(
payment
.
Type
!=
PaymentType
.
Bank
)
throw
new
Exception
(
"非银行到账不可以认领!"
);
...
@@ -395,7 +395,7 @@ namespace Kivii.Finances
...
@@ -395,7 +395,7 @@ namespace Kivii.Finances
splitPayment
.
AmountUsed
=
0
;
splitPayment
.
AmountUsed
=
0
;
splitPayment
.
AmountInvoice
=
amountInvoice
;
// payment.AmountInvoice > amountSplit ? amountSplit : payment.AmountInvoice;
splitPayment
.
AmountInvoice
=
amountInvoice
;
// payment.AmountInvoice > amountSplit ? amountSplit : payment.AmountInvoice;
splitPayment
.
Summary
=
string
.
Empty
;
splitPayment
.
Summary
=
string
.
Empty
;
splitPayment
.
Remark
=
string
.
Empty
;
splitPayment
.
Remark
=
remark
;
splitPayment
.
OperateTime
=
payment
.
OperateTime
;
splitPayment
.
OperateTime
=
payment
.
OperateTime
;
splitPayment
.
OperatorName
=
KiviiContext
.
CurrentMember
.
FullName
;
splitPayment
.
OperatorName
=
KiviiContext
.
CurrentMember
.
FullName
;
splitPayment
.
OperatorKvid
=
KiviiContext
.
CurrentMember
.
Kvid
;
splitPayment
.
OperatorKvid
=
KiviiContext
.
CurrentMember
.
Kvid
;
...
@@ -414,7 +414,7 @@ namespace Kivii.Finances
...
@@ -414,7 +414,7 @@ namespace Kivii.Finances
/// <param name="ownerKvid"></param>
/// <param name="ownerKvid"></param>
/// <param name="ownerName"></param>
/// <param name="ownerName"></param>
/// <returns></returns>
/// <returns></returns>
public
static
Payment
UnBizSplit
(
this
Payment
payment
,
decimal
amountSplit
,
PaymentType
paymentType
,
IDbConnection
conn
=
null
)
public
static
Payment
UnBizSplit
(
this
Payment
payment
,
decimal
amountSplit
,
PaymentType
paymentType
,
string
remark
=
null
,
IDbConnection
conn
=
null
)
{
{
payment
.
ThrowIfNull
(
$"传入payment参数为空"
);
payment
.
ThrowIfNull
(
$"传入payment参数为空"
);
if
(
payment
.
Type
!=
PaymentType
.
Bank
)
throw
new
Exception
(
"非银行到账不可以操作!"
);
if
(
payment
.
Type
!=
PaymentType
.
Bank
)
throw
new
Exception
(
"非银行到账不可以操作!"
);
...
@@ -466,7 +466,7 @@ namespace Kivii.Finances
...
@@ -466,7 +466,7 @@ namespace Kivii.Finances
splitPayment
.
AmountUsed
=
0
;
splitPayment
.
AmountUsed
=
0
;
splitPayment
.
AmountInvoice
=
amountInvoice
;
splitPayment
.
AmountInvoice
=
amountInvoice
;
splitPayment
.
Summary
=
string
.
Empty
;
splitPayment
.
Summary
=
string
.
Empty
;
splitPayment
.
Remark
=
string
.
Empty
;
splitPayment
.
Remark
=
remark
;
splitPayment
.
OperateTime
=
payment
.
OperateTime
;
splitPayment
.
OperateTime
=
payment
.
OperateTime
;
splitPayment
.
OperatorName
=
KiviiContext
.
CurrentMember
.
FullName
;
splitPayment
.
OperatorName
=
KiviiContext
.
CurrentMember
.
FullName
;
splitPayment
.
OperatorKvid
=
KiviiContext
.
CurrentMember
.
Kvid
;
splitPayment
.
OperatorKvid
=
KiviiContext
.
CurrentMember
.
Kvid
;
...
...
Src/Transforms/RestfulAccount.cs
View file @
864227ae
...
@@ -110,7 +110,10 @@ namespace Kivii.Finances.Transforms
...
@@ -110,7 +110,10 @@ namespace Kivii.Finances.Transforms
var
request
=
new
RestfulQuery
<
Account
>();
var
request
=
new
RestfulQuery
<
Account
>();
request
=
request
.
PopulateWith
(
this
);
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Where
(
o
=>
o
.
Type
!=
AccountType
.
Balance
&&
Sql
.
In
(
o
.
OwnerKvid
,
KiviiContext
.
CurrentMember
.
OrganizationKvid
,
KiviiContext
.
CurrentMember
.
DepartmentKvid
,
KiviiContext
.
CurrentMember
.
Kvid
));
var
ownerKvids
=
KiviiContext
.
CurrentMember
.
DepartmentKvids
.
ToList
();
ownerKvids
.
Add
(
KiviiContext
.
CurrentMember
.
OrganizationKvid
);
ownerKvids
.
Add
(
KiviiContext
.
CurrentMember
.
Kvid
);
sqlExpress
.
Where
(
o
=>
o
.
Type
!=
AccountType
.
Balance
&&
Sql
.
In
(
o
.
OwnerKvid
,
ownerKvids
));
var
rtns
=
autoQuery
.
Execute
(
Request
,
conn
,
request
,
sqlExpress
);
var
rtns
=
autoQuery
.
Execute
(
Request
,
conn
,
request
,
sqlExpress
);
return
rtns
;
return
rtns
;
}
}
...
...
Src/Transforms/RestfulInvoiceApply.Apply.cs
View file @
864227ae
...
@@ -518,14 +518,17 @@ namespace Kivii.Finances.Transforms
...
@@ -518,14 +518,17 @@ namespace Kivii.Finances.Transforms
/// </summary>
/// </summary>
public
Guid
OperatorKvid
{
get
;
set
;
}
public
Guid
OperatorKvid
{
get
;
set
;
}
public
Guid
OwnerKvid
{
get
;
set
;
}
public
Guid
OwnerKvid
{
get
;
set
;
}
public
List
<
Guid
>
OwnerKvids
{
get
;
set
;
}
public
Guid
OrganizationKvid
{
get
;
set
;
}
public
Guid
OrganizationKvid
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
{
if
(
OwnerKvids
.
IsNullOrEmpty
())
OwnerKvids
=
new
List
<
Guid
>();
if
(
OwnerKvid
!=
Guid
.
Empty
)
OwnerKvids
.
Add
(
OwnerKvid
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
InvoiceApply
>();
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
InvoiceApply
>();
var
query
=
conn
.
From
<
InvoiceApply
>();
var
query
=
conn
.
From
<
InvoiceApply
>();
query
.
Where
(
o
=>
o
.
Status
==
(
int
)
InvoiceApplyStatus
.
FinancialExecute
);
query
.
Where
(
o
=>
o
.
Status
==
(
int
)
InvoiceApplyStatus
.
FinancialExecute
);
if
(
OperatorKvid
!=
Guid
.
Empty
)
query
.
And
(
o
=>
o
.
OperatorKvid
==
OperatorKvid
);
if
(
OperatorKvid
!=
Guid
.
Empty
)
query
.
And
(
o
=>
o
.
OperatorKvid
==
OperatorKvid
);
else
if
(
OwnerKvid
!=
Guid
.
Empty
)
query
.
And
(
o
=>
o
.
OwnerKvid
==
OwnerKvid
);
else
if
(
!
OwnerKvids
.
IsNullOrEmpty
())
query
.
And
(
o
=>
Sql
.
In
(
o
.
OwnerKvid
,
OwnerKvids
)
);
else
if
(
OrganizationKvid
!=
Guid
.
Empty
)
query
.
And
(
o
=>
o
.
OrganizationKvid
==
OrganizationKvid
);
else
if
(
OrganizationKvid
!=
Guid
.
Empty
)
query
.
And
(
o
=>
o
.
OrganizationKvid
==
OrganizationKvid
);
var
applys
=
conn
.
Select
(
query
);
var
applys
=
conn
.
Select
(
query
);
...
...
Src/Transforms/RestfulPayment.Split.cs
View file @
864227ae
...
@@ -27,8 +27,14 @@ namespace Kivii.Finances.Transforms
...
@@ -27,8 +27,14 @@ namespace Kivii.Finances.Transforms
[
ApiMember
(
Description
=
"认领类型,默认为Department,Organization,Member"
)]
[
ApiMember
(
Description
=
"认领类型,默认为Department,Organization,Member"
)]
public
OwnerType
OwnerType
{
get
;
set
;
}
=
OwnerType
.
Department
;
public
OwnerType
OwnerType
{
get
;
set
;
}
=
OwnerType
.
Department
;
public
Guid
OwnerKvid
{
get
;
set
;
}
public
string
OwnerName
{
get
;
set
;
}
public
Guid
Kvid
{
get
;
set
;
}
public
Guid
Kvid
{
get
;
set
;
}
public
string
Remark
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
{
if
(
Kvid
==
Guid
.
Empty
)
throw
new
Exception
(
"请选择要认领的收款!"
);
if
(
Kvid
==
Guid
.
Empty
)
throw
new
Exception
(
"请选择要认领的收款!"
);
...
@@ -63,7 +69,11 @@ namespace Kivii.Finances.Transforms
...
@@ -63,7 +69,11 @@ namespace Kivii.Finances.Transforms
break
;
break
;
}
}
}
}
if
(
OwnerKvid
!=
Guid
.
Empty
)
{
ownerKvid
=
OwnerKvid
;
ownerName
=
OwnerName
;
}
Payment
bank
=
null
;
Payment
bank
=
null
;
Payment
split
=
null
;
Payment
split
=
null
;
EntityLog
<
Payment
>
log
=
null
;
EntityLog
<
Payment
>
log
=
null
;
...
@@ -77,7 +87,7 @@ namespace Kivii.Finances.Transforms
...
@@ -77,7 +87,7 @@ namespace Kivii.Finances.Transforms
if
(
amountSplit
+
Amount
>
payment
.
Amount
)
throw
new
Exception
(
"认领金额超出范围!"
);
if
(
amountSplit
+
Amount
>
payment
.
Amount
)
throw
new
Exception
(
"认领金额超出范围!"
);
bank
=
payment
;
bank
=
payment
;
split
=
bank
.
BizSplit
(
Amount
,
ownerKvid
,
ownerName
,
conn
);
split
=
bank
.
BizSplit
(
Amount
,
Remark
,
ownerKvid
,
ownerName
,
conn
);
#
region
记录日志
#
region
记录日志
log
=
new
EntityLog
<
Payment
>();
log
=
new
EntityLog
<
Payment
>();
...
@@ -98,6 +108,8 @@ namespace Kivii.Finances.Transforms
...
@@ -98,6 +108,8 @@ namespace Kivii.Finances.Transforms
split
.
AddOnlyProperties
(
o
=>
o
.
OwnerKvid
);
split
.
AddOnlyProperties
(
o
=>
o
.
OwnerKvid
);
split
.
OwnerName
=
ownerName
;
split
.
OwnerName
=
ownerName
;
split
.
AddOnlyProperties
(
o
=>
o
.
OwnerName
);
split
.
AddOnlyProperties
(
o
=>
o
.
OwnerName
);
split
.
Remark
=
Remark
;
split
.
AddOnlyProperties
(
o
=>
o
.
Remark
);
#
region
记录日志
#
region
记录日志
log
=
new
EntityLog
<
Payment
>();
log
=
new
EntityLog
<
Payment
>();
...
@@ -155,7 +167,13 @@ namespace Kivii.Finances.Transforms
...
@@ -155,7 +167,13 @@ namespace Kivii.Finances.Transforms
[
ApiMember
(
Description
=
"认领类型,默认为Department,Organization,Member"
)]
[
ApiMember
(
Description
=
"认领类型,默认为Department,Organization,Member"
)]
public
OwnerType
OwnerType
{
get
;
set
;
}
=
OwnerType
.
Department
;
public
OwnerType
OwnerType
{
get
;
set
;
}
=
OwnerType
.
Department
;
public
Guid
OwnerKvid
{
get
;
set
;
}
public
string
OwnerName
{
get
;
set
;
}
public
List
<
Guid
>
Kvids
{
get
;
set
;
}
public
List
<
Guid
>
Kvids
{
get
;
set
;
}
public
string
Remark
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
{
if
(
Kvids
.
IsNullOrEmpty
())
throw
new
Exception
(
"请选择要认领的收款!"
);
if
(
Kvids
.
IsNullOrEmpty
())
throw
new
Exception
(
"请选择要认领的收款!"
);
...
@@ -191,7 +209,11 @@ namespace Kivii.Finances.Transforms
...
@@ -191,7 +209,11 @@ namespace Kivii.Finances.Transforms
break
;
break
;
}
}
}
}
if
(
OwnerKvid
!=
Guid
.
Empty
)
{
ownerKvid
=
OwnerKvid
;
ownerName
=
OwnerName
;
}
var
banks
=
new
List
<
Payment
>();
var
banks
=
new
List
<
Payment
>();
var
splits
=
new
List
<
Payment
>();
var
splits
=
new
List
<
Payment
>();
var
splitsSetOwner
=
new
List
<
Payment
>();
var
splitsSetOwner
=
new
List
<
Payment
>();
...
@@ -203,7 +225,7 @@ namespace Kivii.Finances.Transforms
...
@@ -203,7 +225,7 @@ namespace Kivii.Finances.Transforms
{
{
var
amount
=
payment
.
Amount
-
payment
.
AmountSplited
;
var
amount
=
payment
.
Amount
-
payment
.
AmountSplited
;
if
(
amount
<=
0
)
continue
;
if
(
amount
<=
0
)
continue
;
var
splitPayment
=
payment
.
BizSplit
(
amount
,
ownerKvid
,
ownerName
,
conn
);
var
splitPayment
=
payment
.
BizSplit
(
amount
,
Remark
,
ownerKvid
,
ownerName
,
conn
);
splits
.
Add
(
splitPayment
);
splits
.
Add
(
splitPayment
);
banks
.
Add
(
payment
);
banks
.
Add
(
payment
);
...
@@ -225,6 +247,8 @@ namespace Kivii.Finances.Transforms
...
@@ -225,6 +247,8 @@ namespace Kivii.Finances.Transforms
payment
.
AddOnlyProperties
(
o
=>
o
.
OwnerKvid
);
payment
.
AddOnlyProperties
(
o
=>
o
.
OwnerKvid
);
payment
.
OwnerName
=
ownerName
;
payment
.
OwnerName
=
ownerName
;
payment
.
AddOnlyProperties
(
o
=>
o
.
OwnerName
);
payment
.
AddOnlyProperties
(
o
=>
o
.
OwnerName
);
payment
.
Remark
=
Remark
;
payment
.
AddOnlyProperties
(
o
=>
o
.
Remark
);
splitsSetOwner
.
Add
(
payment
);
splitsSetOwner
.
Add
(
payment
);
#
region
记录日志
#
region
记录日志
...
...
Src/Transforms/RestfulPayment.UnBiz.Refund.cs
View file @
864227ae
...
@@ -17,6 +17,7 @@ namespace Kivii.Finances.Transforms
...
@@ -17,6 +17,7 @@ namespace Kivii.Finances.Transforms
public
Guid
Kvid
{
get
;
set
;
}
public
Guid
Kvid
{
get
;
set
;
}
public
string
Remark
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
{
if
(
Amount
<=
0
)
throw
new
Exception
(
"金额不能为小于0!"
);
if
(
Amount
<=
0
)
throw
new
Exception
(
"金额不能为小于0!"
);
...
@@ -33,7 +34,7 @@ namespace Kivii.Finances.Transforms
...
@@ -33,7 +34,7 @@ namespace Kivii.Finances.Transforms
//if (payment.AmountInvoice > 0) throw new Exception("已开票,无法非业务处理!");
//if (payment.AmountInvoice > 0) throw new Exception("已开票,无法非业务处理!");
if
(
payment
.
AmountUsed
>
0
)
throw
new
Exception
(
"已使用金额,无法非业务处理!"
);
if
(
payment
.
AmountUsed
>
0
)
throw
new
Exception
(
"已使用金额,无法非业务处理!"
);
var
split
=
payment
.
UnBizSplit
(
Amount
,
PaymentType
.
UnBiz
);
var
split
=
payment
.
UnBizSplit
(
Amount
,
PaymentType
.
UnBiz
,
Remark
);
#
region
记录日志
#
region
记录日志
var
log
=
new
EntityLog
<
Payment
>();
var
log
=
new
EntityLog
<
Payment
>();
...
@@ -75,6 +76,7 @@ namespace Kivii.Finances.Transforms
...
@@ -75,6 +76,7 @@ namespace Kivii.Finances.Transforms
{
{
public
List
<
Guid
>
Kvids
{
get
;
set
;
}
public
List
<
Guid
>
Kvids
{
get
;
set
;
}
public
string
Remark
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
{
if
(
Kvids
.
IsNullOrEmpty
())
throw
new
Exception
(
"请选择要非业务收款处理的到账!"
);
if
(
Kvids
.
IsNullOrEmpty
())
throw
new
Exception
(
"请选择要非业务收款处理的到账!"
);
...
@@ -97,7 +99,7 @@ namespace Kivii.Finances.Transforms
...
@@ -97,7 +99,7 @@ namespace Kivii.Finances.Transforms
{
{
var
amount
=
payment
.
Amount
-
payment
.
AmountSplited
;
var
amount
=
payment
.
Amount
-
payment
.
AmountSplited
;
if
(
amount
<=
0
)
continue
;
if
(
amount
<=
0
)
continue
;
var
split
=
payment
.
UnBizSplit
(
amount
,
PaymentType
.
UnBiz
);
var
split
=
payment
.
UnBizSplit
(
amount
,
PaymentType
.
UnBiz
,
Remark
);
banks
.
Add
(
payment
);
banks
.
Add
(
payment
);
splits
.
Add
(
split
);
splits
.
Add
(
split
);
...
@@ -222,6 +224,7 @@ namespace Kivii.Finances.Transforms
...
@@ -222,6 +224,7 @@ namespace Kivii.Finances.Transforms
public
Guid
Kvid
{
get
;
set
;
}
public
Guid
Kvid
{
get
;
set
;
}
public
string
Remark
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
{
if
(
Amount
<=
0
)
throw
new
Exception
(
"金额不能为小于0!"
);
if
(
Amount
<=
0
)
throw
new
Exception
(
"金额不能为小于0!"
);
...
@@ -238,7 +241,7 @@ namespace Kivii.Finances.Transforms
...
@@ -238,7 +241,7 @@ namespace Kivii.Finances.Transforms
//if (payment.AmountInvoice > 0) throw new Exception("已开票,无法退款处理!");
//if (payment.AmountInvoice > 0) throw new Exception("已开票,无法退款处理!");
if
(
payment
.
AmountUsed
>
0
)
throw
new
Exception
(
"已使用金额,无法退款处理!"
);
if
(
payment
.
AmountUsed
>
0
)
throw
new
Exception
(
"已使用金额,无法退款处理!"
);
var
split
=
payment
.
UnBizSplit
(
Amount
,
PaymentType
.
Refund
);
var
split
=
payment
.
UnBizSplit
(
Amount
,
PaymentType
.
Refund
,
Remark
);
#
region
记录日志
#
region
记录日志
var
log
=
new
EntityLog
<
Payment
>();
var
log
=
new
EntityLog
<
Payment
>();
...
@@ -279,6 +282,7 @@ namespace Kivii.Finances.Transforms
...
@@ -279,6 +282,7 @@ namespace Kivii.Finances.Transforms
public
class
PaymentMultiRefund
:
RestfulExecution
<
Payment
>
public
class
PaymentMultiRefund
:
RestfulExecution
<
Payment
>
{
{
public
List
<
Guid
>
Kvids
{
get
;
set
;
}
public
List
<
Guid
>
Kvids
{
get
;
set
;
}
public
string
Remark
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
{
...
@@ -302,7 +306,7 @@ namespace Kivii.Finances.Transforms
...
@@ -302,7 +306,7 @@ namespace Kivii.Finances.Transforms
{
{
var
amount
=
payment
.
Amount
-
payment
.
AmountSplited
;
var
amount
=
payment
.
Amount
-
payment
.
AmountSplited
;
if
(
amount
<=
0
)
continue
;
if
(
amount
<=
0
)
continue
;
var
split
=
payment
.
UnBizSplit
(
amount
,
PaymentType
.
Refund
);
var
split
=
payment
.
UnBizSplit
(
amount
,
PaymentType
.
Refund
,
Remark
);
banks
.
Add
(
payment
);
banks
.
Add
(
payment
);
splits
.
Add
(
split
);
splits
.
Add
(
split
);
...
...
Src/Transforms/RestfulPayment.cs
View file @
864227ae
...
@@ -55,7 +55,7 @@ namespace Kivii.Finances.Transforms
...
@@ -55,7 +55,7 @@ namespace Kivii.Finances.Transforms
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
AliPay
,
PaymentType
.
WeChat
,
PaymentType
.
Bank
,
PaymentType
.
Cash
,
PaymentType
.
Pos
));
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
AliPay
,
PaymentType
.
WeChat
,
PaymentType
.
Bank
,
PaymentType
.
Cash
,
PaymentType
.
Pos
));
if
(
OwnerType
==
OwnerType
.
Organization
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
OrganizationKvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
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
.
Department
)
sqlExpress
.
And
(
o
=>
Sql
.
In
(
o
.
OwnerKvid
,
KiviiContext
.
CurrentMember
.
DepartmentKvids
)
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Member
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
Kvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Member
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
Kvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
IsSplit
!=
null
)
if
(
IsSplit
!=
null
)
{
{
...
@@ -289,7 +289,7 @@ namespace Kivii.Finances.Transforms
...
@@ -289,7 +289,7 @@ namespace Kivii.Finances.Transforms
request
=
request
.
PopulateWith
(
this
);
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
if
(
OwnerType
==
OwnerType
.
Organization
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
OrganizationKvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
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
.
Department
)
sqlExpress
.
And
(
o
=>
Sql
.
In
(
o
.
OwnerKvid
,
KiviiContext
.
CurrentMember
.
DepartmentKvids
)
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Member
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
Kvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Member
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
Kvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
IsBiz
==
null
)
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
(
IsBiz
==
null
)
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
));
else
if
(
IsBiz
.
Value
)
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
WeChat
,
PaymentType
.
Cash
,
PaymentType
.
AliPay
,
PaymentType
.
Pos
,
PaymentType
.
Split
));
else
if
(
IsBiz
.
Value
)
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
WeChat
,
PaymentType
.
Cash
,
PaymentType
.
AliPay
,
PaymentType
.
Pos
,
PaymentType
.
Split
));
...
...
Src/Transforms/RestfulSettlement.cs
View file @
864227ae
...
@@ -27,22 +27,26 @@ namespace Kivii.Finances.Transforms
...
@@ -27,22 +27,26 @@ namespace Kivii.Finances.Transforms
Items
.
Exists
(
o
=>
o
.
PayerName
.
IsNullOrEmpty
()).
ThrowIfTrue
(
"付款单位不能为空!"
);
Items
.
Exists
(
o
=>
o
.
PayerName
.
IsNullOrEmpty
()).
ThrowIfTrue
(
"付款单位不能为空!"
);
Items
.
Exists
(
o
=>
o
.
Currency
==
CurrencyUnit
.
Unsupported
).
ThrowIfTrue
(
"不支持的货币单位!"
);
Items
.
Exists
(
o
=>
o
.
Currency
==
CurrencyUnit
.
Unsupported
).
ThrowIfTrue
(
"不支持的货币单位!"
);
Items
.
Exists
(
o
=>
o
.
Details
.
IsNullOrEmpty
()).
ThrowIfTrue
(
"结算明细不能为空!"
);
Items
.
Exists
(
o
=>
o
.
Details
.
IsNullOrEmpty
()).
ThrowIfTrue
(
"结算明细不能为空!"
);
var
bizKvids
=
Items
.
ConvertAll
(
p
=>
p
.
BizKvid
);
//
var bizKvids = Items.ConvertAll(p => p.BizKvid);
bizKvids
.
RemoveAll
(
o
=>
o
==
Guid
.
Empty
);
//
bizKvids.RemoveAll(o => o == Guid.Empty);
var
bizids
=
Items
.
ConvertAll
(
p
=>
p
.
BizId
);
var
bizids
=
Items
.
ConvertAll
(
p
=>
p
.
BizId
);
bizids
.
RemoveAll
(
o
=>
o
.
IsNullOrEmpty
());
bizids
.
RemoveAll
(
o
=>
o
.
IsNullOrEmpty
());
var
connF
=
KiviiContext
.
GetOpenedDbConnection
<
Settlement
>();
var
connF
=
KiviiContext
.
GetOpenedDbConnection
<
Settlement
>();
if
(
connF
.
Exists
<
Settlement
>(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
(
Sql
.
In
(
o
.
BizKvid
,
bizKvids
)
||
Sql
.
In
(
o
.
BizId
,
bizids
))))
throw
new
Exception
(
"存在重复结算的对象!"
);
foreach
(
var
bizId
in
bizids
)
{
if
(
connF
.
Exists
<
Settlement
>(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
o
.
BizId
==
bizId
))
throw
new
Exception
(
$"
{
bizId
}
重复结算的对象!"
);
}
//if (connF.Exists<Settlement>(o => o.OffsetKvid == Guid.Empty && (Sql.In(o.BizKvid, bizKvids) || Sql.In(o.BizId, bizids)))) throw new Exception("存在重复结算的对象!");
var
connE
=
KiviiContext
.
GetOpenedDbConnection
<
G
>();
var
connE
=
KiviiContext
.
GetOpenedDbConnection
<
G
>();
//如果泛型类型不是Settlement本身就需要判断
//
//
如果泛型类型不是Settlement本身就需要判断
if
(
typeof
(
G
)
!=
typeof
(
Settlement
))
connE
.
Exists
<
EntitySettlement
<
G
>>(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
(
Sql
.
In
(
o
.
BizKvid
,
bizKvids
)
||
Sql
.
In
(
o
.
BizId
,
bizids
)
)).
ThrowIfTrue
(
"存在重复结算的对象!"
);
//if (typeof(G) != typeof(Settlement)) connE.Exists<EntitySettlement<G>>(o => o.OffsetKvid == Guid.Empty && Sql.In(o.BizId, bizids
)).ThrowIfTrue("存在重复结算的对象!");
var
allDetails
=
new
List
<
SettlementDetail
>();
//
var allDetails = new List<SettlementDetail>();
Items
.
ForEach
(
o
=>
allDetails
.
AddRange
(
o
.
Details
));
//
Items.ForEach(o => allDetails.AddRange(o.Details));
var
detailBizKvids
=
allDetails
.
ConvertAll
(
p
=>
p
.
BizKvid
);
//
var detailBizKvids = allDetails.ConvertAll(p => p.BizKvid);
detailBizKvids
.
RemoveAll
(
o
=>
o
==
Guid
.
Empty
);
//
detailBizKvids.RemoveAll(o => o == Guid.Empty);
var
detailBizids
=
allDetails
.
ConvertAll
(
p
=>
p
.
BizId
);
//
var detailBizids = allDetails.ConvertAll(p => p.BizId);
detailBizids
.
RemoveAll
(
o
=>
o
.
IsNullOrEmpty
());
//
detailBizids.RemoveAll(o => o.IsNullOrEmpty());
if
(
connE
.
Exists
<
EntitySettlementDetail
<
G
>>(
o
=>
o
.
OffsetKvid
!=
Guid
.
Empty
&&
(
Sql
.
In
(
o
.
BizKvid
,
detailBizKvids
)
||
Sql
.
In
(
o
.
BizId
,
detailBizids
))))
throw
new
Exception
(
"存在重复结算的明细项目!"
);
//
if (connE.Exists<EntitySettlementDetail<G>>(o => o.OffsetKvid != Guid.Empty && (Sql.In(o.BizKvid, detailBizKvids) || Sql.In(o.BizId, detailBizids)))) throw new Exception("存在重复结算的明细项目!");
var
rtns
=
new
RestfulCreateResponse
<
Settlement
>();
var
rtns
=
new
RestfulCreateResponse
<
Settlement
>();
rtns
.
Results
=
new
List
<
Settlement
>();
rtns
.
Results
=
new
List
<
Settlement
>();
...
...
Src/Transforms/RestfulStatistic.cs
View file @
864227ae
This diff is collapsed.
Click to expand it.
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