PayRefund.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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_refund}}".
  7. *
  8. * @property int $id 主键id
  9. * @property int|null $pay_id 支付ID
  10. * @property int|null $merchant_id 商户id
  11. * @property int|null $member_id 买家id
  12. * @property string|null $app_id 应用id
  13. * @property string|null $order_sn 关联订单号
  14. * @property string|null $order_group 组别[默认统一支付类型]
  15. * @property string|null $out_trade_no 商户订单号
  16. * @property string|null $transaction_id 微信订单号
  17. * @property string|null $refund_trade_no 退款交易号
  18. * @property float|null $refund_money 退款金额
  19. * @property int|null $refund_way 退款方式
  20. * @property string|null $ip 申请者ip
  21. * @property string|null $error_data 报错日志
  22. * @property int|null $is_addon 是否插件
  23. * @property string|null $addon_name 插件名称
  24. * @property string|null $remark 备注
  25. * @property string|null $req_id 唯一ID
  26. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  27. * @property int|null $created_at
  28. * @property int|null $updated_at
  29. */
  30. class PayRefund extends \common\models\base\BaseModel
  31. {
  32. use HasOneMember;
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public static function tableName()
  37. {
  38. return '{{%extend_pay_refund}}';
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function rules()
  44. {
  45. return [
  46. [['pay_id', 'merchant_id', 'member_id', 'refund_way', 'is_addon', 'status', 'created_at', 'updated_at'], 'integer'],
  47. [['refund_money'], 'number'],
  48. [['error_data'], 'safe'],
  49. [['app_id', 'transaction_id', 'req_id'], 'string', 'max' => 50],
  50. [['order_sn', 'ip'], 'string', 'max' => 30],
  51. [['order_group'], 'string', 'max' => 20],
  52. [['out_trade_no'], 'string', 'max' => 32],
  53. [['refund_trade_no'], 'string', 'max' => 55],
  54. [['addon_name'], 'string', 'max' => 200],
  55. [['remark'], 'string', 'max' => 255],
  56. ];
  57. }
  58. /**
  59. * {@inheritdoc}
  60. */
  61. public function attributeLabels()
  62. {
  63. return [
  64. 'id' => '主键id',
  65. 'pay_id' => '支付ID',
  66. 'merchant_id' => '商户id',
  67. 'member_id' => '买家id',
  68. 'app_id' => '应用id',
  69. 'order_sn' => '关联订单号',
  70. 'order_group' => '组别[默认统一支付类型]',
  71. 'out_trade_no' => '商户订单号',
  72. 'transaction_id' => '微信订单号',
  73. 'refund_trade_no' => '退款交易号',
  74. 'refund_money' => '退款金额',
  75. 'refund_way' => '退款方式',
  76. 'ip' => '申请者ip',
  77. 'error_data' => '报错日志',
  78. 'is_addon' => '是否插件',
  79. 'addon_name' => '插件名称',
  80. 'remark' => '备注',
  81. 'req_id' => '唯一ID',
  82. 'status' => '状态[-1:删除;0:禁用;1启用]',
  83. 'created_at' => 'Created At',
  84. 'updated_at' => 'Updated At',
  85. ];
  86. }
  87. /**
  88. * @param bool $insert
  89. * @return bool
  90. */
  91. public function beforeSave($insert)
  92. {
  93. if ($this->isNewRecord) {
  94. $this->app_id = Yii::$app->id;
  95. $this->ip = Yii::$app->services->base->getUserIp();
  96. $this->addon_name = Yii::$app->params['addon']['name'] ?? '';
  97. $this->req_id = Yii::$app->params['uuid'];
  98. !empty($this->addon_name) && $this->is_addon = 1;
  99. }
  100. return parent::beforeSave($insert);
  101. }
  102. }
粤ICP备19079148号