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 d795cca9
authored
Jan 03, 2020
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
数据逻辑调整
1 parent
c698fed5
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
124 additions
and
66 deletions
app/common/queue.js
app/controller/screen/merchant.js
app/controller/screen/user.js
app/model/screen/merchant/t_merchant_daily_stat.js
app/model/t_user_city_daily.js
app/router/screen/merchant.js
app/schedule/update_cache.js
app/schedule/update_cache_merchant.js
app/service/screen/merchant.js
app/service/screen/user.js
app/common/queue.js
View file @
d795cca
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: limin
* @Author: limin
* @Date: 2019-12-06 14:58:35
* @Date: 2019-12-06 14:58:35
* @Last Modified by: limin
* @Last Modified by: limin
* @Last Modified time: 20
19-12-08 21:19:20
* @Last Modified time: 20
20-01-03 18:12:37
*/
*/
// const items = new WeakMap(); //WeakMap对象是密钥/值对的集合,其中密钥被弱引用。键必须是对象,值可以是任意值。
// const items = new WeakMap(); //WeakMap对象是密钥/值对的集合,其中密钥被弱引用。键必须是对象,值可以是任意值。
...
@@ -110,7 +110,7 @@ module.exports = class Queue {
...
@@ -110,7 +110,7 @@ module.exports = class Queue {
this
.
enqueue
(
this
.
_last_dequeue
);
this
.
enqueue
(
this
.
_last_dequeue
);
}
else
if
(
_result_size
<
this
.
_size
)
{
}
else
if
(
_result_size
<
this
.
_size
)
{
// 从上一次返回的数据中 获取相差的几条数据 补充到最新数据的末尾 保证队列数据的数量 公式为: [data][_result_size]
// 从上一次返回的数据中 获取相差的几条数据 补充到最新数据的末尾 保证队列数据的数量 公式为: [data][_result_size]
const
_last_data_list
=
data
.
filter
((
item
,
index
)
=>
index
>=
_result_size
);
const
_last_data_list
=
this
.
_last_dequeue
.
filter
((
item
,
index
)
=>
index
>=
_result_size
);
this
.
enqueue
(...
result
,
...
_last_data_list
);
this
.
enqueue
(...
result
,
...
_last_data_list
);
}
else
{
}
else
{
this
.
enqueue
(
result
);
this
.
enqueue
(
result
);
...
...
app/controller/screen/merchant.js
View file @
d795cca
...
@@ -2,15 +2,15 @@
...
@@ -2,15 +2,15 @@
* @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: 20
19-12-26 18:25:56
* @Last Modified time: 20
20-01-03 18:16:02
*/
*/
"use strict"
;
"use strict"
;
const
Controller
=
require
(
"egg"
).
Controller
;
const
Controller
=
require
(
"egg"
).
Controller
;
/**
/**
* @Controller screen/
user
* @Controller screen/
merchant
* @Description 数据大屏-
用
户
* @Description 数据大屏-
商
户
*/
*/
class
MerchantController
extends
Controller
{
class
MerchantController
extends
Controller
{
constructor
(
ctx
)
{
constructor
(
ctx
)
{
...
@@ -58,7 +58,7 @@ class MerchantController extends Controller {
...
@@ -58,7 +58,7 @@ class MerchantController extends Controller {
var
result
=
[];
var
result
=
[];
if
(
isGetLast
){
if
(
isGetLast
){
const
{
cache_data_last_date_merchant
}
=
await
this
.
_fetch_date_in_cache_
();
const
{
cache_data_last_date_merchant
}
=
await
this
.
_fetch_date_in_cache_
();
result
=
summary_30_day
[
cache_data_last_date_merchant
];
result
=
[
summary_30_day
[
cache_data_last_date_merchant
]
];
fn
&&
fn
(
cache_data_last_date_merchant
,
summary_30_day
[
cache_data_last_date_merchant
])
fn
&&
fn
(
cache_data_last_date_merchant
,
summary_30_day
[
cache_data_last_date_merchant
])
}
else
if
(
beginDate
){
}
else
if
(
beginDate
){
endDate
=
endDate
||
beginDate
;
endDate
=
endDate
||
beginDate
;
...
@@ -87,7 +87,9 @@ class MerchantController extends Controller {
...
@@ -87,7 +87,9 @@ class MerchantController extends Controller {
}
}
async
_fetch_total_
({
field
,
isGetLast
}
){
async
_fetch_total_
({
field
,
isGetLast
}
){
const
_summary
=
await
this
.
_fetch_summary_
({
isGetLast
});
const
_summary
=
await
this
.
_fetch_summary_
({
isGetLast
});
return
this
.
_set_
(
field
,(
f
)
=>
_summary
[
f
]
||
0
);
// return this._set_(field,async (f)=>_summary[f]||0);
const
result
=
await
this
.
_set_
(
field
,(
f
)
=>
_summary
.
reduce
((
pre
,
next
)
=>
pre
+
+
next
[
f
],
0
));
return
result
}
}
/**
/**
...
@@ -143,8 +145,8 @@ class MerchantController extends Controller {
...
@@ -143,8 +145,8 @@ class MerchantController extends Controller {
* @Description 数据大屏-商户总数统计.---- 广联商户总数 商户累计订单数 当日订单数
* @Description 数据大屏-商户总数统计.---- 广联商户总数 商户累计订单数 当日订单数
*/
*/
async
total
()
{
async
total
()
{
var
merchant_total
=
await
this
.
_fetch_total_
({
field
:
'
merchant_total'
,
isGetLast
:
true
})
var
merchant_total
=
await
this
.
_fetch_total_
({
field
:
'
total_merchant'
,
isGetLast
:
true
})
var
order_total
=
await
this
.
_fetch_total_
({
field
:
'
order_total'
,
isGetLast
:
true
})
var
order_total
=
await
this
.
_fetch_total_
({
field
:
'
total_order'
,
isGetLast
:
true
})
const
realtime
=
await
this
.
MerchantService
.
merchant_realtime
();
const
realtime
=
await
this
.
MerchantService
.
merchant_realtime
();
const
realtime_new_order
=
realtime
.
reduce
((
pre
,
next
)
=>
pre
+
+
next
[
'new_order'
],
0
);
const
realtime_new_order
=
realtime
.
reduce
((
pre
,
next
)
=>
pre
+
+
next
[
'new_order'
],
0
);
const
realtime_new_merchant
=
realtime
.
reduce
((
pre
,
next
)
=>
pre
+
+
next
[
'new_merchant'
],
0
);
const
realtime_new_merchant
=
realtime
.
reduce
((
pre
,
next
)
=>
pre
+
+
next
[
'new_merchant'
],
0
);
...
@@ -207,47 +209,36 @@ class MerchantController extends Controller {
...
@@ -207,47 +209,36 @@ class MerchantController extends Controller {
/**
/**
* @Router GET /screen/merchant/trend_device
* @Router GET /screen/merchant/trend_device
* @Description 数据大屏-设备订单统计 1.商户订单类型分布
2.订购设备类型分布
* @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)
* @Request query string endDate 查询结束时间 (2019-12-12)
* @Request query string endDate 查询结束时间 (2019-12-12)
*/
*/
async
device_order_stat
()
{
async
device_order_stat
()
{
const
q
=
this
.
_fetch_total_
({
field
:[
'type_4s'
,
'type_weixiu'
,
'type_yingai'
,
'type_jingpin'
,
'type_meibao'
,
'maintain_order'
,
'repair_order'
,
'insurance_order'
,
'device_order'
,
'p'
],
isGetLast
:
true
})
const
{
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
,
maintain_order
,
repair_order
,
insurance_order
,
device_order
}
const
{
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
,
maintain_order
,
repair_order
,
insurance_order
,
device_order
}
=
q
=
const
data
=
{}
await
this
.
_fetch_total_
({
field
:[
'type_4s'
,
'type_weixiu'
,
'type_yingai'
,
'type_jingpin'
,
'type_meibao'
,
'maintain_order'
,
'repair_order'
,
'insurance_order'
,
'device_order'
],
isGetLast
:
true
})
data
.
merchant_type
=
{
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
}
// 商户类型
data
.
order_type
=
{
maintain_order
,
repair_order
,
insurance_order
,
device_order
}
// 订单类型
//订单数量区域排名
//订单数量区域排名
// Object.values(p).sort(obj=>obj.)
const
last
=
await
this
.
_fetch_summary_
({
isGetLast
:
true
});
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
const
order_sort
=
[]
const
province
=
last
[
0
].
p
for
(
const
key
in
province
)
{
order_sort
.
push
({
prov_code
:
key
,
value
:
province
[
key
].
total_order
})
}
}
/**
order_sort
.
sort
((
a
,
b
)
=>
b
.
value
-
a
.
value
).
length
=
10
* @Router GET /screen/user/activation
* @Description 实时激活数据播报
const
channel
=
await
this
.
MerchantService
.
channel_stat
({
limit
:
6
})
* @Request query integer pid 省份id
const
device_type
=
await
this
.
MerchantService
.
device_type
()
*/
const
data
=
{
async
activation
({
query
:
{
pid
}
})
{
merchant_type
:
{
type_4s
,
type_weixiu
,
type_yingai
,
type_jingpin
,
type_meibao
},
// 商户类型
const
data
=
this
.
queue
.
peek
();
order_type
:
{
maintain_order
,
repair_order
,
insurance_order
,
device_order
},
// 商户订单类型分布
const
{
USER_ACTIVE_DATA_LASI_ID
}
=
this
.
helper
.
constant
;
order_sort
,
//订单数量区域排名
const
_last_id
=
await
this
.
CacheService
.
get
(
USER_ACTIVE_DATA_LASI_ID
);
channel
,
// 商户渠道分布
this
.
queue
.
fill
(
async
()
=>
await
this
.
UserService
.
activation
({
pid
,
limit
:
this
.
queue
.
size
(),
last_id
:
_last_id
}))
device_type
//订购设备类型分布
.
then
(
last_id
=>
last_id
&&
this
.
CacheService
.
set
(
USER_ACTIVE_DATA_LASI_ID
,
last_id
))
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
}
}
/**
* @Router GET /screen/user/total_group_by_province
* @Description 获取每个省的总用户数
* @Request query integer pid 省份id
*/
async
total_group_by_province
({
query
:
{
pid
}
})
{
const
data
=
await
this
.
UserService
.
total_group_by_province
({
pid
});
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
}
}
}
}
module
.
exports
=
MerchantController
;
module
.
exports
=
MerchantController
;
app/controller/screen/user.js
View file @
d795cca
...
@@ -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: 20
19-12-23 17:25:2
2
* @Last Modified time: 20
20-01-03 18:23:3
2
*/
*/
"use strict"
;
"use strict"
;
...
@@ -165,7 +165,7 @@ class UserController extends Controller {
...
@@ -165,7 +165,7 @@ class UserController extends Controller {
if
(
cid
){
if
(
cid
){
fn
=
async
f
=>
value
&&
value
[
'p'
][
pid
]
&&
value
[
'p'
][
pid
][
'c'
][
cid
]?
value
[
'p'
][
pid
][
'c'
][
cid
][
f
]:
0
fn
=
async
f
=>
value
&&
value
[
'p'
][
pid
]
&&
value
[
'p'
][
pid
][
'c'
][
cid
]?
value
[
'p'
][
pid
][
'c'
][
cid
][
f
]:
0
}
else
{
}
else
{
fn
=
async
f
=>
value
&&
value
[
'p'
][
pid
]
?
value
[
'p'
][
pid
][
f
]:
0
fn
=
async
f
=>
value
&&
value
[
'p'
][
pid
]
?
value
[
'p'
][
pid
][
f
]:
0
}
}
}
else
{
}
else
{
fn
=
async
f
=>
value
?
value
[
f
]:
0
fn
=
async
f
=>
value
?
value
[
f
]:
0
...
@@ -185,9 +185,9 @@ class UserController extends Controller {
...
@@ -185,9 +185,9 @@ class UserController extends Controller {
const
realtime
=
await
this
.
UserService
.
user_realtime
({
pid
,
cid
});
const
realtime
=
await
this
.
UserService
.
user_realtime
({
pid
,
cid
});
const
realtime_total
=
realtime
.
reduce
((
pre
,
next
)
=>
pre
+
+
next
[
'increase'
],
0
);
const
realtime_total
=
realtime
.
reduce
((
pre
,
next
)
=>
pre
+
+
next
[
'increase'
],
0
);
const
online_total
=
realtime
.
reduce
((
pre
,
next
)
=>
pre
+
+
next
[
'online_total'
],
0
);
const
online_total
=
realtime
.
reduce
((
pre
,
next
)
=>
pre
+
+
next
[
'online_total'
],
0
);
const
online_time
=
realtime
.
reduce
((
pre
,
next
)
=>
pre
+
+
next
[
'online_time'
],
0
);
//
const online_time= realtime.reduce((pre,next)=>pre + +next['online_time'],0);
total
+=
~~
realtime_total
;
total
+=
~~
realtime_total
;
const
data
=
{
total
,
online_total
,
online_time
};
const
data
=
{
total
,
online_total
};
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
}
}
/**
/**
...
@@ -196,10 +196,9 @@ class UserController extends Controller {
...
@@ -196,10 +196,9 @@ class UserController extends Controller {
* @Request query integer pid 省份id
* @Request query integer pid 省份id
*/
*/
async
statistics
({
query
:
{
pid
,
cid
}
})
{
async
statistics
({
query
:
{
pid
,
cid
}
})
{
var
{
r
,
u
,
rt
,
a7
,
a30
}
=
await
this
.
_fetch_total_last_day_
({
pid
,
cid
,
field
:[
'r'
,
'u'
,
'rt'
,
'a7'
,
'a30'
]});
var
{
rr
,
rt
,
a7
,
a30
,
o
}
=
await
this
.
_fetch_total_last_day_
({
pid
,
cid
,
field
:[
'rr'
,
'rt'
,
'a7'
,
'a30'
,
'o'
]});
console
.
log
(
a7
,
a30
);
// 昨天的付费转化率 (昨天的付费总人数 / 昨天用户总数)
// 昨天的付费转化率 (昨天的付费总人数 / 昨天用户总数)
const
renew
=
this
.
helper
.
percent
(
r
,
u
);
const
renew
=
this
.
helper
.
percent
(
r
r
,
rt
);
const
beginDate7
=
this
.
helper
.
date
(
-
7
);
const
beginDate7
=
this
.
helper
.
date
(
-
7
);
const
{
yesterday
}
=
await
this
.
_fetch_date_in_cache_
();
const
{
yesterday
}
=
await
this
.
_fetch_date_in_cache_
();
//近7天所有
//近7天所有
...
@@ -210,8 +209,9 @@ class UserController extends Controller {
...
@@ -210,8 +209,9 @@ class UserController extends Controller {
const
{
i
:
increased30
}
=
await
this
.
_fetch_total_by_range_
({
pid
,
cid
,
field
:[
'i'
]});
const
{
i
:
increased30
}
=
await
this
.
_fetch_total_by_range_
({
pid
,
cid
,
field
:[
'i'
]});
// 近30天 用户活跃度 (昨天的数据: 近30天 活跃用户数 / 昨天用户数)
// 近30天 用户活跃度 (昨天的数据: 近30天 活跃用户数 / 昨天用户数)
const
live30
=
this
.
helper
.
percent
(
a30
,
rt
);
const
live30
=
this
.
helper
.
percent
(
a30
,
rt
);
const
data
=
{
increased7
,
live7
,
increased30
,
live30
,
renew
};
//在线时长 / 3600 / 近两年用户数
const
online_time
=
o
/
3600
/
rt
const
data
=
{
increased7
,
live7
,
increased30
,
live30
,
renew
,
online_time
};
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
}
}
...
@@ -280,9 +280,10 @@ class UserController extends Controller {
...
@@ -280,9 +280,10 @@ class UserController extends Controller {
var
{
yesterday
:
endDate
}
=
await
this
.
_fetch_date_in_cache_
();
var
{
yesterday
:
endDate
}
=
await
this
.
_fetch_date_in_cache_
();
}
}
}
}
const
{
rt
}
=
await
this
.
_fetch_total_last_day_
({
pid
,
cid
,
field
:[
'rt'
]});
type
=
type
?
(
type
.
includes
(
','
)
?
type
.
split
(
','
)
:
type
)
:
[
'u'
,
'i'
,
'a'
,
'r'
,
'j'
];
type
=
type
?
(
type
.
includes
(
','
)
?
type
.
split
(
','
)
:
type
)
:
[
'u'
,
'i'
,
'a'
,
'r'
,
'j'
];
const
data
=
await
this
.
_fetch_detail_by_range_
(
{
pid
,
cid
,
field
:
type
,
beginDate
,
endDate
}
)
const
list
=
await
this
.
_fetch_detail_by_range_
(
{
pid
,
cid
,
field
:
type
,
beginDate
,
endDate
}
)
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
{
recent_total
:
rt
,
list
}
);
}
}
/**
/**
* @Router GET /screen/user/activation
* @Router GET /screen/user/activation
...
...
app/model/screen/merchant/t_merchant_daily_stat.js
View file @
d795cca
...
@@ -68,6 +68,51 @@ module.exports = app => {
...
@@ -68,6 +68,51 @@ module.exports = app => {
allowNull
:
true
,
allowNull
:
true
,
defaultValue
:
'0'
defaultValue
:
'0'
},
},
maintain_order
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
repair_order
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
insurance_order
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
device_order
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
type_4s
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
type_weixiu
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
type_yingai
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
type_jingpin
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
type_meibao
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
create_time
:
{
create_time
:
{
type
:
DataTypes
.
DATE
,
type
:
DataTypes
.
DATE
,
allowNull
:
true
allowNull
:
true
...
...
app/model/t_user_city_daily.js
View file @
d795cca
...
@@ -27,6 +27,11 @@ module.exports = app => {
...
@@ -27,6 +27,11 @@ module.exports = app => {
allowNull
:
true
,
allowNull
:
true
,
defaultValue
:
'0'
defaultValue
:
'0'
},
},
recent_renew
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
defaultValue
:
'0'
},
renew
:
{
renew
:
{
type
:
DataTypes
.
INTEGER
(
10
),
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
true
,
allowNull
:
true
,
...
...
app/router/screen/merchant.js
View file @
d795cca
...
@@ -2,11 +2,13 @@
...
@@ -2,11 +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: 2019-12-2
6 15:55:15
* @Last Modified time: 2019-12-2
7 15:51:21
*/
*/
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/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.js
View file @
d795cca
...
@@ -37,8 +37,9 @@ class UpdateCache extends Subscription {
...
@@ -37,8 +37,9 @@ class UpdateCache extends Subscription {
function
__init_or_plus__
(
target
,
obj
)
{
function
__init_or_plus__
(
target
,
obj
)
{
target
=
target
||
{};
target
=
target
||
{};
if
(
obj
)
{
if
(
obj
)
{
const
{
r
,
u
,
a
,
i
,
j
,
m
,
o
,
rt
,
a7
,
a30
}
=
obj
;
const
{
r
,
rr
,
u
,
a
,
i
,
j
,
m
,
o
,
rt
,
a7
,
a30
}
=
obj
;
target
[
"r"
]
+=
+
r
;
//续费 renew
target
[
"r"
]
+=
+
r
;
//续费 renew
target
[
"rr"
]
+=
+
rr
;
//近年续费总数 recent_renew
target
[
"u"
]
+=
+
u
;
//用户总数 user
target
[
"u"
]
+=
+
u
;
//用户总数 user
target
[
"a"
]
+=
+
a
;
// 活跃用户数 active
target
[
"a"
]
+=
+
a
;
// 活跃用户数 active
target
[
"i"
]
+=
+
i
;
// 新增用户数 increase
target
[
"i"
]
+=
+
i
;
// 新增用户数 increase
...
@@ -50,13 +51,14 @@ class UpdateCache extends Subscription {
...
@@ -50,13 +51,14 @@ class UpdateCache extends Subscription {
target
[
"a30"
]
+=
+
a30
;
// 近30天 活跃数
target
[
"a30"
]
+=
+
a30
;
// 近30天 活跃数
}
else
{
}
else
{
target
[
"r"
]
=
0
;
//续费 renew
target
[
"r"
]
=
0
;
//续费 renew
target
[
"rr"
]
=
0
;
//近年续费总数 recent_renew
target
[
"u"
]
=
0
;
//用户总数 user
target
[
"u"
]
=
0
;
//用户总数 user
target
[
"a"
]
=
0
;
// 活跃用户数 active
target
[
"a"
]
=
0
;
// 活跃用户数 active
target
[
"i"
]
=
0
;
// 新增用户数 increase
target
[
"i"
]
=
0
;
// 新增用户数 increase
target
[
"j"
]
=
0
;
// 出行 journey
target
[
"j"
]
=
0
;
// 出行 journey
target
[
"m"
]
=
0.0
;
// 里程 miles
target
[
"m"
]
=
0.0
;
// 里程 miles
target
[
"o"
]
=
0
;
// online 在线时间
target
[
"o"
]
=
0
;
// online 在线时间
target
[
"rt"
]
=
0
;
//
最近总数
target
[
"rt"
]
=
0
;
//
近年活跃的用户总数 recent_total
target
[
"a7"
]
=
0
;
// 近7天 活跃数
target
[
"a7"
]
=
0
;
// 近7天 活跃数
target
[
"a30"
]
=
0
;
// 近30天 活跃数
target
[
"a30"
]
=
0
;
// 近30天 活跃数
}
}
...
@@ -65,13 +67,13 @@ class UpdateCache extends Subscription {
...
@@ -65,13 +67,13 @@ class UpdateCache extends Subscription {
cities
.
forEach
(
cities
.
forEach
(
function
(
city
)
{
function
(
city
)
{
const
prov_code
=
f
(
city
);
const
prov_code
=
f
(
city
);
let
{
city_code
,
total_user
:
u
,
renew
:
r
,
active
:
a
,
increase
:
i
,
journey
:
j
,
miles
:
m
,
online_time
:
o
,
day
,
recent_total
:
rt
,
recent_7_day_active
:
a7
,
recent_30_day_active
:
a30
}
=
city
;
let
{
city_code
,
total_user
:
u
,
renew
:
r
,
recent_renew
:
rr
,
active
:
a
,
increase
:
i
,
journey
:
j
,
miles
:
m
,
online_time
:
o
,
day
,
recent_total
:
rt
,
recent_7_day_active
:
a7
,
recent_30_day_active
:
a30
}
=
city
;
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
],
{
r
,
u
,
a
,
i
,
j
,
m
,
o
,
rt
,
a7
,
a30
});
// 累加全国总数值
data
[
day
]
=
__init_or_plus__
(
data
[
day
],
{
r
,
rr
,
u
,
a
,
i
,
j
,
m
,
o
,
rt
,
a7
,
a30
});
// 累加全国总数值
data
[
day
][
"p"
][
prov_code
]
=
data
[
day
][
"p"
][
prov_code
]
||
Object
.
assign
(
__init_or_plus__
(
null
),{
'c'
:{}});
//如果day 下的 省份 不存在 则 初始化一个
data
[
day
][
"p"
][
prov_code
]
=
data
[
day
][
"p"
][
prov_code
]
||
Object
.
assign
(
__init_or_plus__
(
null
),{
'c'
:{}});
//如果day 下的 省份 不存在 则 初始化一个
data
[
day
][
"p"
][
prov_code
]
=
__init_or_plus__
(
data
[
day
][
"p"
][
prov_code
],
{
r
,
u
,
a
,
i
,
j
,
m
,
o
,
rt
,
a7
,
a30
});
//累加 prov_code 省份总数据
data
[
day
][
"p"
][
prov_code
]
=
__init_or_plus__
(
data
[
day
][
"p"
][
prov_code
],
{
r
,
u
,
rr
,
a
,
i
,
j
,
m
,
o
,
rt
,
a7
,
a30
});
//累加 prov_code 省份总数据
data
[
day
][
"p"
][
prov_code
][
"c"
][
city_code
]
=
{
u
,
r
,
a
,
i
,
j
,
m
,
o
,
rt
,
a7
,
a30
};
data
[
day
][
"p"
][
prov_code
][
"c"
][
city_code
]
=
{
u
,
r
,
rr
,
a
,
i
,
j
,
m
,
o
,
rt
,
a7
,
a30
};
}.
bind
(
this
)
}.
bind
(
this
)
);
);
return
{
data
,
date
};
return
{
data
,
date
};
...
...
app/schedule/update_cache_merchant.js
View file @
d795cca
...
@@ -123,6 +123,7 @@ class UpdateCacheMerchant extends Subscription {
...
@@ -123,6 +123,7 @@ class UpdateCacheMerchant extends Subscription {
MERCHANT_SUMMARY_30_DAY
,
MERCHANT_SUMMARY_30_DAY
,
data
data
);
);
cache_data_last_date_merchant
=
date
// 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'
)
...
...
app/service/screen/merchant.js
View file @
d795cca
...
@@ -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: 20
19-12-26 18:32:25
* @Last Modified time: 20
20-01-03 16:52:13
*/
*/
const
Service
=
require
(
"egg"
).
Service
;
const
Service
=
require
(
"egg"
).
Service
;
...
@@ -137,8 +137,17 @@ class MerchantService extends Service {
...
@@ -137,8 +137,17 @@ class MerchantService extends Service {
* @Description 商户渠道分布
* @Description 商户渠道分布
*/
*/
async
channel_stat
({
limit
})
{
async
channel_stat
({
limit
})
{
var
option
=
this
.
__build__option__
({
limit
,
order
:[[
"merchant_total"
,
"DESC"
]]});
const
{
col
,
fn
}
=
this
.
app
.
Sequelize
;
var
option
=
this
.
__build__option__
();
Object
.
assign
(
option
,
{
attributes
:
[
'channel'
,
[
fn
(
"SUM"
,
col
(
"merchant_total"
)),
"total"
],
],
group
:
'channel'
});
const
data
=
await
this
.
MCS
.
findAll
(
option
);
const
data
=
await
this
.
MCS
.
findAll
(
option
);
data
.
sort
((
a
,
b
)
=>
b
.
total
-
a
.
total
).
length
=
limit
return
data
;
return
data
;
}
}
...
@@ -146,17 +155,18 @@ class MerchantService extends Service {
...
@@ -146,17 +155,18 @@ class MerchantService extends Service {
* @param field {String}
* @param field {String}
* @param value {String}
* @param value {String}
* @return {Promise.<boolean>}
* @return {Promise.<boolean>}
* @Description 设备类型分布
* @Description
订购
设备类型分布
*/
*/
async
device_type
()
{
async
device_type
()
{
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_cod
e'
,
'
device_typ
e'
,
"device_type"
,
[
fn
(
"SUM"
,
col
(
"device_total"
)),
"total"
]
,
'device_total'
],
]
group
:
'device_type'
})
})
;
const
data
=
await
this
.
MODS
.
findAll
(
option
);
const
data
=
await
this
.
MODS
.
findAll
(
option
);
return
data
;
return
data
;
}
}
...
...
app/service/screen/user.js
View file @
d795cca
...
@@ -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: 20
19-12-25 10:44:44
* @Last Modified time: 20
20-01-03 18:15:00
*/
*/
const
Service
=
require
(
"egg"
).
Service
;
const
Service
=
require
(
"egg"
).
Service
;
...
@@ -176,6 +176,7 @@ class UserService extends Service {
...
@@ -176,6 +176,7 @@ class UserService extends Service {
'prov_code'
,
'prov_code'
,
"total_user"
,
"total_user"
,
'renew'
,
'renew'
,
'recent_renew'
,
'active'
,
'active'
,
'increase'
,
'increase'
,
'journey'
,
'journey'
,
...
...
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