第三段完善 代理商绑定 激活等 正式上线的版本

This commit is contained in:
huangzhenpc
2025-02-13 15:25:19 +08:00
parent abfa783907
commit d1b0a26dd2
31 changed files with 2729 additions and 641 deletions

View File

@@ -1,31 +0,0 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class Agents extends Migrator
{
public function change()
{
$table = $this->table('cursor_agents', ['engine' => 'InnoDB']);
$table->addColumn('username', 'string', ['limit' => 50, 'null' => false, 'comment' => '代理商用户名'])
->addColumn('password', 'string', ['limit' => 255, 'null' => false, 'comment' => '密码'])
->addColumn('nickname', 'string', ['limit' => 50, 'null' => true, 'comment' => '昵称'])
->addColumn('parent_id', 'integer', ['null' => true, 'default' => 0, 'comment' => '上级代理ID0表示一级代理'])
->addColumn('level', 'integer', ['limit' => 1, 'null' => false, 'default' => 1, 'comment' => '代理级别1=一级代理2=二级代理'])
->addColumn('balance', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => '0.00', 'comment' => '余额'])
->addColumn('total_income', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => '0.00', 'comment' => '总收入'])
->addColumn('commission_rate', 'decimal', ['precision' => 5, 'scale' => 2, 'default' => '0.00', 'comment' => '佣金比例'])
->addColumn('status', 'integer', ['limit' => 1, 'null' => false, 'default' => 1, 'comment' => '状态0=禁用1=启用'])
->addColumn('remark', 'string', ['limit' => 255, 'null' => true, 'comment' => '备注'])
->addColumn('last_login_time', 'datetime', ['null' => true, 'comment' => '最后登录时间'])
->addColumn('last_login_ip', 'string', ['limit' => 50, 'null' => true, 'comment' => '最后登录IP'])
->addColumn('created_at', 'datetime', ['null' => false, 'comment' => '创建时间'])
->addColumn('updated_at', 'datetime', ['null' => false, 'comment' => '更新时间'])
->addIndex(['username'], ['unique' => true])
->addIndex(['parent_id'])
->addIndex(['level'])
->addIndex(['status'])
->create();
}
}

View File

@@ -1,25 +0,0 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class AgentCodes extends Migrator
{
public function change()
{
$table = $this->table('cursor_agent_codes', ['engine' => 'InnoDB']);
$table->addColumn('agent_id', 'integer', ['null' => false, 'comment' => '代理商ID'])
->addColumn('code_id', 'integer', ['null' => false, 'comment' => '激活码ID'])
->addColumn('price', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => '0.00', 'comment' => '销售价格'])
->addColumn('commission', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => '0.00', 'comment' => '佣金'])
->addColumn('parent_commission', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => '0.00', 'comment' => '上级佣金'])
->addColumn('status', 'integer', ['limit' => 1, 'null' => false, 'default' => 0, 'comment' => '状态0=未结算1=已结算'])
->addColumn('settle_time', 'datetime', ['null' => true, 'comment' => '结算时间'])
->addColumn('created_at', 'datetime', ['null' => false, 'comment' => '创建时间'])
->addColumn('updated_at', 'datetime', ['null' => false, 'comment' => '更新时间'])
->addIndex(['agent_id'])
->addIndex(['code_id'])
->addIndex(['status'])
->create();
}
}

View File

