Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
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
黄奎
mall.oytour.com
Commits
d37f82bc
Commit
d37f82bc
authored
Jun 03, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增统计
parent
94b2c445
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
570 additions
and
9 deletions
+570
-9
MallIndexStatistics.cs
Mall.Model/Extend/Statistics/MallIndexStatistics.cs
+142
-0
StatisticsQuery.cs
Mall.Model/Query/StatisticsQuery.cs
+46
-1
MiniProgramModule.cs
Mall.Module.User/MiniProgramModule.cs
+95
-0
MallStatisticsRepository.cs
Mall.Repository/User/MallStatisticsRepository.cs
+230
-8
TenantController.cs
Mall.WebApi/Controllers/User/TenantController.cs
+57
-0
No files found.
Mall.Model/Extend/Statistics/MallIndexStatistics.cs
View file @
d37f82bc
using
Mall.Common.AOP
;
using
Mall.Common.Enum.Goods
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
...
...
@@ -12,5 +13,146 @@ namespace Mall.Model.Extend.Statistics
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
MallIndexStatistics
{
/// <summary>
/// 用户数量
/// </summary>
public
int
UserTotalNum
{
get
;
set
;
}
/// <summary>
/// 商品数量
/// </summary>
public
int
GoodsTotalNum
{
get
;
set
;
}
/// <summary>
/// 总订单数量
/// </summary>
public
int
TotalOrderNum
{
get
;
set
;
}
/// <summary>
/// 代发货数量
/// </summary>
public
int
NoSendOrderNum
{
get
;
set
;
}
/// <summary>
/// 维权订单数量
/// </summary>
public
int
ActivistOrderNum
{
get
;
set
;
}
}
/// <summary>
/// 订单数量统计
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
OrderNum
{
/// <summary>
/// 订单状态 枚举
/// </summary>
public
OrderStatusEnum
?
OrderStatus
{
get
;
set
;
}
/// <summary>
/// 订单数量
/// </summary>
public
int
OrderCount
{
get
;
set
;
}
}
/// <summary>
/// 销售情况统计
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
MallSalesStatistics
{
/// <summary>
/// 时间类型
/// </summary>
public
string
TimeStr
{
get
;
set
;
}
/// <summary>
/// 支付订单数
/// </summary>
public
int
OrderCount
{
get
;
set
;
}
/// <summary>
/// 支付金额
/// </summary>
public
decimal
Income
{
get
;
set
;
}
/// <summary>
/// 用户数量
/// </summary>
public
int
UserCount
{
get
;
set
;
}
/// <summary>
/// 购买商品件数
/// </summary>
public
int
GoodCount
{
get
;
set
;
}
}
/// <summary>
/// 商品购买力TOP排行
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
MallSalesGoodsTop
{
/// <summary>
/// 排名
/// </summary>
public
int
Num
{
get
;
set
;
}
/// <summary>
/// 商品名称
/// </summary>
public
string
GoodsName
{
get
;
set
;
}
/// <summary>
/// 销售额
/// </summary>
public
decimal
Income
{
get
;
set
;
}
/// <summary>
/// 销量
/// </summary>
public
int
SaleCount
{
get
;
set
;
}
}
/// <summary>
/// 用户购买力TOP排行
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
MallSalesUserTop
{
/// <summary>
/// 排名
/// </summary>
public
int
Num
{
get
;
set
;
}
/// <summary>
/// 用户头像
/// </summary>
public
string
Photo
{
get
;
set
;
}
/// <summary>
/// 用户名称
/// </summary>
public
string
UserName
{
get
;
set
;
}
/// <summary>
/// 支付金额
/// </summary>
public
decimal
Income
{
get
;
set
;
}
/// <summary>
/// 支付件数
/// </summary>
public
int
SaleCount
{
get
;
set
;
}
}
}
Mall.Model/Query/StatisticsQuery.cs
View file @
d37f82bc
using
System
;
using
Mall.Common.Enum.User
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
...
...
@@ -9,5 +10,49 @@ namespace Mall.Model.Query
/// </summary>
public
class
StatisticsQuery
{
/// <summary>
/// 商户号Id
/// </summary>
public
int
TenantId
{
get
;
set
;
}
/// <summary>
/// 小程序Id
/// </summary>
public
int
MallBaseId
{
get
;
set
;
}
/// <summary>
/// 来源 1微信 2支付宝【见枚举】
/// </summary>
public
UserSourceEnum
?
Source
{
get
;
set
;
}
/// <summary>
/// 开始时间
/// </summary>
public
string
StartDate
{
get
;
set
;
}
/// <summary>
/// 结束时间
/// </summary>
public
string
EndDate
{
get
;
set
;
}
/// <summary>
/// 销售查询【1-昨日,7-七日】
/// </summary>
public
int
SalesTimeType
{
get
;
set
;
}
}
}
Mall.Module.User/MiniProgramModule.cs
View file @
d37f82bc
...
...
@@ -11,6 +11,8 @@ using Newtonsoft.Json;
using
Mall.Common.Plugin
;
using
NPOI.SS.Formula.Functions
;
using
Mall.Repository.User
;
using
Mall.Model.Extend.Statistics
;
using
Mall.Model.Query
;
namespace
Mall.Module.User
{
...
...
@@ -62,6 +64,11 @@ namespace Mall.Module.User
/// </summary>
private
readonly
UserCommonModule
userCommonModule
=
new
UserCommonModule
();
/// <summary>
/// 首页统计
/// </summary>
private
readonly
MallStatisticsRepository
mallStatisticsRepository
=
new
MallStatisticsRepository
();
#
region
轮播图管理
/// <summary>
...
...
@@ -1890,5 +1897,93 @@ namespace Mall.Module.User
}
}
#
endregion
#
region
首页统计
/// <summary>
/// 订单数量、商品、用户统计
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public
MallIndexStatistics
MallIndexStatisticsModule
(
StatisticsQuery
query
)
{
return
mallStatisticsRepository
.
MallIndexStatisticsRepository
(
query
);
}
/// <summary>
/// 销售情况统计
/// </summary>
/// <param name="query"></param>
public
object
MallIndexSalesStatisticsModule
(
StatisticsQuery
query
)
{
var
list
=
mallStatisticsRepository
.
MallIndexSalesStatisticsRepository
(
query
);
List
<
object
>
resultList
=
new
List
<
object
>();
List
<
MallSalesStatistics
>
subList
=
new
List
<
MallSalesStatistics
>();
if
(
query
.
SalesTimeType
==
1
)
{
for
(
var
i
=
0
;
i
<=
23
;
i
++)
{
var
subModel
=
list
?.
Where
(
qitem
=>
qitem
.
TimeStr
==
i
.
ToString
())?.
FirstOrDefault
();
subList
.
Add
(
new
MallSalesStatistics
()
{
TimeStr
=
i
.
ToString
(),
GoodCount
=
subModel
?.
GoodCount
??
0
,
Income
=
subModel
?.
Income
??
0
,
OrderCount
=
subModel
?.
OrderCount
??
0
,
UserCount
=
subModel
?.
UserCount
??
0
,
});
}
}
else
{
var
startDate
=
DateTime
.
Now
.
AddDays
(-
7
);
for
(
var
i
=
0
;
i
<=
7
;
i
++)
{
var
subModel
=
list
?.
Where
(
qitem
=>
qitem
.
TimeStr
==
startDate
.
AddDays
(
i
).
ToString
(
"yyyy-MM-dd"
))?.
FirstOrDefault
();
subList
.
Add
(
new
MallSalesStatistics
()
{
TimeStr
=
startDate
.
AddDays
(
i
).
ToString
(
"yyyy-MM-dd"
),
GoodCount
=
subModel
?.
GoodCount
??
0
,
Income
=
subModel
?.
Income
??
0
,
OrderCount
=
subModel
?.
OrderCount
??
0
,
UserCount
=
subModel
?.
UserCount
??
0
,
});
}
}
var
obj
=
new
{
//支付订单数
OrderCount
=
list
?.
Sum
(
qitem
=>
qitem
.
OrderCount
)??
0
,
//支付金额
Income
=
list
?.
Sum
(
qitem
=>
qitem
.
Income
)
??
0
,
//支付人数
UserCount
=
list
?.
Sum
(
qitem
=>
qitem
.
UserCount
)
??
0
,
//支付件数
GoodCount
=
list
?.
Sum
(
qitem
=>
qitem
.
GoodCount
)
??
0
,
subList
,
};
return
obj
;
}
/// <summary>
/// 商品购买力TOP排行
/// </summary>
/// <param name="query"></param>
public
List
<
MallSalesGoodsTop
>
MallIndesSalesIncomeStatisticsModule
(
StatisticsQuery
query
)
{
return
mallStatisticsRepository
.
MallIndesSalesIncomeStatisticsRepository
(
query
);
}
/// <summary>
/// 用户购买力TOP排行
/// </summary>
/// <param name="query"></param>
public
List
<
MallSalesUserTop
>
MallIndesSalesUserStatisticsModule
(
StatisticsQuery
query
)
{
return
mallStatisticsRepository
.
MallIndesSalesUserStatisticsRepository
(
query
);
}
#
endregion
}
}
Mall.Repository/User/MallStatisticsRepository.cs
View file @
d37f82bc
This diff is collapsed.
Click to expand it.
Mall.WebApi/Controllers/User/TenantController.cs
View file @
d37f82bc
...
...
@@ -21,6 +21,7 @@ using Mall.Common.Enum.MallBase;
using
Mall.Model.Entity.User
;
using
Mall.Module.Product
;
using
Microsoft.AspNetCore.Authorization
;
using
Mall.Model.Query
;
namespace
Mall.WebApi.Controllers.User
{
...
...
@@ -1357,5 +1358,61 @@ namespace Mall.WebApi.Controllers.User
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
#
endregion
#
region
商城首页统计
/// <summary>
/// 首页基础数据统计
/// </summary>
/// <returns></returns>
public
ApiResult
MallIndexStatistics
()
{
var
query
=
JsonConvert
.
DeserializeObject
<
StatisticsQuery
>(
RequestParm
.
msg
.
ToString
());
query
.
MallBaseId
=
RequestParm
.
MallBaseId
;
query
.
TenantId
=
RequestParm
.
TenantId
;
var
list
=
programModule
.
MallIndexStatisticsModule
(
query
);
return
ApiResult
.
Success
(
data
:
list
);
}
/// <summary>
/// 销售情况统计
/// </summary>
/// <returns></returns>
public
ApiResult
MallIndexSalesStatistics
()
{
var
query
=
JsonConvert
.
DeserializeObject
<
StatisticsQuery
>(
RequestParm
.
msg
.
ToString
());
query
.
MallBaseId
=
RequestParm
.
MallBaseId
;
query
.
TenantId
=
RequestParm
.
TenantId
;
var
list
=
programModule
.
MallIndexSalesStatisticsModule
(
query
);
return
ApiResult
.
Success
(
data
:
list
);
}
/// <summary>
/// 商品购买力TOP排行
/// </summary>
/// <returns></returns>
public
ApiResult
MallIndesSalesIncomeStatistics
()
{
var
query
=
JsonConvert
.
DeserializeObject
<
StatisticsQuery
>(
RequestParm
.
msg
.
ToString
());
query
.
MallBaseId
=
RequestParm
.
MallBaseId
;
query
.
TenantId
=
RequestParm
.
TenantId
;
var
list
=
programModule
.
MallIndesSalesIncomeStatisticsModule
(
query
);
return
ApiResult
.
Success
(
data
:
list
);
}
/// <summary>
/// 用户购买力TOP排行
/// </summary>
/// <returns></returns>
public
ApiResult
MallIndesSalesUserStatistics
()
{
var
query
=
JsonConvert
.
DeserializeObject
<
StatisticsQuery
>(
RequestParm
.
msg
.
ToString
());
query
.
MallBaseId
=
RequestParm
.
MallBaseId
;
query
.
TenantId
=
RequestParm
.
TenantId
;
var
list
=
programModule
.
MallIndesSalesUserStatisticsModule
(
query
);
return
ApiResult
.
Success
(
data
:
list
);
}
#
endregion
}
}
\ 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