Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projecttwo
Project
Project
Details
Activity
Releases
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
wangtao
projecttwo
Commits
bd67e1a2
Commit
bd67e1a2
authored
Jun 16, 2025
by
wangzhengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
作业我的课程修改
parent
ceaa7084
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
41 deletions
+65
-41
CourseProgress.php
app/api/controller/CourseProgress.php
+48
-31
CourseProgressService.php
app/api/service/CourseProgressService.php
+6
-1
UtilService.php
app/api/service/UtilService.php
+10
-9
AdvertCate.php
app/model/project/AdvertCate.php
+1
-0
No files found.
app/api/controller/CourseProgress.php
View file @
bd67e1a2
...
@@ -35,6 +35,23 @@ class CourseProgress extends BaseController
...
@@ -35,6 +35,23 @@ class CourseProgress extends BaseController
$data
=
Request
::
only
([
'course_id'
,
'class_id'
,
'current_time'
]);
$data
=
Request
::
only
([
'course_id'
,
'class_id'
,
'current_time'
]);
$userId
=
$this
->
request
->
userId
;
$userId
=
$this
->
request
->
userId
;
// 获取课程信息
$course
=
CourseModel
::
where
([
'id'
=>
$data
[
'course_id'
],
'status'
=>
3
,
'is_sell'
=>
1
,
'is_del'
=>
0
])
->
find
();
if
(
!
$course
)
{
return
$this
->
returnMsg
(
'课程不存在'
);
}
// 验证购买状态(1表示视频类型)添加作业不验证试看
if
(
$course
[
'price'
]
>
0
&&
!
UtilService
::
checkPurchase
(
$userId
,
$data
[
'course_id'
],
1
,
0
))
{
return
$this
->
returnMsg
(
'操作成功'
,
1
);
}
$result
=
CourseProgressService
::
updateProgress
(
$result
=
CourseProgressService
::
updateProgress
(
$userId
,
$userId
,
$data
[
'course_id'
],
$data
[
'course_id'
],
...
@@ -91,36 +108,36 @@ class CourseProgress extends BaseController
...
@@ -91,36 +108,36 @@ class CourseProgress extends BaseController
public
function
addUserWork
()
public
function
addUserWork
()
{
{
return
$this
->
returnMsg
(
'操作成功'
,
1
);
//
return $this->returnMsg('操作成功',1);
//
$vo = (new CourseValidate())->goCheck(['course_id']);
$vo
=
(
new
CourseValidate
())
->
goCheck
([
'course_id'
]);
//
if ($vo !== true) {
if
(
$vo
!==
true
)
{
//
return $vo;
return
$vo
;
//
}
}
//
//
$userId = $this->request->userId;
$userId
=
$this
->
request
->
userId
;
//
$data = Request::only(['course_id']);
$data
=
Request
::
only
([
'course_id'
]);
//
//
// 获取课程信息
// 获取课程信息
//
$course = CourseModel::where([
$course
=
CourseModel
::
where
([
//
'id' => $data['course_id'],
'id'
=>
$data
[
'course_id'
],
//
'status' => 3,
'status'
=>
3
,
//
'is_sell' => 1,
'is_sell'
=>
1
,
//
'is_del' => 0
'is_del'
=>
0
//
])->find();
])
->
find
();
//
//
if (!$course) {
if
(
!
$course
)
{
//
return $this->returnMsg('课程不存在');
return
$this
->
returnMsg
(
'课程不存在'
);
//
}
}
//
// // 验证购买状态(1表示视频类型)
// 验证购买状态(1表示视频类型)添加作业不验证试看
// if ($course['price'] > 0 && !UtilService::checkPurchase($userId, $data['course_id'], 1
)) {
if
(
$course
[
'price'
]
>
0
&&
!
UtilService
::
checkPurchase
(
$userId
,
$data
[
'course_id'
],
1
,
0
))
{
// return $this->returnMsg('课程未购买', 202
);
return
$this
->
returnMsg
(
'操作成功'
,
1
);
//
}
}
//
//
$userWork = CourseProgressService::addUserWork($userId, $data['course_id']);
$userWork
=
CourseProgressService
::
addUserWork
(
$userId
,
$data
[
'course_id'
]);
//
//
return $this->returnMsg('操作成功',1,$userWork);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$userWork
);
}
}
//视频播放
//视频播放
...
@@ -156,7 +173,7 @@ class CourseProgress extends BaseController
...
@@ -156,7 +173,7 @@ class CourseProgress extends BaseController
CourseClass
::
where
(
'id'
,
$class_id
)
->
inc
(
'tvclick'
)
->
update
();
CourseClass
::
where
(
'id'
,
$class_id
)
->
inc
(
'tvclick'
)
->
update
();
//添加作业
//添加作业
CourseProgressService
::
addUserWork
(
$userId
,
$courseId
);
//
CourseProgressService::addUserWork($userId, $courseId);
return
$this
->
returnMsg
(
'操作成功'
,
1
);
return
$this
->
returnMsg
(
'操作成功'
,
1
);
}
}
...
...
app/api/service/CourseProgressService.php
View file @
bd67e1a2
...
@@ -6,6 +6,7 @@ use app\model\CourseClass;
...
@@ -6,6 +6,7 @@ use app\model\CourseClass;
use
app\model\CourseProgress
;
use
app\model\CourseProgress
;
use
app\model\CourseUserWork
;
use
app\model\CourseUserWork
;
use
app\model\CourseWork
;
use
app\model\CourseWork
;
use
app\model\Payment
;
class
CourseProgressService
class
CourseProgressService
{
{
...
@@ -95,8 +96,9 @@ class CourseProgressService
...
@@ -95,8 +96,9 @@ class CourseProgressService
{
{
$workIds
=
CourseWork
::
where
([
$workIds
=
CourseWork
::
where
([
'user_id'
=>
$userId
,
//
'user_id' => $userId,
'course_id'
=>
$courseId
,
'course_id'
=>
$courseId
,
'is_del'
=>
0
])
->
column
(
'id'
);
])
->
column
(
'id'
);
if
(
empty
(
$workIds
))
{
if
(
empty
(
$workIds
))
{
...
@@ -140,6 +142,9 @@ class CourseProgressService
...
@@ -140,6 +142,9 @@ class CourseProgressService
$courseIds
=
CourseProgress
::
where
(
'user_id'
,
$userId
)
$courseIds
=
CourseProgress
::
where
(
'user_id'
,
$userId
)
->
distinct
(
true
)
->
distinct
(
true
)
->
column
(
'course_id'
);
->
column
(
'course_id'
);
//获取所有已购买的课程id
$buyCourseIds
=
Payment
::
where
([
'user_id'
=>
$userId
,
'pay_status'
=>
1
,
'order_type'
=>
1
])
->
column
(
'order_id'
);
$courseIds
=
array_unique
(
array_merge
(
$courseIds
,
$buyCourseIds
));
// 如果没有学习记录,返回空分页
// 如果没有学习记录,返回空分页
if
(
empty
(
$courseIds
))
{
if
(
empty
(
$courseIds
))
{
...
...
app/api/service/UtilService.php
View file @
bd67e1a2
...
@@ -107,14 +107,15 @@ class UtilService
...
@@ -107,14 +107,15 @@ class UtilService
* @param int $userId 用户ID
* @param int $userId 用户ID
* @param int $productId 产品ID
* @param int $productId 产品ID
* @param int $orderType 订单类型(1:视频 2:证书)
* @param int $orderType 订单类型(1:视频 2:证书)
* @param int $isCheckSk 验证试看(0:不验证 1:验证) 添加作业,上报进度不验证
*/
*/
public
static
function
checkPurchase
(
$userId
,
$productId
,
$orderType
)
public
static
function
checkPurchase
(
$userId
,
$productId
,
$orderType
,
$isCheckSk
=
1
)
{
{
//如果是课程课时存在试看的情况下
//如果是课程课时存在试看的情况下
if
(
$orderType
==
1
)
if
(
$orderType
==
1
and
$isCheckSk
==
1
)
{
{
$course_class_id
=
input
(
'course_class'
);
// 尝试从多个可能的参数名获取课时ID
$course_class_id
=
input
(
'course_class'
,
input
(
'class_id'
,
0
));
// 后备参数名
if
(
$course_class_id
)
if
(
$course_class_id
)
{
{
$is_sk
=
CourseClass
::
where
([
'course_id'
=>
$productId
,
'id'
=>
$course_class_id
])
->
value
(
'is_sk'
);
$is_sk
=
CourseClass
::
where
([
'course_id'
=>
$productId
,
'id'
=>
$course_class_id
])
->
value
(
'is_sk'
);
...
@@ -126,10 +127,10 @@ class UtilService
...
@@ -126,10 +127,10 @@ class UtilService
}
}
return
Payment
::
where
([
return
Payment
::
where
([
'user_id'
=>
$userId
,
'user_id'
=>
$userId
,
'order_type'
=>
$orderType
,
'order_type'
=>
$orderType
,
'pay_status'
=>
1
,
'pay_status'
=>
1
,
'order_id'
=>
$productId
'order_id'
=>
$productId
])
->
count
();
])
->
count
();
}
}
}
}
\ No newline at end of file
app/model/project/AdvertCate.php
View file @
bd67e1a2
...
@@ -18,6 +18,7 @@ class AdvertCate extends Model
...
@@ -18,6 +18,7 @@ class AdvertCate extends Model
{
{
return
$this
->
hasMany
(
Advert
::
class
,
'p_id'
,
'id'
)
return
$this
->
hasMany
(
Advert
::
class
,
'p_id'
,
'id'
)
->
where
(
'is_del'
,
0
)
->
where
(
'is_del'
,
0
)
->
where
(
'is_show'
,
1
)
->
field
(
'id,name,type,url,p_id,url,cover_img_id'
)
->
field
(
'id,name,type,url,p_id,url,cover_img_id'
)
->
order
(
'sort desc'
);
->
order
(
'sort desc'
);
}
}
...
...
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