PayLog.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. namespace common\models\extend;
  3. use Yii;
  4. use common\traits\HasOneMember;
  5. /**
  6. * This is the model class for table "{{%extend_pay_log}}".
  7. *
  8. * @property int $id 主键
  9. * @property int|null $merchant_id 商户id
  10. * @property int|null $member_id 用户id
  11. * @property string|null $app_id 应用id
  12. * @property string|null $out_trade_no 商户订单号
  13. * @property string|null $order_sn 关联订单号
  14. * @property string|null $order_group 组别[默认统一支付类型]
  15. * @property string|null $openid openid
  16. * @property string|null $mch_id 商户支付账户
  17. * @property string|null $body 支付内容
  18. * @property string|null $detail 支付详情
  19. * @property string|null $auth_code 刷卡码
  20. * @property string|null $transaction_id 关联订单号
  21. * @property float|null $total_fee 初始金额
  22. * @property string|null $fee_type 标价币种
  23. * @property int $pay_type 支付类型
  24. * @property float $pay_fee 支付金额
  25. * @property int|null $pay_status 支付状态
  26. * @property int|null $pay_time 支付时间
  27. * @property string|null $trade_type 交易类型
  28. * @property float $refund_fee 退款金额
  29. * @property int|null $refund_type 退款情况[0:未退款;1部分退款;2:全部退款]
  30. * @property string|null $create_ip 创建者ip
  31. * @property string|null $pay_ip 支付者ip
  32. * @property string|null $unite_no 联合订单号
  33. * @property string|null $notify_url 支付通知回调地址
  34. * @property string|null $return_url 买家付款成功跳转地址
  35. * @property int|null $is_addon 是否插件
  36. * @property string|null $addon_name 插件名称
  37. * @property int|null $is_error 是否有报错
  38. * @property string|null $error_data 报错日志
  39. * @property string|null $req_id 唯一ID
  40. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  41. * @property int|null $created_at 创建时间
  42. * @property int|null $updated_at 修改时间
  43. */
  44. class PayLog extends \common\models\base\BaseModel
  45. {
  46. use HasOneMember;
  47. /**
  48. * {@inheritdoc}
  49. */
  50. public static function tableName()
  51. {
  52. return '{{%extend_pay_log}}';
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public function rules()
  58. {
  59. return [
  60. [['merchant_id', 'member_id', 'pay_type', 'pay_status', 'pay_time', 'refund_type', 'is_addon', 'is_error', 'status', 'created_at', 'updated_at'], 'integer'],
  61. [['total_fee', 'pay_fee', 'refund_fee'], 'number'],
  62. [['error_data'], 'safe'],
  63. [['app_id', 'openid', 'auth_code', 'transaction_id', 'req_id'], 'string', 'max' => 50],
  64. [['out_trade_no'], 'string', 'max' => 32],
  65. [['order_sn', 'create_ip', 'pay_ip', 'unite_no'], 'string', 'max' => 30],
  66. [['order_group', 'mch_id', 'fee_type'], 'string', 'max' => 20],
  67. [['body', 'detail', 'notify_url', 'return_url'], 'string', 'max' => 100],
  68. [['trade_type'], 'string', 'max' => 16],
  69. [['addon_name'], 'string', 'max' => 200],
  70. ];
  71. }
  72. /**
  73. * {@inheritdoc}
  74. */
  75. public function attributeLabels()
  76. {
  77. return [
  78. 'id' => '主键',
  79. 'merchant_id' => '商户id',
  80. 'member_id' => '用户id',
  81. 'app_id' => '应用id',
  82. 'out_trade_no' => '商户订单号',
  83. 'order_sn' => '关联订单号',
  84. 'order_group' => '组别[默认统一支付类型]',
  85. 'openid' => 'openid',
  86. 'mch_id' => '商户支付账户',
  87. 'body' => '支付内容',
  88. 'detail' => '支付详情',
  89. 'auth_code' => '刷卡码',
  90. 'transaction_id' => '关联订单号',
  91. 'total_fee' => '初始金额',
  92. 'fee_type' => '标价币种',
  93. 'pay_type' => '支付类型',
  94. 'pay_fee' => '支付金额',
  95. 'pay_status' => '支付状态',
  96. 'pay_time' => '支付时间',
  97. 'trade_type' => '交易类型',
  98. 'refund_fee' => '退款金额',
  99. 'refund_type' => '退款情况[0:未退款;1部分退款;2:全部退款]',
  100. 'create_ip' => '创建者ip',
  101. 'pay_ip' => '支付者ip',
  102. 'unite_no' => '联合订单号',
  103. 'notify_url' => '支付通知回调地址',
  104. 'return_url' => '买家付款成功跳转地址',
  105. 'is_addon' => '是否插件',
  106. 'addon_name' => '插件名称',
  107. 'is_error' => '是否有报错',
  108. 'error_data' => '报错日志',
  109. 'req_id' => '唯一ID',
  110. 'status' => '状态[-1:删除;0:禁用;1启用]',
  111. 'created_at' => '创建时间',
  112. 'updated_at' => '修改时间',
  113. ];
  114. }
  115. /**
  116. * @param bool $insert
  117. * @return bool
  118. */
  119. public function beforeSave($insert)
  120. {
  121. if ($this->isNewRecord) {
  122. $this->app_id = Yii::$app->id;
  123. $this->create_ip = Yii::$app->services->base->getUserIp();
  124. $this->addon_name = Yii::$app->params['addon']['name'] ?? '';
  125. $this->req_id = Yii::$app->params['uuid'];
  126. !empty($this->addon_name) && $this->is_addon = 1;
  127. }
  128. return parent::beforeSave($insert);
  129. }
  130. }
粤ICP备19079148号