初始化项目:添加后端代码、ThinkPHP框架、前端资源

This commit is contained in:
amb
2026-09-03 12:42:39 +08:00
commit 482bece22e
3726 changed files with 416708 additions and 0 deletions
@@ -0,0 +1,37 @@
<?php
namespace app\api\model\course;
use think\Model;
class ColumnBind extends Model
{
// 表名
protected $name = 'course_bind_column';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
public function course()
{
return $this->belongsTo('Course', 'course_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function column()
{
return $this->belongsTo('Course', 'column_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace app\api\model\course;
use think\Model;
class Course extends Model
{
// 表名
protected $name = 'course';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
public function getList(){
return self::order('createtime','desc')
->field(['name','cover','price','price_marking','pay_type','type','id'])
->select();
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace app\api\model\course;
use think\Model;
class Group extends Model
{
// 表名
protected $name = 'course_group';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
public function getList(){
return self::where([
'status'=>1
])
->order('sort','asc')->order('createtime','desc')->select();
}
}
+206
View File
@@ -0,0 +1,206 @@
<?php
namespace app\api\model\course;
use think\Model;
use app\api\model\course\Course;
class GroupBind extends Model
{
// 表名
protected $name = 'course_bind_group';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
public function course()
{
return $this->belongsTo('Course', 'course_id', 'id', [], 'right')->setEagerlyType(0);
}
/**
* 获取课程列表
* @param $groupId 分组ID
* @param $params 分页信息 page页码 limit获取数量
* @return array
*/
public function getCourseList($groupId = 0,$params = []){
$where = [
'course.status'=>1,
'sales_type'=>['like',"%alone%"],
'hide'=>0
];
if(isset($params['sort']) && !empty($params['sort'])){
if($params['sort']=='time'){
$orderField = 'course.createtime';
}else{
$orderField = 'course.views';
}
}
if(isset($params['searchKey']) && !empty($params['searchKey'])){
$where['course.name'] = ['like',"%{$params['searchKey']}%"];
}
if(isset($params['type']) && !empty($params['type'])){
$where['course.type'] = $params['type'];
}
if($groupId){
$where['group_bind.group_id'] = $groupId;
$rows = self::with(['course'])->order('group_bind.sort','desc');
}else{
$rows = Course::alias('course')->order('createtime','desc');
}
$list = $rows
->where($where)
->limit($params['limit'])->page($params['page'])
->order($orderField,'desc')
->group('course.id')
->select();
$data = [];
if(!empty($list)){
$vipAppConfig = \app\common\model\app\Config::getConfig('vip');
foreach ($list as $item){
$item['is_vip_goods'] = false;
if($vipAppConfig['status'] == 1){
//判断是否为会员权益课程
$item['is_vip_goods'] = \app\api\model\app\vip\CardPrivilege::checkVipGoods($item['id']);
}
if($groupId){
$item->getRelation('course')->visible(['name','cover','price','price_marking','pay_type','type','id','briefing','is_vip_goods']);
$courseData = $item['course']->toArray();
$buyData = \app\common\model\course\Course::getPrice($courseData['id']);
$buyData['type_text'] = __('type.'.$courseData['type']);
$courseData = array_merge($courseData,$buyData);
$goodsType = $courseData['type'] ?? '';
$isVirtualPay = \app\common\library\pay\VirtualPayService::isUseVirtualPay($goodsType);
$courseData['is_virtual_pay'] = $isVirtualPay ? 1 : 0;
if ($isVirtualPay) {
$courseData = \app\common\library\pay\VirtualPayService::convertPriceFields($courseData, ['price', 'price_marking']);
}
$data[] = $courseData;
}else{
$item->visible(['name','cover','price','price_marking','pay_type','type','id','briefing','is_vip_goods']);
$itemData = $item->toArray();
$buyData = \app\common\model\course\Course::getPrice($itemData['id']);
$itemData = array_merge($itemData,$buyData);
$goodsType = $itemData['type'] ?? '';
$isVirtualPay = \app\common\library\pay\VirtualPayService::isUseVirtualPay($goodsType);
$itemData['is_virtual_pay'] = $isVirtualPay ? 1 : 0;
if ($isVirtualPay) {
$itemData = \app\common\library\pay\VirtualPayService::convertPriceFields($itemData, ['price', 'price_marking']);
}
$data[] = $itemData;
}
}
}
return $data;
}
/**
* 通过多个分组ID获取课程列表
* @param array $groupIds 分组ID数组
* @param array $params 分页信息 page页码 limit获取数量
* @return array
*/
public function getCourseListByGroupIds($groupIds = [], $params = [])
{
if (empty($groupIds)) {
return [];
}
$where = [
'course.status' => 1,
'sales_type' => ['like', "%alone%"],
'hide' => 0
];
$orderField = 'course.createtime';
if (isset($params['sort']) && !empty($params['sort'])) {
if ($params['sort'] == 'time') {
$orderField = 'course.createtime';
} else {
$orderField = 'course.views';
}
}
if (isset($params['searchKey']) && !empty($params['searchKey'])) {
$where['course.name'] = ['like', "%{$params['searchKey']}%"];
}
if (isset($params['type']) && !empty($params['type'])) {
$where['course.type'] = $params['type'];
}
$query = self::with(['course'])
->where('group_bind.group_id', 'in', $groupIds)
->where($where);
if (isset($params['limit']) && isset($params['page'])) {
$query = $query->limit($params['limit'])->page($params['page']);
}
$list = $query
->order('group_bind.sort', 'desc')
->order($orderField, 'desc')
->group('course.id')
->select();
$data = [];
if (!empty($list)) {
$vipAppConfig = \app\common\model\app\Config::getConfig('vip');
foreach ($list as $item) {
$item['is_vip_goods'] = false;
if ($vipAppConfig['status'] == 1) {
$item['is_vip_goods'] = \app\api\model\app\vip\CardPrivilege::checkVipGoods($item['id']);
}
$item->getRelation('course')->visible(['name', 'cover', 'price', 'price_marking', 'pay_type', 'type', 'id', 'briefing', 'is_vip_goods']);
$courseData = $item['course']->toArray();
$buyData = \app\common\model\course\Course::getPrice($courseData['id']);
$buyData['type_text'] = __('type.' . $courseData['type']);
$courseData = array_merge($courseData, $buyData);
$goodsType = $courseData['type'] ?? '';
$isVirtualPay = \app\common\library\pay\VirtualPayService::isUseVirtualPay($goodsType);
$courseData['is_virtual_pay'] = $isVirtualPay ? 1 : 0;
if ($isVirtualPay) {
$courseData = \app\common\library\pay\VirtualPayService::convertPriceFields($courseData, ['price', 'price_marking']);
}
$data[] = $courseData;
}
}
return $data;
}
}