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 a3ed1bd3
authored
Jan 03, 2020
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调整
1 parent
d795cca9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
52 deletions
app/controller/screen/merchant.js
app/router/screen/merchant.js
app/schedule/update_cache_merchant.js
app/service/screen/merchant.js
app/controller/screen/merchant.js
View file @
a3ed1bd
...
@@ -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-03 1
8:16:02
* @Last Modified time: 2020-01-03 1
9:40:16
*/
*/
"use strict"
;
"use strict"
;
...
@@ -78,7 +78,7 @@ class MerchantController extends Controller {
...
@@ -78,7 +78,7 @@ class MerchantController extends Controller {
}
else
{
}
else
{
if
(
fn
){
if
(
fn
){
for
(
const
day
in
summary_30_day
){
for
(
const
day
in
summary_30_day
){
fn
(
day
,
summary_30_day
[
day
])
await
fn
(
day
,
summary_30_day
[
day
])
}
}
}
}
result
=
Object
.
values
(
summary_30_day
)
result
=
Object
.
values
(
summary_30_day
)
...
@@ -135,9 +135,9 @@ class MerchantController extends Controller {
...
@@ -135,9 +135,9 @@ class MerchantController extends Controller {
* @param {*} field
* @param {*} field
* @param {*} fn
* @param {*} fn
*/
*/
async
_get_stats
(){
async
_get_stats
(
field
){
const
result
=
await
this
.
_compare_get_
(
true
,
this
.
helper
.
constant
.
MERCHANT_SUMMARY_STATS
);
const
result
=
await
this
.
_compare_get_
(
true
,
this
.
helper
.
constant
.
MERCHANT_SUMMARY_STATS
);
return
result
return
await
this
.
_set_
(
field
,
f
=>
result
[
f
])
}
}
/**
/**
...
@@ -167,48 +167,17 @@ class MerchantController extends Controller {
...
@@ -167,48 +167,17 @@ class MerchantController extends Controller {
}
}
/**
/**
* @Router GET /screen/merchant/trend
* @Router GET /screen/merchant/trend
* @Description 数据大屏-1 商户订单趋势 2.设备订购趋势, 3.商户活跃趋势 4.系统使用率趋势
* @Description 数据大屏-1 商户订单趋势(merchant_data) 2.设备订购趋势(order_trend), 3.商户活跃(merchant_data) 4.系统使用率趋势
* @Request query integer n 近N天数据 默认 30天
* @Request query string beginDate 查询开始时间 (2019-12-12)
* @Request query string endDate 查询结束时间 (2019-12-12)
*/
async
trend
({
query
:
{
pid
,
type
,
n
=
30
,
beginDate
,
endDate
}
})
{
if
(
n
){
if
(
n
===
30
){
beginDate
=
endDate
=
null
;
}
else
{
beginDate
=
this
.
helper
.
date
(
-
n
);
var
{
yesterday
:
endDate
}
=
await
this
.
_fetch_date_in_cache_
();
}
}
type
=
type
?
(
type
.
includes
(
','
)
?
type
.
split
(
','
)
:
type
)
:
[
'maintain_order'
,
'repair_order'
,
'insurance_order'
,
'device_order'
,
'recent_7day_active'
,
'recent_7day_use'
,
'active_merchant'
,
'use_sys_merchant'
,
'total_merchant'
];
const
data
=
await
this
.
_fetch_detail_by_range_
(
{
pid
,
field
:
type
,
beginDate
,
endDate
}
)
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
}
/**
* @Router GET /screen/merchant/trend_device
* @Description 数据大屏-订购设备趋势
* @Request query integer n 近N天数据 默认 30天
* @Request query string beginDate 查询开始时间 (2019-12-12)
* @Request query string endDate 查询结束时间 (2019-12-12)
*/
*/
async
trend_device
({
query
:
{
pid
,
type
,
n
=
30
,
beginDate
,
endDate
}
})
{
async
trend
()
{
if
(
n
){
const
order_trend
=
await
this
.
_get_stats
(
'order_trend'
)
//设备订购趋势
if
(
n
===
30
){
const
merchant_data
=
await
this
.
_fetch_detail_by_range_
({
field
:[
'active_merchant'
,
'total_merchant'
,
'maintain_order'
,
'repair_order'
,
'insurance_order'
,
'device_order'
]});
beginDate
=
endDate
=
null
;
const
data
=
{
order_trend
,
merchant_data
}
}
else
{
beginDate
=
this
.
helper
.
date
(
-
n
);
var
{
yesterday
:
endDate
}
=
await
this
.
_fetch_date_in_cache_
();
}
}
type
=
type
?
(
type
.
includes
(
','
)
?
type
.
split
(
','
)
:
type
)
:
[
'maintain_order'
,
'repair_order'
,
'insurance_order'
,
'device_order'
,
'recent_7day_active'
,
'recent_7day_use'
,
'active_merchant'
,
'use_sys_merchant'
,
'total_merchant'
];
const
data
=
await
this
.
_fetch_detail_by_range_
(
{
pid
,
field
:
type
,
beginDate
,
endDate
}
)
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
}
}
/**
/**
* @Router GET /screen/merchant/
trend_device
* @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)
* @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)
...
@@ -226,9 +195,10 @@ class MerchantController extends Controller {
...
@@ -226,9 +195,10 @@ class MerchantController extends Controller {
order_sort
.
push
({
prov_code
:
key
,
value
:
province
[
key
].
total_order
})
order_sort
.
push
({
prov_code
:
key
,
value
:
province
[
key
].
total_order
})
}
}
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
data
=
{
const
data
=
{
merchant_type
:
{
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
},
// 商户类型
merchant_type
:
{
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
},
// 商户类型
order_type
:
{
maintain_order
,
repair_order
,
insurance_order
,
device_order
},
// 商户订单类型分布
order_type
:
{
maintain_order
,
repair_order
,
insurance_order
,
device_order
},
// 商户订单类型分布
...
...
app/router/screen/merchant.js
View file @
a3ed1bd
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
* @Author: limin
* @Author: limin
* @Date: 2019-11-21 11:18:45
* @Date: 2019-11-21 11:18:45
* @Last Modified by: limin
* @Last Modified by: limin
* @Last Modified time: 20
19-12-27 15:51:21
* @Last Modified time: 20
20-01-03 19:33:23
*/
*/
module
.
exports
=
app
=>
{
module
.
exports
=
app
=>
{
app
.
router
.
get
(
'/screen/merchant/total'
,
app
.
controller
.
screen
.
merchant
.
total
);
app
.
router
.
get
(
'/screen/merchant/total'
,
app
.
controller
.
screen
.
merchant
.
total
);
app
.
router
.
get
(
'/screen/merchant/statistics'
,
app
.
controller
.
screen
.
merchant
.
statistics
);
app
.
router
.
get
(
'/screen/merchant/statistics'
,
app
.
controller
.
screen
.
merchant
.
statistics
);
app
.
router
.
get
(
'/screen/merchant/trend'
,
app
.
controller
.
screen
.
merchant
.
trend
);
app
.
router
.
get
(
'/screen/merchant/trend'
,
app
.
controller
.
screen
.
merchant
.
trend
);
app
.
router
.
get
(
'/screen/merchant/trend_device'
,
app
.
controller
.
screen
.
merchant
.
trend_device
);
//
app.router.get('/screen/merchant/trend_device', app.controller.screen.merchant.trend_device);
app
.
router
.
get
(
'/screen/merchant/device_order_stat'
,
app
.
controller
.
screen
.
merchant
.
device_order_stat
);
app
.
router
.
get
(
'/screen/merchant/device_order_stat'
,
app
.
controller
.
screen
.
merchant
.
device_order_stat
);
};
};
\ No newline at end of file
\ No newline at end of file
app/schedule/update_cache_merchant.js
View file @
a3ed1bd
...
@@ -127,11 +127,11 @@ class UpdateCacheMerchant extends Subscription {
...
@@ -127,11 +127,11 @@ class UpdateCacheMerchant extends Subscription {
// STAT
// STAT
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
_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
,
//
设备订购
趋势
'channel'
:
_channel_stat
,
//商户渠道分布
'channel'
:
_channel_stat
,
//商户渠道分布
'device_type'
:
_device_type
//订购设备类型分布
'device_type'
:
_device_type
//订购设备类型分布
}
}
...
...
app/service/screen/merchant.js
View file @
a3ed1bd
...
@@ -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-03 1
6:52:13
* @Last Modified time: 2020-01-03 1
9:36:44
*/
*/
const
Service
=
require
(
"egg"
).
Service
;
const
Service
=
require
(
"egg"
).
Service
;
...
@@ -110,15 +110,17 @@ class MerchantService extends Service {
...
@@ -110,15 +110,17 @@ class MerchantService extends Service {
* @Description 订购设备趋势
* @Description 订购设备趋势
*/
*/
async
device_order
({
beginDate
,
endDate
})
{
async
device_order
({
beginDate
,
endDate
})
{
const
{
col
,
fn
}
=
this
.
app
.
Sequelize
;
var
option
=
this
.
__build__option__
();
var
option
=
this
.
__build__option__
();
Object
.
assign
(
option
,
{
Object
.
assign
(
option
,
{
attributes
:
[
attributes
:
[
'prov_code'
,
'prov_code'
,
"month"
,
"month"
,
'order_total'
,
[
fn
(
"SUM"
,
col
(
"order_total"
)),
"order_total"
]
,
'sale_total'
,
[
fn
(
"SUM"
,
col
(
"sale_total"
)),
"sale_total"
]
,
'stock_total'
[
fn
(
"SUM"
,
col
(
"stock_total"
)),
"stock_total"
],
],
],
group
:
'month'
,
where
:{
where
:{
month
:{
month
:{
[
this
.
app
.
Sequelize
.
Op
.
gt
]:
beginDate
,
[
this
.
app
.
Sequelize
.
Op
.
gt
]:
beginDate
,
...
...
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