Add baccarat loss cover activity
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:百家乐买单活动主表迁移
|
||||
*
|
||||
* 保存每一次“你玩游戏我买单”活动的完整档案,
|
||||
* 包括开启人、开始时间、结束时间、领取截止时间与最终补偿发放总额。
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 创建 baccarat_loss_cover_events 表。
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('baccarat_loss_cover_events', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title', 100)->comment('活动标题');
|
||||
$table->string('description', 500)->nullable()->comment('活动说明');
|
||||
$table->enum('status', ['scheduled', 'active', 'settlement_pending', 'claimable', 'completed', 'cancelled'])
|
||||
->default('scheduled')
|
||||
->comment('活动状态');
|
||||
$table->dateTime('starts_at')->comment('活动开始时间');
|
||||
$table->dateTime('ends_at')->comment('活动结束时间');
|
||||
$table->dateTime('claim_deadline_at')->comment('补偿领取截止时间');
|
||||
$table->foreignId('created_by_user_id')
|
||||
->nullable()
|
||||
->constrained('users')
|
||||
->nullOnDelete()
|
||||
->comment('开启人');
|
||||
$table->foreignId('closed_by_user_id')
|
||||
->nullable()
|
||||
->constrained('users')
|
||||
->nullOnDelete()
|
||||
->comment('结束人');
|
||||
$table->timestamp('started_notice_sent_at')->nullable()->comment('开始通知发送时间');
|
||||
$table->timestamp('ended_notice_sent_at')->nullable()->comment('结束通知发送时间');
|
||||
$table->unsignedInteger('participant_count')->default(0)->comment('参与人数');
|
||||
$table->unsignedInteger('compensable_user_count')->default(0)->comment('可领取补偿人数');
|
||||
$table->unsignedBigInteger('total_loss_amount')->default(0)->comment('活动内用户总输金币');
|
||||
$table->unsignedBigInteger('total_claimed_amount')->default(0)->comment('最终已补偿发放金币');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['status', 'starts_at'], 'blce_status_starts_idx');
|
||||
$table->index(['starts_at', 'ends_at'], 'blce_window_idx');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚迁移。
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('baccarat_loss_cover_events');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:百家乐买单活动用户记录表迁移
|
||||
*
|
||||
* 为每次活动中的每个用户维护一条聚合记录,
|
||||
* 便于前台查看参与情况、补偿金额以及领取状态。
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 创建 baccarat_loss_cover_records 表。
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('baccarat_loss_cover_records', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('event_id')
|
||||
->constrained('baccarat_loss_cover_events')
|
||||
->cascadeOnDelete()
|
||||
->comment('所属活动 ID');
|
||||
$table->foreignId('user_id')
|
||||
->constrained('users')
|
||||
->cascadeOnDelete()
|
||||
->comment('参与用户 ID');
|
||||
$table->unsignedBigInteger('total_bet_amount')->default(0)->comment('活动内累计下注金额');
|
||||
$table->unsignedBigInteger('total_win_payout')->default(0)->comment('活动内累计赢钱赔付');
|
||||
$table->unsignedBigInteger('total_loss_amount')->default(0)->comment('活动内累计输掉金币');
|
||||
$table->unsignedBigInteger('compensation_amount')->default(0)->comment('可领取补偿总额');
|
||||
$table->enum('claim_status', ['not_eligible', 'pending', 'claimed', 'expired'])
|
||||
->default('not_eligible')
|
||||
->comment('领取状态');
|
||||
$table->unsignedBigInteger('claimed_amount')->default(0)->comment('已领取补偿金额');
|
||||
$table->timestamp('claimed_at')->nullable()->comment('领取时间');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['event_id', 'user_id'], 'uq_blcr_event_user');
|
||||
$table->index(['user_id', 'claim_status'], 'blcr_user_claim_status_idx');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚迁移。
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('baccarat_loss_cover_records');
|
||||
}
|
||||
};
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:为百家乐下注表补充买单活动关联字段
|
||||
*
|
||||
* 用于标记某一笔下注是否参与了指定的买单活动。
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 为 baccarat_bets 表新增活动关联字段。
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('baccarat_bets', function (Blueprint $table) {
|
||||
$table->foreignId('loss_cover_event_id')
|
||||
->nullable()
|
||||
->after('user_id')
|
||||
->constrained('baccarat_loss_cover_events')
|
||||
->nullOnDelete()
|
||||
->comment('参与的买单活动 ID');
|
||||
|
||||
$table->index(['loss_cover_event_id', 'status'], 'bb_loss_cover_status_idx');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚新增字段。
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('baccarat_bets', function (Blueprint $table) {
|
||||
$table->dropIndex('bb_loss_cover_status_idx');
|
||||
$table->dropConstrainedForeignId('loss_cover_event_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user