20250905165126_extension_refund.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. use think\migration\db\Column;
  3. use think\migration\Migrator;
  4. class ExtensionRefund extends Migrator
  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(Column::integer('payment_id')->setComment('关联支付记录ID'))
  32. ->addColumn(Column::char('order_sn', 20)->setComment('支付订单编号'))
  33. ->addColumn(Column::char('out_refund_no', 20)->setComment('商户退款单号'))
  34. ->addColumn(Column::string('reason'))->setComment('退款原因')
  35. ->addColumn(Column::decimal('amount', 10, 2)->setComment('退款金额(元)'))
  36. ->addColumn(Column::tinyInteger('status')->setComment('退款状态:0-待退款/1-退款中/2-成功/3-失败'))
  37. ->addColumn(Column::char('refund_id', 32)->setComment('三方退款唯一订单号'))
  38. ->addColumn(Column::integer('success_time')->setComment('退款成功时间'))
  39. ->addColumn(Column::json('refund_param')->setComment('退款参数'))
  40. ->addColumn(Column::json('refund_result')->setComment('查询退款结果信息'))
  41. ->addColumn(Column::string('status_desc')->setComment('退款状态说明'))
  42. ->addTimestamps()
  43. ->addIndex(['refund_id'])
  44. ->addIndex(['out_refund_no'], ['unique' => true])
  45. ->addIndex(['order_sn'])
  46. ->create();
  47. }
  48. }