<?php

use think\migration\Migrator;

class SeedPriceAdjustCateData extends Migrator
{
    public function up(): void
    {
        $now = time();
        foreach ($this->data() as [$type, $title, $value, $isOther, $sort]) {
            $this->execute("INSERT INTO `oa_price_adjust_cate`
                (`type`, `title`, `value`, `is_other`, `sort`, `status`, `create_time`, `delete_time`)
                VALUES ({$type}, '{$title}', {$value}, {$isOther}, {$sort}, 1, {$now}, 0)");
        }
    }

    public function down(): void
    {
        foreach ($this->data() as [$type, $title]) {
            $this->execute("DELETE FROM `oa_price_adjust_cate` WHERE `type` = {$type} AND `title` = '{$title}'");
        }
    }

    /**
     * @return array<int, array{0:int,1:string,2:int,3:int,4:int}> [type, title, value, is_other, sort]
     */
    protected function data(): array
    {
        return [
            // 客户交易主要场景（type=1）
            [1, '广告服务类：Facebook、Google、Tiktok等', 1, 0, 1],
            [1, '平台电商类：速卖通、Ebay、亚马逊等', 2, 0, 2],
            [1, '钱包类：PayPal消费类、WeChatPay、wise等', 3, 0, 3],
            [1, '订阅类：娱乐服务', 4, 0, 4],
            [1, '游戏类', 5, 0, 5],
            [1, '航空机旅', 6, 0, 6],
            [1, '留学缴费', 7, 0, 7],
            [1, 'SAAS：云', 8, 0, 8],
            [1, '其他-需在备注中说明', 9, 1, 9],
            // 卡BIN（type=2）
            [2, '投流组（G/A/Q/P）', 1, 0, 1],
            [2, '电商组（D/P/Q/G）', 2, 0, 2],
            [2, 'Q卡', 3, 0, 3],
            [2, 'A卡', 4, 0, 4],
            [2, 'V卡', 5, 0, 5],
            // 卡类型（type=3）
            [3, '储值卡', 1, 0, 1],
            [3, '共享卡', 2, 0, 2],
        ];
    }
}