OrderPayFrom.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace common\forms;
  3. use Yii;
  4. use yii\base\Model;
  5. use common\interfaces\PayHandler;
  6. /**
  7. * Class OrderPayFrom
  8. * @package common\forms
  9. * @author jianyan74 <751393839@qq.com>
  10. */
  11. class OrderPayFrom extends Model implements PayHandler
  12. {
  13. /**
  14. * @var
  15. */
  16. public $order_id;
  17. protected $order;
  18. /**
  19. * @return array
  20. */
  21. public function rules()
  22. {
  23. return [
  24. ['order_id', 'required'],
  25. ['order_id', 'integer', 'min' => 0],
  26. ['order_id', 'verifyPay'],
  27. ];
  28. }
  29. /**
  30. * @param $attribute
  31. */
  32. public function verifyPay($attribute)
  33. {
  34. // TODO 查询订单
  35. $this->order = '';
  36. if (!$this->order) {
  37. $this->addError($attribute, '找不到订单');
  38. return;
  39. }
  40. }
  41. /**
  42. * 支付说明
  43. *
  44. * @return string
  45. */
  46. public function getBody(): string
  47. {
  48. return '订单支付';
  49. }
  50. /**
  51. * 支付详情
  52. *
  53. * @return string
  54. */
  55. public function getDetails(): string
  56. {
  57. return '';
  58. }
  59. /**
  60. * 支付金额
  61. *
  62. * @return float
  63. */
  64. public function getTotalFee(): float
  65. {
  66. return $this->order['pay_money'];
  67. }
  68. /**
  69. * 获取订单号
  70. *
  71. * @return float
  72. */
  73. public function getOrderSn(): string
  74. {
  75. return $this->order['order_sn'];
  76. }
  77. /**
  78. * 交易流水号
  79. *
  80. * @return string
  81. */
  82. public function getOutTradeNo()
  83. {
  84. return $this->order['out_trade_no'] ?? '';
  85. }
  86. /**
  87. * @return int
  88. */
  89. public function getMerchantId(): int
  90. {
  91. return $this->order['merchant_id'];
  92. }
  93. /**
  94. * 是否查询订单号(避免重复生成)
  95. *
  96. * @return bool
  97. */
  98. public function isQueryOrderSn(): bool
  99. {
  100. return true;
  101. }
  102. }
粤ICP备19079148号