新增银行功能:存取金币、流水记录、PC/手机端双入口;迁移 bank_jjb 字段和 bank_logs 表
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:为 users 表新增银行存款字段 bank_jjb
|
||||
*
|
||||
* 银行金币与流通金币(jjb)完全隔离,所有游戏仅扣 jjb,不动 bank_jjb。
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 执行迁移:在 frozen_jjb 之后追加 bank_jjb 字段
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table): void {
|
||||
$table->integer('bank_jjb')->default(0)->after('frozen_jjb')->comment('银行存款金币(与流通金币隔离)');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚迁移
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table): void {
|
||||
$table->dropColumn('bank_jjb');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:创建银行流水记录表 bank_logs
|
||||
*
|
||||
* 记录每次存款、取款的明细,便于用户查看历史。
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 执行迁移:创建 bank_logs 流水表
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bank_logs', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('user_id')->comment('操作用户ID');
|
||||
$table->enum('type', ['deposit', 'withdraw'])->comment('操作类型:存款/取款');
|
||||
$table->integer('amount')->comment('操作金额(正数)');
|
||||
$table->integer('balance_after')->comment('操作后 bank_jjb 余额');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id', 'created_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚迁移
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bank_logs');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user