PaymentCallback.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * 支付回调日志.
  6. *
  7. * @property int $id
  8. * @property string $trade_no 本地订单号
  9. * @property string $out_trade_no 外部订单号(支付平台)
  10. * @property string $amount 交易金额,单位分
  11. * @property int $status 交易状态:0-失败、1-成功
  12. * @property \Illuminate\Support\Carbon $created_at 创建时间
  13. * @property \Illuminate\Support\Carbon $updated_at 最后更新时间
  14. * @property-read string $status_label
  15. * @method static \Illuminate\Database\Eloquent\Builder|PaymentCallback newModelQuery()
  16. * @method static \Illuminate\Database\Eloquent\Builder|PaymentCallback newQuery()
  17. * @method static \Illuminate\Database\Eloquent\Builder|PaymentCallback query()
  18. * @method static \Illuminate\Database\Eloquent\Builder|PaymentCallback whereAmount($value)
  19. * @method static \Illuminate\Database\Eloquent\Builder|PaymentCallback whereCreatedAt($value)
  20. * @method static \Illuminate\Database\Eloquent\Builder|PaymentCallback whereId($value)
  21. * @method static \Illuminate\Database\Eloquent\Builder|PaymentCallback whereOutTradeNo($value)
  22. * @method static \Illuminate\Database\Eloquent\Builder|PaymentCallback whereStatus($value)
  23. * @method static \Illuminate\Database\Eloquent\Builder|PaymentCallback whereTradeNo($value)
  24. * @method static \Illuminate\Database\Eloquent\Builder|PaymentCallback whereUpdatedAt($value)
  25. * @mixin \Eloquent
  26. */
  27. class PaymentCallback extends Model
  28. {
  29. protected $table = 'payment_callback';
  30. public function getStatusLabelAttribute(): string
  31. {
  32. $status_label = '';
  33. switch ($this->attributes['status']) {
  34. case 'WAIT_BUYER_PAY':
  35. $status_label = '等待买家付款';
  36. break;
  37. case 'WAIT_SELLER_SEND_GOODS':
  38. $status_label = '等待卖家发货';
  39. break;
  40. case 'TRADE_SUCCESS':
  41. $status_label = '交易成功';
  42. break;
  43. case 'PAID':
  44. $status_label = '支付完成';
  45. break;
  46. }
  47. return $status_label;
  48. }
  49. }