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
56f973b7
Commit
56f973b7
authored
Jun 09, 2025
by
wangzhengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6.9
parent
514777b8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
17 deletions
+63
-17
Course.php
app/api/controller/Course.php
+3
-3
PayController.php
app/api/controller/PayController.php
+25
-0
Project.php
app/api/controller/manage/Project.php
+7
-5
UtilService.php
app/api/service/UtilService.php
+4
-5
Course.php
app/model/Course.php
+17
-3
CourseClass.php
app/model/CourseClass.php
+7
-1
No files found.
app/api/controller/Course.php
View file @
56f973b7
...
@@ -119,11 +119,11 @@ class Course extends BaseController
...
@@ -119,11 +119,11 @@ class Course extends BaseController
return
$vo
;
return
$vo
;
}
}
$data
=
$request
->
param
();
$data
=
$request
->
param
();
$data
=
(
new
CourseModel
())
$data
=
(
new
CourseModel
())
// ->with(['getTeacher','getSections'=>['getCourseClass'],'getCourseClass'])
// ->with(['getTeacher','getSections'=>['getCourseClass'],'getCourseClass'])
->
getCouresDetail
(
$data
[
'course_id'
]);
->
getCouresDetail
(
$data
[
'course_id'
]);
CourseModel
::
where
(
'id'
,
$data
[
'course_id'
])
->
inc
(
'click'
)
->
update
([]);
CourseModel
::
where
(
'id'
,
$request
->
param
(
'course_id'
))
->
inc
(
'click'
)
->
update
([]);
return
$this
->
returnMsg
(
'success'
,
1
,
$data
);
return
$this
->
returnMsg
(
'success'
,
1
,
$data
);
...
@@ -142,7 +142,7 @@ class Course extends BaseController
...
@@ -142,7 +142,7 @@ class Course extends BaseController
$data
=
$request
->
param
();
$data
=
$request
->
param
();
$data
=
(
new
CourseModel
())
$data
=
(
new
CourseModel
())
->
with
([
'getSections'
=>
[
'getCourseClass'
],
'getCourseClass'
])
->
with
([
'getSections'
=>
[
'getCourseClass'
=>
[
'fileData'
]],
'getCourseClass'
=>
[
'fileData'
]
])
->
where
(
'id'
,
$data
[
'course_id'
])
->
where
(
'id'
,
$data
[
'course_id'
])
->
field
(
'id,thumb,title,createtime,description,price,content,teacher_id,tvclick,click'
)
->
field
(
'id,thumb,title,createtime,description,price,content,teacher_id,tvclick,click'
)
->
find
();
->
find
();
...
...
app/api/controller/PayController.php
View file @
56f973b7
...
@@ -35,6 +35,31 @@ class PayController
...
@@ -35,6 +35,31 @@ class PayController
// if (!$validate->scene('create')->check($params)) {
// if (!$validate->scene('create')->check($params)) {
// return json(['code' => 400, 'msg' => $validate->getError()]);
// return json(['code' => 400, 'msg' => $validate->getError()]);
// }
// }
// 在调用 PayService::createPayment() 之前先检查是否存在有效支付记录
$existingPayment
=
Db
::
name
(
'payment'
)
->
where
([
'user_id'
=>
$params
[
'user_id'
],
'order_id'
=>
$params
[
'order_id'
],
'pay_method'
=>
$params
[
'pay_method'
],
'order_type'
=>
$params
[
'order_type'
],
'pay_amount'
=>
$params
[
'amount'
],
'pay_status'
=>
0
,
// 未支付
])
->
where
(
'expire_time'
,
'>'
,
time
()
+
300
)
// 未过期
->
order
(
'id'
,
'desc'
)
->
find
();
if
(
$existingPayment
)
{
// 返回已存在的支付记录
return
json
([
'code'
=>
1
,
'data'
=>
[
'payment_id'
=>
$existingPayment
[
'id'
],
'order_no'
=>
$existingPayment
[
'order_no'
]
]
]);
}
// 创建支付订单
// 创建支付订单
$result
=
PayService
::
createPayment
(
$result
=
PayService
::
createPayment
(
$params
[
'user_id'
],
$params
[
'user_id'
],
...
...
app/api/controller/manage/Project.php
View file @
56f973b7
...
@@ -5,6 +5,7 @@ namespace app\api\controller\manage;
...
@@ -5,6 +5,7 @@ namespace app\api\controller\manage;
use
app\api\common\StatusConstants
;
use
app\api\common\StatusConstants
;
use
app\api\middleware\Auth
;
use
app\api\middleware\Auth
;
use
app\api\service\ProjectService
;
use
app\api\service\ProjectService
;
use
app\api\service\UserService
;
use
app\api\service\UtilService
;
use
app\api\service\UtilService
;
use
app\api\validate\ProjectValidate
;
use
app\api\validate\ProjectValidate
;
use
app\BaseController
;
use
app\BaseController
;
...
@@ -92,17 +93,18 @@ class Project extends BaseController
...
@@ -92,17 +93,18 @@ class Project extends BaseController
if
(
$vo
!==
true
)
{
if
(
$vo
!==
true
)
{
return
$vo
;
return
$vo
;
}
}
$data
=
$request
->
param
();
$userId
=
$request
->
userId
;
$data
=
$request
->
only
(
$filed
);
$res
=
ProjectModel
::
where
([
'id'
=>
$data
[
'project_id'
],
'user_id'
=>
$request
->
userId
])
->
find
(
);
$res
=
(
new
ProjectModel
())
->
projectDetail
(
$data
[
'project_id'
],
$userId
);
if
(
!
$res
)
{
if
(
!
$res
)
{
return
$this
->
returnMsg
(
'项目不存在'
);
return
$this
->
returnMsg
(
'项目不存在'
);
}
}
$applyProgress
=
StatusConstants
::
PROGRESS_RULES
[
'apply'
][
$res
->
sh_status
]
??
0
;
$applyProgress
=
StatusConstants
::
PROGRESS_RULES
[
'apply'
][
$res
[
'sh_status'
]
]
??
0
;
$completeProgress
=
(
$res
->
sh_status
==
2
)
?
(
StatusConstants
::
PROGRESS_RULES
[
'complete'
][
$res
->
status
]
??
0
)
:
0
;
$completeProgress
=
(
$res
[
'sh_status'
]
==
2
)
?
(
StatusConstants
::
PROGRESS_RULES
[
'complete'
][
$res
[
'status'
]
]
??
0
)
:
0
;
$res
->
progress
=
max
(
1
,
min
(
100
,
$applyProgress
+
$completeProgress
));
$res
[
'progress'
]
=
max
(
1
,
min
(
100
,
$applyProgress
+
$completeProgress
));
$res
=
UtilService
::
infoWithTags
(
$res
,
\app\model\ProjectTag
::
class
,
'tag_ids'
);
$res
=
UtilService
::
infoWithTags
(
$res
,
\app\model\ProjectTag
::
class
,
'tag_ids'
);
...
...
app/api/service/UtilService.php
View file @
56f973b7
...
@@ -96,8 +96,8 @@ class UtilService
...
@@ -96,8 +96,8 @@ class UtilService
->
select
()
->
select
()
->
toArray
();
->
toArray
();
}
}
$result
=
is_array
(
$info
)
?
$info
:
$info
->
toArray
();
$result
=
$info
->
toArray
();
$result
[
'tags'
]
=
$tags
;
$result
[
'tags'
]
=
$tags
;
return
$result
;
return
$result
;
}
}
...
@@ -107,13 +107,12 @@ class UtilService
...
@@ -107,13 +107,12 @@ 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:证书)
* @return bool
*/
*/
public
static
function
checkPurchase
(
$userId
,
$productId
,
$orderType
)
public
static
function
checkPurchase
(
$userId
,
$productId
,
$orderType
)
{
{
//如果是课程课时存在试看的情况下
//如果是课程课时存在试看的情况下
if
(
$
productId
==
1
)
if
(
$
orderType
==
1
)
{
{
$course_class_id
=
input
(
'course_class'
);
$course_class_id
=
input
(
'course_class'
);
if
(
$course_class_id
)
if
(
$course_class_id
)
...
@@ -121,7 +120,7 @@ class UtilService
...
@@ -121,7 +120,7 @@ class UtilService
$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'
);
if
(
$is_sk
)
if
(
$is_sk
)
{
{
return
true
;
return
1
;
}
}
}
}
}
}
...
@@ -131,6 +130,6 @@ class UtilService
...
@@ -131,6 +130,6 @@ class UtilService
'order_type'
=>
$orderType
,
'order_type'
=>
$orderType
,
'pay_status'
=>
1
,
'pay_status'
=>
1
,
'order_id'
=>
$productId
'order_id'
=>
$productId
])
->
count
()
>
0
;
])
->
count
();
}
}
}
}
\ No newline at end of file
app/model/Course.php
View file @
56f973b7
...
@@ -69,7 +69,7 @@ class Course extends Model
...
@@ -69,7 +69,7 @@ class Course extends Model
}
}
$list
=
$query
->
order
(
'click,tvclick,createtime'
,
'desc'
)
$list
=
$query
->
order
(
'click,tvclick,createtime'
,
'desc'
)
->
field
(
'id,thumb,title,description,tag_ids,teacher_id'
)
->
field
(
'id,thumb,title,description,tag_ids,teacher_id
,description
'
)
->
with
([
'thumb'
,
'getTeacher'
=>
[
'thumb'
]])
->
with
([
'thumb'
,
'getTeacher'
=>
[
'thumb'
]])
->
paginate
([
->
paginate
([
'page'
=>
$page
,
'page'
=>
$page
,
...
@@ -113,11 +113,16 @@ class Course extends Model
...
@@ -113,11 +113,16 @@ class Course extends Model
}
}
$detail
=
self
::
where
(
$where
)
$detail
=
self
::
where
(
$where
)
->
with
([
'getTeacher'
=>
[
'thumb'
]])
->
with
([
'getTeacher'
=>
[
'thumb'
]
,
'thumb'
])
->
field
(
'id,thumb,title,createtime,description,price,content,teacher_id,tvclick,click'
)
->
field
(
'id,thumb,title,createtime,description,price,content,teacher_id,tvclick,click'
)
->
find
();
->
find
();
if
(
!
$detail
)
{
return
$detail
;
}
$detail
[
'is_learned'
]
=
0
;
//是否学习
$detail
[
'is_learned'
]
=
0
;
//是否学习
$detail
[
'is_buy'
]
=
0
;
//是否购买
$detail
[
'is_buy'
]
=
0
;
//是否购买
$token
=
request
()
->
header
(
'token'
);
$token
=
request
()
->
header
(
'token'
);
...
@@ -126,9 +131,18 @@ class Course extends Model
...
@@ -126,9 +131,18 @@ class Course extends Model
if
(
$user
)
if
(
$user
)
{
{
$detail
[
'is_learned'
]
=
CourseProgress
::
where
([
'course_id'
=>
$detail
[
'id'
],
'user_id'
=>
$user
[
'id'
]])
->
count
();
$detail
[
'is_learned'
]
=
CourseProgress
::
where
([
'course_id'
=>
$detail
[
'id'
],
'user_id'
=>
$user
[
'id'
]])
->
count
();
if
(
$detail
[
'price'
]
<
0
)
{
$detail
[
'is_buy'
]
=
1
;
}
else
{
$detail
[
'is_buy'
]
=
UtilService
::
checkPurchase
(
$user
[
'id'
],
$course_id
,
1
);
//是否购买
}
}
}
return
$detail
;
return
$detail
;
}
}
...
...
app/model/CourseClass.php
View file @
56f973b7
...
@@ -2,9 +2,15 @@
...
@@ -2,9 +2,15 @@
namespace
app\model
;
namespace
app\model
;
use
app\model\system\SystemUploadFile
;
use
think\Model
;
use
think\Model
;
class
CourseClass
extends
Model
class
CourseClass
extends
Model
{
{
public
function
fileData
()
{
return
$this
->
hasOne
(
SystemUploadFile
::
class
,
'fileid'
,
'tv_file'
)
->
where
(
'isdel'
,
0
)
->
field
(
'fileid,filename,filesize,fileurl,filetype'
);
}
}
}
\ No newline at end of file
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