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 e1885f9c
authored
Dec 12, 2019
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改问题
1 parent
9595019e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
31 deletions
app/controller/screen/user.js
app/extend/helper.js
app/model/t_user_new_active_detail.js
app/service/screen/user.js
app/controller/screen/user.js
View file @
e1885f9
...
@@ -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: 2019-12-12 1
1:10:21
* @Last Modified time: 2019-12-12 1
5:57:29
*/
*/
"use strict"
;
"use strict"
;
...
@@ -203,12 +203,12 @@ class UserController extends Controller {
...
@@ -203,12 +203,12 @@ class UserController extends Controller {
const
{
yesterday
}
=
await
this
.
_fetch_date_in_cache_
();
const
{
yesterday
}
=
await
this
.
_fetch_date_in_cache_
();
//近7天所有
//近7天所有
const
{
i
:
increased7
,
a
:
nLive7
}
=
await
this
.
_fetch_total_by_range_
({
pid
,
cid
,
field
:[
'i'
,
'a'
],
beginDate
:
beginDate7
,
endDate
:
yesterday
});
const
{
i
:
increased7
,
a
:
nLive7
}
=
await
this
.
_fetch_total_by_range_
({
pid
,
cid
,
field
:[
'i'
,
'a'
],
beginDate
:
beginDate7
,
endDate
:
yesterday
});
// 近七天 用户活跃度 (近7天 活跃用户数 /
近7天新增
用户数)
// 近七天 用户活跃度 (近7天 活跃用户数 /
昨天
用户数)
const
live7
=
this
.
helper
.
percent
(
nLive7
,
increased7
);
const
live7
=
this
.
helper
.
percent
(
nLive7
,
u
);
//近30天所有
//近30天所有
const
{
i
:
increased30
,
a
:
nLive30
}
=
await
this
.
_fetch_total_by_range_
({
pid
,
cid
,
field
:[
'i'
,
'a'
]});
const
{
i
:
increased30
,
a
:
nLive30
}
=
await
this
.
_fetch_total_by_range_
({
pid
,
cid
,
field
:[
'i'
,
'a'
]});
// 近30天 用户活跃度 (近30天 活跃用户数 /
近30天新增
用户数)
// 近30天 用户活跃度 (近30天 活跃用户数 /
昨天
用户数)
const
live30
=
this
.
helper
.
percent
(
nLive30
,
increased30
);
const
live30
=
this
.
helper
.
percent
(
nLive30
,
u
);
const
data
=
{
increased7
,
live7
,
increased30
,
live30
,
renew
};
const
data
=
{
increased7
,
live7
,
increased30
,
live30
,
renew
};
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
this
.
ctx
.
body
=
this
.
ServerResponse
.
Success
(
data
);
}
}
...
...
app/extend/helper.js
View file @
e1885f9
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: limin
* @Author: limin
* @Date: 2019-11-21 11:19:43
* @Date: 2019-11-21 11:19:43
* @Last Modified by: limin
* @Last Modified by: limin
* @Last Modified time: 2019-12-
07 13:35:15
* @Last Modified time: 2019-12-
12 15:10:54
*/
*/
const
moment
=
require
(
"moment"
);
const
moment
=
require
(
"moment"
);
...
@@ -104,7 +104,8 @@ exports.seq_option = function({
...
@@ -104,7 +104,8 @@ exports.seq_option = function({
};
};
}
}
const
option
=
{
const
option
=
{
where
where
,
raw
:
true
};
};
if
(
limit
)
{
if
(
limit
)
{
option
.
limit
=
+
limit
;
option
.
limit
=
+
limit
;
...
...
app/model/t_user_new_active_detail.js
0 → 100644
View file @
e1885f9
/* indent size: 2 */
module
.
exports
=
app
=>
{
const
DataTypes
=
app
.
Sequelize
;
const
Model
=
app
.
model
.
define
(
't_user_new_active_detail'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
(
10
),
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
},
sn
:
{
type
:
DataTypes
.
STRING
(
32
),
allowNull
:
false
},
active_time
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
false
},
prov_code
:
{
type
:
DataTypes
.
STRING
(
32
),
allowNull
:
false
},
city_code
:
{
type
:
DataTypes
.
STRING
(
32
),
allowNull
:
false
},
device_type
:
{
type
:
DataTypes
.
STRING
(
32
),
allowNull
:
false
},
create_time
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
},
update_time
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
}
},
{
tableName
:
't_user_new_active_detail'
});
Model
.
associate
=
function
()
{
}
return
Model
;
};
app/service/screen/user.js
View file @
e1885f9
...
@@ -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: 2019-12-12 1
1:09:12
* @Last Modified time: 2019-12-12 1
6:04:48
*/
*/
const
Service
=
require
(
"egg"
).
Service
;
const
Service
=
require
(
"egg"
).
Service
;
...
@@ -24,6 +24,7 @@ class UserService extends Service {
...
@@ -24,6 +24,7 @@ class UserService extends Service {
TUserCityDaily
,
TUserCityDaily
,
TUserCityDriveInfo
,
TUserCityDriveInfo
,
TUserCityRealtime
,
TUserCityRealtime
,
TUserNewActiveDetail
,
TProvince
,
TProvince
,
TCity
TCity
}
=
this
.
app
.
model
;
}
=
this
.
app
.
model
;
...
@@ -32,6 +33,7 @@ class UserService extends Service {
...
@@ -32,6 +33,7 @@ class UserService extends Service {
this
.
MUserCarBrand
=
TUserCityCarbrand
;
this
.
MUserCarBrand
=
TUserCityCarbrand
;
this
.
MUserDaily
=
TUserCityDaily
;
this
.
MUserDaily
=
TUserCityDaily
;
this
.
MUserDriveInfo
=
TUserCityDriveInfo
;
this
.
MUserDriveInfo
=
TUserCityDriveInfo
;
this
.
MUserActive
=
TUserNewActiveDetail
;
this
.
MProvice
=
TProvince
;
this
.
MProvice
=
TProvince
;
this
.
MCity
=
TCity
;
this
.
MCity
=
TCity
;
}
}
...
@@ -56,6 +58,14 @@ class UserService extends Service {
...
@@ -56,6 +58,14 @@ class UserService extends Service {
foreignKey
:
"city_code"
,
foreignKey
:
"city_code"
,
targetKey
:
"city_code"
targetKey
:
"city_code"
});
});
this
.
MUserActive
.
belongsTo
(
this
.
MProvice
,
{
foreignKey
:
"prov_code"
,
targetKey
:
"prov_code"
});
this
.
MUserActive
.
belongsTo
(
this
.
MCity
,
{
foreignKey
:
"city_code"
,
targetKey
:
"city_code"
});
}
}
/**
/**
...
@@ -66,7 +76,7 @@ class UserService extends Service {
...
@@ -66,7 +76,7 @@ class UserService extends Service {
*/
*/
async
city_range
({
pid
,
limit
})
{
async
city_range
({
pid
,
limit
})
{
const
{
app
,
helper
,
MCity
,
MUserDaily
}
=
this
;
const
{
app
,
helper
,
MCity
,
MUserDaily
}
=
this
;
const
{
col
}
=
app
.
Sequelize
;
const
{
col
,
fn
,
Op
}
=
app
.
Sequelize
;
const
option
=
helper
.
seq_option
({
const
option
=
helper
.
seq_option
({
pid
,
pid
,
limit
,
limit
,
...
@@ -75,11 +85,17 @@ class UserService extends Service {
...
@@ -75,11 +85,17 @@ class UserService extends Service {
Object
.
assign
(
option
,
{
Object
.
assign
(
option
,
{
attributes
:
[
attributes
:
[
col
(
"total_user"
,
'total'
),
'city_code'
,
[
fn
(
"SUM"
,
col
(
"total_user"
)),
"total"
],
col
(
"t_city.city_name"
,
'city'
)
col
(
"t_city.city_name"
,
'city'
)
],
],
include
:
{
model
:
MCity
,
attributes
:
[]
},
include
:
{
model
:
MCity
,
attributes
:
[]
},
raw
:
true
group
:
'city_code'
,
where
:{
city_code
:{
[
Op
.
gt
]:
0
,
}
}
});
});
const
data
=
await
MUserDaily
.
findAll
(
option
);
const
data
=
await
MUserDaily
.
findAll
(
option
);
return
data
;
return
data
;
...
@@ -106,8 +122,7 @@ class UserService extends Service {
...
@@ -106,8 +122,7 @@ class UserService extends Service {
[
fn
(
"SUM"
,
col
(
"brand_cars"
)),
"total"
],
[
fn
(
"SUM"
,
col
(
"brand_cars"
)),
"total"
],
col
(
"update_time"
,
'date'
)
col
(
"update_time"
,
'date'
)
],
],
group
:
'brand_name'
,
group
:
'brand_name'
raw
:
true
});
});
const
data
=
await
MUserCarBrand
.
findAll
(
option
);
const
data
=
await
MUserCarBrand
.
findAll
(
option
);
return
data
;
return
data
;
...
@@ -140,8 +155,7 @@ class UserService extends Service {
...
@@ -140,8 +155,7 @@ class UserService extends Service {
[
fn
(
"SUM"
,
col
(
"w_20_30"
)),
'w_20_30'
],
[
fn
(
"SUM"
,
col
(
"w_20_30"
)),
'w_20_30'
],
[
fn
(
"SUM"
,
col
(
"w_30_50"
)),
'w_30_50'
],
[
fn
(
"SUM"
,
col
(
"w_30_50"
)),
'w_30_50'
],
[
fn
(
"SUM"
,
col
(
"w_50_"
)),
'w_50_'
]
[
fn
(
"SUM"
,
col
(
"w_50_"
)),
'w_50_'
]
],
]
raw
:
true
});
});
const
data
=
await
MUserDriveInfo
.
findAll
(
option
);
const
data
=
await
MUserDriveInfo
.
findAll
(
option
);
return
data
;
return
data
;
...
@@ -172,8 +186,7 @@ class UserService extends Service {
...
@@ -172,8 +186,7 @@ class UserService extends Service {
col
(
"t_city.city_name"
),
col
(
"t_city.city_name"
),
col
(
"t_province.prov_name"
)
col
(
"t_province.prov_name"
)
],
],
include
:
[{
model
:
MCity
,
attributes
:
[]
},{
model
:
MProvice
,
attributes
:
[]}],
include
:
[{
model
:
MCity
,
attributes
:
[]
},{
model
:
MProvice
,
attributes
:
[]}]
raw
:
true
});
});
const
data
=
await
MUserCity
.
findAll
(
option
);
const
data
=
await
MUserCity
.
findAll
(
option
);
return
data
;
return
data
;
...
@@ -201,8 +214,7 @@ class UserService extends Service {
...
@@ -201,8 +214,7 @@ class UserService extends Service {
col
(
"t_city.city_name"
),
col
(
"t_city.city_name"
),
col
(
"t_province.prov_name"
)
col
(
"t_province.prov_name"
)
],
],
include
:
[{
model
:
MCity
,
attributes
:
[]
},{
model
:
MProvice
,
attributes
:
[]}],
include
:
[{
model
:
MCity
,
attributes
:
[]
},{
model
:
MProvice
,
attributes
:
[]}]
raw
:
true
});
});
const
data
=
await
MUserRealTime
.
findAll
(
option
);
const
data
=
await
MUserRealTime
.
findAll
(
option
);
return
data
;
return
data
;
...
@@ -225,8 +237,7 @@ class UserService extends Service {
...
@@ -225,8 +237,7 @@ class UserService extends Service {
[
fn
(
"SUM"
,
col
(
"male"
)),
"male"
],
[
fn
(
"SUM"
,
col
(
"male"
)),
"male"
],
[
fn
(
"SUM"
,
col
(
"female"
)),
"female"
]
[
fn
(
"SUM"
,
col
(
"female"
)),
"female"
]
],
],
group
:
'gender_range'
,
group
:
'gender_range'
raw
:
true
});
});
const
data
=
await
MUserGender
.
findAll
(
option
);
const
data
=
await
MUserGender
.
findAll
(
option
);
return
data
;
return
data
;
...
@@ -239,7 +250,7 @@ class UserService extends Service {
...
@@ -239,7 +250,7 @@ class UserService extends Service {
* @Description 获取用户性别年龄数量占比
* @Description 获取用户性别年龄数量占比
*/
*/
async
activation
({
pid
,
limit
,
last_id
})
{
async
activation
({
pid
,
limit
,
last_id
})
{
const
{
app
,
helper
,
MUser
Gender
}
=
this
;
const
{
app
,
helper
,
MUser
Active
}
=
this
;
const
{
Op
}
=
app
.
Sequelize
const
{
Op
}
=
app
.
Sequelize
var
option
=
helper
.
seq_option
({
pid
,
limit
});
var
option
=
helper
.
seq_option
({
pid
,
limit
});
Object
.
assign
(
option
.
where
,{
Object
.
assign
(
option
.
where
,{
...
@@ -247,10 +258,7 @@ class UserService extends Service {
...
@@ -247,10 +258,7 @@ class UserService extends Service {
[
Op
.
gt
]:
last_id
,
[
Op
.
gt
]:
last_id
,
}
}
})
})
Object
.
assign
(
option
,
{
const
data
=
await
MUserActive
.
findAll
(
option
);
raw
:
true
});
const
data
=
await
MUserGender
.
findAll
(
option
);
return
data
;
return
data
;
}
}
...
@@ -261,19 +269,27 @@ class UserService extends Service {
...
@@ -261,19 +269,27 @@ class UserService extends Service {
* @Description 获取每个省的用户数
* @Description 获取每个省的用户数
*/
*/
async
total_group_by_province
({
pid
})
{
async
total_group_by_province
({
pid
})
{
const
{
app
,
helper
,
MUserDaily
,
MProvice
}
=
this
;
const
{
app
,
helper
,
MUserDaily
,
MProvice
,
MCity
}
=
this
;
var
option
=
helper
.
seq_option
({
pid
});
var
option
=
helper
.
seq_option
({
pid
});
const
{
fn
,
col
}
=
app
.
Sequelize
;
const
{
fn
,
col
}
=
app
.
Sequelize
;
Object
.
assign
(
option
,
{
const
_opt
=
pid
?
{
attributes
:
[
'city_code'
,
[
fn
(
"SUM"
,
col
(
"total_user"
)),
"total_user"
],
col
(
"t_city.city_name"
),
],
include
:
[{
model
:
MCity
,
attributes
:
[]}],
group
:
'city_code'
}:{
attributes
:
[
attributes
:
[
'prov_code'
,
'prov_code'
,
[
fn
(
"SUM"
,
col
(
"total_user"
)),
"total_user"
],
[
fn
(
"SUM"
,
col
(
"total_user"
)),
"total_user"
],
col
(
"t_province.prov_name"
)
col
(
"t_province.prov_name"
)
],
],
include
:
[{
model
:
MProvice
,
attributes
:
[]}],
include
:
[{
model
:
MProvice
,
attributes
:
[]}],
group
:
'prov_code'
,
group
:
'prov_code'
raw
:
true
}
});
Object
.
assign
(
option
,
_opt
)
const
data
=
await
MUserDaily
.
findAll
(
option
);
const
data
=
await
MUserDaily
.
findAll
(
option
);
return
data
;
return
data
;
}
}
...
...
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