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
29ccb808
Commit
29ccb808
authored
Jan 04, 2023
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增接口重复提交验证
parent
a4d0ea53
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
167 additions
and
73 deletions
+167
-73
Kivii.Biz.Finances.V2.0.csproj
Src/Kivii.Biz.Finances.V2.0.csproj
+6
-9
RestfulInvoice.cs
Src/Transforms/RestfulInvoice.cs
+16
-1
RestfulPay.cs
Src/Transforms/RestfulPay.cs
+29
-0
RestfulPayment.Accept.cs
Src/Transforms/RestfulPayment.Accept.cs
+18
-0
RestfulPayment.Split.cs
Src/Transforms/RestfulPayment.Split.cs
+17
-0
RestfulSettlement.cs
Src/Transforms/RestfulSettlement.cs
+16
-0
RestfulStatistic.cs
Src/Transforms/Statistics/RestfulStatistic.cs
+61
-60
packages.config
Src/packages.config
+4
-3
No files found.
Src/Kivii.Biz.Finances.V2.0.csproj
View file @
29ccb808
...
...
@@ -31,17 +31,14 @@
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Kivii.Common.V4.5, Version=5.6.2022.10000, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\..\..\njzj.k5\packages\Kivii.Common.5.6.2022.10000\lib\net45\Kivii.Common.V4.5.dll
</HintPath>
<Private>
False
</Private>
<Reference
Include=
"Kivii.Common.V4.5, Version=5.6.2022.12000, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\..\..\njzj.k5\packages\Kivii.Common.5.6.2022.12000\lib\net45\Kivii.Common.V4.5.dll
</HintPath>
</Reference>
<Reference
Include=
"Kivii.Core.V4.5, Version=5.6.2022.10250, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\..\..\njzj.k5\packages\Kivii.Core.5.6.2022.10250\lib\net45\Kivii.Core.V4.5.dll
</HintPath>
<Private>
False
</Private>
<Reference
Include=
"Kivii.Core.V4.5, Version=5.6.2022.12000, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\..\..\njzj.k5\packages\Kivii.Core.5.6.2022.12000\lib\net45\Kivii.Core.V4.5.dll
</HintPath>
</Reference>
<Reference
Include=
"Kivii.Linq.V4.5, Version=5.6.2022.12000, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\..\..\njzj.k5\packages\Kivii.Linq.5.6.2022.12000\lib\net45\Kivii.Linq.V4.5.dll
</HintPath>
<Private>
False
</Private>
<Reference
Include=
"Kivii.Linq.V4.5, Version=5.6.2022.12180, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\..\..\njzj.k5\packages\Kivii.Linq.5.6.2022.12180\lib\net45\Kivii.Linq.V4.5.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
...
...
Src/Transforms/RestfulInvoice.cs
View file @
29ccb808
...
...
@@ -381,7 +381,18 @@ namespace Kivii.Finances.Transforms
}
var
rtns
=
new
RestfulUpdateResponse
<
Invoice
>();
rtns
.
Results
=
new
List
<
Invoice
>();
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
insertInvoices
.
ConvertAll
(
o
=>
o
.
SerialNumber
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
var
trans
=
conn
.
OpenTransaction
();
try
{
...
...
@@ -392,6 +403,8 @@ namespace Kivii.Finances.Transforms
if
(
item
.
Type
==
"Relation"
)
item
.
SerialNumber
=
item
.
GetSubSerialNumber
(
conn
);
conn
.
Insert
(
item
);
if
(
item
.
Type
!=
"Relation"
)
rtns
.
Results
.
Add
(
item
);
caches
.
Remove
(
item
.
SerialNumber
);
cache
.
Replace
(
cacheKey
,
caches
);
}
}
if
(!
insertInvoiceDetails
.
IsNullOrEmpty
())
insertInvoiceDetails
.
ForEach
(
o
=>
conn
.
Insert
(
o
));
...
...
@@ -404,11 +417,13 @@ namespace Kivii.Finances.Transforms
parentPayments
.
ForEach
(
o
=>
o
.
RecalculateAmountInvoice
(
conn
));
}
trans
.
Commit
();
cache
.
Remove
(
cacheKey
);
return
rtns
;
}
catch
(
Exception
ex
)
{
trans
.
Rollback
();
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
...
...
Src/Transforms/RestfulPay.cs
View file @
29ccb808
...
...
@@ -49,6 +49,19 @@ namespace Kivii.Finances.Transforms
var
accountBiz
=
currency
.
GetBizAccount
();
//conn.Single<Account>(o => o.OwnerKvid == KiviiContext.CurrentMember.OrganizationKvid && o.Type == AccountType.Biz && o.Currency == Item.Currency);
accountBiz
.
ThrowIfNull
(
$"未能正确获取系统
{
currency
}
业务账户!请联系管理员!"
);
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
settlements
.
ConvertAll
(
o
=>
o
.
BizId
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
if
(
PayingMethods
.
Count
==
1
)
//单笔付款登记
{
using
(
KiviiContext
.
Profiler
(
"单个方式收款"
))
...
...
@@ -86,6 +99,8 @@ namespace Kivii.Finances.Transforms
foreach
(
var
item
in
settlements
)
{
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了AmountPayment
caches
.
Remove
(
item
.
BizId
);
cache
.
Replace
(
cacheKey
,
caches
);
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
if
(
_realMethod
==
null
)
...
...
@@ -105,11 +120,13 @@ namespace Kivii.Finances.Transforms
trans
.
Commit
();
subTrans
.
ForEach
(
o
=>
o
?.
Commit
());
cache
.
Remove
(
cacheKey
);
}
catch
(
Exception
ex
)
{
trans
.
Rollback
();
subTrans
.
ForEach
(
o
=>
o
?.
Rollback
());
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
...
...
@@ -141,6 +158,8 @@ namespace Kivii.Finances.Transforms
foreach
(
var
item
in
settlements
)
{
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
caches
.
Remove
(
item
.
BizId
);
cache
.
Replace
(
cacheKey
,
caches
);
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
if
(
_realMethod
==
null
)
...
...
@@ -160,11 +179,13 @@ namespace Kivii.Finances.Transforms
trans
.
Commit
();
subTrans
.
ForEach
(
o
=>
o
?.
Commit
());
cache
.
Remove
(
cacheKey
);
}
catch
(
Exception
ex
)
{
trans
.
Rollback
();
subTrans
.
ForEach
(
o
=>
o
?.
Rollback
());
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
...
...
@@ -194,6 +215,8 @@ namespace Kivii.Finances.Transforms
foreach
(
var
item
in
settlements
)
{
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
caches
.
Remove
(
item
.
BizId
);
cache
.
Replace
(
cacheKey
,
caches
);
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
if
(
_realMethod
==
null
)
...
...
@@ -213,11 +236,13 @@ namespace Kivii.Finances.Transforms
trans
.
Commit
();
subTrans
.
ForEach
(
o
=>
o
?.
Commit
());
cache
.
Remove
(
cacheKey
);
}
catch
(
Exception
ex
)
{
trans
.
Rollback
();
subTrans
.
ForEach
(
o
=>
o
?.
Rollback
());
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
...
...
@@ -331,6 +356,8 @@ namespace Kivii.Finances.Transforms
foreach
(
var
item
in
settlements
)
{
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
caches
.
Remove
(
item
.
BizId
);
cache
.
Replace
(
cacheKey
,
caches
);
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
if
(
_realMethod
==
null
)
...
...
@@ -350,11 +377,13 @@ namespace Kivii.Finances.Transforms
trans
.
Commit
();
subTrans
.
ForEach
(
o
=>
o
?.
Commit
());
cache
.
Remove
(
cacheKey
);
}
catch
(
Exception
ex
)
{
trans
.
Rollback
();
subTrans
.
ForEach
(
o
=>
o
?.
Rollback
());
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
...
...
Src/Transforms/RestfulPayment.Accept.cs
View file @
29ccb808
...
...
@@ -37,6 +37,7 @@ namespace Kivii.Finances.Transforms
var
serialNumbers
=
Items
.
ConvertAll
(
o
=>
o
.
SerialNumber
);
serialNumbers
.
RemoveAll
(
o
=>
o
.
IsNullOrEmpty
());
serialNumbers
=
serialNumbers
.
Distinct
().
ToList
();
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Payment
>();
var
accountBalance
=
CurrencyUnit
.
CNY
.
GetBalanceAccount
();
...
...
@@ -200,6 +201,19 @@ namespace Kivii.Finances.Transforms
var
rtns
=
new
RestfulCreateResponse
<
Payment
>();
rtns
.
Results
=
new
List
<
Payment
>();
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
allAcceptPayments
.
ConvertAll
(
o
=>
o
.
SerialNumber
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
var
trans
=
conn
.
OpenTransaction
();
try
...
...
@@ -211,6 +225,8 @@ namespace Kivii.Finances.Transforms
conn
.
Insert
(
item
);
item
.
RemoveAllOnlyProperties
();
rtns
.
Results
.
Add
(
item
);
caches
.
Remove
(
item
.
SerialNumber
);
cache
.
Replace
(
cacheKey
,
caches
);
}
}
if
(!
allAccountDetails
.
IsNullOrEmpty
())
allAccountDetails
.
ForEach
(
o
=>
o
.
Insert
(
conn
));
...
...
@@ -222,10 +238,12 @@ namespace Kivii.Finances.Transforms
}
}
trans
.
Commit
();
cache
.
Remove
(
cacheKey
);
}
catch
(
Exception
ex
)
{
trans
.
Rollback
();
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
...
...
Src/Transforms/RestfulPayment.Split.cs
View file @
29ccb808
...
...
@@ -267,6 +267,19 @@ namespace Kivii.Finances.Transforms
var
rtns
=
new
RestfulExecutionResponse
<
Payment
>();
rtns
.
Results
=
new
List
<
Payment
>();
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
splits
.
ConvertAll
(
o
=>
o
.
SerialNumber
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
//开启事务进行数据库操作
var
trans
=
conn
.
OpenTransaction
();
try
...
...
@@ -275,6 +288,8 @@ namespace Kivii.Finances.Transforms
{
conn
.
Insert
(
split
);
rtns
.
Results
.
Add
(
split
);
caches
.
Remove
(
split
.
SerialNumber
);
cache
.
Replace
(
cacheKey
,
caches
);
}
foreach
(
var
item
in
splitsSetOwner
)
{
...
...
@@ -291,10 +306,12 @@ namespace Kivii.Finances.Transforms
}
trans
.
Commit
();
cache
.
Remove
(
cacheKey
);
}
catch
(
Exception
ex
)
{
trans
.
Rollback
();
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
return
rtns
;
...
...
Src/Transforms/RestfulSettlement.cs
View file @
29ccb808
...
...
@@ -47,6 +47,18 @@ namespace Kivii.Finances.Transforms
//var detailBizids = allDetails.ConvertAll(p => p.BizId);
//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("存在重复结算的明细项目!");
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
Items
.
ConvertAll
(
o
=>
o
.
BizId
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
var
rtns
=
new
RestfulCreateResponse
<
Settlement
>();
rtns
.
Results
=
new
List
<
Settlement
>();
...
...
@@ -180,15 +192,19 @@ namespace Kivii.Finances.Transforms
}
connF
.
Insert
(
policyRecord
);
}
caches
.
Remove
(
item
.
BizId
);
cache
.
Replace
(
cacheKey
,
caches
);
}
}
tranE
?.
Commit
();
tranF
?.
Commit
();
cache
.
Remove
(
cacheKey
);
}
catch
(
Exception
ex
)
{
tranE
?.
Rollback
();
tranF
?.
Rollback
();
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
...
...
Src/Transforms/Statistics/RestfulStatistic.cs
View file @
29ccb808
...
...
@@ -401,7 +401,8 @@ namespace Kivii.Finances.Transforms
public
Guid
OwnerKvid
{
get
;
set
;
}
public
List
<
Guid
>
OwnerKvids
{
get
;
set
;
}
//public AnalysisType Type { get; set; }
public
AnalysisType
Type
{
get
;
set
;
}
public
DateTime
BeginTime
{
get
;
set
;
}
...
...
@@ -441,9 +442,9 @@ namespace Kivii.Finances.Transforms
//{
// item.Summary = item.OperateTime.ToString("yyyy-MM");
//}
//
if (Type == AnalysisType.Depart)
//
{
sqlExpress
.
GroupBy
(
o
=>
o
.
OwnerName
);
if
(
Type
==
AnalysisType
.
Depart
)
{
sqlExpress
.
GroupBy
(
o
=>
o
.
OwnerName
);
sqlExpress
.
Select
(
o
=>
new
{
Summary
=
o
.
OwnerName
,
...
...
@@ -457,62 +458,62 @@ namespace Kivii.Finances.Transforms
QuantitySplit
=
Sql
.
Count
(
o
.
Kvid
)
});
rtns
.
Results
=
conn
.
Select
<
Analysis
>(
sqlExpress
);
//var group = results.GroupBy(o => o.OwnerName);
//foreach (var kv in group)
//{
// var rtn = new Analysis();
// rtn.Summary = kv.Key;
// rtn.Amount = kv.Sum(o => o.Amount);
// rtn.Quantity = kv.Count();
// rtn.AmountInvoice = kv.Sum(o => o.AmountInvoice);
// rtn.QuantityInvoice = kv.Count(o => o.Amount == o.AmountInvoice);
// rtn.AmountUsed = kv.Sum(o => o.AmountUsed);
// rtn.QuantityUsed = kv.Count(o => o.Amount == o.AmountUsed);
// rtn.AmountSplit = kv.Where(o => o.Type == PaymentType.Split || o.Type == PaymentType.WeChat || o.Type == PaymentType.Cash || o.Type == PaymentType.AliPay || o.Type == PaymentType.Pos).Sum(o => o.Amount);
// rtn.QuantitySplit = kv.Count(o => o.Type == PaymentType.Split || o.Type == PaymentType.WeChat || o.Type == PaymentType.Cash || o.Type == PaymentType.AliPay || o.Type == PaymentType.Pos);
// rtn.AmountRefund = kv.Where(o => o.Type == PaymentType.Refund).Sum(o => o.Amount);
// rtn.QuantityRefund = kv.Count(o => o.Type == PaymentType.Refund);
// rtn.AmountUnBiz = kv.Where(o => o.Type == PaymentType.UnBiz).Sum(o => o.Amount);
// rtn.QuantityUnBiz = kv.Count(o => o.Type == PaymentType.UnBiz);
// rtns.Results.Add(rtn);
//}
//
}
//
else
//
{
//
sqlExpress.GroupBy(o => o.OperateTime.ToString("yyyy-MM"));
//
sqlExpress.Select(o => new
//
{
//
Summary = o.OperateTime.ToString("yyyy-MM"),
//
Amount = Sql.Sum(o.Amount),
//
Quantity = Sql.Count(o.Kvid),
//
AmountInvoice = Sql.Sum(o.AmountInvoice),
//
QuantityInvoice = Sql.Sum(o.AmountInvoice == o.Amount ? 1 : 0),
//
AmountUsed = Sql.Sum(o.AmountUsed),
//
QuantityUsed = Sql.Sum(o.AmountUsed == o.Amount ? 1 : 0),
//
AmountSplit = Sql.Sum(o.Amount),
//
QuantitySplit = Sql.Count(o.Kvid)
//
});
//
rtns.Results = conn.Select<Analysis>(sqlExpress);
//
//var group = results.GroupBy(o => o.Summary);
//
//foreach (var kv in group)
//
//{
//
// var rtn = new Analysis();
//
// rtn.Summary = kv.Key;
//
// rtn.Amount = kv.Sum(o => o.Amount);
//
// rtn.Quantity = kv.Count();
//
// rtn.AmountInvoice = kv.Sum(o => o.AmountInvoice);
//
// rtn.QuantityInvoice = kv.Count(o => o.Amount == o.AmountInvoice);
//
// rtn.AmountUsed = kv.Sum(o => o.AmountUsed);
//
// rtn.QuantityUsed = kv.Count(o => o.Amount == o.AmountUsed);
//
// rtn.AmountSplit = kv.Where(o => o.Type == PaymentType.Split || o.Type == PaymentType.WeChat || o.Type == PaymentType.Cash || o.Type == PaymentType.AliPay || o.Type == PaymentType.Pos).Sum(o => o.Amount);
//
// rtn.QuantitySplit = kv.Count(o => o.Type == PaymentType.Split || o.Type == PaymentType.WeChat || o.Type == PaymentType.Cash || o.Type == PaymentType.AliPay || o.Type == PaymentType.Pos);
//
// rtn.AmountRefund = kv.Where(o => o.Type == PaymentType.Refund).Sum(o => o.Amount);
//
// rtn.QuantityRefund = kv.Count(o => o.Type == PaymentType.Refund);
//
// rtn.AmountUnBiz = kv.Where(o => o.Type == PaymentType.UnBiz).Sum(o => o.Amount);
//
// rtn.QuantityUnBiz = kv.Count(o => o.Type == PaymentType.UnBiz);
//
// rtns.Results.Add(rtn);
//
//}
//
}
//var group = results.GroupBy(o => o.OwnerName);
//foreach (var kv in group)
//{
// var rtn = new Analysis();
// rtn.Summary = kv.Key;
// rtn.Amount = kv.Sum(o => o.Amount);
// rtn.Quantity = kv.Count();
// rtn.AmountInvoice = kv.Sum(o => o.AmountInvoice);
// rtn.QuantityInvoice = kv.Count(o => o.Amount == o.AmountInvoice);
// rtn.AmountUsed = kv.Sum(o => o.AmountUsed);
// rtn.QuantityUsed = kv.Count(o => o.Amount == o.AmountUsed);
// rtn.AmountSplit = kv.Where(o => o.Type == PaymentType.Split || o.Type == PaymentType.WeChat || o.Type == PaymentType.Cash || o.Type == PaymentType.AliPay || o.Type == PaymentType.Pos).Sum(o => o.Amount);
// rtn.QuantitySplit = kv.Count(o => o.Type == PaymentType.Split || o.Type == PaymentType.WeChat || o.Type == PaymentType.Cash || o.Type == PaymentType.AliPay || o.Type == PaymentType.Pos);
// rtn.AmountRefund = kv.Where(o => o.Type == PaymentType.Refund).Sum(o => o.Amount);
// rtn.QuantityRefund = kv.Count(o => o.Type == PaymentType.Refund);
// rtn.AmountUnBiz = kv.Where(o => o.Type == PaymentType.UnBiz).Sum(o => o.Amount);
// rtn.QuantityUnBiz = kv.Count(o => o.Type == PaymentType.UnBiz);
// rtns.Results.Add(rtn);
//}
}
else
{
sqlExpress
.
GroupBy
(
o
=>
o
.
OperateTime
.
ToString
(
"yyyy-MM"
));
sqlExpress
.
Select
(
o
=>
new
{
Summary
=
o
.
OperateTime
.
ToString
(
"yyyy-MM"
),
Amount
=
Sql
.
Sum
(
o
.
Amount
),
Quantity
=
Sql
.
Count
(
o
.
Kvid
),
AmountInvoice
=
Sql
.
Sum
(
o
.
AmountInvoice
),
QuantityInvoice
=
Sql
.
Sum
(
o
.
AmountInvoice
==
o
.
Amount
?
1
:
0
),
AmountUsed
=
Sql
.
Sum
(
o
.
AmountUsed
),
QuantityUsed
=
Sql
.
Sum
(
o
.
AmountUsed
==
o
.
Amount
?
1
:
0
),
AmountSplit
=
Sql
.
Sum
(
o
.
Amount
),
QuantitySplit
=
Sql
.
Count
(
o
.
Kvid
)
});
rtns
.
Results
=
conn
.
Select
<
Analysis
>(
sqlExpress
);
//var group = results.GroupBy(o => o.Summary);
//foreach (var kv in group)
//{
// var rtn = new Analysis();
// rtn.Summary = kv.Key;
// rtn.Amount = kv.Sum(o => o.Amount);
// rtn.Quantity = kv.Count();
// rtn.AmountInvoice = kv.Sum(o => o.AmountInvoice);
// rtn.QuantityInvoice = kv.Count(o => o.Amount == o.AmountInvoice);
// rtn.AmountUsed = kv.Sum(o => o.AmountUsed);
// rtn.QuantityUsed = kv.Count(o => o.Amount == o.AmountUsed);
// rtn.AmountSplit = kv.Where(o => o.Type == PaymentType.Split || o.Type == PaymentType.WeChat || o.Type == PaymentType.Cash || o.Type == PaymentType.AliPay || o.Type == PaymentType.Pos).Sum(o => o.Amount);
// rtn.QuantitySplit = kv.Count(o => o.Type == PaymentType.Split || o.Type == PaymentType.WeChat || o.Type == PaymentType.Cash || o.Type == PaymentType.AliPay || o.Type == PaymentType.Pos);
// rtn.AmountRefund = kv.Where(o => o.Type == PaymentType.Refund).Sum(o => o.Amount);
// rtn.QuantityRefund = kv.Count(o => o.Type == PaymentType.Refund);
// rtn.AmountUnBiz = kv.Where(o => o.Type == PaymentType.UnBiz).Sum(o => o.Amount);
// rtn.QuantityUnBiz = kv.Count(o => o.Type == PaymentType.UnBiz);
// rtns.Results.Add(rtn);
//}
}
rtns
.
Total
=
rtns
.
Results
.
Count
;
return
rtns
;
...
...
Src/packages.config
View file @
29ccb808
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"Kivii.Common"
version
=
"5.6.2022.1
0
000"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Core"
version
=
"5.6.2022.1
025
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Linq"
version
=
"5.6.2022.12
00
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Common"
version
=
"5.6.2022.1
2
000"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Core"
version
=
"5.6.2022.1
200
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Linq"
version
=
"5.6.2022.12
18
0"
targetFramework
=
"net45"
/>
</
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