Commit b204303f authored by wangzhengwen's avatar wangzhengwen

5.23

parent de4c25ca
......@@ -105,6 +105,7 @@ class Course extends BaseController
$data = (new CourseModel())
// ->with(['getTeacher','getSections'=>['getCourseClass'],'getCourseClass'])
->getCouresDetail($data['course_id']);
CourseModel::where('id',$data['course_id'])->inc('click')->update([]);
return $this->returnMsg('success',1,$data);
......
......@@ -4,10 +4,13 @@ namespace app\api\controller;
use app\api\middleware\Auth;
use app\api\service\UserService;
use app\api\service\UtilService;
use app\api\validate\CourseValidate;
use app\BaseController;
use think\facade\Request;
use app\model\Payment;
use think\Request;
use app\api\service\CourseProgressService;
use app\model\Course as CourseModel;
class CourseProgress extends BaseController
{
......@@ -111,4 +114,39 @@ class CourseProgress extends BaseController
return $this->returnMsg('操作成功',1,$userWork);
}
//视频播放
public function playVideo(Request $request)
{
// 参数验证
$vo = (new CourseValidate())->goCheck(['course_id']);
if ($vo !== true) {
return $vo;
}
$courseId = $request->param('course_id');
$userId = $request->userId;
// 获取课程信息
$course = CourseModel::where([
'id' => $courseId,
'status' => 3,
'is_sell' => 1,
'is_del' => 0
])->find();
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();
return $this->returnMsg('操作成功', 1);
}
}
\ No newline at end of file
......@@ -81,18 +81,54 @@ class Index extends BaseController
public function getProjectPendingList($userId)
{
$list = \app\model\Project::where('user_id', $userId)
->where('status', 'in',[0,1,3])
->field([
'id','title','status','tag_ids'
])
// 1. 查询项目列表
$projects = \app\model\Project::where('user_id', $userId)
->where('status', 'in', [0, 1, 3])
->field(['id', 'title', 'status', 'tag_ids'])
->select();
$list = $list->map(function($item){
return UtilService::infoWithTags($item, \app\model\ProjectTag::class, 'tag_ids');
});
// 2. 收集所有标签ID(去重)
$allTagIds = [];
foreach ($projects as $project) {
if ($project->tag_ids) {
$ids = explode(',', $project->tag_ids);
$allTagIds = array_merge($allTagIds, $ids);
}
}
$allTagIds = array_unique($allTagIds);
// 3. 批量查询所有需要的标签
$tagsMap = [];
if (!empty($allTagIds)) {
$tags = \app\model\ProjectTag::where('is_del', 0)
->where('id', 'in', $allTagIds)
->column('title', 'id');
$tagsMap = $tags ?: [];
}
// 4. 组装结果
$result = [];
foreach ($projects as $project) {
$tagIds = $project->tag_ids ? explode(',', $project->tag_ids) : [];
$tags = [];
foreach ($tagIds as $tagId) {
if (isset($tagsMap[$tagId])) {
$tags[] = [
'id' => $tagId,
'title' => $tagsMap[$tagId]
];
}
}
$result[] = [
'id' => $project->id,
'title' => $project->title,
'status' => $project->status,
'tags' => $tags
];
}
return $list;
return $result;
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ use app\api\middleware\Auth;
use app\api\service\UserService;
use app\api\validate\UserValidate;
use app\BaseController;
use app\model\project\Mail;
use app\model\project\UserAccount;
use app\model\project\UserMoneyLog;
use app\model\project\UserSmrz;
......@@ -136,7 +137,7 @@ class User extends BaseController
->count();
if ($count)
{
// return $this->returnMsg('每天只能提现一次');
return $this->returnMsg('每天只能提现一次');
}
$UserWithdrawalModel = new UserWithdrawal();
......@@ -158,12 +159,27 @@ class User extends BaseController
if (!$res['status'])
{
return $this->returnMsg('网络错误');
return $this->returnMsg($res['msg']);
}
return $this->returnMsg('success',1);
}
//站内信
public function getUserMailList(Request $request)
{
$page = $request->param('page/d', 1);
$pageSize = $request->param('pageSize/d', 10);
$list = Mail::order('createtime','desc')
->paginate([
'page' => $page,
'list_rows' => $pageSize
]);
return $this->returnMsg('success',1,$list);
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@
namespace app\api\service;
use app\model\Payment;
use think\facade\Cache;
class UtilService
......@@ -93,10 +94,27 @@ class UtilService
->field('id,title')
->select()
->toArray();
}
$result = $info->toArray();
$result['tags'] = $tags;
return $result;
}
/**
* 通用购买验证方法
* @param int $userId 用户ID
* @param int $productId 产品ID
* @param int $orderType 订单类型(1:视频 2:证书)
* @return bool
*/
public static function checkPurchase($userId, $productId, $orderType)
{
return Payment::where([
'user_id' => $userId,
'order_type' => $orderType,
'pay_status' => 1,
'order_id' => $productId
])->count() > 0;
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Model;
class Payment extends Model
{
}
\ No newline at end of file
......@@ -128,16 +128,34 @@ class Project extends Model
}
public function projectDetail($id,$userId)
//项目详情
public function projectDetail($id, $userId)
{
$where = ['id'=>$id];
$detail = self::where($where)->find();
$project = self::find($id);
if (!$project) {
return [];
}
$detail['is_put'] = ProjectPut::where(['project_id'=>$id,'user_id'=>$userId])->count();
return array_merge($project->toArray(), [
'is_put' => ProjectPut::where([
'project_id' => $id,
'user_id' => $userId
])->count(),
'fileData' => $this->getValidFiles($project->file_id_str)
]);
}
return $detail;
protected function getValidFiles($fileIds)
{
if (empty($fileIds)) {
return [];
}
return SystemUploadFile::whereIn('fileid', explode(',', $fileIds))
->where('isdel', 0)
->field('fileid,filename,filesize,fileurl,filetype')
->select()
->toArray();
}
......@@ -145,5 +163,4 @@ class Project extends Model
}
\ No newline at end of file
<?php
namespace app\model\project;
use think\Model;
class Mail extends Model
{
}
\ No newline at end of file
......@@ -2,6 +2,7 @@
namespace app\model\project;
use app\model\Payment;
use app\model\system\SystemUploadFile;
use think\Model;
use function Symfony\Component\Translation\t;
......@@ -93,5 +94,10 @@ class User extends Model
->field('id,title');
}
public function payments()
{
return $this->hasMany(Payment::class);
}
}
\ No newline at end of file
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