| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Support\Facades\DB;
- return new class extends Migration {
- public function up(): void
- {
- $rules = [
- 7 => ['title' => '净亏邀请奖励', 'params' => ['turnover_ratio' => '0.00', 'loss_amount' => '500.00', 'invite_count' => 3, 'reward_amount' => '500.00']],
- 9 => ['title' => '转盘活动', 'params' => ['turnover_ratio' => '0.00', 'completion_probability' => '20.00', 'online_seconds' => 3600,
- 'deposit_amount' => '3000.00', 'team_deposit_amount' => '500.00', 'bet_amount' => '5000.00', 'team_bet_amount' => '3000.00']],
- ];
- DB::transaction(function () use ($rules) {
- $now = now('Asia/Shanghai');
- foreach ($rules as $type => $config) {
- if (DB::table('promotion_activities')->where('type', $type)->exists()) continue;
- $id = DB::table('promotion_activities')->insertGetId([
- 'title' => $config['title'], 'type' => $type, 'status' => 0,
- 'start_time' => $now->timestamp, 'end_time' => $now->copy()->addYear()->timestamp,
- 'lang' => 'zh', 'sort' => 0, 'params' => json_encode($config['params'], JSON_THROW_ON_ERROR),
- 'publish_platforms' => '[]', 'register_platforms' => '[]',
- 'register_time_limited' => 0, 'deposit_limited' => 0, 'show_ineligible' => 1,
- 'reward_quota' => null, 'budget' => null, 'created_at' => $now, 'updated_at' => $now,
- ]);
- DB::table('promotion_campaigns')->insert(['activity_id' => $id, 'first_published_at' => null, 'created_at' => $now, 'updated_at' => $now]);
- }
- });
- }
- public function down(): void
- {
- // Keep activity IDs, publication dates and participation history when rolling back code.
- }
- };
|