20260527100003_seed_withdraw_cate_data.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use think\migration\Migrator;
  3. class SeedWithdrawCateData extends Migrator
  4. {
  5. public function up(): void
  6. {
  7. $now = time();
  8. foreach ($this->data() as [$type, $title, $value, $isOther, $sort]) {
  9. $this->execute("INSERT INTO `oa_withdraw_cate`
  10. (`type`, `title`, `value`, `is_other`, `sort`, `status`, `create_time`, `delete_time`)
  11. VALUES ({$type}, '{$title}', {$value}, {$isOther}, {$sort}, 1, {$now}, 0)");
  12. }
  13. }
  14. public function down(): void
  15. {
  16. foreach ($this->data() as [$type, $title]) {
  17. $this->execute("DELETE FROM `oa_withdraw_cate` WHERE `type` = {$type} AND `title` = '{$title}'");
  18. }
  19. }
  20. /**
  21. * @return array<int, array{0:int,1:string,2:int,3:int,4:int}> [type, title, value, is_other, sort]
  22. */
  23. protected function data(): array
  24. {
  25. return [
  26. // 客户交易场景(type=1)
  27. [1, 'Facebook', 1, 0, 1],
  28. [1, '其他-需在备注中说明', 9, 1, 9],
  29. // 提现类型(type=2)
  30. [2, '清退提现(全额提现)', 1, 0, 1],
  31. [2, '部分提现', 2, 0, 2],
  32. ];
  33. }
  34. }