@@ -0,0 +1,79 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class CreateVersionTables extends Migrator
{
public function change()
{
// 添加系统配置
$this->addSystemConfig();
// 软件版本表
if (!$this->hasTable('version')) {
$this->table('version', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci'])
->addColumn('version_no', 'string', ['limit' => 50, 'null' => false, 'comment' => '版本号'])
->addColumn('version_name', 'string', ['limit' => 100, 'null' => false, 'comment' => '版本名称'])
->addColumn('download_url', 'string', ['limit' => 500, 'null' => false, 'comment' => '下载地址'])
->addColumn('is_force', 'boolean', ['null' => false, 'default' => 0, 'comment' => '是否强制更新'])
->addColumn('min_version', 'string', ['limit' => 50, 'null' => true, 'comment' => '最低要求版本'])
->addColumn('platform', 'string', ['limit' => 20, 'null' => false, 'default' => 'all', 'comment' => '平台(windows,mac,linux)'])
->addColumn('status', 'boolean', ['null' => false, 'default' => 1, 'comment' => '状态(0禁用,1启用)'])
->addColumn('description', 'text', ['null' => true, 'comment' => '版本描述'])
->addColumn('create_time', 'datetime', ['null' => true, 'comment' => '创建时间'])
->addColumn('update_time', 'datetime', ['null' => true, 'comment' => '更新时间'])
->addIndex('version_no', ['name' => 'idx_version_no'])
->create();
}
// 版本更新日志表
if (!$this->hasTable('version_log')) {
$this->table('version_log', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci'])
->addColumn('version_id', 'integer', ['limit' => 20, 'null' => false, 'comment' => '版本ID'])
->addColumn('type', 'string', ['limit' => 20, 'null' => false, 'default' => 'feature', 'comment' => '更新类型(feature,fix,optimize)'])
->addColumn('content', 'text', ['null' => false, 'comment' => '更新内容'])
->addColumn('create_time', 'datetime', ['null' => true, 'comment' => '创建时间'])
->addIndex('version_id', ['name' => 'idx_version_id'])
->create();
}
// 版本控制表
if (!$this->hasTable('version_control')) {
$this->table('version_control', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci'])
->addColumn('version_id', 'integer', ['limit' => 20, 'null' => false, 'comment' => '版本ID'])
->addColumn('control_type', 'string', ['limit' => 20, 'null' => false, 'comment' => '控制类型(white_list,black_list)'])
->addColumn('target_id', 'integer', ['limit' => 20, 'null' => false, 'comment' => '目标ID'])
->addColumn('target_type', 'string', ['limit' => 20, 'null' => false, 'comment' => '目标类型(user,agent,device)'])
->addColumn('expire_time', 'datetime', ['null' => true, 'comment' => '过期时间'])
->addColumn('create_time', 'datetime', ['null' => true, 'comment' => '创建时间'])
->addColumn('update_time', 'datetime', ['null' => true, 'comment' => '更新时间'])
->addIndex(['version_id', 'target_id', 'target_type'], ['name' => 'idx_version_target'])
->create();
}
}
/**
* 添加系统配置
*/
protected function addSystemConfig()
{
// 检查是否存在配置
$exists = \think\facade\Db::name('system_config')
->where('type', 'base')
->where('name', 'site_domain')
->find();
if (!$exists) {
// 添加站点域名配置
\think\facade\Db::name('system_config')->insert([
'type' => 'base',
'name' => 'site_domain',
'value' => '',
'title' => '站点域名',
'description' => '请设置站点访问域名,例如: https://www.example.com',
'create_at' => date('Y-m-d H:i:s'),
]);
}
}
}

View File

@@ -0,0 +1,82 @@
<?php
use think\migration\Migrator;
use think\facade\Db;
class AddVersionMenu extends Migrator
{
public function change()
{
// 检查是否已存在版本管理菜单
$exists = Db::name('system_menu')->where(['node' => 'version_manage'])->find();
if (!$exists) {
// 添加版本管理主菜单
$pid = Db::name('system_menu')->insertGetId([
'pid' => 0,
'title' => '版本管理',
'icon' => 'layui-icon layui-icon-template-1',
'node' => 'version_manage',
'url' => '#',
'sort' => 100,
'status' => 1,
'create_at' => date('Y-m-d H:i:s'),
]);
// 添加版本列表菜单
$menu_id = Db::name('system_menu')->insertGetId([
'pid' => $pid,
'title' => '版本列表',
'icon' => 'layui-icon layui-icon-list',
'node' => 'version_manage/version/index',
'url' => 'manager/version/index',
'sort' => 100,
'status' => 1,
'create_at' => date('Y-m-d H:i:s'),
]);
// 添加操作权限节点(不显示在菜单中)
Db::name('system_menu')->insertAll([
[
'pid' => $menu_id,
'title' => '添加版本',
'icon' => 'layui-icon layui-icon-add-1',
'node' => 'version_manage/version/add',
'url' => 'manager/version/add',
'sort' => 100,
'status' => 0, // 不显示在菜单中
'create_at' => date('Y-m-d H:i:s'),
],
[
'pid' => $menu_id,
'title' => '编辑版本',
'icon' => 'layui-icon layui-icon-edit',
'node' => 'version_manage/version/edit',
'url' => 'manager/version/edit',
'sort' => 100,
'status' => 0, // 不显示在菜单中
'create_at' => date('Y-m-d H:i:s'),
],
[
'pid' => $menu_id,
'title' => '删除版本',
'icon' => 'layui-icon layui-icon-delete',
'node' => 'version_manage/version/remove',
'url' => 'manager/version/remove',
'sort' => 100,
'status' => 0, // 不显示在菜单中
'create_at' => date('Y-m-d H:i:s'),
],
[
'pid' => $menu_id,
'title' => '版本状态',
'icon' => 'layui-icon layui-icon-circle',
'node' => 'version_manage/version/state',
'url' => 'manager/version/state',
'sort' => 100,
'status' => 0, // 不显示在菜单中
'create_at' => date('Y-m-d H:i:s'),
]
]);
}
}
}