| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <?php
- 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('payment_direct_recharges', function (Blueprint $table) {
- $table->id();
- $table->string('recharge_code', 64)->unique()->comment('充值ID/前端识别码');
- $table->string('name', 100);
- $table->decimal('amount', 20, 2);
- $table->decimal('fee_rate', 8, 4)->default(0)->comment('手续费百分比');
- $table->tinyInteger('status')->default(1)->index();
- $table->unsignedBigInteger('operator_id')->nullable();
- $table->string('operator_name', 100)->default('');
- $table->timestamps();
- $table->softDeletes();
- });
- Schema::create('payment_gateways', function (Blueprint $table) {
- $table->id();
- $table->string('kind', 16)->index()->comment('deposit/withdraw');
- $table->string('currency', 16)->default('RMB');
- $table->string('payment_company', 100);
- $table->string('merchant_no', 128);
- $table->string('payment_method', 64)->default('');
- $table->string('channel_code', 64)->default('');
- $table->string('channel_name', 100)->default('');
- $table->decimal('fee_rate', 8, 4)->default(0);
- $table->text('withdrawal_secret')->nullable();
- $table->decimal('min_amount', 20, 2)->default(0);
- $table->decimal('max_amount', 20, 2)->default(0);
- $table->string('level_scope', 64)->default('all');
- $table->unsignedInteger('sort')->default(0);
- $table->tinyInteger('status')->default(1)->index();
- $table->unsignedBigInteger('operator_id')->nullable();
- $table->string('operator_name', 100)->default('');
- $table->timestamps();
- $table->softDeletes();
- $table->index(['kind', 'payment_company']);
- });
- Schema::create('payment_collection_channels', function (Blueprint $table) {
- $table->id();
- $table->string('kind', 24)->index()->comment('collection_scan/collection_third_party');
- $table->string('currency', 16)->default('RMB');
- $table->string('provider_name', 100);
- $table->string('group_name', 100);
- $table->string('collection_method', 64);
- $table->string('channel_code', 64);
- $table->string('channel_name', 100);
- $table->decimal('fee_rate', 8, 4)->default(0);
- $table->decimal('min_amount', 20, 2)->default(0);
- $table->decimal('max_amount', 20, 2)->default(0);
- $table->string('level_scope', 64)->default('all');
- $table->unsignedInteger('sort')->default(0);
- $table->tinyInteger('status')->default(1)->index();
- $table->unsignedBigInteger('operator_id')->nullable();
- $table->string('operator_name', 100)->default('');
- $table->timestamps();
- $table->softDeletes();
- });
- Schema::create('operation_audits', function (Blueprint $table) {
- $table->id();
- $table->string('resource_type', 64)->index();
- $table->unsignedBigInteger('resource_id')->nullable()->index();
- $table->string('action', 32);
- $table->json('changes')->nullable();
- $table->unsignedBigInteger('operator_id')->nullable();
- $table->string('operator_name', 100)->default('');
- $table->timestamp('created_at')->useCurrent()->index();
- $table->index(['resource_type', 'resource_id', 'created_at'], 'idx_operation_audits_resource');
- });
- Schema::create('app_settings', function (Blueprint $table) {
- $table->id();
- $table->tinyInteger('ios_frontend_visible')->default(0);
- $table->tinyInteger('android_frontend_visible')->default(0);
- $table->unsignedBigInteger('operator_id')->nullable();
- $table->string('operator_name', 100)->default('');
- $table->timestamps();
- });
- Schema::create('app_packages', function (Blueprint $table) {
- $table->id();
- $table->string('platform', 16)->index();
- $table->string('version', 50);
- $table->string('package_name', 150);
- $table->tinyInteger('force_update')->default(0);
- $table->string('package_type', 32);
- $table->string('download_url', 1000);
- $table->text('update_content')->nullable();
- $table->tinyInteger('status')->default(1)->index();
- $table->unsignedBigInteger('operator_id')->nullable();
- $table->string('operator_name', 100)->default('');
- $table->timestamps();
- $table->softDeletes();
- $table->index(['platform', 'version']);
- });
- Schema::create('app_download_events', function (Blueprint $table) {
- $table->id();
- $table->string('event_key', 64)->unique()->comment('客户端事件幂等键哈希');
- $table->unsignedBigInteger('package_id')->nullable()->index();
- $table->string('event_type', 16)->index()->comment('click/open');
- $table->string('platform', 16)->index();
- $table->string('package_type', 32)->default('');
- $table->string('source', 100)->default('direct');
- $table->string('download_url', 1000)->default('')->comment('事件发生时下载链接快照');
- $table->string('app_version', 50)->default('');
- $table->string('device_id_hash', 64)->default('')->index();
- $table->string('ip_hash', 64)->default('');
- $table->timestamp('occurred_at')->useCurrent()->index();
- $table->index(['event_type', 'occurred_at']);
- $table->index(['ip_hash', 'occurred_at']);
- $table->index(['device_id_hash', 'occurred_at']);
- });
- Schema::create('app_ios_review_settings', function (Blueprint $table) {
- $table->id();
- $table->string('platform', 16)->default('ios');
- $table->string('store_version', 50)->index();
- $table->string('operating_version', 50);
- $table->json('review_user_ids')->nullable();
- $table->tinyInteger('status')->default(1)->index();
- $table->unsignedBigInteger('operator_id')->nullable();
- $table->string('operator_name', 100)->default('');
- $table->timestamps();
- $table->softDeletes();
- });
- Schema::create('share_settings', function (Blueprint $table) {
- $table->id();
- $table->tinyInteger('enabled')->default(0);
- $table->string('share_domain', 500)->default('');
- $table->decimal('valid_member_min_deposit', 20, 2)->default(20);
- $table->tinyInteger('benefit_enabled')->default(0);
- $table->decimal('non_seller_threshold', 20, 2)->default(200);
- $table->decimal('tier_one_rate', 8, 4)->default(4);
- $table->decimal('tier_two_rate', 8, 4)->default(6);
- $table->unsignedBigInteger('operator_id')->nullable();
- $table->string('operator_name', 100)->default('');
- $table->timestamps();
- });
- Schema::create('share_blacklists', function (Blueprint $table) {
- $table->id();
- $table->unsignedBigInteger('user_id')->index();
- $table->string('member_id', 64)->index();
- $table->json('blocked_categories');
- $table->tinyInteger('status')->default(1)->index();
- $table->unsignedBigInteger('operator_id')->nullable();
- $table->string('operator_name', 100)->default('');
- $table->timestamps();
- $table->softDeletes();
- $table->unique('user_id');
- });
- Schema::create('share_commission_records', function (Blueprint $table) {
- $table->id();
- $table->date('stat_date')->index();
- $table->unsignedBigInteger('promoter_user_id')->index();
- $table->unsignedBigInteger('invitee_user_id')->nullable()->index();
- $table->string('type', 24)->comment('commission/fee_waiver');
- $table->string('category', 32)->default('');
- $table->decimal('base_amount', 20, 4)->default(0);
- $table->decimal('rate', 8, 4)->default(0);
- $table->decimal('amount', 20, 4)->default(0);
- $table->string('source_type', 64)->default('');
- $table->string('source_id', 100)->default('');
- $table->tinyInteger('status')->default(1);
- $table->timestamps();
- $table->index(['promoter_user_id', 'stat_date', 'type'], 'idx_share_commission_promoter');
- $table->unique(['source_type', 'source_id', 'type', 'promoter_user_id'], 'uniq_share_commission_source');
- });
- DB::table('app_settings')->insert([
- 'ios_frontend_visible' => 0,
- 'android_frontend_visible' => 0,
- 'created_at' => now(),
- 'updated_at' => now(),
- ]);
- DB::table('share_settings')->insert([
- 'enabled' => 0,
- 'share_domain' => '',
- 'valid_member_min_deposit' => 20,
- 'benefit_enabled' => 0,
- 'non_seller_threshold' => 200,
- 'tier_one_rate' => 4,
- 'tier_two_rate' => 6,
- 'created_at' => now(),
- 'updated_at' => now(),
- ]);
- }
- public function down(): void
- {
- foreach ([
- 'share_commission_records', 'share_blacklists', 'share_settings',
- 'app_ios_review_settings', 'app_download_events', 'app_packages', 'app_settings',
- 'operation_audits', 'payment_collection_channels', 'payment_gateways',
- 'payment_direct_recharges',
- ] as $table) {
- Schema::dropIfExists($table);
- }
- }
- };
|