Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
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
方斌
51business
Commits
2dbbdcde
Commit
2dbbdcde
authored
Apr 21, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add categoryTip
parent
8db9062e
Pipeline
#21953
passed with stage
in 16 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
5 deletions
+118
-5
option.js
app/controller/course/v5/option.js
+13
-0
courseV5CategoryTip.js
app/model/class/v5/courseV5CategoryTip.js
+45
-0
course_v5.js
app/router/course_v5.js
+2
-1
option.js
app/service/course/v5/option.js
+58
-4
No files found.
app/controller/course/v5/option.js
View file @
2dbbdcde
...
...
@@ -54,6 +54,19 @@ class OptionController extends Controller {
const
ret
=
await
service
.
course
.
v5
.
option
.
addFeedback
(
params
);
ctx
.
success
(
ret
);
}
// 获取分类年龄提示
async
getCategoryTip
()
{
const
{
ctx
,
service
}
=
this
;
const
queryParams
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
queryParams
)
||
ctx
.
isEmpty
(
queryParams
.
cat_id
))
{
ctx
.
failed
(
'cat_id is empty'
);
}
const
ret
=
await
service
.
course
.
v5
.
option
.
getCategoryTip
(
queryParams
);
ctx
.
success
(
ret
);
}
}
module
.
exports
=
OptionController
;
app/model/class/v5/courseV5CategoryTip.js
0 → 100644
View file @
2dbbdcde
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseV5CategoryTip
=
app
.
classModel
.
define
(
'course_v5_category_tip'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
cat_id
:
INTEGER
,
content
:
STRING
,
advice
:
STRING
,
button_text
:
STRING
,
button_url
:
STRING
,
status
:
INTEGER
,
is_deleted
:
INTEGER
,
created_time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
updated_time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
},
{
timestamps
:
false
,
tableName
:
'course_v5_category_tip'
,
});
return
CourseV5CategoryTip
;
};
app/router/course_v5.js
View file @
2dbbdcde
...
...
@@ -12,13 +12,14 @@ module.exports = app => {
router
.
get
(
'third'
,
'/user/info'
,
auth
,
'course.v5.user.getUserInfo'
);
// 获取用户信息
router
.
post
(
'third'
,
'/user/baby'
,
auth
,
'course.v5.user.addUserBaby'
);
// 上传用户宝宝信息
router
.
get
(
'third'
,
'/category/all'
,
'course.v5.option.getCategoryList'
);
// 获取分类列表
router
.
get
(
'third'
,
'/category/all'
,
auth
,
'course.v5.option.getCategoryList'
);
// 获取分类列表
router
.
get
(
'third'
,
'/banner/all'
,
'course.v5.option.getBannerList'
);
// 获取banner列表
router
.
get
(
'third'
,
'/options'
,
'course.v5.option.getOptions'
);
// 获取配置项
router
.
post
(
'third'
,
'/wechat/qrcode'
,
'course.v5.wechat.getQRCode'
);
// 获取二维码
router
.
post
(
'third'
,
'/wechat/unlimited_code'
,
'course.v5.wechat.getUnlimitedCode'
);
// 获取小程序码
router
.
get
(
'third'
,
'/feedback/type'
,
'course.v5.option.getFeedbackTypeList'
);
// 获取反馈分类
router
.
post
(
'third'
,
'/feedback'
,
auth
,
'course.v5.option.addFeedback'
);
// 反馈
router
.
get
(
'third'
,
'/category/tip'
,
auth
,
'course.v5.option.getCategoryTip'
);
// 获取分类提示(年龄不符合)
router
.
get
(
'third'
,
'/class/all'
,
auth
,
'course.v5.institution.getClassList'
);
// 获取课程列表
router
.
get
(
'third'
,
'/class/:class_id'
,
auth
,
'course.v5.institution.getClassInfo'
);
// 获取课程详情
...
...
app/service/course/v5/option.js
View file @
2dbbdcde
...
...
@@ -11,13 +11,21 @@ const MODE = [
value
:
1
,
},
{
id
:
2
,
name
:
'录播'
,
name
:
'录播
(动画)
'
,
value
:
2
,
},
{
id
:
3
,
name
:
'
直播+回放
'
,
name
:
'
录播(真人)
'
,
value
:
3
,
},
{
id
:
4
,
name
:
'APP'
,
value
:
4
,
},
{
id
:
5
,
name
:
'小程序'
,
value
:
5
,
},
{
id
:
0
,
name
:
'全部'
,
value
:
0
,
...
...
@@ -27,11 +35,11 @@ const MODE = [
const
PRICE_TYPE
=
[
{
id
:
1
,
name
:
'
低价体验
课'
,
name
:
'
免费公益
课'
,
value
:
1
,
},
{
id
:
2
,
name
:
'
公益免费
课'
,
name
:
'
低价体验
课'
,
value
:
2
,
},
{
id
:
3
,
...
...
@@ -125,6 +133,24 @@ class OptionService extends Service {
const
categoryList
=
await
ctx
.
classModel
.
V5
.
CourseV5Category
.
findAll
(
filter
);
const
filterIds
=
[];
// 智能选课要判断年龄
if
(
type
===
3
)
{
const
userBabyInfo
=
await
ctx
.
classModel
.
V5
.
CourseV5UserBaby
.
findOne
({
where
:
{
user_uuid
:
ctx
.
userUuid
,
status
:
1
,
is_deleted
:
0
}
});
if
(
!
ctx
.
isEmpty
(
userBabyInfo
))
{
switch
(
userBabyInfo
.
baby_age
)
{
case
1
:
filterIds
.
push
(
17
);
break
;
case
2
:
filterIds
.
push
(
17
);
break
;
default
:
break
;
}
}
}
const
results
=
[];
for
(
const
v
of
categoryList
)
{
results
.
push
({
...
...
@@ -136,6 +162,7 @@ class OptionService extends Service {
unselected_icon
:
v
.
unselected_icon
,
is_open
:
v
.
is_open
,
url
:
v
.
url
,
is_valid
:
filterIds
.
includes
(
v
.
id
)
?
0
:
1
,
sort
:
v
.
sort
,
});
}
...
...
@@ -181,6 +208,33 @@ class OptionService extends Service {
return
{
result
:
true
};
}
// 获取分类提示(年龄不符合)
async
getCategoryTip
(
input
)
{
const
{
ctx
}
=
this
;
const
catId
=
Number
(
input
.
cat_id
)
||
0
;
const
tip
=
await
ctx
.
classModel
.
V5
.
CourseV5CategoryTip
.
findOne
({
where
:
{
cat_id
:
catId
,
status
:
1
,
is_deleted
:
0
}
});
if
(
ctx
.
isEmpty
(
tip
))
{
return
{};
}
const
category
=
await
ctx
.
classModel
.
V5
.
CourseV5Category
.
findOne
({
where
:
{
id
:
catId
},
attributes
:
[
'name'
]
});
const
userBabyInfo
=
await
ctx
.
classModel
.
V5
.
CourseV5UserBaby
.
findOne
({
where
:
{
user_uuid
:
ctx
.
userUuid
,
status
:
1
,
is_deleted
:
0
}
});
let
age
=
ctx
.
isEmpty
(
userBabyInfo
)
?
0
:
userBabyInfo
.
baby_age
;
age
=
await
ctx
.
classModel
.
V5
.
CourseV5Age
.
findOne
({
where
:
{
id
:
age
},
attributes
:
[
'name'
]
});
age
=
ctx
.
isEmpty
(
age
)
?
''
:
age
.
name
;
const
ret
=
ctx
.
isEmpty
(
tip
)
?
{}
:
{
id
:
tip
.
id
,
category
:
ctx
.
isEmpty
(
category
)
?
''
:
category
.
name
,
content
:
`您的孩子当前处于【
${
age
}
】阶段,`
+
tip
.
content
,
advice
:
tip
.
advice
,
button_text
:
tip
.
button_text
,
button_url
:
tip
.
button_url
,
};
return
ret
;
}
}
module
.
exports
=
OptionService
;
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