PayOrdersModel.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace App\Models;
  3. /**
  4. * 充值缴费订单模型
  5. */
  6. class PayOrdersModel extends BaseModel
  7. {
  8. protected $table = 'pay_orders';
  9. protected $fillable = [
  10. 'order_no',
  11. 'user_id',
  12. 'total',
  13. 'type',
  14. 'discount',
  15. 'pay_total',
  16. 'charge_amount',
  17. 'pay_at',
  18. 'account',
  19. 'transaction_id',
  20. 'meal_id',
  21. 'product_id',
  22. 'out_trade_no',
  23. 'charge_kami',
  24. 'area',
  25. 'ytype',
  26. 'id_card_no',
  27. 'city',
  28. 'remark',
  29. 'result',
  30. 'failed_remark',
  31. 'create_time',
  32. 'update_time',
  33. 'refund_status',
  34. 'refund_money',
  35. 'refund_remark',
  36. 'status',
  37. 'mark'
  38. ];
  39. /**
  40. * 关联用户
  41. */
  42. public function user()
  43. {
  44. return $this->belongsTo(MemberModel::class, 'user_id', 'id');
  45. }
  46. /**
  47. * 关联套餐
  48. */
  49. public function meal()
  50. {
  51. return $this->belongsTo(PayMealsModel::class, 'meal_id', 'id');
  52. }
  53. /**
  54. * 获取类型文本
  55. */
  56. public function getTypeTextAttribute()
  57. {
  58. $typeMap = [
  59. 1 => '话费',
  60. 2 => '电费',
  61. 3 => '燃气'
  62. ];
  63. return $typeMap[$this->type] ?? '未知';
  64. }
  65. /**
  66. * 获取状态文本
  67. */
  68. public function getStatusTextAttribute()
  69. {
  70. $statusMap = [
  71. 1 => '待付款',
  72. 2 => '已付款',
  73. 3 => '充值中',
  74. 4 => '充值成功',
  75. 5 => '充值失败',
  76. 6 => '部分成功'
  77. ];
  78. return $statusMap[$this->status] ?? '未知';
  79. }
  80. /**
  81. * 获取退款状态文本
  82. */
  83. public function getRefundStatusTextAttribute()
  84. {
  85. $refundStatusMap = [
  86. 0 => '无',
  87. 1 => '已成功',
  88. 2 => '待退款',
  89. 3 => '退款失败'
  90. ];
  91. return $refundStatusMap[$this->refund_status] ?? '未知';
  92. }
  93. }