Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Biz.Finances.V2.5
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.5
Commits
40c38680
Commit
40c38680
authored
May 22, 2025
by
Neo Turing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加发票申请及流程审批,发票关联到账等功能
parent
c63f4bf2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
5 deletions
+113
-5
.gitignore
.gitignore
+1
-0
ApplyExtension.cs
Src/Extensions/ApplyExtension.cs
+88
-0
Kivii.Biz.Finances.V2.5.csproj
Src/Kivii.Biz.Finances.V2.5.csproj
+2
-0
AssemblyInfo.cs
Src/Properties/AssemblyInfo.cs
+2
-2
RestfulApply.cs
Src/Transforms/RestfulApply.cs
+0
-0
RestfulInvoice.cs
Src/Transforms/RestfulInvoice.cs
+20
-3
No files found.
.gitignore
View file @
40c38680
...
@@ -4,3 +4,4 @@
...
@@ -4,3 +4,4 @@
/.vs
/.vs
/Src/obj
/Src/obj
/Src/bin/Debug
Src/Extensions/ApplyExtension.cs
0 → 100644
View file @
40c38680
using
Kivii.Finances.Entities
;
using
Kivii.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Kivii.Finances
{
public
static
class
ApplyExtension
{
public
static
void
ExcuteCompleted
(
this
List
<
InvoiceApply
>
allApplys
,
IDbConnection
conn
=
null
)
{
if
(
allApplys
.
IsNullOrEmpty
())
return
;
var
applys
=
allApplys
.
Where
(
o
=>
o
.
AmountInvoice
<
o
.
Amount
).
ToList
();
if
(
applys
.
IsNullOrEmpty
())
return
;
var
applyKvids
=
applys
.
ConvertAll
(
p
=>
p
.
Kvid
);
bool
useTransaction
=
conn
==
null
;
//是否启用事务,如果外部未传入conn,启用内部事务
if
(
conn
==
null
)
conn
=
KiviiContext
.
GetOpenedDbConnection
<
InvoiceApply
>();
var
queryInvoices
=
conn
.
From
<
Invoice
>();
queryInvoices
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
o
.
RootKvid
==
o
.
Kvid
&&
Sql
.
In
(
o
.
ApplyKvid
,
applyKvids
));
queryInvoices
.
Select
(
o
=>
new
{
o
.
Kvid
,
o
.
Amount
,
o
.
ApplyKvid
});
var
invoices
=
conn
.
Select
(
queryInvoices
);
if
(
invoices
.
IsNullOrEmpty
())
return
;
var
relations
=
conn
.
Select
<
InvoiceApply
>(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
o
.
OperateType
==
InvoiceApplyType
.
Related
&&
Sql
.
In
(
o
.
ParentKvid
,
applyKvids
));
List
<
InvoiceApply
>
preUpdates
=
new
List
<
InvoiceApply
>();
foreach
(
var
apply
in
applys
)
{
if
(
apply
.
AmountInvoice
==
apply
.
Amount
)
continue
;
var
currentInvoices
=
invoices
.
Where
(
o
=>
o
.
ApplyKvid
==
apply
.
Kvid
).
ToList
();
if
(
currentInvoices
.
IsNullOrEmpty
())
continue
;
var
amountSum
=
currentInvoices
.
Sum
(
o
=>
o
.
Amount
);
List
<
InvoiceApply
>
applyRelations
=
null
;
if
(!
relations
.
IsNullOrEmpty
())
applyRelations
=
relations
.
Where
(
o
=>
o
.
ParentKvid
==
apply
.
Kvid
).
ToList
();
if
(
amountSum
!=
apply
.
Amount
)
throw
new
Exception
(
$"
{
apply
.
PayerName
}
:发票金额
{
currentInvoices
.
Sum
(
o
=>
o
.
Amount
)}
和申请金额
{
apply
.
Amount
}
不一致"
);
apply
.
AmountInvoice
=
amountSum
;
apply
.
AddOnlyProperties
(
o
=>
o
.
AmountInvoice
);
if
(
apply
.
AmountInvoice
==
apply
.
Amount
)
{
apply
.
Status
=
(
int
)
InvoiceApplyStatus
.
Completed
;
apply
.
AddOnlyProperties
(
o
=>
o
.
Status
);
}
preUpdates
.
Add
(
apply
);
if
(!
applyRelations
.
IsNullOrEmpty
())
{
foreach
(
var
item
in
applyRelations
)
{
item
.
AmountInvoice
=
item
.
Amount
;
item
.
AddOnlyProperties
(
o
=>
o
.
AmountInvoice
);
if
(
item
.
AmountInvoice
==
item
.
Amount
)
{
item
.
Status
=
(
int
)
InvoiceApplyStatus
.
Completed
;
item
.
AddOnlyProperties
(
o
=>
o
.
Status
);
}
preUpdates
.
Add
(
item
);
}
}
}
if
(
preUpdates
.
IsNullOrEmpty
())
return
;
IDbTransaction
trans
=
null
;
//事务,如果外部来了Connection,不生成事务
if
(
useTransaction
)
trans
=
conn
.
OpenTransaction
();
try
{
if
(!
preUpdates
.
IsNullOrEmpty
())
{
foreach
(
var
item
in
preUpdates
)
{
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
}
}
trans
?.
Commit
();
}
catch
(
Exception
ex
)
{
trans
?.
Rollback
();
throw
ex
;
}
}
}
}
Src/Kivii.Biz.Finances.V2.5.csproj
View file @
40c38680
...
@@ -59,11 +59,13 @@
...
@@ -59,11 +59,13 @@
<Compile
Include=
"Entities\InvoiceDetail.cs"
/>
<Compile
Include=
"Entities\InvoiceDetail.cs"
/>
<Compile
Include=
"Entities\InvoiceTitle.cs"
/>
<Compile
Include=
"Entities\InvoiceTitle.cs"
/>
<Compile
Include=
"Entities\Payment.cs"
/>
<Compile
Include=
"Entities\Payment.cs"
/>
<Compile
Include=
"Extensions\ApplyExtension.cs"
/>
<Compile
Include=
"Extensions\Extension.cs"
/>
<Compile
Include=
"Extensions\Extension.cs"
/>
<Compile
Include=
"Extensions\InvoiceExtension.cs"
/>
<Compile
Include=
"Extensions\InvoiceExtension.cs"
/>
<Compile
Include=
"Extensions\PaymentExtension.cs"
/>
<Compile
Include=
"Extensions\PaymentExtension.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Transforms\RestfulAccount.cs"
/>
<Compile
Include=
"Transforms\RestfulAccount.cs"
/>
<Compile
Include=
"Transforms\RestfulApply.cs"
/>
<Compile
Include=
"Transforms\RestfulInvoice.cs"
/>
<Compile
Include=
"Transforms\RestfulInvoice.cs"
/>
<Compile
Include=
"Transforms\RestfulInvoiceDetail.cs"
/>
<Compile
Include=
"Transforms\RestfulInvoiceDetail.cs"
/>
<Compile
Include=
"Transforms\RestfulInvoiceTitle.cs"
/>
<Compile
Include=
"Transforms\RestfulInvoiceTitle.cs"
/>
...
...
Src/Properties/AssemblyInfo.cs
View file @
40c38680
...
@@ -37,5 +37,5 @@ using System.Runtime.InteropServices;
...
@@ -37,5 +37,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.2025.5
07
0")]
[assembly: AssemblyVersion("5.4.2025.5
22
0")]
[assembly: AssemblyFileVersion("5.4.2025.5
07
0")]
[assembly: AssemblyFileVersion("5.4.2025.5
22
0")]
Src/Transforms/RestfulApply.cs
0 → 100644
View file @
40c38680
This diff is collapsed.
Click to expand it.
Src/Transforms/RestfulInvoice.cs
View file @
40c38680
...
@@ -55,7 +55,6 @@ namespace Kivii.Finances.Transforms
...
@@ -55,7 +55,6 @@ namespace Kivii.Finances.Transforms
(
Payments
.
Exists
(
o
=>
o
.
Amount
<=
0
)).
ThrowIfTrue
(
"未指定到账开票金额!"
);
(
Payments
.
Exists
(
o
=>
o
.
Amount
<=
0
)).
ThrowIfTrue
(
"未指定到账开票金额!"
);
(
Payments
.
Sum
(
o
=>
o
.
Amount
)
!=
Items
.
Sum
(
o
=>
o
.
Amount
)).
ThrowIfTrue
(
"到账开票金额和发票金额不一致!"
);
(
Payments
.
Sum
(
o
=>
o
.
Amount
)
!=
Items
.
Sum
(
o
=>
o
.
Amount
)).
ThrowIfTrue
(
"到账开票金额和发票金额不一致!"
);
}
}
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
...
@@ -72,6 +71,10 @@ namespace Kivii.Finances.Transforms
...
@@ -72,6 +71,10 @@ namespace Kivii.Finances.Transforms
// 数据库连接初始化(移到外层以确保异常时能正确关闭)
// 数据库连接初始化(移到外层以确保异常时能正确关闭)
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Invoice
>();
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Invoice
>();
var
applyKvids
=
Items
.
ConvertAll
(
o
=>
o
.
ApplyKvid
).
Distinct
().
ToList
();
var
applys
=
conn
.
SelectByIds
<
InvoiceApply
>(
applyKvids
);
var
trans
=
null
as
IDbTransaction
;
var
trans
=
null
as
IDbTransaction
;
var
lockAcquired
=
false
;
var
lockAcquired
=
false
;
var
lockName
=
$"invoice_lock_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
;
var
lockName
=
$"invoice_lock_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
;
...
@@ -144,7 +147,7 @@ namespace Kivii.Finances.Transforms
...
@@ -144,7 +147,7 @@ namespace Kivii.Finances.Transforms
var
invoice
=
new
Invoice
();
var
invoice
=
new
Invoice
();
invoice
.
RootKvid
=
invoiceKvid
;
invoice
.
RootKvid
=
invoiceKvid
;
invoice
.
Kvid
=
invoiceKvid
;
invoice
.
Kvid
=
invoiceKvid
;
//invoice.ApplyKvid =
ApplyKvid;
invoice
.
ApplyKvid
=
info
.
ApplyKvid
;
invoice
.
OwnerKvid
=
info
.
OwnerKvid
;
invoice
.
OwnerKvid
=
info
.
OwnerKvid
;
invoice
.
OwnerName
=
info
.
OwnerName
;
invoice
.
OwnerName
=
info
.
OwnerName
;
if
(
invoice
.
OwnerKvid
==
Guid
.
Empty
&&
invoice
.
OwnerName
.
IsNullOrEmpty
())
if
(
invoice
.
OwnerKvid
==
Guid
.
Empty
&&
invoice
.
OwnerName
.
IsNullOrEmpty
())
...
@@ -320,7 +323,21 @@ namespace Kivii.Finances.Transforms
...
@@ -320,7 +323,21 @@ namespace Kivii.Finances.Transforms
// 缓存清理失败仅记录警告
// 缓存清理失败仅记录警告
KiviiContext
.
Logger
.
Warn
(
$"缓存清理失败:
{
cacheEx
.
Message
}
"
);
KiviiContext
.
Logger
.
Warn
(
$"缓存清理失败:
{
cacheEx
.
Message
}
"
);
}
}
if
(!
applys
.
IsNullOrEmpty
())
{
try
{
var
th
=
KiviiContext
.
NewThread
(
"发票申请标记完成"
,
()
=>
{
applys
.
ExcuteCompleted
();
});
th
.
Start
();
}
catch
(
Exception
ex
)
{
throw
ex
;
}
}
return
rtns
;
return
rtns
;
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
...
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