PaymentCallback.php 1.8 KB

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