20250720063342_extension_payment.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class ExtensionPayment 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_payment')
  30. ->setComment('订单支付记录表')
  31. ->addColumn(Column::integer('order_id')->setComment('关联订单ID'))
  32. ->addColumn(Column::char('order_sn', 20)->setComment('订单编号'))
  33. ->addColumn(Column::char('out_trade_no', 20)->setComment('商户支付订单号'))
  34. ->addColumn(Column::tinyInteger('biz_type')->setComment('业务类型:1-商品订单支付'))
  35. ->addColumn(Column::string('pay_type', 20)->setComment('支付方式:wechatpay-微信 xlpayment-信联支付'))
  36. ->addColumn(Column::json('payment_param')->setComment('支付参数'))
  37. ->addColumn(Column::decimal('amount', 10, 2)->setComment('支付金额(元)'))
  38. ->addColumn(Column::tinyInteger('status')->setComment('支付状态:0-待支付/1-支付中/2-成功/3-失败/4-已关闭/5-退款中'))
  39. ->addColumn(Column::char('transaction_id', 32)->setComment('三方支付订单号'))
  40. ->addColumn(Column::integer('payment_time')->setComment('支付成功时间'))
  41. ->addColumn(Column::integer('expire_time')->setComment('订单失效时间'))
  42. ->addColumn(Column::json('payment_result')->setComment('查询支付结果信息'))
  43. ->addColumn(Column::string('status_desc', 255)->setComment('支付状态说明'))
  44. ->addTimestamps()
  45. ->addIndex(['order_id', 'biz_type'])
  46. ->addIndex(['transaction_id'])
  47. ->addIndex(['out_trade_no'], ['unique' => true])
  48. ->create();
  49. }
  50. }