Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx-business
/
glsx-data-screen-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0dc221eb
authored
Jan 04, 2020
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调整
1 parent
988e60af
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
22 deletions
app/controller/screen/merchant.js
app/model/screen/merchant/t_merchant_daily_stat.js
app/model/screen/merchant/t_merchant_device_order_stat.js
app/model/screen/merchant/t_merchant_order_detail.js
app/schedule/update_cache_merchant.js
app/service/screen/merchant.js
app/controller/screen/merchant.js
View file @
0dc221e
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: limin
* @Author: limin
* @Date: 2019-11-21 11:20:01
* @Date: 2019-11-21 11:20:01
* @Last Modified by: limin
* @Last Modified by: limin
* @Last Modified time: 2020-01-04 1
2:24:23
* @Last Modified time: 2020-01-04 1
9:05:01
*/
*/
"use strict"
;
"use strict"
;
...
@@ -143,7 +143,7 @@ class MerchantController extends Controller {
...
@@ -143,7 +143,7 @@ class MerchantController extends Controller {
/**
/**
* @Router GET /screen/merchant/total
* @Router GET /screen/merchant/total
* @Description 数据大屏-商户总数统计.---- 广联商户总数
商户累计订单数 当日订单数
* @Description 数据大屏-商户总数统计.---- 广联商户总数
(merchant_total) 商户累计订单数(order_total) 当日订单数(realtime_new_order)
*/
*/
async
total
()
{
async
total
()
{
var
merchant_total
=
await
this
.
_fetch_total_
({
field
:
'total_merchant'
,
isGetLast
:
true
})
var
merchant_total
=
await
this
.
_fetch_total_
({
field
:
'total_merchant'
,
isGetLast
:
true
})
...
@@ -158,28 +158,31 @@ class MerchantController extends Controller {
...
@@ -158,28 +158,31 @@ class MerchantController extends Controller {
}
}
/**
/**
* @Router GET /screen/merchant/statistics
* @Router GET /screen/merchant/statistics
* @Description 数据大屏-数据统计 1. 近七天订单数
2.商户订购设备数 3.商户订购设备总额 4.商户活跃度 5. 广联系统使用率
* @Description 数据大屏-数据统计 1. 近七天订单数
(recent_7day_order) 2.商户订购设备数(total_device) 3.商户订购设备总额(total_amount) 4.商户活跃度(active_merchant) 5. 当日活跃商户(active_merchant)
* @Request query integer pid 省份id
* @Request query integer pid 省份id
*/
*/
async
statistics
()
{
async
statistics
()
{
const
summary
=
await
this
.
_fetch_total_
({
field
:[
'recent_7day_active'
,
'recent_7day_use'
,
'recent_7day_order'
,
'total_device'
,
'total_amount'
,
'active_merchant'
,
'use_sys_merchant'
]})
const
{
recent_7day_order
,
total_device
,
total_amount
,
active_merchant
,
total_merchant
}
const
data
=
{
summary
}
=
await
this
.
_fetch_total_
({
field
:[
'recent_7day_order'
,
'total_device'
,
'total_amount'
,
'active_merchant'
,
'total_merchant'
],
isGetLast
:
true
})
const
active_percent
=
this
.
helper
.
percent
(
active_merchant
,
total_merchant
);
const
data
=
{
recent_7day_order
,
total_device
,
total_amount
,
active_percent
,
active_merchant
}
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
}
}
/**
/**
* @Router GET /screen/merchant/trend
* @Router GET /screen/merchant/trend
* @Description 数据大屏-1 商户订单趋势(merchant_data) 2.设备订购趋势(order_trend), 3.商户活跃
(merchant_data) 4.系统使用率趋势
* @Description 数据大屏-1 商户订单趋势(merchant_data) 2.设备订购趋势(order_trend), 3.商户活跃
度(active) 4:(活跃商户数 TODO)
*/
*/
async
trend
()
{
async
trend
()
{
const
order_trend
=
await
this
.
_get_stats
(
'order_trend'
)
//设备订购趋势
const
{
active_trend
:
active
,
order_trend
}
=
await
this
.
_get_stats
([
'order_trend'
,
'active_trend'
])
//月度数据
const
merchant_data
=
await
this
.
_fetch_detail_by_range_
({
field
:[
'
active_merchant'
,
'total_merchant'
,
'
maintain_order'
,
'repair_order'
,
'insurance_order'
,
'device_order'
]});
const
merchant_data
=
await
this
.
_fetch_detail_by_range_
({
field
:[
'maintain_order'
,
'repair_order'
,
'insurance_order'
,
'device_order'
]});
const
data
=
{
order_trend
,
merchant_data
}
const
data
=
{
order_trend
,
merchant_data
,
active
}
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
}
}
/**
/**
* @Router GET /screen/merchant/device_order_stat
* @Router GET /screen/merchant/device_order_stat
* @Description 数据大屏-设备订单统计 1.商户订单类型分布(order_type) 2.订购设备类型分布(device_type) 3商户类型分布(merchant_type) 4订单数量区域排名(order_sort) 5:商户渠道分布(channel)
* @Description 数据大屏-设备订单统计 1.商户订单类型分布(order_type) 2.订购设备类型分布(device_type) 3商户类型分布(merchant_type) 4订单数量区域排名(order_sort) 5:商户渠道分布(channel)
6:每个省对应的商户数(merchants)
* @Request query integer n 近N天数据 默认 30天
* @Request query integer n 近N天数据 默认 30天
* @Request query string beginDate 查询开始时间 (2019-12-12)
* @Request query string beginDate 查询开始时间 (2019-12-12)
* @Request query string endDate 查询结束时间 (2019-12-12)
* @Request query string endDate 查询结束时间 (2019-12-12)
...
@@ -191,13 +194,15 @@ class MerchantController extends Controller {
...
@@ -191,13 +194,15 @@ class MerchantController extends Controller {
//订单数量区域排名
//订单数量区域排名
const
last
=
await
this
.
_fetch_summary_
({
isGetLast
:
true
});
const
last
=
await
this
.
_fetch_summary_
({
isGetLast
:
true
});
const
order_sort
=
[]
const
order_sort
=
[]
const
merchants
=
[]
const
province
=
last
[
0
].
p
const
province
=
last
[
0
].
p
for
(
const
key
in
province
)
{
for
(
const
key
in
province
)
{
if
(
key
===
'0'
)
continue
if
(
key
===
'0'
)
continue
order_sort
.
push
({
prov_code
:
key
,
value
:
province
[
key
].
total_order
})
order_sort
.
push
({
prov_code
:
key
,
value
:
province
[
key
].
total_order
})
merchants
.
push
({
prov_code
:
key
,
value
:
province
[
key
].
total_merchant
})
}
}
order_sort
.
sort
((
a
,
b
)
=>
b
.
value
-
a
.
value
).
length
=
10
order_sort
.
sort
((
a
,
b
)
=>
b
.
value
-
a
.
value
).
length
=
10
// const channel = await this.MerchantService.channel_stat({limit:6})
// const channel = await this.MerchantService.channel_stat({limit:6})
// const device_type = await this.MerchantService.device_type()
// const device_type = await this.MerchantService.device_type()
const
{
channel
,
device_type
}
=
await
this
.
_get_stats
([
'channel'
,
'device_type'
])
const
{
channel
,
device_type
}
=
await
this
.
_get_stats
([
'channel'
,
'device_type'
])
...
@@ -206,9 +211,9 @@ class MerchantController extends Controller {
...
@@ -206,9 +211,9 @@ class MerchantController extends Controller {
order_type
:
{
maintain_order
,
repair_order
,
insurance_order
,
device_order
},
// 商户订单类型分布
order_type
:
{
maintain_order
,
repair_order
,
insurance_order
,
device_order
},
// 商户订单类型分布
order_sort
,
//订单数量区域排名
order_sort
,
//订单数量区域排名
channel
,
// 商户渠道分布
channel
,
// 商户渠道分布
device_type
//订购设备类型分布
device_type
,
//订购设备类型分布
merchants
// 每个省对应的商户数
}
}
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
}
}
...
...
app/model/screen/merchant/t_merchant_daily_stat.js
View file @
0dc221e
...
@@ -23,6 +23,11 @@ module.exports = app => {
...
@@ -23,6 +23,11 @@ module.exports = app => {
allowNull
:
true
,
allowNull
:
true
,
defaultValue
:
'0'
defaultValue
:
'0'
},
},
recent_merchant
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
total_device
:
{
total_device
:
{
type
:
DataTypes
.
INTEGER
(
10
),
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
allowNull
:
true
,
...
...
app/model/screen/merchant/t_merchant_device_order_stat.js
View file @
0dc221e
...
@@ -28,6 +28,16 @@ module.exports = app => {
...
@@ -28,6 +28,16 @@ module.exports = app => {
allowNull
:
true
,
allowNull
:
true
,
defaultValue
:
'0'
defaultValue
:
'0'
},
},
stock_total
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
active_merchant
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
create_time
:
{
create_time
:
{
type
:
DataTypes
.
DATE
,
type
:
DataTypes
.
DATE
,
allowNull
:
true
allowNull
:
true
...
...
app/model/screen/merchant/t_merchant_order_detail.js
View file @
0dc221e
...
@@ -22,11 +22,15 @@ module.exports = app => {
...
@@ -22,11 +22,15 @@ module.exports = app => {
type
:
DataTypes
.
DATE
,
type
:
DataTypes
.
DATE
,
allowNull
:
true
allowNull
:
true
},
},
merCode
:
{
type
:
DataTypes
.
STRING
(
32
),
allowNull
:
true
},
merchant
:
{
merchant
:
{
type
:
DataTypes
.
STRING
(
256
),
type
:
DataTypes
.
STRING
(
256
),
allowNull
:
true
allowNull
:
true
},
},
order_
no
:
{
order_
type
:
{
type
:
DataTypes
.
STRING
(
64
),
type
:
DataTypes
.
STRING
(
64
),
allowNull
:
true
allowNull
:
true
},
},
...
...
app/schedule/update_cache_merchant.js
View file @
0dc221e
...
@@ -38,7 +38,7 @@ class UpdateCacheMerchant extends Subscription {
...
@@ -38,7 +38,7 @@ class UpdateCacheMerchant extends Subscription {
if
(
obj
)
{
if
(
obj
)
{
const
{
total_merchant
,
total_device
,
total_amount
,
active_merchant
,
use_sys_merchant
,
total_order
,
today_order
,
const
{
total_merchant
,
total_device
,
total_amount
,
active_merchant
,
use_sys_merchant
,
total_order
,
today_order
,
recent_7day_order
,
recent_7day_active
,
recent_7day_use
,
maintain_order
,
repair_order
,
insurance_order
,
device_order
,
recent_7day_order
,
recent_7day_active
,
recent_7day_use
,
maintain_order
,
repair_order
,
insurance_order
,
device_order
,
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
,
type_jingxiao
}
=
obj
;
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
,
type_jingxiao
,
recent_merchant
}
=
obj
;
target
[
"total_merchant"
]
+=
+
total_merchant
;
//商户总数
target
[
"total_merchant"
]
+=
+
total_merchant
;
//商户总数
target
[
"total_device"
]
+=
+
total_device
;
//订购设备总数
target
[
"total_device"
]
+=
+
total_device
;
//订购设备总数
target
[
"total_amount"
]
+=
parseFloat
(
total_amount
);
// 订购设备总额
target
[
"total_amount"
]
+=
parseFloat
(
total_amount
);
// 订购设备总额
...
@@ -59,10 +59,11 @@ class UpdateCacheMerchant extends Subscription {
...
@@ -59,10 +59,11 @@ class UpdateCacheMerchant extends Subscription {
target
[
"type_jingpin"
]
+=
+
type_jingpin
;
//商户类型:精品店
target
[
"type_jingpin"
]
+=
+
type_jingpin
;
//商户类型:精品店
target
[
"type_meibao"
]
+=
+
type_meibao
;
// 商户类型:美保店
target
[
"type_meibao"
]
+=
+
type_meibao
;
// 商户类型:美保店
target
[
"type_jingxiao"
]
+=
+
type_jingxiao
;
// 商户类型:经销商
target
[
"type_jingxiao"
]
+=
+
type_jingxiao
;
// 商户类型:经销商
target
[
"recent_merchant"
]
+=
+
recent_merchant
;
// 近活跃商户
}
else
{
}
else
{
target
[
"total_merchant"
]
=
0
;
//商户总数
target
[
"total_merchant"
]
=
0
;
//商户总数
target
[
"total_device"
]
=
0
;
//订购设备总数
target
[
"total_device"
]
=
0
;
//订购设备总数
target
[
"total_amount"
]
=
0
;
// 订购设备总额
target
[
"total_amount"
]
=
0
.00
;
// 订购设备总额
target
[
"active_merchant"
]
=
0
;
// 活跃商户
target
[
"active_merchant"
]
=
0
;
// 活跃商户
target
[
"use_sys_merchant"
]
=
0
;
// 使用的商户
target
[
"use_sys_merchant"
]
=
0
;
// 使用的商户
target
[
"total_order"
]
=
0
;
// 累计订单数
target
[
"total_order"
]
=
0
;
// 累计订单数
...
@@ -80,6 +81,7 @@ class UpdateCacheMerchant extends Subscription {
...
@@ -80,6 +81,7 @@ class UpdateCacheMerchant extends Subscription {
target
[
"type_jingpin"
]
=
0
;
//商户类型:精品店
target
[
"type_jingpin"
]
=
0
;
//商户类型:精品店
target
[
"type_meibao"
]
=
0
;
// 商户类型:美保店
target
[
"type_meibao"
]
=
0
;
// 商户类型:美保店
target
[
"type_jingxiao"
]
=
0
;
// 商户类型:经销商
target
[
"type_jingxiao"
]
=
0
;
// 商户类型:经销商
target
[
"recent_merchant"
]
=
0
;
//近活跃商户
}
}
return
target
;
return
target
;
}
}
...
@@ -88,15 +90,15 @@ class UpdateCacheMerchant extends Subscription {
...
@@ -88,15 +90,15 @@ class UpdateCacheMerchant extends Subscription {
const
prov_code
=
f
(
merchant
);
const
prov_code
=
f
(
merchant
);
let
{
total_merchant
,
total_device
,
total_amount
,
active_merchant
,
use_sys_merchant
,
total_order
,
today_order
,
let
{
total_merchant
,
total_device
,
total_amount
,
active_merchant
,
use_sys_merchant
,
total_order
,
today_order
,
recent_7day_order
,
recent_7day_active
,
recent_7day_use
,
maintain_order
,
repair_order
,
insurance_order
,
device_order
,
recent_7day_order
,
recent_7day_active
,
recent_7day_use
,
maintain_order
,
repair_order
,
insurance_order
,
device_order
,
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
,
type_jingxiao
,
day
}
=
merchant
;
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
,
type_jingxiao
,
recent_merchant
,
day
}
=
merchant
;
date
=
this
.
helper
.
moment
(
day
).
isAfter
(
date
)
?
day
:
date
;
date
=
this
.
helper
.
moment
(
day
).
isAfter
(
date
)
?
day
:
date
;
data
[
day
]
=
data
[
day
]
||
Object
.
assign
(
__init_or_plus__
(
null
),{
'p'
:{}})
//如果day 节点不存在 则 初始化一个
data
[
day
]
=
data
[
day
]
||
Object
.
assign
(
__init_or_plus__
(
null
),{
'p'
:{}})
//如果day 节点不存在 则 初始化一个
data
[
day
]
=
__init_or_plus__
(
data
[
day
],
{
total_merchant
,
total_device
,
total_amount
,
active_merchant
,
use_sys_merchant
,
total_order
,
today_order
,
data
[
day
]
=
__init_or_plus__
(
data
[
day
],
{
total_merchant
,
total_device
,
total_amount
,
active_merchant
,
use_sys_merchant
,
total_order
,
today_order
,
recent_7day_order
,
recent_7day_active
,
recent_7day_use
,
maintain_order
,
repair_order
,
insurance_order
,
device_order
,
recent_7day_order
,
recent_7day_active
,
recent_7day_use
,
maintain_order
,
repair_order
,
insurance_order
,
device_order
,
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
,
type_jingxiao
});
// 累加全国总数值
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
,
type_jingxiao
,
recent_merchant
});
// 累加全国总数值
data
[
day
][
"p"
][
prov_code
]
=
{
total_merchant
,
total_device
,
total_amount
,
active_merchant
,
use_sys_merchant
,
total_order
,
today_order
,
data
[
day
][
"p"
][
prov_code
]
=
{
total_merchant
,
total_device
,
total_amount
,
active_merchant
,
use_sys_merchant
,
total_order
,
today_order
,
recent_7day_order
,
recent_7day_active
,
recent_7day_use
,
maintain_order
,
repair_order
,
insurance_order
,
device_order
,
recent_7day_order
,
recent_7day_active
,
recent_7day_use
,
maintain_order
,
repair_order
,
insurance_order
,
device_order
,
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
,
type_jingxiao
};
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
,
type_jingxiao
,
recent_merchant
};
}.
bind
(
this
)
}.
bind
(
this
)
);
);
return
{
data
,
date
};
return
{
data
,
date
};
...
@@ -130,10 +132,12 @@ class UpdateCacheMerchant extends Subscription {
...
@@ -130,10 +132,12 @@ class UpdateCacheMerchant extends Subscription {
const
_last_month_
=
moment
().
format
(
'YYYY-MM'
)
const
_last_month_
=
moment
().
format
(
'YYYY-MM'
)
const
_last_month_7
=
moment
().
subtract
(
7
,
'months'
).
format
(
'YYYY-MM'
)
const
_last_month_7
=
moment
().
subtract
(
7
,
'months'
).
format
(
'YYYY-MM'
)
const
_order_trend
=
await
this
.
MerchantService
.
device_order
({
beginDate
:
_last_month_7
,
endDate
:
_last_month_
})
//设备订购趋势
const
_order_trend
=
await
this
.
MerchantService
.
device_order
({
beginDate
:
_last_month_7
,
endDate
:
_last_month_
})
//设备订购趋势
const
_active_trend
=
await
this
.
MerchantService
.
active_trend
({
beginDate
:
_last_month_7
,
endDate
:
_last_month_
})
//商户激活月度数据
const
_channel_stat
=
await
this
.
MerchantService
.
channel_stat
({
limit
:
6
})
//商户渠道分布
const
_channel_stat
=
await
this
.
MerchantService
.
channel_stat
({
limit
:
6
})
//商户渠道分布
const
_device_type
=
await
this
.
MerchantService
.
device_type
()
//订购设备类型分布
const
_device_type
=
await
this
.
MerchantService
.
device_type
()
//订购设备类型分布
const
_stats
=
{
const
_stats
=
{
'order_trend'
:
_order_trend
,
//设备订购趋势
'order_trend'
:
_order_trend
,
//设备订购趋势
'active_trend'
:
_active_trend
,
// 商户激活
'channel'
:
_channel_stat
,
//商户渠道分布
'channel'
:
_channel_stat
,
//商户渠道分布
'device_type'
:
_device_type
//订购设备类型分布
'device_type'
:
_device_type
//订购设备类型分布
}
}
...
...
app/service/screen/merchant.js
View file @
0dc221e
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: limin
* @Author: limin
* @Date: 2019-11-21 11:18:37
* @Date: 2019-11-21 11:18:37
* @Last Modified by: limin
* @Last Modified by: limin
* @Last Modified time: 2020-01-04 1
2:53:22
* @Last Modified time: 2020-01-04 1
8:56:18
*/
*/
const
Service
=
require
(
"egg"
).
Service
;
const
Service
=
require
(
"egg"
).
Service
;
...
@@ -135,6 +135,33 @@ class MerchantService extends Service {
...
@@ -135,6 +135,33 @@ class MerchantService extends Service {
* @param field {String}
* @param field {String}
* @param value {String}
* @param value {String}
* @return {Promise.<boolean>}
* @return {Promise.<boolean>}
* @Description 商户激活
*/
async
active_trend
({
beginDate
,
endDate
})
{
const
{
col
,
fn
}
=
this
.
app
.
Sequelize
;
var
option
=
this
.
__build__option__
();
Object
.
assign
(
option
,
{
attributes
:
[
"prov_code"
,
"month"
,
[
fn
(
"SUM"
,
col
(
"active_merchant"
)),
"active_merchant"
],
],
group
:
"month"
,
where
:
{
month
:
{
[
this
.
app
.
Sequelize
.
Op
.
gt
]:
beginDate
,
[
this
.
app
.
Sequelize
.
Op
.
lt
]:
endDate
}
}
});
const
data
=
await
this
.
MDOS
.
findAll
(
option
);
return
data
;
}
/**
* @param field {String}
* @param value {String}
* @return {Promise.<boolean>}
* @Description 商户渠道分布
* @Description 商户渠道分布
*/
*/
async
channel_stat
({
limit
})
{
async
channel_stat
({
limit
})
{
...
@@ -179,9 +206,10 @@ class MerchantService extends Service {
...
@@ -179,9 +206,10 @@ class MerchantService extends Service {
"id"
,
"id"
,
"merchant"
,
"merchant"
,
"order_time"
,
"order_time"
,
"
order_no
"
,
"
merCode
"
,
"total"
,
"total"
,
"prov_code"
,
"prov_code"
,
"order_type"
,
"city_code"
,
"city_code"
,
"device_type"
"device_type"
]
]
...
@@ -209,9 +237,10 @@ class MerchantService extends Service {
...
@@ -209,9 +237,10 @@ class MerchantService extends Service {
"id"
,
"id"
,
"merchant"
,
"merchant"
,
"order_time"
,
"order_time"
,
"
order_no
"
,
"
merCode
"
,
"total"
,
"total"
,
"prov_code"
,
"prov_code"
,
"order_type"
,
"city_code"
,
"city_code"
,
"device_type"
"device_type"
]
]
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment