RechargePayFrom.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace common\forms;
  3. use Yii;
  4. use yii\base\Model;
  5. use common\helpers\StringHelper;
  6. use common\interfaces\PayHandler;
  7. /**
  8. * Class RechargePayFrom
  9. * @package common\forms
  10. * @author jianyan74 <751393839@qq.com>
  11. */
  12. class RechargePayFrom extends Model implements PayHandler
  13. {
  14. /**
  15. * @var
  16. */
  17. public $money;
  18. /**
  19. * @return array
  20. */
  21. public function rules()
  22. {
  23. return [
  24. ['money', 'required'],
  25. ['money', 'number', 'min' => 0.01],
  26. ];
  27. }
  28. /**
  29. * 支付说明
  30. *
  31. * @return string
  32. */
  33. public function getBody(): string
  34. {
  35. return '在线充值';
  36. }
  37. /**
  38. * 支付详情
  39. *
  40. * @return string
  41. */
  42. public function getDetails(): string
  43. {
  44. return '';
  45. }
  46. /**
  47. * 支付金额
  48. *
  49. * @return float
  50. */
  51. public function getTotalFee(): float
  52. {
  53. return $this->money;
  54. }
  55. /**
  56. * 获取订单号
  57. *
  58. * @return float
  59. */
  60. public function getOrderSn(): string
  61. {
  62. return time() . StringHelper::random(8, true);
  63. }
  64. /**
  65. * 交易流水号
  66. *
  67. * @return string
  68. */
  69. public function getOutTradeNo()
  70. {
  71. return '';
  72. }
  73. /**
  74. * @return int
  75. */
  76. public function getMerchantId(): int
  77. {
  78. return Yii::$app->services->merchant->getNotNullId();
  79. }
  80. /**
  81. * 是否查询订单号(避免重复生成)
  82. *
  83. * @return bool
  84. */
  85. public function isQueryOrderSn(): bool
  86. {
  87. return false;
  88. }
  89. }
粤ICP备19079148号