20250905165126_extension_refund.php 2.1 KB

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