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
02452643
Commit
02452643
authored
May 05, 2022
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
事务添加判断
parent
d2923001
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
356 additions
and
82 deletions
+356
-82
.gitignore
.gitignore
+2
-0
InvoiceApplyExtension.cs
Src/Extensions/InvoiceApplyExtension.cs
+1
-0
PayExtension.cs
Src/Extensions/PayExtension.cs
+20
-6
Kivii.Biz.Finances.V2.0.csproj
Src/Kivii.Biz.Finances.V2.0.csproj
+6
-6
RestfulAccount.cs
Src/Transforms/RestfulAccount.cs
+44
-30
RestfulBill.cs
Src/Transforms/RestfulBill.cs
+9
-5
RestfulInvoice.cs
Src/Transforms/RestfulInvoice.cs
+4
-1
RestfulPay.cs
Src/Transforms/RestfulPay.cs
+23
-3
RestfulSettlement.Offset.cs
Src/Transforms/RestfulSettlement.Offset.cs
+26
-5
RestfulSettlement.cs
Src/Transforms/RestfulSettlement.cs
+104
-22
RestfulStatistic.cs
Src/Transforms/RestfulStatistic.cs
+113
-1
packages.config
Src/packages.config
+4
-3
No files found.
.gitignore
View file @
02452643
...
@@ -4,3 +4,5 @@
...
@@ -4,3 +4,5 @@
/Src/obj/Debug
/Src/obj/Debug
/Src/bin/Debug
/Src/bin/Debug
/.vs
/Src/obj/Release
Src/Extensions/InvoiceApplyExtension.cs
View file @
02452643
...
@@ -80,6 +80,7 @@ namespace Kivii.Finances
...
@@ -80,6 +80,7 @@ namespace Kivii.Finances
relationInvoice
.
AmountUntaxed
=
Math
.
Round
(
relationInvoice
.
Amount
/
(
1
+
relationInvoice
.
TaxRate
),
2
);
relationInvoice
.
AmountUntaxed
=
Math
.
Round
(
relationInvoice
.
Amount
/
(
1
+
relationInvoice
.
TaxRate
),
2
);
//税额
//税额
relationInvoice
.
AmountTax
=
relationInvoice
.
Amount
-
relationInvoice
.
AmountUntaxed
;
relationInvoice
.
AmountTax
=
relationInvoice
.
Amount
-
relationInvoice
.
AmountUntaxed
;
relationInvoice
.
Summary
=
payment
.
PayerName
;
rtns
.
Add
(
relationInvoice
);
rtns
.
Add
(
relationInvoice
);
#
endregion
#
endregion
...
...
Src/Extensions/PayExtension.cs
View file @
02452643
using
Kivii.Finances.Entities
;
using
Kivii.Finances.Entities
;
using
Kivii.Linq
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Kivii.Finances
namespace
Kivii.Finances
{
{
...
@@ -58,7 +55,8 @@ namespace Kivii.Finances
...
@@ -58,7 +55,8 @@ namespace Kivii.Finances
rtns
.
AmountSplited
=
0
;
rtns
.
AmountSplited
=
0
;
rtns
.
AmountUsed
=
amount
;
rtns
.
AmountUsed
=
amount
;
rtns
.
Summary
=
"收款登记"
;
rtns
.
Summary
=
"收款登记"
;
rtns
.
OperateTime
=
DateTime
.
Now
;
rtns
.
OperateTime
=
payment
.
OperateTime
;
//rtns.OperateTime = DateTime.Now;
rtns
.
OperatorName
=
KiviiContext
.
CurrentMember
.
FullName
;
rtns
.
OperatorName
=
KiviiContext
.
CurrentMember
.
FullName
;
rtns
.
OperatorKvid
=
KiviiContext
.
CurrentMember
.
Kvid
;
rtns
.
OperatorKvid
=
KiviiContext
.
CurrentMember
.
Kvid
;
rtns
.
Currency
=
payment
.
Currency
;
rtns
.
Currency
=
payment
.
Currency
;
...
@@ -92,7 +90,7 @@ namespace Kivii.Finances
...
@@ -92,7 +90,7 @@ namespace Kivii.Finances
var
pay
=
new
Pay
();
var
pay
=
new
Pay
();
pay
.
BizId
=
settlement
.
SerialNumber
;
pay
.
BizId
=
settlement
.
SerialNumber
;
pay
.
BizKvid
=
settlement
.
Kvid
;
pay
.
BizKvid
=
settlement
.
Kvid
;
pay
.
BizType
=
typeof
(
Settlement
).
FullName
;
pay
.
BizType
=
typeof
(
Settlement
).
FullName
;
pay
.
OwnerKvid
=
KiviiContext
.
CurrentMember
.
DepartmentKvid
;
pay
.
OwnerKvid
=
KiviiContext
.
CurrentMember
.
DepartmentKvid
;
pay
.
OwnerName
=
KiviiContext
.
CurrentMember
.
DepartmentName
;
pay
.
OwnerName
=
KiviiContext
.
CurrentMember
.
DepartmentName
;
pay
.
PayerKvid
=
rtns
.
PayerKvid
;
pay
.
PayerKvid
=
rtns
.
PayerKvid
;
...
@@ -104,7 +102,8 @@ namespace Kivii.Finances
...
@@ -104,7 +102,8 @@ namespace Kivii.Finances
pay
.
ToKvid
=
accountPayee
.
Kvid
;
pay
.
ToKvid
=
accountPayee
.
Kvid
;
pay
.
ToType
=
PayType
.
Account
;
pay
.
ToType
=
PayType
.
Account
;
pay
.
Type
=
"DynamicPay"
;
pay
.
Type
=
"DynamicPay"
;
pay
.
PayedTime
=
DateTime
.
Now
;
pay
.
Summary
=
settlement
.
Type
;
pay
.
PayedTime
=
rtns
.
OperateTime
;
pay
.
Amount
=
currentAmount
;
pay
.
Amount
=
currentAmount
;
pay
.
AmountPayment
=
currentAmount
;
pay
.
AmountPayment
=
currentAmount
;
pay
.
AmountDiscount
=
0
;
pay
.
AmountDiscount
=
0
;
...
@@ -117,6 +116,13 @@ namespace Kivii.Finances
...
@@ -117,6 +116,13 @@ namespace Kivii.Finances
settlement
.
AmountPayment
+=
currentAmount
;
settlement
.
AmountPayment
+=
currentAmount
;
settlement
.
AddOnlyProperties
(
o
=>
o
.
AmountPayment
);
settlement
.
AddOnlyProperties
(
o
=>
o
.
AmountPayment
);
settlement
.
PayedTime
=
rtns
.
OperateTime
;
settlement
.
AddOnlyProperties
(
o
=>
o
.
PayedTime
);
if
(
settlement
.
Metadata
.
IsNullOrEmpty
())
settlement
.
Metadata
=
new
Dictionary
<
string
,
string
>();
settlement
.
Metadata
[
"PayedType"
]
=
typeof
(
Payment
).
FullName
;
settlement
.
Metadata
[
"PayedName"
]
=
payment
.
PayerName
;
settlement
.
Metadata
[
"PayedSerialNumber"
]
=
payment
.
SerialNumber
;
settlement
.
AddOnlyProperties
(
o
=>
o
.
Metadata
);
amount
-=
currentAmount
;
amount
-=
currentAmount
;
}
}
...
@@ -210,6 +216,7 @@ namespace Kivii.Finances
...
@@ -210,6 +216,7 @@ namespace Kivii.Finances
pay
.
ToKvid
=
accountPayee
.
Kvid
;
pay
.
ToKvid
=
accountPayee
.
Kvid
;
pay
.
ToType
=
PayType
.
Account
;
pay
.
ToType
=
PayType
.
Account
;
pay
.
Type
=
"DynamicPay"
;
pay
.
Type
=
"DynamicPay"
;
pay
.
Summary
=
settlement
.
Type
;
pay
.
PayedTime
=
DateTime
.
Now
;
pay
.
PayedTime
=
DateTime
.
Now
;
pay
.
Amount
=
currentAmount
;
pay
.
Amount
=
currentAmount
;
if
(
accountPayer
.
Type
==
AccountType
.
Discount
)
//要是 折扣账户 则记录到AmountDiscount
if
(
accountPayer
.
Type
==
AccountType
.
Discount
)
//要是 折扣账户 则记录到AmountDiscount
...
@@ -231,6 +238,13 @@ namespace Kivii.Finances
...
@@ -231,6 +238,13 @@ namespace Kivii.Finances
settlement
.
AmountPayment
+=
currentAmount
;
settlement
.
AmountPayment
+=
currentAmount
;
settlement
.
AddOnlyProperties
(
o
=>
o
.
AmountPayment
);
settlement
.
AddOnlyProperties
(
o
=>
o
.
AmountPayment
);
settlement
.
PayedTime
=
DateTime
.
Now
;
settlement
.
AddOnlyProperties
(
o
=>
o
.
PayedTime
);
if
(
settlement
.
Metadata
.
IsNullOrEmpty
())
settlement
.
Metadata
=
new
Dictionary
<
string
,
string
>();
settlement
.
Metadata
[
"PayedType"
]
=
typeof
(
Account
).
FullName
;
settlement
.
Metadata
[
"PayedName"
]
=
accountPayer
.
Name
;
settlement
.
Metadata
[
"PayedSerialNumber"
]
=
accountPayer
.
SerialNumber
;
settlement
.
AddOnlyProperties
(
o
=>
o
.
Metadata
);
amount
-=
currentAmount
;
amount
-=
currentAmount
;
}
}
...
...
Src/Kivii.Biz.Finances.V2.0.csproj
View file @
02452643
...
@@ -31,14 +31,14 @@
...
@@ -31,14 +31,14 @@
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference
Include=
"Kivii.Common.V4.5, Version=5.6.2022.4
06
0, Culture=neutral, processorArchitecture=MSIL"
>
<Reference
Include=
"Kivii.Common.V4.5, Version=5.6.2022.4
11
0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\Kivii.Common.5.6.2022.4
06
0\lib\net45\Kivii.Common.V4.5.dll
</HintPath>
<HintPath>
..\..\packages\Kivii.Common.5.6.2022.4
11
0\lib\net45\Kivii.Common.V4.5.dll
</HintPath>
</Reference>
</Reference>
<Reference
Include=
"Kivii.Core.V4.5, Version=5.6.2022.4
05
0, Culture=neutral, processorArchitecture=MSIL"
>
<Reference
Include=
"Kivii.Core.V4.5, Version=5.6.2022.4
11
0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\Kivii.Core.5.6.2022.4
05
0\lib\net45\Kivii.Core.V4.5.dll
</HintPath>
<HintPath>
..\..\packages\Kivii.Core.5.6.2022.4
11
0\lib\net45\Kivii.Core.V4.5.dll
</HintPath>
</Reference>
</Reference>
<Reference
Include=
"Kivii.Linq.V4.5, Version=5.6.2022.41
0
0, Culture=neutral, processorArchitecture=MSIL"
>
<Reference
Include=
"Kivii.Linq.V4.5, Version=5.6.2022.41
2
0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\Kivii.Linq.5.6.2022.41
0
0\lib\net45\Kivii.Linq.V4.5.dll
</HintPath>
<HintPath>
..\..\packages\Kivii.Linq.5.6.2022.41
2
0\lib\net45\Kivii.Linq.V4.5.dll
</HintPath>
</Reference>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Core"
/>
...
...
Src/Transforms/RestfulAccount.cs
View file @
02452643
...
@@ -26,41 +26,55 @@ namespace Kivii.Finances.Transforms
...
@@ -26,41 +26,55 @@ namespace Kivii.Finances.Transforms
//if (Item.Type == AccountType.WeChat && dbConnection.Exists<Account>(o => o.OwnerKvid == Item.OwnerKvid && o.Type == AccountType.WeChat && o.OrganizationKvid == KiviiContext.CurrentMember.OrganizationKvid)) throw new Exception("当前组织已存在微信账户!");
//if (Item.Type == AccountType.WeChat && dbConnection.Exists<Account>(o => o.OwnerKvid == Item.OwnerKvid && o.Type == AccountType.WeChat && o.OrganizationKvid == KiviiContext.CurrentMember.OrganizationKvid)) throw new Exception("当前组织已存在微信账户!");
//if (Item.Type == AccountType.AliPay && dbConnection.Exists<Account>(o => o.OwnerKvid == Item.OwnerKvid && o.Type == AccountType.AliPay && o.OrganizationKvid == KiviiContext.CurrentMember.OrganizationKvid)) throw new Exception("当前组织已存在支付宝账户!");
//if (Item.Type == AccountType.AliPay && dbConnection.Exists<Account>(o => o.OwnerKvid == Item.OwnerKvid && o.Type == AccountType.AliPay && o.OrganizationKvid == KiviiContext.CurrentMember.OrganizationKvid)) throw new Exception("当前组织已存在支付宝账户!");
//if (Item.Type == AccountType.Bank && dbConnection.Exists<Account>(o => o.OwnerKvid == Item.OwnerKvid && o.Type == AccountType.Bank && o.OrganizationKvid == KiviiContext.CurrentMember.OrganizationKvid)) throw new Exception("当前组织已存在银行账户!");
//if (Item.Type == AccountType.Bank && dbConnection.Exists<Account>(o => o.OwnerKvid == Item.OwnerKvid && o.Type == AccountType.Bank && o.OrganizationKvid == KiviiContext.CurrentMember.OrganizationKvid)) throw new Exception("当前组织已存在银行账户!");
if
(
dbConnection
is
LinqConnection
&&
(
dbConnection
as
LinqConnection
).
DbTransaction
==
null
)
_trans
=
dbConnection
.
OpenTransaction
();
{
_trans
=
dbConnection
.
OpenTransaction
();
}
return
base
.
OnPreRestfulCreate
(
req
,
res
,
dbConnection
,
rtns
);
return
base
.
OnPreRestfulCreate
(
req
,
res
,
dbConnection
,
rtns
);
}
}
public
override
bool
OnPostRestfulCreate
(
IRequest
req
,
IResponse
res
,
IDbConnection
dbConnection
,
IRestfulCreateResponse
<
Account
>
rtns
)
public
override
bool
OnPostRestfulCreate
(
IRequest
req
,
IResponse
res
,
IDbConnection
dbConnection
,
IRestfulCreateResponse
<
Account
>
rtns
)
{
{
//新建开户记录
try
var
accountDetail
=
new
AccountDetail
();
{
accountDetail
.
AccountKvid
=
Item
.
Kvid
;
//新建开户记录
accountDetail
.
BizKvid
=
Item
.
Kvid
;
var
accountDetail
=
new
AccountDetail
();
accountDetail
.
BizType
=
typeof
(
Account
).
FullName
;
accountDetail
.
AccountKvid
=
Item
.
Kvid
;
accountDetail
.
BizId
=
Item
.
SerialNumber
;
accountDetail
.
BizKvid
=
Item
.
Kvid
;
accountDetail
.
BizType
=
typeof
(
Account
).
FullName
;
accountDetail
.
PayerKvid
=
Item
.
Kvid
;
accountDetail
.
BizId
=
Item
.
SerialNumber
;
accountDetail
.
PayerName
=
Item
.
Name
;
accountDetail
.
PayerAccountKvid
=
Item
.
Kvid
;
accountDetail
.
PayerKvid
=
Item
.
Kvid
;
accountDetail
.
PayerAccountName
=
Item
.
Name
;
accountDetail
.
PayerName
=
Item
.
Name
;
accountDetail
.
PayerAccountSerialNumber
=
Item
.
SerialNumber
;
accountDetail
.
PayerAccountKvid
=
Item
.
Kvid
;
accountDetail
.
PayerAccountName
=
Item
.
Name
;
accountDetail
.
PayeeKvid
=
Item
.
Kvid
;
accountDetail
.
PayerAccountSerialNumber
=
Item
.
SerialNumber
;
accountDetail
.
PayeeName
=
Item
.
Name
;
accountDetail
.
PayeeAccountKvid
=
Item
.
Kvid
;
accountDetail
.
PayeeKvid
=
Item
.
Kvid
;
accountDetail
.
PayeeAccountName
=
Item
.
Name
;
accountDetail
.
PayeeName
=
Item
.
Name
;
accountDetail
.
PayeeAccountSerialNumber
=
Item
.
SerialNumber
;
accountDetail
.
PayeeAccountKvid
=
Item
.
Kvid
;
accountDetail
.
PayeeAccountName
=
Item
.
Name
;
accountDetail
.
AmountPayment
=
0
;
accountDetail
.
PayeeAccountSerialNumber
=
Item
.
SerialNumber
;
accountDetail
.
Amount
=
0
;
accountDetail
.
AmountPayment
=
0
;
accountDetail
.
Summary
=
"开户"
;
accountDetail
.
Amount
=
0
;
accountDetail
.
Remark
=
"开户"
;
dbConnection
.
Insert
(
accountDetail
);
accountDetail
.
Summary
=
"开户"
;
accountDetail
.
Remark
=
"开户"
;
_trans
.
Commit
();
dbConnection
.
Insert
(
accountDetail
);
return
base
.
OnPostRestfulCreate
(
req
,
res
,
dbConnection
,
rtns
);
_trans
?.
Commit
();
return
base
.
OnPostRestfulCreate
(
req
,
res
,
dbConnection
,
rtns
);
}
catch
(
Exception
ex
)
{
_trans
?.
Rollback
();
throw
ex
;
}
finally
{
_trans
?.
Dispose
();
}
}
}
}
}
...
...
Src/Transforms/RestfulBill.cs
View file @
02452643
...
@@ -121,16 +121,16 @@ namespace Kivii.Finances.Transforms
...
@@ -121,16 +121,16 @@ namespace Kivii.Finances.Transforms
}
}
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
BillDelete
:
RestfulDelete
<
Bill
>
public
class
BillDelete
:
RestfulDelete
<
Bill
>
{
{
IDbTransaction
_trans
=
null
;
IDbTransaction
_trans
=
null
;
public
override
bool
OnPreRestfulDelete
(
IRequest
req
,
IResponse
res
,
IDbConnection
dbConnection
,
IRestfulDeleteResponse
<
Bill
>
rtns
)
public
override
bool
OnPreRestfulDelete
(
IRequest
req
,
IResponse
res
,
IDbConnection
dbConnection
,
IRestfulDeleteResponse
<
Bill
>
rtns
)
{
{
dbConnection
.
Exists
<
Bill
>(
o
=>
Sql
.
In
(
o
.
Kvid
,
Kvids
)
&&
o
.
AmountPayment
==
o
.
Amount
).
ThrowIfTrue
(
"此账单已归档付款登记,无法删除"
);
dbConnection
.
Exists
<
Bill
>(
o
=>
Sql
.
In
(
o
.
Kvid
,
Kvids
)
&&
o
.
AmountPayment
==
o
.
Amount
).
ThrowIfTrue
(
"此账单已归档付款登记,无法删除"
);
//
if (dbConnection is LinqConnection && (dbConnection as LinqConnection).DbTransaction == null)
if
(
dbConnection
is
LinqConnection
&&
(
dbConnection
as
LinqConnection
).
DbTransaction
==
null
)
//
{
{
_trans
=
dbConnection
.
OpenTransaction
();
_trans
=
dbConnection
.
OpenTransaction
();
//
}
}
return
base
.
OnPreRestfulDelete
(
req
,
res
,
dbConnection
,
rtns
);
return
base
.
OnPreRestfulDelete
(
req
,
res
,
dbConnection
,
rtns
);
}
}
...
@@ -142,13 +142,17 @@ namespace Kivii.Finances.Transforms
...
@@ -142,13 +142,17 @@ namespace Kivii.Finances.Transforms
dbConnection
.
UpdateOnly
<
BillDetail
>(
new
BillDetail
{
Status
=
-
1
},
deleteBillDetails
);
dbConnection
.
UpdateOnly
<
BillDetail
>(
new
BillDetail
{
Status
=
-
1
},
deleteBillDetails
);
_trans
?.
Commit
();
_trans
?.
Commit
();
return
base
.
OnPostRestfulDelete
(
req
,
res
,
dbConnection
,
rtns
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
_trans
?.
Rollback
();
_trans
?.
Rollback
();
throw
ex
;
throw
ex
;
}
}
return
base
.
OnPostRestfulDelete
(
req
,
res
,
dbConnection
,
rtns
);
finally
{
_trans
?.
Dispose
();
}
}
}
}
}
...
...
Src/Transforms/RestfulInvoice.cs
View file @
02452643
...
@@ -145,7 +145,8 @@ namespace Kivii.Finances.Transforms
...
@@ -145,7 +145,8 @@ namespace Kivii.Finances.Transforms
(
Payments
.
Sum
(
o
=>
o
.
Amount
)
!=
Items
.
Sum
(
o
=>
o
.
Amount
)).
ThrowIfTrue
(
"到账开票金额和发票金额不一致!"
);
(
Payments
.
Sum
(
o
=>
o
.
Amount
)
!=
Items
.
Sum
(
o
=>
o
.
Amount
)).
ThrowIfTrue
(
"到账开票金额和发票金额不一致!"
);
}
}
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Invoice
>();
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Invoice
>();
(
conn
.
Exists
<
Invoice
>(
o
=>
Sql
.
In
(
o
.
SerialNumber
,
Items
.
ConvertAll
(
p
=>
p
.
SerialNumber
)))).
ThrowIfTrue
(
"存在重复录入的发票信息"
);
var
exists
=
conn
.
Select
<
Invoice
>(
o
=>
Sql
.
In
(
o
.
SerialNumber
,
Items
.
ConvertAll
(
p
=>
p
.
SerialNumber
)));
//(conn.Exists<Invoice>(o => Sql.In(o.SerialNumber, Items.ConvertAll(p => p.SerialNumber)))).ThrowIfTrue("存在重复录入的发票信息");
List
<
Payment
>
preCorrelatingPayments
=
new
List
<
Payment
>();
List
<
Payment
>
preCorrelatingPayments
=
new
List
<
Payment
>();
List
<
Payment
>
parentPayments
=
new
List
<
Payment
>();
//也要更新父级的AmountInvoice
List
<
Payment
>
parentPayments
=
new
List
<
Payment
>();
//也要更新父级的AmountInvoice
...
@@ -177,6 +178,8 @@ namespace Kivii.Finances.Transforms
...
@@ -177,6 +178,8 @@ namespace Kivii.Finances.Transforms
var
category
=
preCorrelatingPayments
.
IsNullOrEmpty
()
?
InvoiceApplyType
.
Debit
:
InvoiceApplyType
.
Payment
;
var
category
=
preCorrelatingPayments
.
IsNullOrEmpty
()
?
InvoiceApplyType
.
Debit
:
InvoiceApplyType
.
Payment
;
foreach
(
var
info
in
Items
)
foreach
(
var
info
in
Items
)
{
{
//重复的发票
if
(!
exists
.
IsNullOrEmpty
()
&&
exists
.
Exists
(
o
=>
o
.
SerialNumber
==
info
.
SerialNumber
))
continue
;
#
region
开票成功的情况处理
#
region
开票成功的情况处理
var
invoiceKvid
=
Guid
.
NewGuid
();
var
invoiceKvid
=
Guid
.
NewGuid
();
var
invoice
=
new
Invoice
();
var
invoice
=
new
Invoice
();
...
...
Src/Transforms/RestfulPay.cs
View file @
02452643
...
@@ -366,16 +366,36 @@ namespace Kivii.Finances.Transforms
...
@@ -366,16 +366,36 @@ namespace Kivii.Finances.Transforms
{
{
var
connE
=
KiviiContext
.
GetOpenedDbConnection
<
EntitySettlement
<
T
>>();
var
connE
=
KiviiContext
.
GetOpenedDbConnection
<
EntitySettlement
<
T
>>();
#
region
合并数据库连接
,
并启用事务
#
region
合并数据库连接
,
并启用事务
IDbTransaction
tranE
=
null
;
IDbTransaction
tranE
=
null
,
tranF
=
null
;
if
(
connE
.
ConnectionString
==
conn
.
ConnectionString
)
//if (connE.ConnectionString == connR.ConnectionString)//现在的连接会自动取缓存
if
(
connE
==
conn
)
{
//两个连接是同一个,缓存生效,不做任何操作
}
else
if
(
connE
.
ConnectionString
==
conn
.
ConnectionString
)
//连接对象不同,但连接字符串是一样的,因为在本环节中,连接没有被污染,可以关了一个连接
{
{
connE
.
Close
();
connE
.
Close
();
connE
=
conn
;
connE
=
conn
;
}
}
else
if
((
connE
is
LinqConnection
)
&&
(
connE
as
LinqConnection
).
Transaction
==
null
)
{
{
tranE
=
connE
.
OpenTransaction
();
tranE
=
connE
.
OpenTransaction
();
}
}
if
((
conn
is
LinqConnection
)
&&
(
conn
as
LinqConnection
).
Transaction
==
null
)
{
tranF
=
conn
.
OpenTransaction
();
}
//#region 合并数据库连接,并启用事务
//IDbTransaction tranE = null;
//if (connE.ConnectionString == conn.ConnectionString)
//{
// connE.Close();
// connE = conn;
//}
//else
//{
// tranE = connE.OpenTransaction();
//}
#
endregion
#
endregion
var
instance
=
Activator
.
CreateInstance
(
typeof
(
T
))
as
IEntityHasPayment
;
var
instance
=
Activator
.
CreateInstance
(
typeof
(
T
))
as
IEntityHasPayment
;
foreach
(
var
item
in
settlements
)
foreach
(
var
item
in
settlements
)
...
...
Src/Transforms/RestfulSettlement.Offset.cs
View file @
02452643
...
@@ -162,19 +162,40 @@ namespace Kivii.Finances.Transforms
...
@@ -162,19 +162,40 @@ namespace Kivii.Finances.Transforms
rtns
.
Results
=
new
List
<
Settlement
>();
rtns
.
Results
=
new
List
<
Settlement
>();
var
connE
=
KiviiContext
.
GetOpenedDbConnection
<
G
>();
var
connE
=
KiviiContext
.
GetOpenedDbConnection
<
G
>();
#
region
合并数据库连接
,
并启用事务
#
region
合并数据库连接
,
并启用事务
IDbTransaction
tranE
=
null
,
tranF
=
null
;
IDbTransaction
tranE
=
null
,
tranF
=
null
;
if
(
connE
.
ConnectionString
==
connF
.
ConnectionString
)
//if (connE.ConnectionString == connR.ConnectionString)//现在的连接会自动取缓存
if
(
connE
==
connF
)
{
{
connF
.
Close
();
//两个连接是同一个,缓存生效,不做任何操作
connF
=
connE
;
}
tranE
=
connE
.
OpenTransaction
();
else
if
(
connE
.
ConnectionString
==
connF
.
ConnectionString
)
//连接对象不同,但连接字符串是一样的,因为在本环节中,连接没有被污染,可以关了一个连接
{
connE
.
Close
();
connE
=
connF
;
}
}
else
if
((
connE
is
LinqConnection
)
&&
(
connE
as
LinqConnection
).
Transaction
==
null
)
{
{
tranE
=
connE
.
OpenTransaction
();
tranE
=
connE
.
OpenTransaction
();
}
if
((
connF
is
LinqConnection
)
&&
(
connF
as
LinqConnection
).
Transaction
==
null
)
{
tranF
=
connF
.
OpenTransaction
();
tranF
=
connF
.
OpenTransaction
();
}
}
//#region 合并数据库连接,并启用事务
//IDbTransaction tranE = null, tranF = null;
//if (connE.ConnectionString == connF.ConnectionString)
//{
// connF.Close();
// connF = connE;
// tranE = connE.OpenTransaction();
//}
//else
//{
// tranE = connE.OpenTransaction();
// tranF = connF.OpenTransaction();
//}
#
endregion
#
endregion
try
try
{
{
...
...
Src/Transforms/RestfulSettlement.cs
View file @
02452643
...
@@ -47,17 +47,37 @@ namespace Kivii.Finances.Transforms
...
@@ -47,17 +47,37 @@ namespace Kivii.Finances.Transforms
#
region
合并数据库连接
,
并启用事务
#
region
合并数据库连接
,
并启用事务
IDbTransaction
tranE
=
null
,
tranF
=
null
;
IDbTransaction
tranE
=
null
,
tranF
=
null
;
if
(
connE
.
ConnectionString
==
connF
.
ConnectionString
)
//if (connE.ConnectionString == connR.ConnectionString)//现在的连接会自动取缓存
if
(
connE
==
connF
)
{
{
connF
.
Close
();
//两个连接是同一个,缓存生效,不做任何操作
connF
=
connE
;
tranE
=
connE
.
OpenTransaction
();
}
}
else
else
if
(
connE
.
ConnectionString
==
connF
.
ConnectionString
)
//连接对象不同,但连接字符串是一样的,因为在本环节中,连接没有被污染,可以关了一个连接
{
connE
.
Close
();
connE
=
connF
;
}
if
((
connE
is
LinqConnection
)
&&
(
connE
as
LinqConnection
).
Transaction
==
null
)
{
{
tranE
=
connE
.
OpenTransaction
();
tranE
=
connE
.
OpenTransaction
();
}
if
((
connF
is
LinqConnection
)
&&
(
connF
as
LinqConnection
).
Transaction
==
null
)
{
tranF
=
connF
.
OpenTransaction
();
tranF
=
connF
.
OpenTransaction
();
}
}
//#region 合并数据库连接,并启用事务
//IDbTransaction tranE = null, tranF = null;
//if (connE.ConnectionString == connF.ConnectionString)
//{
// connF.Close();
// connF = connE;
// tranE = connE.OpenTransaction();
//}
//else
//{
// tranE = connE.OpenTransaction();
// tranF = connF.OpenTransaction();
//}
#
endregion
#
endregion
try
try
...
@@ -157,25 +177,45 @@ namespace Kivii.Finances.Transforms
...
@@ -157,25 +177,45 @@ namespace Kivii.Finances.Transforms
#
region
合并数据库连接
,
并启用事务
#
region
合并数据库连接
,
并启用事务
IDbTransaction
tranE
=
null
,
tranF
=
null
;
IDbTransaction
tranE
=
null
,
tranF
=
null
;
if
(
connE
.
ConnectionString
==
connF
.
ConnectionString
)
//if (connE.ConnectionString == connR.ConnectionString)//现在的连接会自动取缓存
if
(
connE
==
connF
)
{
{
connF
.
Close
();
//两个连接是同一个,缓存生效,不做任何操作
connF
=
connE
;
tranE
=
connE
.
OpenTransaction
();
}
}
else
else
if
(
connE
.
ConnectionString
==
connF
.
ConnectionString
)
//连接对象不同,但连接字符串是一样的,因为在本环节中,连接没有被污染,可以关了一个连接
{
connE
.
Close
();
connE
=
connF
;
}
if
((
connE
is
LinqConnection
)
&&
(
connE
as
LinqConnection
).
Transaction
==
null
)
{
{
tranE
=
connE
.
OpenTransaction
();
tranE
=
connE
.
OpenTransaction
();
}
if
((
connF
is
LinqConnection
)
&&
(
connF
as
LinqConnection
).
Transaction
==
null
)
{
tranF
=
connF
.
OpenTransaction
();
tranF
=
connF
.
OpenTransaction
();
}
}
//#region 合并数据库连接,并启用事务
//IDbTransaction tranE = null, tranF = null;
//if (connE.ConnectionString == connF.ConnectionString)
//{
// connF.Close();
// connF = connE;
// tranE = connE.OpenTransaction();
//}
//else
//{
// tranE = connE.OpenTransaction();
// tranF = connF.OpenTransaction();
//}
#
endregion
#
endregion
try
try
{
{
foreach
(
var
item
in
Items
)
foreach
(
var
item
in
Items
)
{
{
if
(
item
.
OnlyProperties
.
IsNullOrEmpty
())
continue
;
if
(
item
.
OnlyProperties
.
IsNullOrEmpty
())
continue
;
item
.
OnlyProperties
.
RemoveAll
(
o
=>
o
!=
"Remark"
&&
o
!=
"Summary"
);
item
.
OnlyProperties
.
RemoveAll
(
o
=>
o
!=
"Remark"
&&
o
!=
"Summary"
&&
o
!=
"Category"
);
if
(
item
.
OnlyProperties
.
IsNullOrEmpty
())
continue
;
if
(
item
.
OnlyProperties
.
IsNullOrEmpty
())
continue
;
connF
.
UpdateOnly
(
item
);
connF
.
UpdateOnly
(
item
);
rtns
.
Results
.
Add
(
item
);
rtns
.
Results
.
Add
(
item
);
...
@@ -348,19 +388,40 @@ namespace Kivii.Finances.Transforms
...
@@ -348,19 +388,40 @@ namespace Kivii.Finances.Transforms
var
rtns
=
new
RestfulDeleteResponse
<
Settlement
>();
var
rtns
=
new
RestfulDeleteResponse
<
Settlement
>();
rtns
.
Results
=
new
List
<
Guid
>();
rtns
.
Results
=
new
List
<
Guid
>();
#
region
合并数据库连接
,
并启用事务
#
region
合并数据库连接
,
并启用事务
IDbTransaction
tranE
=
null
,
tranF
=
null
;
IDbTransaction
tranE
=
null
,
tranF
=
null
;
if
(
connE
.
ConnectionString
==
connF
.
ConnectionString
)
//if (connE.ConnectionString == connR.ConnectionString)//现在的连接会自动取缓存
if
(
connE
==
connF
)
{
{
connF
.
Close
();
//两个连接是同一个,缓存生效,不做任何操作
connF
=
connE
;
tranE
=
connE
.
OpenTransaction
();
}
}
else
else
if
(
connE
.
ConnectionString
==
connF
.
ConnectionString
)
//连接对象不同,但连接字符串是一样的,因为在本环节中,连接没有被污染,可以关了一个连接
{
connE
.
Close
();
connE
=
connF
;
}
if
((
connE
is
LinqConnection
)
&&
(
connE
as
LinqConnection
).
Transaction
==
null
)
{
{
tranE
=
connE
.
OpenTransaction
();
tranE
=
connE
.
OpenTransaction
();
}
if
((
connF
is
LinqConnection
)
&&
(
connF
as
LinqConnection
).
Transaction
==
null
)
{
tranF
=
connF
.
OpenTransaction
();
tranF
=
connF
.
OpenTransaction
();
}
}
//#region 合并数据库连接,并启用事务
//IDbTransaction tranE = null, tranF = null;
//if (connE.ConnectionString == connF.ConnectionString)
//{
// connF.Close();
// connF = connE;
// tranE = connE.OpenTransaction();
//}
//else
//{
// tranE = connE.OpenTransaction();
// tranF = connF.OpenTransaction();
//}
#
endregion
#
endregion
try
try
{
{
...
@@ -541,19 +602,40 @@ namespace Kivii.Finances.Transforms
...
@@ -541,19 +602,40 @@ namespace Kivii.Finances.Transforms
var
rtns
=
new
RestfulQueryResponse
<
Settlement
>();
var
rtns
=
new
RestfulQueryResponse
<
Settlement
>();
rtns
.
Results
=
new
List
<
Settlement
>();
rtns
.
Results
=
new
List
<
Settlement
>();
#
region
合并数据库连接
,
并启用事务
#
region
合并数据库连接
,
并启用事务
IDbTransaction
tranG
=
null
,
tranFins
=
null
;
IDbTransaction
tranG
=
null
,
tranFins
=
null
;
if
(
connG
.
ConnectionString
==
connFins
.
ConnectionString
)
//if (connE.ConnectionString == connR.ConnectionString)//现在的连接会自动取缓存
if
(
connG
==
connFins
)
{
{
connFins
.
Close
();
//两个连接是同一个,缓存生效,不做任何操作
connFins
=
connG
;
tranG
=
connG
.
OpenTransaction
();
}
}
else
else
if
(
connG
.
ConnectionString
==
connFins
.
ConnectionString
)
//连接对象不同,但连接字符串是一样的,因为在本环节中,连接没有被污染,可以关了一个连接
{
connG
.
Close
();
connG
=
connFins
;
}
if
((
connG
is
LinqConnection
)
&&
(
connG
as
LinqConnection
).
Transaction
==
null
)
{
{
tranG
=
connG
.
OpenTransaction
();
tranG
=
connG
.
OpenTransaction
();
}
if
((
connFins
is
LinqConnection
)
&&
(
connFins
as
LinqConnection
).
Transaction
==
null
)
{
tranFins
=
connFins
.
OpenTransaction
();
tranFins
=
connFins
.
OpenTransaction
();
}
}
//#region 合并数据库连接,并启用事务
//IDbTransaction tranG = null, tranFins = null;
//if (connG.ConnectionString == connFins.ConnectionString)
//{
// connFins.Close();
// connFins = connG;
// tranG = connG.OpenTransaction();
//}
//else
//{
// tranG = connG.OpenTransaction();
// tranFins = connFins.OpenTransaction();
//}
#
endregion
#
endregion
try
try
...
...
Src/Transforms/RestfulStatistic.cs
View file @
02452643
...
@@ -33,9 +33,11 @@ namespace Kivii.Finances.Transforms
...
@@ -33,9 +33,11 @@ namespace Kivii.Finances.Transforms
{
{
Depart
=
0
,
//部门
Depart
=
0
,
//部门
Month
,
//月份
Month
,
//月份
Type
//类型
Type
,
//类型
Payer
//付款单位
}
}
#
region
明细统计
[
Api
(
Description
=
"发票统计"
)]
[
Api
(
Description
=
"发票统计"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
InvoiceStatistic
:
RestfulExecution
<
Invoice
>
public
class
InvoiceStatistic
:
RestfulExecution
<
Invoice
>
...
@@ -273,7 +275,9 @@ namespace Kivii.Finances.Transforms
...
@@ -273,7 +275,9 @@ namespace Kivii.Finances.Transforms
return
rtns
;
return
rtns
;
}
}
}
}
#
endregion
#
region
分析
[
Api
(
Description
=
"到账认领分析"
)]
[
Api
(
Description
=
"到账认领分析"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
PaymentSplitAnalysis
:
RestfulExecution
<
Payment
>
public
class
PaymentSplitAnalysis
:
RestfulExecution
<
Payment
>
...
@@ -543,4 +547,112 @@ namespace Kivii.Finances.Transforms
...
@@ -543,4 +547,112 @@ namespace Kivii.Finances.Transforms
return
rtns
;
return
rtns
;
}
}
}
}
#
endregion
#
region
Group
[
Api
(
Description
=
"结算统计Group"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
SettlementStatisticGroup
:
RestfulExecution
<
Settlement
>
{
#
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
AnalysisType
GroupType
{
get
;
set
;
}
=
AnalysisType
.
Depart
;
//按时间,部门,类型分析
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
<
Settlement
>();
var
dynamicParams
=
Request
.
GetRequestParams
();
var
autoQuery
=
Request
.
TryResolve
<
IAutoQueryDb
>();
autoQuery
.
IncludeTotal
=
true
;
var
request
=
new
RestfulQuery
<
Settlement
>();
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Where
(
o
=>
o
.
OperateTime
>=
BeginTime
&&
o
.
OperateTime
<
EndTime
);
sqlExpress
.
Select
(
o
=>
new
{
o
.
OwnerKvid
,
o
.
OwnerName
,
o
.
PayerKvid
,
o
.
PayerName
,
o
.
Type
,
o
.
Category
,
o
.
AmountPlan
,
o
.
Amount
,
o
.
AmountPayment
,
o
.
OperateTime
,
o
.
CreateTime
});
var
results
=
conn
.
Select
(
sqlExpress
);
var
rtns
=
new
StatisticResponse
<
Settlement
>();
if
(
results
.
IsNullOrEmpty
())
return
rtns
;
rtns
.
Results
=
new
List
<
Settlement
>();
foreach
(
var
item
in
results
)
{
item
.
Summary
=
item
.
CreateTime
.
ToString
(
"yyyy-MM"
);
}
if
(
GroupType
==
AnalysisType
.
Depart
)
{
var
group
=
results
.
GroupBy
(
o
=>
o
.
OwnerName
);
foreach
(
var
kv
in
group
)
{
var
rtn
=
new
Settlement
();
rtn
.
Summary
=
kv
.
Key
;
rtn
.
Amount
=
kv
.
Sum
(
o
=>
o
.
Amount
);
rtn
.
AmountPayment
=
kv
.
Sum
(
o
=>
o
.
AmountPayment
);
rtn
.
AmountPlan
=
kv
.
Sum
(
o
=>
o
.
AmountPlan
);
rtn
.
Status
=
kv
.
Count
();
rtns
.
Results
.
Add
(
rtn
);
}
}
else
if
(
GroupType
==
AnalysisType
.
Payer
)
{
var
group
=
results
.
GroupBy
(
o
=>
o
.
PayerName
);
foreach
(
var
kv
in
group
)
{
var
rtn
=
new
Settlement
();
rtn
.
Summary
=
kv
.
Key
;
rtn
.
Amount
=
kv
.
Sum
(
o
=>
o
.
Amount
);
rtn
.
AmountPayment
=
kv
.
Sum
(
o
=>
o
.
AmountPayment
);
rtn
.
AmountPlan
=
kv
.
Sum
(
o
=>
o
.
AmountPlan
);
rtn
.
Status
=
kv
.
Count
();
rtns
.
Results
.
Add
(
rtn
);
}
}
else
{
var
group
=
results
.
GroupBy
(
o
=>
o
.
Summary
);
foreach
(
var
kv
in
group
)
{
var
rtn
=
new
Settlement
();
rtn
.
Summary
=
kv
.
Key
;
rtn
.
Amount
=
kv
.
Sum
(
o
=>
o
.
Amount
);
rtn
.
AmountPayment
=
kv
.
Sum
(
o
=>
o
.
AmountPayment
);
rtn
.
AmountPlan
=
kv
.
Sum
(
o
=>
o
.
AmountPlan
);
rtn
.
Status
=
kv
.
Count
();
rtns
.
Results
.
Add
(
rtn
);
}
}
return
rtns
;
}
}
#
endregion
}
}
Src/packages.config
View file @
02452643
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
packages
>
<
package
id
=
"Kivii.Common"
version
=
"5.6.2022.4
06
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Common"
version
=
"5.6.2022.4
11
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Core"
version
=
"5.6.2022.4
05
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Core"
version
=
"5.6.2022.4
11
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Linq"
version
=
"5.6.2022.41
0
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Linq"
version
=
"5.6.2022.41
2
0"
targetFramework
=
"net45"
/>
</
packages
>
</
packages
>
\ No newline at end of file
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