20250905165126_extension_refund.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. class ExtensionRefund extends AbstractMigration
  5. {
  6. /**
  7. * Change Method.
  8. *
  9. * Write your reversible migrations using this method.
  10. *
  11. * More information on writing migrations is available here:
  12. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  13. *
  14. * The following commands can be used in this method and Phinx will
  15. * automatically reverse them when rolling back:
  16. *
  17. * createTable
  18. * renameTable
  19. * addColumn
  20. * renameColumn
  21. * addIndex
  22. * addForeignKey
  23. *
  24. * Remember to call "create()" or "update()" and NOT "save()" when working
  25. * with the Table class.
  26. */
  27. public function change(): void
  28. {
  29. $this->table('extension_refund')
  30. ->setComment('支付退款记录表')
  31. ->addColumn('payment_id', 'integer', ['comment' => '关联支付记录ID'])
  32. ->addColumn('order_sn', 'char', ['limit' => 20, 'comment' => '支付订单编号'])
  33. ->addColumn('out_refund_no', 'char', ['limit' => 20, 'comment' => '商户退款单号'])
  34. ->addColumn('reason', 'string', ['comment' => '退款原因'])
  35. ->addColumn('amount', 'decimal', ['precision' => 10, 'scale' => 2, 'comment' => '退款金额(元)'])
  36. ->addColumn('status', 'tinyinteger', ['comment' => '退款状态:0-待退款/1-退款中/2-成功/3-失败'])
  37. ->addColumn('refund_id', 'char', ['limit' => 32, 'comment' => '三方退款唯一订单号'])
  38. ->addColumn('success_time', 'integer', ['comment' => '退款成功时间'])
  39. ->addColumn('refund_param', 'json', ['comment' => '退款参数'])
  40. ->addColumn('refund_result', 'json', ['comment' => '查询退款结果信息'])
  41. ->addColumn('status_desc', 'string', ['comment' => '退款状态说明'])
  42. ->addTimestamps('create_time', 'update_time')
  43. ->addIndex(['refund_id'])
  44. ->addIndex(['out_refund_no'], ['unique' => true])
  45. ->addIndex(['order_sn'])
  46. ->create();
  47. }
  48. }