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
fcbb2da5
Commit
fcbb2da5
authored
Jun 08, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add userVideo && more buttonInfo
parent
abe11f25
Pipeline
#24625
passed with stage
in 4 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
4 deletions
+71
-4
test.js
app/controller/common/test.js
+1
-1
courseV5Class.js
app/model/class/v5/courseV5Class.js
+2
-0
courseV5UserVideo.js
app/model/class/v5/courseV5UserVideo.js
+41
-0
institution.js
app/service/course/v5/institution.js
+27
-3
No files found.
app/controller/common/test.js
View file @
fcbb2da5
...
...
@@ -4,7 +4,7 @@ const xml2js = require('xml2js');
const
Controller
=
require
(
'egg'
).
Controller
;
class
TestController
extends
Controller
{
async
test
()
{
const
ret
=
await
this
.
service
.
course
.
v5
.
wechat
.
pay
({}
);
const
ret
=
await
this
.
service
.
course
.
v5
.
wechat
.
sendTest
(
'这是一条测试'
);
this
.
ctx
.
success
(
ret
);
}
}
...
...
app/model/class/v5/courseV5Class.js
View file @
fcbb2da5
...
...
@@ -29,6 +29,8 @@ module.exports = app => {
button_text
:
STRING
,
button_type
:
INTEGER
,
button_sub_text
:
STRING
,
button_url
:
STRING
,
button_pay_text
:
STRING
,
top_price
:
STRING
,
pay_price
:
DECIMAL
,
sort
:
INTEGER
,
...
...
app/model/class/v5/courseV5UserVideo.js
0 → 100644
View file @
fcbb2da5
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseV5UserVideo
=
app
.
classModel
.
define
(
'course_v5_user_video'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
user_uuid
:
STRING
,
class_id
:
INTEGER
,
video_id
:
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_user_video'
,
});
return
CourseV5UserVideo
;
};
app/service/course/v5/institution.js
View file @
fcbb2da5
...
...
@@ -99,7 +99,7 @@ class InstitutionSubService extends Service {
// 课程详情
async
getClassInfo
(
id
)
{
const
{
ctx
}
=
this
;
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'logo'
,
'age'
,
'price'
,
'price_type'
,
'mode'
,
'time'
,
'class_amount'
,
'multi_classes'
,
'cycle'
,
'description'
,
'button_style'
,
'button_text'
,
'button_type'
,
'button_sub_text'
,
'top_price'
,
'pay_price'
,
'sort'
];
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'logo'
,
'age'
,
'price'
,
'price_type'
,
'mode'
,
'time'
,
'class_amount'
,
'multi_classes'
,
'cycle'
,
'description'
,
'button_style'
,
'button_text'
,
'button_type'
,
'button_sub_text'
,
'
button_url'
,
'button_pay_text'
,
'
top_price'
,
'pay_price'
,
'sort'
];
const
classInfo
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findOne
({
where
:
{
id
,
status
:
1
,
is_deleted
:
0
},
attributes
,
raw
:
true
});
if
(
ctx
.
isEmpty
(
classInfo
))
{
ctx
.
failed
(
'数据不存在'
);
...
...
@@ -159,6 +159,10 @@ class InstitutionSubService extends Service {
}
classInfo
.
columns
=
columns
;
// 是否已购买
const
userOrder
=
ctx
.
isEmpty
(
ctx
.
userUuid
)
?
{}
:
await
ctx
.
classModel
.
V5
.
CourseUserOrder
.
findOne
({
where
:
{
user_uuid
:
ctx
.
userUuid
,
class_id
:
id
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
]
});
classInfo
.
is_bought
=
ctx
.
isEmpty
(
userOrder
)
?
0
:
1
;
classInfo
.
price_type
=
await
this
.
getClassPriceType
(
classInfo
.
price_type
);
classInfo
.
mode
=
await
this
.
getClassMode
(
classInfo
.
mode
);
classInfo
.
student_works
=
studentWorks
;
...
...
@@ -386,10 +390,22 @@ class InstitutionSubService extends Service {
async
getVideoList
(
input
)
{
const
{
ctx
}
=
this
;
const
classId
=
input
.
class_id
||
0
;
const
userUuid
=
ctx
.
userUuid
;
const
videoList
=
await
ctx
.
classModel
.
V5
.
CourseV5Video
.
findAll
({
where
:
{
class_id
:
classId
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'class_id'
,
'title'
,
'time'
,
'cover_image'
,
'is_free'
],
order
:
[[
'sort'
,
'asc'
]]
});
let
latestVideoId
=
0
;
let
valid
=
0
;
if
(
!
ctx
.
isEmpty
(
userUuid
))
{
const
userVideo
=
await
ctx
.
classModel
.
V5
.
CourseUserVideo
.
findOne
({
where
:
{
user_uuid
:
userUuid
,
class_id
:
classId
}
});
latestVideoId
=
ctx
.
isEmpty
(
userVideo
)
?
0
:
userVideo
.
video_id
;
const
userOrder
=
await
ctx
.
classModel
.
V5
.
CourseUserOrder
.
findOne
({
where
:
{
user_uuid
:
userUuid
,
class_id
:
classId
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
]
});
valid
=
ctx
.
isEmpty
(
userOrder
)
?
0
:
1
;
}
for
(
const
i
in
videoList
)
{
videoList
[
i
].
is_latest
=
0
;
videoList
[
i
].
is_latest
=
videoList
[
i
].
id
===
latestVideoId
?
1
:
0
;
videoList
[
i
].
valid
=
videoList
[
i
].
is_free
===
1
?
1
:
valid
;
}
const
ret
=
{
list
:
videoList
,
...
...
@@ -419,6 +435,14 @@ class InstitutionSubService extends Service {
}
}
// 更新最新播放
const
userVideo
=
await
ctx
.
classModel
.
V5
.
CourseUserVideo
.
findOne
({
where
:
{
user_uuid
:
userUuid
,
class_id
:
video
.
class_id
}
});
if
(
ctx
.
isEmpty
(
userVideo
))
{
await
ctx
.
classModel
.
V5
.
CourseUserVideo
.
create
({
user_uuid
:
userUuid
,
class_id
:
video
.
class_id
,
video_id
:
video
.
id
});
}
else
{
await
ctx
.
classModel
.
V5
.
CourseUserVideo
.
update
({
video_id
:
video
.
id
},
{
where
:
{
id
:
userVideo
.
id
}
});
}
const
ret
=
{
id
:
video
.
id
,
class_id
:
video
.
class_id
,
...
...
@@ -427,7 +451,7 @@ class InstitutionSubService extends Service {
cover_image
:
video
.
cover_image
,
url
:
video
.
url
,
is_free
:
video
.
is_free
,
is_latest
:
0
,
is_latest
:
1
,
};
return
ret
;
...
...
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