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
fd62cef4
Commit
fd62cef4
authored
May 15, 2025
by
wangzhengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
证书模块
parent
1a5861f2
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
342 additions
and
12 deletions
+342
-12
Course.php
app/api/controller/Course.php
+4
-1
System.php
app/api/controller/System.php
+1
-1
Cert.php
app/api/controller/cert/Cert.php
+70
-0
CertOrder.php
app/api/controller/cert/CertOrder.php
+49
-0
UtilService.php
app/api/service/UtilService.php
+13
-0
CertValidate.php
app/api/validate/CertValidate.php
+24
-0
Cert.php
app/model/Cert.php
+84
-1
CertCategory.php
app/model/CertCategory.php
+19
-0
CertOrder.php
app/model/CertOrder.php
+60
-0
CertTag.php
app/model/CertTag.php
+10
-0
Course.php
app/model/Course.php
+8
-9
No files found.
app/api/controller/Course.php
View file @
fd62cef4
...
...
@@ -79,7 +79,10 @@ class Course extends BaseController
}
$data
=
$request
->
param
();
$list
=
(
new
CourseModel
())
->
getCourseList
(
$data
[
'category_id'
]);
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$list
=
(
new
CourseModel
())
->
getCourseList
(
$data
[
'category_id'
],
$page
,
$pageSize
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
...
...
app/api/controller/System.php
View file @
fd62cef4
...
...
@@ -13,7 +13,7 @@ class System extends BaseController
*/
public
function
getBannerList
()
{
$list
=
AdvertCate
::
where
([
'position'
=>
1
,
'is_show'
=>
1
])
$list
=
AdvertCate
::
where
([
'position'
=>
1
,
'is_show'
=>
1
,
'is_del'
=>
0
])
->
with
([
'getAdvertList'
=>
[
'coverImg'
]])
->
find
()
->
toArray
();
...
...
app/api/controller/cert/Cert.php
0 → 100644
View file @
fd62cef4
<?php
namespace
app\api\controller\cert
;
use
app\api\validate\CertValidate
;
use
app\BaseController
;
use
app\model\CertCategory
;
use
app\model\CertOrder
;
use
think\Request
;
use
app\model\Cert
as
CertModel
;
class
Cert
extends
BaseController
{
//项目分类列表
public
function
getCertCategoryList
()
{
$list
=
(
new
CertCategory
())
->
getCertCategoryList
();
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
//项目列表
public
function
getCertList
(
Request
$request
)
{
$vo
=
(
new
CertValidate
())
->
goCheck
([
'category_id'
,
'type'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
param
();
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$list
=
(
new
CertModel
())
->
getCertList
(
$data
[
'category_id'
],
$page
,
$pageSize
,
$data
[
'type'
]);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
//认证动态
public
function
getLatestCertList
(
Request
$request
)
{
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$list
=
(
new
CertOrder
())
->
latestCertList
(
$page
,
$pageSize
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
//详情
public
function
getDetailCert
(
Request
$request
)
{
$vo
=
(
new
CertValidate
())
->
goCheck
([
'cert_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
param
();
$detail
=
CertModel
::
where
(
'id'
,
$data
[
'cert_id'
])
->
append
([
'starttimetxt'
,
'endtimetxt'
])
->
find
();
return
$this
->
returnMsg
(
'success'
,
1
,
$detail
);
}
}
\ No newline at end of file
app/api/controller/cert/CertOrder.php
0 → 100644
View file @
fd62cef4
<?php
namespace
app\api\controller\cert
;
use
app\api\middleware\Auth
;
use
app\api\service\UtilService
;
use
app\api\validate\CertValidate
;
use
app\BaseController
;
use
think\queue\Queueable
;
use
think\Request
;
use
app\model\CertOrder
as
OrderModel
;
class
CertOrder
extends
BaseController
{
protected
$middleware
=
[
Auth
::
class
,
];
//报名
public
function
enrollCert
(
Request
$request
)
{
$allowArray
=
[
'cert_id'
,
'name'
,
'idcard'
,
'idcard_q'
,
'idcard_h'
,
'mobile'
,
'email'
,
'head_img_id'
,
'other_file_id'
,
'pay_type'
];
$vo
=
(
new
CertValidate
())
->
goCheck
(
$allowArray
);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
only
(
$allowArray
);
$data
[
'user_id'
]
=
$request
->
userId
;
$data
[
'createtime'
]
=
time
();
// $data['order_sn'] = UtilService::generateOrderNo($request->userId,'cert');
unset
(
$data
[
'pay_type'
]);
$where
=
[
'is_del'
=>
0
,
'user_id'
=>
$data
[
'user_id'
],
'cert_id'
=>
$data
[
'cert_id'
]];
$count
=
OrderModel
::
where
(
$where
)
->
count
();
if
(
$count
>
0
)
{
return
$this
->
returnMsg
(
'请勿重复提交'
);
}
$enrollCert
=
OrderModel
::
create
(
$data
);
return
$this
->
returnMsg
(
'success'
,
1
,
$enrollCert
);
}
}
\ No newline at end of file
app/api/service/UtilService.php
View file @
fd62cef4
...
...
@@ -4,5 +4,18 @@ namespace app\api\service;
class
UtilService
{
public
static
function
generateOrderNo
(
$userId
=
0
,
$str
=
null
)
{
$microtime
=
microtime
(
true
);
$timestamp
=
date
(
'YmdHis'
)
.
substr
(
$microtime
,
11
,
3
);
$random
=
str_pad
(
mt_rand
(
0
,
999999
),
6
,
'0'
,
STR_PAD_LEFT
);
$userPart
=
$userId
?
substr
(
str_pad
(
$userId
,
4
,
'0'
,
STR_PAD_LEFT
),
-
4
)
:
''
;
return
$str
.
'-'
.
$timestamp
.
$random
.
(
$userPart
?
(
'-'
.
$userPart
)
:
''
);
}
}
\ No newline at end of file
app/api/validate/CertValidate.php
0 → 100644
View file @
fd62cef4
<?php
namespace
app\api\validate
;
class
CertValidate
extends
BaseValidate
{
protected
$rule
=
[
'searchKeyWords'
=>
'require'
,
'category_id'
=>
'require|number'
,
'cert_id'
=>
'require|number'
,
'type'
=>
'require|number'
,
'name'
=>
'require'
,
'idcard'
=>
'require|number'
,
'idcard_q'
=>
'require|number'
,
'idcard_h'
=>
'require|number'
,
'mobile'
=>
'require|mobile'
,
'email'
=>
'require|email'
,
'head_img_id'
=>
'require|number'
,
'other_file_id'
=>
'require|number'
,
'pay_type'
=>
'require|number'
,
];
}
\ No newline at end of file
app/model/Cert.php
View file @
fd62cef4
...
...
@@ -53,11 +53,94 @@ class Cert extends Model
public
function
certcatedata
()
{
return
$this
->
hasOne
(
CertCategory
::
class
,
'id'
,
'cate_id'
)
->
field
(
'id,title'
);
}
/**分类下的项目列表
* @param $category_id
* @param $page
* @param $pageSize
* @param $type 1 普通列表 2即将开始
* @return array|\think\Paginator
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public
function
getCertList
(
$category_id
,
$page
,
$pageSize
,
$type
)
{
$where
=
[
'is_sell'
=>
1
,
'is_del'
=>
0
];
if
(
$category_id
)
{
$where
[
'cate_id'
]
=
$category_id
;
}
$query
=
self
::
where
(
$where
);
if
(
$type
==
2
)
{
$currentTime
=
time
();
$query
->
where
(
'start_time'
,
'<='
,
$currentTime
)
->
where
(
'end_time'
,
'>='
,
$currentTime
);
$query
->
order
(
'end_time'
,
'asc'
);
}
else
{
$query
->
order
(
'createtime'
,
'desc'
);
}
$list
=
$query
->
field
(
'id,thumb_id,title,createtime,description,shrq,fzjg,price,tag_ids,start_time,end_time'
)
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
if
(
$list
->
isEmpty
()
||
$type
==
2
)
{
return
$list
;
}
// 收集所有tag_ids
$allTagIds
=
[];
foreach
(
$list
->
items
()
as
$item
)
{
if
(
!
empty
(
$item
->
tag_ids
))
{
$tagIds
=
explode
(
','
,
$item
->
tag_ids
);
$allTagIds
=
array_merge
(
$allTagIds
,
$tagIds
);
}
}
// 批量查询所有标签
$tags
=
[];
if
(
!
empty
(
$allTagIds
))
{
$tags
=
CertTag
::
where
(
'is_del'
,
0
)
->
whereIn
(
'id'
,
array_unique
(
$allTagIds
))
->
field
(
'id,title'
)
->
select
()
->
toArray
();
$tags
=
array_column
(
$tags
,
null
,
'id'
);
}
// 组装结果
$result
=
$list
->
toArray
();
foreach
(
$result
[
'data'
]
as
&
$item
)
{
$itemTags
=
[];
if
(
!
empty
(
$item
[
'tag_ids'
]))
{
$tagIds
=
explode
(
','
,
$item
[
'tag_ids'
]);
foreach
(
$tagIds
as
$tagId
)
{
if
(
isset
(
$tags
[
$tagId
]))
{
$itemTags
[]
=
$tags
[
$tagId
];
}
}
}
$item
[
'tags'
]
=
$itemTags
;
}
return
$result
;
}
}
\ No newline at end of file
app/model/CertCategory.php
View file @
fd62cef4
...
...
@@ -38,6 +38,25 @@ class CertCategory extends Model
return
get_upload_file
(
$data
[
'thumb'
]);
}
public
function
children
()
{
return
$this
->
hasMany
(
CertCategory
::
class
,
'pid'
);
}
public
function
getCertCategoryList
()
{
$where
[]
=
[
'is_del'
,
'='
,
0
];
return
$this
->
with
([
'children'
=>
function
(
$query
)
use
(
$where
)
{
$query
->
where
(
$where
);
$query
->
order
(
'sort'
,
'asc'
);
}])
->
where
(
'pid'
,
0
)
->
where
(
$where
)
->
order
(
'sort'
,
'asc'
)
->
select
();
}
}
\ No newline at end of file
app/model/CertOrder.php
View file @
fd62cef4
...
...
@@ -54,4 +54,64 @@ class CertOrder extends Model
return
$statustxt
;
}
//最新认证动态
public
function
latestCertList
(
$page
,
$pageSize
)
{
$where
=
[
'status'
=>
3
,
'is_del'
=>
0
];
$list
=
self
::
where
(
$where
)
->
with
([
'user'
=>
[
'headico'
],
'cert'
])
->
order
(
'createtime'
,
'desc'
)
->
field
(
'id,cert_id,user_id,name,updatetime'
)
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
$list
->
each
(
function
(
$item
)
{
$item
->
append
([
'updatetime_text'
]);
return
$item
;
});
return
$list
;
}
public
function
user
()
{
return
$this
->
hasOne
(
User
::
class
,
'id'
,
'user_id'
)
->
field
(
'id,username,headico'
);
}
public
function
cert
()
{
return
$this
->
hasOne
(
Cert
::
class
,
'id'
,
'cert_id'
)
->
field
(
'id,title'
);
}
public
function
getUpdatetimeTextAttr
(
$value
,
$data
)
{
$timestamp
=
is_numeric
(
$data
[
'updatetime'
])
?
$data
[
'updatetime'
]
:
strtotime
(
$data
[
'updatetime'
]);
return
$this
->
timeElapsedString
(
$timestamp
);
}
protected
function
timeElapsedString
(
$timestamp
)
{
$currentTime
=
time
();
$timeDiff
=
$currentTime
-
$timestamp
;
if
(
$timeDiff
<
60
)
{
return
'刚刚'
;
}
elseif
(
$timeDiff
<
3600
)
{
return
floor
(
$timeDiff
/
60
)
.
'分钟前'
;
}
elseif
(
$timeDiff
<
86400
)
{
return
floor
(
$timeDiff
/
3600
)
.
'小时前'
;
}
elseif
(
$timeDiff
<
2592000
)
{
return
floor
(
$timeDiff
/
86400
)
.
'天前'
;
}
elseif
(
$timeDiff
<
31536000
)
{
return
floor
(
$timeDiff
/
2592000
)
.
'个月前'
;
}
else
{
return
floor
(
$timeDiff
/
31536000
)
.
'年前'
;
}
}
}
\ No newline at end of file
app/model/CertTag.php
0 → 100644
View file @
fd62cef4
<?php
namespace
app\model
;
use
think\Model
;
class
CertTag
extends
Model
{
}
\ No newline at end of file
app/model/Course.php
View file @
fd62cef4
...
...
@@ -37,23 +37,22 @@ class Course extends Model
}
/**获取分类下的课程列表
* @param $cate_id
* @return Course[]|array|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*
*/
public
function
getCourseList
(
$cate
_id
=
0
)
public
function
getCourseList
(
$cate
gory_id
,
$page
,
$pageSize
)
{
$where
=
[
'status'
=>
3
,
'is_sell'
=>
1
,
'is_del'
=>
0
];
if
(
$cate_id
)
if
(
$cate
gory
_id
)
{
$where
[
'cate_id'
]
=
$cate_id
;
$where
[
'cate_id'
]
=
$cate
gory
_id
;
}
return
self
::
where
(
$where
)
->
field
(
'id,thumb,title,createtime,description,price,content'
)
->
select
();
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
}
//获取课程详情
...
...
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