Commit ead737c0 authored by wangzhengwen's avatar wangzhengwen

排序课程课时修改

parent f3b88cfd
......@@ -165,7 +165,7 @@ class Course extends BaseController
$query->where('user_id', $userId);
}])
->append(['tvtime_str'])
->order('sort', 'asc');
->order('sort', 'desc');
}]);
},
'getCourseClass' => function ($query) use ($userId) {
......@@ -175,7 +175,7 @@ class Course extends BaseController
$query->where('user_id', $userId);
}])
->append(['tvtime_str'])
->order('sort', 'asc');
->order('sort', 'desc');
}
])
->where('id', $data['course_id'])
......
......@@ -7,6 +7,7 @@ use app\api\service\UserService;
use app\api\service\UtilService;
use app\api\validate\CourseValidate;
use app\BaseController;
use app\model\CourseClass;
use app\model\Payment;
use think\facade\Request;
use app\api\service\CourseProgressService;
......@@ -89,31 +90,51 @@ class CourseProgress extends BaseController
*/
public function addUserWork()
{
$vo = (new CourseValidate())->goCheck(['course_id']);
if ($vo !== true) {
return $vo;
}
$userId = $this->request->userId;
$data = Request::only(['course_id']);
$userWork = CourseProgressService::addUserWork($userId, $data['course_id']);
return $this->returnMsg('操作成功',1,$userWork);
return $this->returnMsg('操作成功',1);
// $vo = (new CourseValidate())->goCheck(['course_id']);
// if ($vo !== true) {
// return $vo;
// }
//
// $userId = $this->request->userId;
// $data = Request::only(['course_id']);
//
// // 获取课程信息
// $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)) {
// return $this->returnMsg('课程未购买', 202);
// }
//
// $userWork = CourseProgressService::addUserWork($userId, $data['course_id']);
//
// return $this->returnMsg('操作成功',1,$userWork);
}
//视频播放
public function playVideo(Request $request)
{
// 参数验证
$vo = (new CourseValidate())->goCheck(['course_id']);
$vo = (new CourseValidate())->goCheck(['course_id','course_class_id']);
if ($vo !== true) {
return $vo;
}
$courseId = $request->param('course_id');
$userId = $request->userId;
$courseId = input('course_id');
$class_id = input('course_class_id');
$userId = $this->request->userId ?? 0;
// 获取课程信息
$course = CourseModel::where([
'id' => $courseId,
......@@ -125,14 +146,17 @@ class CourseProgress extends BaseController
if (!$course) {
return $this->returnMsg('课程不存在');
}
// 验证购买状态(1表示视频类型)
if ($course['price'] > 0 && !UtilService::checkPurchase($userId, $courseId, 1)) {
return $this->returnMsg('课程未购买', 202);
}
// 更新点击
// 更新播放
CourseModel::where('id', $courseId)->inc('tvclick')->update();
CourseClass::where('id', $class_id)->inc('tvclick')->update();
//添加作业
CourseProgressService::addUserWork($userId, $courseId);
return $this->returnMsg('操作成功', 1);
}
......
......@@ -19,7 +19,15 @@ class Project extends BaseController
$data = $request->param();
$list = (new ProjectCategory())->getProjectCategoryList(999,$data['is_tj'] ?? 1);
$list = (new ProjectCategory())->getProjectCategoryList();
return $this->returnMsg('success',1,$list);
}
//推荐项目列表
public function getProjectCategoryTjList(Request $request)
{
$list = (new ProjectCategory())->getProjectCategoryTjList();
return $this->returnMsg('success',1,$list);
}
......
......@@ -48,11 +48,11 @@ class CertCategory extends Model
$where[] = ['is_del', '=', 0];
return $this->with(['children' => function($query) use($where) {
$query->where($where);
$query->order('sort', 'asc');
$query->order('sort', 'desc');
}])
->where('pid', $pid)
->where($where)
->order('sort', 'asc')
->order('sort', 'desc')
->select();
}
......
......@@ -160,7 +160,7 @@ class Course extends Model
{
return $this->hasMany(CourseClassCategory::class, 'course_id','id')
->where('is_del',0)
->order('sort','asc')
->order('sort','desc')
->field('id,title,course_id');
}
......@@ -169,7 +169,7 @@ class Course extends Model
{
return $this->hasMany(\app\model\CourseClass::class, 'course_id','id')
->where('is_del',0)
->order('sort','asc');
->order('sort','desc');
}
//封面图
......
......@@ -56,11 +56,11 @@ class CourseCategory extends Model
$where[] = ['is_del', '=', 0];
return $this->with(['children' => function($query) use($where) {
$query->where($where);
$query->order('sort', 'asc');
$query->order('sort', 'desc');
}])
->where('pid', $pid)
->where($where)
->order('sort', 'asc')
->order('sort', 'desc')
->select();
}
......
......@@ -11,7 +11,7 @@ class CourseClassCategory extends Model
{
return $this->hasMany(\app\model\CourseClass::class, 'cate_id','id')
->where('is_del',0)
->order('sort','asc');
->order('sort','desc');
// ->field('id,title,cate_id');
}
}
\ No newline at end of file
......@@ -58,21 +58,28 @@ class ProjectCategory extends Model
->field('fileid,filename,filesize,fileurl,filetype,storage');
}
public function getProjectCategoryList($pid = 0,$is_tj = 0)
public function getProjectCategoryList($pid = 0)
{
return $this->with(['children' => function($query) {
$query->order('sort', 'desc');
$query->with(['thumb']);
},'thumb'])
->where('pid', $pid)
->order('sort', 'desc')
->select();
}
public function getProjectCategoryTjList()
{
$query = $this->with(['children' => function($query) {
$query->order('sort', 'asc');
$query->with(['thumb']);
},'thumb'])
->order('sort', 'asc')
->where('is_tj', $is_tj);
if ($pid!=999)
{
$query->where('pid', $pid);
}
$query->order('sort', 'desc');
$query->with(['thumb']);
},'thumb'])
->order('sort', 'desc');
$query->where('is_tj', 1);
return $query->select();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment