整理:合并零散迁移文件,36个简化为24个纯建表迁移

- users 表:吸收 s_color类型变更/sign/question/answer/vip_level_id/has_received_new_gift
- rooms 表:吸收 visit_num、announcement
- sysparam 表:吸收全部 seed(99级经验/权限等级/钓鱼/魅力/排行榜,直接写最终值)
- 新增 create_shop_tables(shop_items+user_purchases+username_blacklist+默认商品)
- 新增 create_user_currency_logs_table(积分流水表含完整索引)
- 删除 14 个已吸收的 add_column / seed 零散迁移
This commit is contained in:
2026-02-28 14:03:04 +08:00
parent 27b52da0e5
commit aeffb8e4d4
28 changed files with 1186 additions and 169 deletions

View File

@@ -0,0 +1,116 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建用户表(含所有字段,合并历次 add_column 迁移)
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('username', 50)->unique()->comment('用户名');
$table->string('password')->comment('密码 (MD5 or Bcrypt)');
$table->string('email', 250)->nullable()->comment('邮箱');
$table->string('question', 100)->nullable()->comment('密保问题');
$table->string('answer', 100)->nullable()->comment('密保答案');
$table->tinyInteger('sex')->default(0)->comment('性别 (0保密 1男 2女)');
$table->string('sign', 255)->nullable()->comment('个性签名');
$table->tinyInteger('user_level')->default(1)->comment('用户等级');
$table->dateTime('log_time')->nullable()->comment('登录时间');
$table->integer('visit_num')->default(0)->comment('访问次数');
$table->dateTime('in_time')->nullable()->comment('进房时间');
$table->tinyInteger('out_info')->default(0)->comment('退出信息');
$table->dateTime('out_time')->nullable()->comment('退出时间');
$table->integer('exp_num')->default(0)->index()->comment('经验值');
$table->tinyInteger('f_size')->nullable()->comment('字体大小');
$table->tinyInteger('l_height')->nullable()->comment('行高');
$table->tinyInteger('n_color')->nullable()->comment('名称颜色');
// s_color 直接以 varchar 存储 hex 颜色(如 #ff0000
$table->string('s_color', 10)->nullable()->comment('发言颜色hex如 #ff0000');
$table->string('remand', 250)->nullable()->comment('密码提示问题');
$table->string('bgcolor', 50)->nullable()->comment('背景颜色');
$table->string('temppass', 20)->nullable()->comment('临时密码');
$table->string('oicq', 30)->nullable()->comment('QQ号');
$table->tinyInteger('saved')->nullable()->comment('是否保存');
$table->string('first_ip', 50)->nullable()->comment('首次IP');
$table->string('last_ip', 50)->nullable()->comment('最后IP');
$table->string('aihaos', 250)->nullable()->comment('爱好');
$table->string('friends', 250)->nullable()->comment('好友列表');
$table->integer('headface')->nullable()->comment('头像');
$table->integer('room_id')->default(0)->index()->comment('所在房间');
$table->tinyInteger('auto_update')->nullable()->comment('自动刷新');
$table->string('ppass', 50)->nullable()->comment('二级密码');
$table->integer('jjb')->default(0)->comment('交友币/金币');
$table->string('love', 50)->nullable()->comment('伴侣');
$table->string('gzdw', 50)->nullable()->comment('工作单位');
$table->integer('photo')->nullable()->comment('照片');
$table->integer('hj')->default(0)->comment('呼叫状态');
$table->string('djname', 50)->nullable()->comment('等级名称');
$table->string('usersf', 50)->nullable()->comment('用户身份(头像图片名)');
$table->integer('yh')->nullable()->comment('隐身状态');
$table->text('userpassword')->nullable()->comment('备用密码');
$table->string('huiyuan', 50)->nullable()->comment('会员组别');
// VIP 会员等级 ID关联 vip_levels 表)
$table->unsignedBigInteger('vip_level_id')->nullable()->comment('会员等级ID');
$table->dateTime('hy_time')->nullable()->comment('会员到期时间');
$table->string('tuijian', 50)->nullable()->comment('推荐人');
$table->string('tuijian_ip', 50)->nullable()->comment('推荐IP');
$table->string('xiaohai', 50)->nullable()->comment('小孩');
$table->string('qingren', 50)->nullable()->comment('情人');
$table->string('zhufang', 50)->nullable()->comment('住房');
$table->string('zuoqiimg', 50)->nullable()->comment('坐骑图片');
$table->string('zuoqi', 50)->nullable()->comment('坐骑名称');
$table->integer('guanli')->nullable()->comment('管理员标记');
$table->integer('meili')->nullable()->comment('魅力值');
$table->integer('teshu')->nullable()->comment('特殊权限');
$table->dateTime('xr_time')->nullable()->comment('仙人时间');
$table->dateTime('yx_time')->nullable()->comment('英雄时间');
$table->integer('q1')->nullable();
$table->integer('q2')->nullable();
$table->integer('q3')->nullable();
$table->string('hua', 255)->nullable()->comment('鲜花');
$table->dateTime('sj')->nullable()->comment('注册/更新时间');
$table->string('pig', 255)->nullable()->comment('宠物');
$table->text('qianming')->nullable()->comment('个性签名(旧字段)');
$table->dateTime('q3_time')->nullable();
// 新人礼包是否已领取(首次入场赠送 6666 金币)
$table->boolean('has_received_new_gift')->default(false)->comment('是否已领取新人礼包');
$table->rememberToken();
$table->timestamps();
// VIP 外键(引用 vip_levels 表vip_levels 在后续迁移中创建)
// 注意:外键在 create_vip_levels_table 之后才添加
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* 回滚:删除用户相关表
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建房间表(含 visit_num 人气字段 + announcement 公告字段,合并历次变更)
*/
public function up(): void
{
Schema::create('rooms', function (Blueprint $table) {
$table->id();
$table->string('room_name', 10)->unique()->comment('房间标识/名称');
$table->string('room_auto', 10)->nullable()->comment('房间别名/自动属性');
$table->string('room_owner', 10)->nullable()->comment('房主');
$table->string('room_des', 250)->nullable()->comment('房间描述');
$table->string('announcement', 500)->nullable()->comment('房间公告/祝福语(滚动显示)');
$table->string('room_top', 100)->nullable()->comment('置顶信息');
$table->string('room_title', 250)->nullable()->comment('房间标题');
$table->tinyInteger('room_keep')->default(0)->comment('是否保留');
$table->dateTime('room_time')->nullable()->comment('建立/最后时间');
$table->tinyInteger('room_tt')->default(0)->comment('相关开关');
$table->tinyInteger('room_html')->default(0)->comment('是否允许HTML');
$table->integer('room_exp')->default(0)->comment('所需经验');
$table->dateTime('build_time')->nullable()->comment('建立时间');
$table->tinyInteger('permit_level')->default(1)->comment('允许进入的最低等级');
$table->tinyInteger('door_open')->default(1)->comment('大门是否开启 (1开 0关)');
$table->integer('ooooo')->nullable()->comment('未知/扩展属性');
$table->unsignedBigInteger('visit_num')->default(0)->comment('房间人气(总访问人次)');
$table->timestamps();
});
}
/**
* 回滚:删除 rooms
*/
public function down(): void
{
Schema::dropIfExists('rooms');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('audit_logs', function (Blueprint $table) {
$table->id();
$table->dateTime('occ_time')->nullable()->index()->comment('发生时间');
$table->text('occ_env')->nullable()->comment('发生环境/详情');
$table->tinyInteger('stype')->default(0)->comment('类别标识');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('audit_logs');
}
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('guestbooks', function (Blueprint $table) {
$table->id();
$table->string('who', 50)->index()->comment('留言人');
$table->string('towho', 50)->nullable()->index()->comment('给谁留言');
$table->tinyInteger('secret')->default(0)->comment('是否悄悄话 (1是 0否)');
$table->string('ip', 50)->nullable()->comment('留言者IP');
$table->string('email', 250)->nullable()->comment('留言者邮箱');
$table->string('web', 250)->nullable()->comment('留言者网站');
$table->string('addr', 250)->nullable()->comment('留言者地址');
$table->dateTime('post_time')->nullable()->index()->comment('留言时间');
$table->string('text_title', 250)->nullable()->comment('留言标题');
$table->text('text_body')->nullable()->comment('留言内容');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('guestbooks');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ip_locks', function (Blueprint $table) {
$table->id();
$table->string('ip', 20)->unique()->comment('封锁的IP');
$table->dateTime('end_time')->nullable()->comment('封禁结束时间');
$table->tinyInteger('act_level')->unsigned()->default(1)->comment('封禁级别');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ip_locks');
}
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('messages', function (Blueprint $table) {
$table->id();
$table->integer('room_id')->index()->comment('房间ID');
$table->string('from_user', 50)->index()->comment('发送者');
$table->string('to_user', 50)->nullable()->index()->comment('接收者');
$table->text('content')->comment('消息内容');
$table->tinyInteger('is_secret')->default(0)->comment('是否私聊');
$table->string('font_color', 50)->nullable()->comment('字体颜色');
$table->string('action', 50)->nullable()->comment('动作');
$table->dateTime('sent_at')->useCurrent()->index()->comment('发送时间');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('messages');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('actions', function (Blueprint $table) {
$table->id();
$table->string('act_name', 50)->unique()->comment('动作名称');
$table->string('alias', 50)->nullable()->comment('动作别名');
$table->string('toall', 200)->nullable()->comment('对所有人表现');
$table->string('toself', 200)->nullable()->comment('对自己的表现');
$table->string('toother', 200)->nullable()->comment('对其他人的表现');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('actions');
}
};

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('admin_logs', function (Blueprint $table) {
$table->id();
$table->string('username', 50)->index()->comment('管理员账号');
$table->integer('uu_level')->nullable()->comment('管理员等级');
$table->dateTime('in_time')->nullable()->comment('进入时间');
$table->integer('out_time')->nullable()->comment('离开时间');
$table->text('caozuo')->nullable()->comment('操作详情');
$table->integer('fs_sl')->default(0)->comment('封杀数量');
$table->text('fs_name')->nullable()->comment('封杀名单');
$table->integer('tr_sl')->default(0)->comment('踢人数量');
$table->text('tr_name')->nullable()->comment('踢人名单');
$table->integer('jg_sl')->default(0)->comment('警告数量');
$table->text('jg_name')->nullable()->comment('警告名单');
$table->integer('dj_sl')->default(0)->comment('冻结数量');
$table->text('dj_name')->nullable()->comment('冻结名单');
$table->integer('yjdj_sl')->default(0)->comment('永久冻结数量');
$table->text('yjdj_name')->nullable()->comment('永久冻结名单');
$table->integer('fip_sl')->default(0)->comment('封IP数量');
$table->text('fip_name')->nullable()->comment('封IP名单');
$table->integer('fjj_sl')->default(0)->comment('发奖金数量');
$table->integer('fjy_sl')->default(0)->comment('发经验数量');
$table->integer('flh_sl')->default(0)->comment('发老虎数量');
$table->dateTime('jl_time')->nullable()->index()->comment('记录时间');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('admin_logs');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('friend_calls', function (Blueprint $table) {
$table->id();
$table->string('who', 50)->index()->comment('呼叫人');
$table->string('towho', 50)->index()->comment('被呼叫人');
$table->text('callmess')->nullable()->comment('呼叫信息');
$table->dateTime('calltime')->nullable()->index()->comment('呼叫时间');
$table->tinyInteger('read')->default(0)->comment('是否已读 (1是 0否)');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('friend_calls');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('friend_requests', function (Blueprint $table) {
$table->id();
$table->string('who', 50)->index()->comment('申请人');
$table->string('towho', 50)->index()->comment('被申请人');
$table->dateTime('sub_time')->nullable()->index()->comment('申请时间');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('friend_requests');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ip_logs', function (Blueprint $table) {
$table->id();
$table->string('ip', 50)->index()->comment('登录IP');
$table->dateTime('sdate')->nullable()->index()->comment('登录时间');
$table->string('uuname', 50)->index()->comment('登录用户名');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ip_logs');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('marriages', function (Blueprint $table) {
$table->id();
$table->string('hyname', 50)->index()->comment('夫');
$table->string('hyname1', 50)->index()->comment('妻');
$table->dateTime('hytime')->nullable()->comment('结婚时间');
$table->string('hygb', 50)->nullable()->comment('婚姻状态/广播');
$table->string('hyjb', 50)->nullable()->comment('婚姻级别');
$table->integer('i')->nullable()->comment('亲密度/属性');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('marriages');
}
};

View File

@@ -11,8 +11,11 @@ return new class extends Migration
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('has_received_new_gift')->default(false)->after('id')->comment('是否已领取新人礼包');
Schema::create('room_descriptions', function (Blueprint $table) {
$table->id();
$table->string('alias', 10)->unique()->comment('房间别名关联');
$table->string('describ', 254)->nullable()->comment('房间详细描述文本');
$table->timestamps();
});
}
@@ -21,8 +24,6 @@ return new class extends Migration
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('has_received_new_gift');
});
Schema::dropIfExists('room_descriptions');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('scroll_ads', function (Blueprint $table) {
$table->id();
$table->string('ad_title', 250)->comment('广告/公告标题');
$table->string('ad_link', 250)->nullable()->comment('链接地址');
$table->tinyInteger('ad_new_flag')->default(0)->comment('新窗口打开标识 (1是 0否)');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('scroll_ads');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('user_items', function (Blueprint $table) {
$table->id();
$table->string('name', 50)->index()->comment('使用者');
$table->dateTime('times')->nullable()->index()->comment('获得时间');
$table->text('gg')->nullable()->comment('道具类型/说明');
$table->integer('dayy')->nullable()->comment('道具天数/数量');
$table->string('lx', 50)->nullable()->comment('道具种类');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_items');
}
};

View File

@@ -0,0 +1,82 @@
<?php
/**
* 文件功能创建系统参数表sysparam并填充所有默认配置
* 合并原来分散的多个 seed 迁移,统一在此处完成
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建 sysparam 表并一次性填入所有系统参数(最终值)
*/
public function up(): void
{
Schema::create('sysparam', function (Blueprint $table) {
$table->id();
$table->string('alias', 100)->unique()->comment('参数别名(唯一标识)');
$table->text('body')->nullable()->comment('参数值');
$table->string('guidetxt', 500)->nullable()->comment('参数说明(后台显示)');
$table->timestamps();
});
// 生成 99 级经验阶梯level^2.5 曲线,取整到十位)
$thresholds = [];
for ($level = 1; $level <= 99; $level++) {
$thresholds[] = (int) (ceil(10 * pow($level, 2.5) / 10) * 10);
}
$levelExpStr = implode(',', $thresholds);
$now = now();
DB::table('sysparam')->insert([
// ── 等级体系99 级)────────────────────────────────────────
['alias' => 'levelexp', 'body' => $levelExpStr, 'guidetxt' => '等级经验阈值配置逗号分隔第N个=升到N级所需累计经验', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'maxlevel', 'body' => '99', 'guidetxt' => '用户最高可达等级', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'superlevel', 'body' => '100', 'guidetxt' => '管理员级别(= 最高等级 + 1拥有最高权限的等级阈值', 'created_at' => $now, 'updated_at' => $now],
// ── 心跳奖励 ──────────────────────────────────────────────
['alias' => 'exp_per_heartbeat', 'body' => '1', 'guidetxt' => '⚡ 每次心跳经验奖励(支持固定值如"1"或范围如"1-10"0关闭', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'jjb_per_heartbeat', 'body' => '1-3', 'guidetxt' => '💰 每次心跳金币奖励(支持固定值如"1"或范围如"1-5"0关闭', 'created_at' => $now, 'updated_at' => $now],
// ── 管理操作权限等级 ──────────────────────────────────────
['alias' => 'level_warn', 'body' => '5', 'guidetxt' => '警告所需等级', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'level_mute', 'body' => '50', 'guidetxt' => '禁言所需等级', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'level_kick', 'body' => '60', 'guidetxt' => '踢人所需等级', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'level_announcement','body' => '60', 'guidetxt' => '设置公告所需等级', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'level_ban', 'body' => '80', 'guidetxt' => '封号所需等级', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'level_banip', 'body' => '90', 'guidetxt' => '封IP所需等级', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'level_freeze', 'body' => '14', 'guidetxt' => '冻结账号所需等级', 'created_at' => $now, 'updated_at' => $now],
// ── 随机事件 ──────────────────────────────────────────────
['alias' => 'auto_event_chance','body' => '10', 'guidetxt' => '随机事件触发概率百分比1-100', 'created_at' => $now, 'updated_at' => $now],
// ── 钓鱼系统 ──────────────────────────────────────────────
['alias' => 'fishing_cost', 'body' => '5', 'guidetxt' => '每次钓鱼花费金币数量', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'fishing_cooldown', 'body' => '300', 'guidetxt' => '钓鱼冷却时间默认300=5分钟', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'fishing_wait_min', 'body' => '8', 'guidetxt' => '钓鱼最短等待上钩时间(秒)', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'fishing_wait_max', 'body' => '15', 'guidetxt' => '钓鱼最长等待上钩时间(秒)', 'created_at' => $now, 'updated_at' => $now],
// ── 魅力系统 ──────────────────────────────────────────────
['alias' => 'charm_cross_sex', 'body' => '2', 'guidetxt' => '异性聊天每条消息增加的魅力值', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'charm_same_sex', 'body' => '1', 'guidetxt' => '同性聊天每条消息增加的魅力值', 'created_at' => $now, 'updated_at' => $now],
['alias' => 'charm_hourly_limit','body' => '20', 'guidetxt' => '每小时通过聊天获取的魅力值上限(防刷屏)', 'created_at' => $now, 'updated_at' => $now],
// ── 排行榜 ────────────────────────────────────────────────
['alias' => 'leaderboard_limit','body' => '20', 'guidetxt' => '🏆 排行榜每榜显示人数', 'created_at' => $now, 'updated_at' => $now],
]);
}
/**
* 回滚:删除 sysparam
*/
public function down(): void
{
Schema::dropIfExists('sysparam');
}
};

View File

@@ -0,0 +1,73 @@
<?php
/**
* 文件功能创建自动动作事件表autoact
* 复刻原版 ASP 聊天室的 autoact
* 存储系统随机事件(好运/坏运/经验/金币奖惩等)
* 管理员可在后台增删改这些事件
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建 autoact 表并插入默认随机事件
*/
public function up(): void
{
Schema::create('autoact', function (Blueprint $table) {
$table->id();
$table->string('text_body', 500)->comment('事件文本内容(支持变量替换)');
$table->string('event_type', 20)->default('neutral')->comment('事件类型good=好运, bad=坏运, neutral=中性');
$table->integer('exp_change')->default(0)->comment('经验变化值(正=奖励, 负=惩罚)');
$table->integer('jjb_change')->default(0)->comment('金币变化值(正=奖励, 负=惩罚)');
$table->boolean('enabled')->default(true)->comment('是否启用');
$table->timestamps();
});
// 插入默认随机事件
$events = [
// 好运事件(奖励经验/金币)
['text_body' => '🎉 恭喜【{username}】路遇仙人指点,获得 100 经验值!', 'event_type' => 'good', 'exp_change' => 100, 'jjb_change' => 0],
['text_body' => '💰 【{username}】在路边捡到一袋金币,获得 500 金币!', 'event_type' => 'good', 'exp_change' => 0, 'jjb_change' => 500],
['text_body' => '🌟 天降祥瑞!【{username}】获得 200 经验 + 200 金币!', 'event_type' => 'good', 'exp_change' => 200, 'jjb_change' => 200],
['text_body' => '🎊 【{username}】参加武林大会获胜,奖励 300 经验!', 'event_type' => 'good', 'exp_change' => 300, 'jjb_change' => 0],
['text_body' => '🏆 【{username}】完成了一个神秘任务,获得 150 金币!', 'event_type' => 'good', 'exp_change' => 0, 'jjb_change' => 150],
['text_body' => '✨ 【{username}】领悟了一招绝学,经验暴增 500', 'event_type' => 'good', 'exp_change' => 500, 'jjb_change' => 0],
['text_body' => '🎁 系统随机赠送【{username}】100 金币,请查收!', 'event_type' => 'good', 'exp_change' => 0, 'jjb_change' => 100],
// 坏运事件(扣除经验/金币)
['text_body' => '💀 【{username}】不小心踩到陷阱,损失 50 经验!', 'event_type' => 'bad', 'exp_change' => -50, 'jjb_change' => 0],
['text_body' => '😱 【{username}】遭遇山贼打劫,被抢走 100 金币!', 'event_type' => 'bad', 'exp_change' => 0, 'jjb_change' => -100],
['text_body' => '🌧️ 【{username}】在雨中迷路,消耗 80 经验值。', 'event_type' => 'bad', 'exp_change' => -80, 'jjb_change' => 0],
['text_body' => '🐍 【{username}】被毒蛇咬了一口,损失 30 经验和 50 金币!', 'event_type' => 'bad', 'exp_change' => -30, 'jjb_change' => -50],
// 中性事件(纯文字,不奖惩)
['text_body' => '🔮 星海小博士:【{username}】今天运势不错,继续加油!', 'event_type' => 'neutral', 'exp_change' => 0, 'jjb_change' => 0],
['text_body' => '📜 星海小博士:有人说"坚持就是胜利",【{username}】觉得呢?', 'event_type' => 'neutral', 'exp_change' => 0, 'jjb_change' => 0],
['text_body' => '🌈 星海小博士:【{username}】今天心情如何?记得多喝水哦!', 'event_type' => 'neutral', 'exp_change' => 0, 'jjb_change' => 0],
['text_body' => '🎵 星海小博士:送给【{username}】一首歌,祝你天天开心!', 'event_type' => 'neutral', 'exp_change' => 0, 'jjb_change' => 0],
];
$now = now();
foreach ($events as &$event) {
$event['enabled'] = true;
$event['created_at'] = $now;
$event['updated_at'] = $now;
}
DB::table('autoact')->insert($events);
}
/**
* 回滚:删除 autoact
*/
public function down(): void
{
Schema::dropIfExists('autoact');
}
};

View File

@@ -0,0 +1,129 @@
<?php
/**
* 文件功能:创建 vip_levels 会员等级配置表
* 存储会员等级名称、图标、颜色、倍率、专属模板等配置
* 后台可完整 CRUD 管理
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建 vip_levels 表并填充默认数据
*/
public function up(): void
{
Schema::create('vip_levels', function (Blueprint $table) {
$table->id();
$table->string('name', 50)->comment('会员名称(如:白银会员)');
$table->string('icon', 20)->default('⭐')->comment('等级图标/emoji');
$table->string('color', 10)->default('#f59e0b')->comment('等级颜色hex');
$table->decimal('exp_multiplier', 3, 1)->default(1.0)->comment('经验倍率');
$table->decimal('jjb_multiplier', 3, 1)->default(1.0)->comment('金币倍率');
$table->text('join_templates')->nullable()->comment('进入聊天室专属欢迎语 JSON 数组');
$table->text('leave_templates')->nullable()->comment('离开聊天室专属提示语 JSON 数组');
$table->tinyInteger('sort_order')->default(0)->comment('排序(越大越高级)');
$table->integer('price')->default(0)->comment('赞助金额(元,供展示参考)');
$table->integer('duration_days')->default(30)->comment('有效天数0=永久)');
$table->timestamps();
});
// 默认种子数据(后台可随时修改/删除/新增)
$now = now();
DB::table('vip_levels')->insert([
[
'name' => '白银会员',
'icon' => '🥈',
'color' => '#94a3b8',
'exp_multiplier' => 1.5,
'jjb_multiplier' => 1.2,
'join_templates' => json_encode([
'白银贵宾{username}乘坐银色马车缓缓驶入,气质不凡!',
'白银贵宾{username}手持银色令牌,大步流星走了进来!',
], JSON_UNESCAPED_UNICODE),
'leave_templates' => json_encode([
'白银贵宾{username}挥了挥手,潇洒离去',
'白银贵宾{username}骑着银色骏马飘然而去',
], JSON_UNESCAPED_UNICODE),
'sort_order' => 1,
'price' => 10,
'duration_days' => 30,
'created_at' => $now,
'updated_at' => $now,
],
[
'name' => '黄金会员',
'icon' => '🥇',
'color' => '#f59e0b',
'exp_multiplier' => 2.0,
'jjb_multiplier' => 1.5,
'join_templates' => json_encode([
'黄金贵宾{username}踩着金光闪闪的地毯,王者归来!',
'黄金贵宾{username}开着金色豪车呼啸而至,全场瞩目!',
], JSON_UNESCAPED_UNICODE),
'leave_templates' => json_encode([
'黄金贵宾{username}乘金色祥云腾空而去,霸气侧漏!',
'黄金贵宾{username}微微拱手,金光一闪消失不见',
], JSON_UNESCAPED_UNICODE),
'sort_order' => 2,
'price' => 30,
'duration_days' => 30,
'created_at' => $now,
'updated_at' => $now,
],
[
'name' => '钻石会员',
'icon' => '💎',
'color' => '#3b82f6',
'exp_multiplier' => 3.0,
'jjb_multiplier' => 2.0,
'join_templates' => json_encode([
'钻石贵宾{username}踏着星辰大海从天而降,万众敬仰!',
'钻石贵宾{username}驾驭钻石巨龙破空而来,威震四方!',
], JSON_UNESCAPED_UNICODE),
'leave_templates' => json_encode([
'钻石贵宾{username}化作一道星光冲天而去,令人叹服!',
'钻石贵宾{username}乘坐钻石飞船消失在银河尽头',
], JSON_UNESCAPED_UNICODE),
'sort_order' => 3,
'price' => 50,
'duration_days' => 30,
'created_at' => $now,
'updated_at' => $now,
],
[
'name' => '至尊会员',
'icon' => '👑',
'color' => '#a855f7',
'exp_multiplier' => 5.0,
'jjb_multiplier' => 3.0,
'join_templates' => json_encode([
'👑至尊{username}御驾亲临!九天雷鸣,万物俯首!众卿接驾!',
'👑至尊{username}脚踏七彩祥云,身披紫金龙袍,驾临此地!天地为之变色!',
], JSON_UNESCAPED_UNICODE),
'leave_templates' => json_encode([
'👑至尊{username}龙袍一甩,紫气东来,瞬间消失在九天之上!',
'👑至尊{username}御驾回宫,百鸟齐鸣相送!',
], JSON_UNESCAPED_UNICODE),
'sort_order' => 4,
'price' => 100,
'duration_days' => 30,
'created_at' => $now,
'updated_at' => $now,
],
]);
}
/**
* 回滚:删除 vip_levels
*/
public function down(): void
{
Schema::dropIfExists('vip_levels');
}
};

View File

@@ -0,0 +1,70 @@
<?php
/**
* 文件功能:创建 AI 厂商配置表和 AI 使用日志表
*
* ai_provider_configs 存储多个 AI 厂商的 API 配置(密钥、端点、模型等)
* ai_usage_logs 记录每次 AI 接口调用的 token 消耗和响应信息
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 执行迁移:创建 AI 相关的两张数据表
*/
public function up(): void
{
// AI 厂商配置表
Schema::create('ai_provider_configs', function (Blueprint $table) {
$table->id();
$table->string('provider', 50)->index()->comment('厂商标识(如 deepseek, qwen, openai');
$table->string('name', 100)->comment('厂商显示名称');
$table->text('api_key')->comment('API Key加密存储');
$table->string('api_endpoint', 255)->comment('API 端点地址');
$table->string('model', 100)->comment('使用的模型名称');
$table->decimal('temperature', 3, 2)->default(0.30)->comment('温度参数');
$table->integer('max_tokens')->default(2048)->comment('最大 Token 数');
$table->boolean('is_enabled')->default(true)->index()->comment('是否启用');
$table->boolean('is_default')->default(false)->comment('是否为默认厂商');
$table->integer('sort_order')->default(0)->comment('排序(故障转移时按此顺序)');
$table->timestamps();
});
// AI 使用日志表
Schema::create('ai_usage_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete()->comment('使用者');
$table->string('provider', 50)->comment('AI 厂商标识');
$table->string('model', 100)->comment('使用的模型');
$table->string('action', 50)->default('chatbot')->comment('操作类型');
$table->integer('prompt_tokens')->default(0)->comment('输入 Token 数');
$table->integer('completion_tokens')->default(0)->comment('输出 Token 数');
$table->integer('total_tokens')->default(0)->comment('总 Token 数');
$table->decimal('cost', 10, 6)->default(0)->comment('费用');
$table->integer('response_time_ms')->default(0)->comment('响应时间(毫秒)');
$table->boolean('success')->default(true)->comment('是否成功');
$table->text('error_message')->nullable()->comment('错误信息');
$table->timestamps();
// 索引
$table->index(['provider', 'created_at']);
});
}
/**
* 回滚迁移:删除 AI 相关的两张数据表
*/
public function down(): void
{
Schema::dropIfExists('ai_usage_logs');
Schema::dropIfExists('ai_provider_configs');
}
};

View File

@@ -0,0 +1,57 @@
<?php
/**
* 文件功能:创建 gifts 礼物表并填充默认鲜花数据
*
* 礼物系统支持后台管理多种花/礼物类型,每种有不同的金币消耗和魅力增量。
* 图片存放在 public/images/gifts/ 目录下。
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建 gifts 表并填充默认礼物数据
*/
public function up(): void
{
Schema::create('gifts', function (Blueprint $table) {
$table->id();
$table->string('name', 50)->comment('礼物名称');
$table->string('emoji', 10)->comment('显示图标/emoji');
$table->string('image', 100)->nullable()->comment('礼物图片路径(相对 /images/gifts/');
$table->unsignedInteger('cost')->default(0)->comment('消耗金币数');
$table->unsignedInteger('charm')->default(1)->comment('增加魅力值');
$table->unsignedTinyInteger('sort_order')->default(0)->comment('排序(越小越靠前)');
$table->boolean('is_active')->default(true)->comment('是否启用');
$table->timestamps();
});
// 填充默认鲜花数据(图片文件名与 sort_order 对应)
DB::table('gifts')->insert([
['name' => '小雏菊', 'emoji' => '🌼', 'image' => 'daisy.png', 'cost' => 5, 'charm' => 1, 'sort_order' => 1, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '玫瑰花', 'emoji' => '🌹', 'image' => 'rose.png', 'cost' => 10, 'charm' => 2, 'sort_order' => 2, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '向日葵', 'emoji' => '🌻', 'image' => 'sunflower.png', 'cost' => 20, 'charm' => 5, 'sort_order' => 3, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '樱花束', 'emoji' => '🌸', 'image' => 'sakura.png', 'cost' => 50, 'charm' => 12, 'sort_order' => 4, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '满天星', 'emoji' => '💐', 'image' => 'bouquet.png', 'cost' => 100, 'charm' => 30, 'sort_order' => 5, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '蓝色妖姬', 'emoji' => '🪻', 'image' => 'bluerose.png', 'cost' => 200, 'charm' => 66, 'sort_order' => 6, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '钻石花冠', 'emoji' => '👑', 'image' => 'crown.png', 'cost' => 520, 'charm' => 188, 'sort_order' => 7, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
]);
}
/**
* 回滚:删除 gifts
*/
public function down(): void
{
Schema::dropIfExists('gifts');
}
};

View File

@@ -1,44 +0,0 @@
<?php
/**
* 文件功能创建商店商品表shop_items
* 存储商店内所有可购买的商品定义
*
* @package Database\Migrations
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 执行迁移:创建商品表
*/
public function up(): void
{
Schema::create('shop_items', function (Blueprint $table) {
$table->id();
$table->string('name', 50)->comment('商品名称');
$table->string('slug', 50)->unique()->comment('商品唯一标识');
$table->string('description', 255)->nullable()->comment('商品描述');
$table->string('icon', 20)->default('🛍')->comment('商品图标 emoji');
$table->unsignedInteger('price')->comment('价格(金币)');
// type: instant=单次立即执行, duration=有时效, one_time=一次性道具
$table->enum('type', ['instant', 'duration', 'one_time'])->comment('商品类型');
$table->unsignedTinyInteger('duration_days')->nullable()->comment('有效天数duration 类型用)');
$table->unsignedTinyInteger('sort_order')->default(0)->comment('排序');
$table->boolean('is_active')->default(true)->comment('是否上架');
$table->timestamps();
});
}
/**
* 回滚迁移:删除商品表
*/
public function down(): void
{
Schema::dropIfExists('shop_items');
}
};

View File

@@ -0,0 +1,86 @@
<?php
/**
* 文件功能:创建商店相关表
* shop_items 商品定义(特效卡、周卡、改名卡等)
* user_purchases 用户购买记录(含状态与有效期)
* username_blacklist 用户改名后的旧名称保留黑名单
*
* @author ChatRoom Laravel
* @version 1.0.0
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建商店相关三张表并填充默认商品
*/
public function up(): void
{
// ── 商品表 ────────────────────────────────────────────────────
Schema::create('shop_items', function (Blueprint $table) {
$table->id();
$table->string('name', 50)->comment('商品名称');
$table->string('slug', 50)->unique()->comment('唯一标识(如 once_fireworks');
$table->string('description', 255)->nullable()->comment('商品描述');
$table->string('icon', 20)->nullable()->comment('显示图标 emoji');
$table->unsignedInteger('price')->default(0)->comment('金币价格');
$table->string('type', 20)->default('instant')->comment('类型instant=单次 / duration=周卡 / rename=改名');
$table->unsignedTinyInteger('duration_days')->nullable()->comment('有效天数duration 类型)');
$table->unsignedTinyInteger('sort_order')->default(0)->comment('排序(越小越靠前)');
$table->boolean('is_active')->default(true)->comment('是否上架');
$table->timestamps();
});
// 填充默认商品
DB::table('shop_items')->insert([
['name' => '🎆 单次烟花', 'slug' => 'once_fireworks', 'description' => '全场燃放一次烟花特效', 'icon' => '🎆', 'price' => 888, 'type' => 'instant', 'duration_days' => null, 'sort_order' => 1, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '🌧️ 单次下雨', 'slug' => 'once_rain', 'description' => '全场下一次雨特效', 'icon' => '🌧️', 'price' => 888, 'type' => 'instant', 'duration_days' => null, 'sort_order' => 2, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '⚡ 单次雷电', 'slug' => 'once_lightning', 'description' => '全场一次雷电特效', 'icon' => '⚡', 'price' => 888, 'type' => 'instant', 'duration_days' => null, 'sort_order' => 3, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '❄️ 单次下雪', 'slug' => 'once_snow', 'description' => '全场下一次雪特效', 'icon' => '❄️', 'price' => 888, 'type' => 'instant', 'duration_days' => null, 'sort_order' => 4, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '🎆 烟花周卡', 'slug' => 'week_fireworks', 'description' => '7天内进房间自动放烟花', 'icon' => '🎆', 'price' => 8888, 'type' => 'duration', 'duration_days' => 7, 'sort_order' => 5, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '🌧️ 下雨周卡', 'slug' => 'week_rain', 'description' => '7天内进房间自动下雨', 'icon' => '🌧️', 'price' => 8888, 'type' => 'duration', 'duration_days' => 7, 'sort_order' => 6, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '⚡ 雷电周卡', 'slug' => 'week_lightning', 'description' => '7天内进房间自动雷电', 'icon' => '⚡', 'price' => 8888, 'type' => 'duration', 'duration_days' => 7, 'sort_order' => 7, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '❄️ 下雪周卡', 'slug' => 'week_snow', 'description' => '7天内进房间自动下雪', 'icon' => '❄️', 'price' => 8888, 'type' => 'duration', 'duration_days' => 7, 'sort_order' => 8, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
['name' => '✏️ 改名卡', 'slug' => 'rename_card', 'description' => '修改一次用户名(受黑名单限制)', 'icon' => '✏️', 'price' => 5000, 'type' => 'rename', 'duration_days' => null, 'sort_order' => 9, 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
]);
// ── 购买记录表 ────────────────────────────────────────────────
Schema::create('user_purchases', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id')->index()->comment('购买用户 ID');
$table->unsignedBigInteger('shop_item_id')->comment('商品 ID');
$table->string('status', 20)->default('active')->comment('状态active / used / expired');
$table->unsignedInteger('price_paid')->default(0)->comment('实际支付金币数');
$table->timestamp('expires_at')->nullable()->comment('过期时间duration 类型有效)');
$table->timestamp('used_at')->nullable()->comment('使用时间instant 类型有效)');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
$table->foreign('shop_item_id')->references('id')->on('shop_items')->cascadeOnDelete();
});
// ── 用户名黑名单表 ────────────────────────────────────────────
Schema::create('username_blacklist', function (Blueprint $table) {
$table->id();
$table->string('username', 50)->index()->comment('被保留的旧用户名');
$table->timestamp('reserved_until')->nullable()->comment('保留截止时间(过期后可被注册)');
$table->timestamp('created_at')->nullable()->comment('写入时间');
});
}
/**
* 回滚:删除商店相关三张表
*/
public function down(): void
{
Schema::dropIfExists('user_purchases');
Schema::dropIfExists('shop_items');
Schema::dropIfExists('username_blacklist');
}
};

View File

@@ -1,49 +0,0 @@
<?php
/**
* 文件功能创建用户购买记录表user_purchases
* 记录每个用户购买商店商品的流水与状态
*
* @package Database\Migrations
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 执行迁移:创建购买记录表
*/
public function up(): void
{
Schema::create('user_purchases', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id')->comment('购买用户 ID');
$table->unsignedBigInteger('shop_item_id')->comment('商品 ID');
// status:
// active = 有效中(周卡 / 改名卡未使用)
// expired = 已过期(周卡到期)
// used = 已使用(单次卡已播 / 改名卡已用)
// cancelled = 被新购买的周卡覆盖作废(金币不退)
$table->enum('status', ['active', 'expired', 'used', 'cancelled'])->default('active');
$table->unsignedInteger('price_paid')->comment('购买时实际扣除金币');
$table->timestamp('expires_at')->nullable()->comment('到期时间duration 类型使用)');
$table->timestamp('used_at')->nullable()->comment('使用时间one_time/instant 使用)');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('shop_item_id')->references('id')->on('shop_items')->onDelete('cascade');
$table->index(['user_id', 'status']);
});
}
/**
* 回滚迁移:删除购买记录表
*/
public function down(): void
{
Schema::dropIfExists('user_purchases');
}
};

View File

@@ -1,36 +0,0 @@
<?php
/**
* 文件功能创建用户名黑名单表username_blacklist
* 用户使用改名卡后旧名称写入此表保留30天防止他人立即抢注
*
* @package Database\Migrations
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 执行迁移:创建用户名黑名单表
*/
public function up(): void
{
Schema::create('username_blacklist', function (Blueprint $table) {
$table->id();
$table->string('username', 20)->unique()->comment('被保留的旧用户名');
$table->timestamp('reserved_until')->comment('保留到期时间默认30天');
$table->timestamp('created_at')->nullable();
});
}
/**
* 回滚迁移:删除黑名单表
*/
public function down(): void
{
Schema::dropIfExists('username_blacklist');
}
};

View File

@@ -1,9 +1,8 @@
<?php
/**
* 文件功能:用户积分流水表 Migration
* 记录所有经验、金币、魅力的变更明细,提供今日排行与活动统计数据源。
* 使用 user_id 作为真实身份锚点username 仅为写入时快照,支持改名场景。
* 文件功能:创建用户积分流水表user_currency_logs
* 记录所有用户经验/金币/魅力的变动来源与金额,支持今日排行与活动统计
*
* @author ChatRoom Laravel
* @version 1.0.0
@@ -16,54 +15,51 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建 user_currency_logs 流水表。
* 创建 user_currency_logs
*/
public function up(): void
{
Schema::create('user_currency_logs', function (Blueprint $table) {
$table->id();
// 真实身份锚点:使用 user_id,即使用户改名历史记录仍可准确归属
$table->unsignedBigInteger('user_id')->index()->comment('用户 ID身份锚点,不随改名变化');
// 用户锚点: user_id 为不变标识username 仅为当时的快照(用户改名
$table->unsignedBigInteger('user_id')->index()->comment('用户 ID不变锚点');
$table->string('username', 50)->comment('用户名快照(记录时的名称)');
// 写入时的用户名快照:仅用于日志可读性,排行榜展示取 users.username 当前值
$table->string('username', 50)->comment('操作时刻用户名快照');
// 货币类型exp=经验 / gold=金币 / charm=魅力
$table->string('currency', 10)->comment('货币类型exp/gold/charm');
// 货币类型(对应 CurrencySource 枚举varchar 允许未来无缝新增
$table->string('currency', 20)->comment('货币类型: exp / gold / charm / 以后可自由扩展');
// 变动量(正=增加,负=消耗
$table->integer('amount')->comment('变动量(正数=增加,负数=消耗)');
// 变更量(正数增加,负数扣除
$table->integer('amount')->comment('变更量,正数为增加,负数为扣除');
// 变动后的余额快照(便于追溯异常
$table->integer('balance_after')->comment('变动后余额');
// 变更后余额(方便对账,无需重算历史
$table->integer('balance_after')->comment('变更后余额快照');
// 来源标识(由 CurrencySource enum 管理,如 auto_save / fishing_gain / admin_adjust 等
$table->string('source', 30)->index()->comment('来源CurrencySource 枚举值)');
// 来源活动varchar 非 ENUM新增活动无需改表只在 CurrencySource 枚举加一行
$table->string('source', 30)->comment('来源标识: auto_save / fishing_gain / send_gift / ...');
// 备注(可选,附加上下文信息
$table->string('remark', 200)->nullable()->comment('备注信息');
// 备注(补充说明,如"送花给流星"
$table->string('remark', 255)->default('')->comment('操作备注');
// 发生房间(可选
$table->unsignedBigInteger('room_id')->nullable()->comment('操作所在房间ID');
// 发生所在房间(部分操作无房间)
$table->unsignedInteger('room_id')->nullable()->comment('所在房间 ID无则为 null');
// 只记录创建时间,流水不允许更新
$table->timestamp('created_at')->nullable()->index()->comment('记录时间');
// 只记录创建时间,流水不可修改
$table->timestamp('created_at')->useCurrent()->comment('记录时间');
// 复合索引:高效支持今日排行榜查询(按日期+货币+用户汇总)
$table->index(['currency', 'created_at'], 'idx_currency_date');
// ── 索引(按高频查询场景设计)────────────────────────────
// 今日排行快速聚合:按货币类型 + 日期 + 金额
$table->index(['currency', 'created_at', 'amount'], 'idx_daily_board');
// 复合索引:高效支持用户个人日志查询
$table->index(['user_id', 'currency', 'created_at'], 'idx_user_currency_date');
// 用户个人流水查询:按 user_id + 货币类型 + 时间
$table->index(['user_id', 'currency', 'created_at'], 'idx_user_log');
// 活动统计聚合:按来源 + 货币类型 + 日期
$table->index(['source', 'currency', 'created_at'], 'idx_source_stat');
// 复合索引:高效支持活动来源统计
$table->index(['source', 'currency', 'created_at'], 'idx_source_currency_date');
});
}
/**
* 回滚:删除流水表
* 回滚:删除流水表
*/
public function down(): void
{

View File

@@ -22,6 +22,10 @@
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.dashboard') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
📊 仪表盘
</a>
<a href="{{ route('admin.currency-stats.index') }}"
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.currency-stats.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
📈 积分流水统计
</a>
@if (Auth::id() === 1)
<a href="{{ route('admin.system.edit') }}"
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.system.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
@@ -48,10 +52,7 @@
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.vip.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
👑 VIP 会员等级
</a>
<a href="{{ route('admin.currency-stats.index') }}"
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.currency-stats.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
📈 积分流水统计
</a>
@if (Auth::id() === 1)
<a href="{{ route('admin.ai-providers.index') }}"
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.ai-providers.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">