feat: 商品/套餐支持全部项目通用 (project_id=0)
- 新增/筛选通用商品, 列表标「通用」 - 商城套餐列表含通用商品, 下单/创建授权/代理发卡可用通用套餐 - 项目套餐列表附带展示通用套餐
This commit is contained in:
1 parent
cf65cbd72d
commit
2f10919196
6 files changed
+42
-14
No files matched your search
@@ -170,8 +170,11 @@ class ProjectController extends Controller
|
||||
public function cardTypes(int $projectId): void
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
// 返回本项目套餐 + 通用套餐(project_id=0)
|
||||
$types = $db->fetchAll(
|
||||
"SELECT * FROM {$db->table('card_types')} WHERE project_id = ? ORDER BY sort ASC",
|
||||
"SELECT * FROM {$db->table('card_types')}
|
||||
WHERE (project_id = ? OR project_id = 0) AND status = 1
|
||||
ORDER BY project_id ASC, sort ASC",
|
||||
[$projectId]
|
||||
);
|
||||
$this->success($types);
|
||||
@@ -179,6 +182,7 @@ class ProjectController extends Controller
|
||||
|
||||
/**
|
||||
* 创建卡密类型
|
||||
* projectId=0 表示全部项目通用商品(仅 admin)
|
||||
*/
|
||||
public function createCardType(int $projectId): void
|
||||
{
|
||||
@@ -193,6 +197,10 @@ class ProjectController extends Controller
|
||||
$this->error($validator->getFirstError());
|
||||
}
|
||||
|
||||
if ($projectId === 0 && $this->getUserRole() !== 'admin') {
|
||||
$this->error('通用商品仅超级管理员可创建', 403);
|
||||
}
|
||||
|
||||
$db = Database::getInstance();
|
||||
$id = $db->insert(
|
||||
"INSERT INTO {$db->table('card_types')} (project_id, name, description, duration_days, price, original_price, agent_cost, sort, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
|
||||
Reference in new issue
Block a user