Order.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. namespace App\Models;
  3. use DateTimeInterface;
  4. use Illuminate\Database\Eloquent\Model;
  5. /**
  6. * 外卖订单
  7. *
  8. * @property int $id 外卖订单id
  9. * @property string $order_sn 订单号
  10. * @property int $order_type 订单类型 1堂食订单 2打包订单
  11. * @property int $order_status 订单状态 1:待支付 2待接单 3拒单 4备餐中 5退款
  12. * @property int $m_id 买家id
  13. * @property int $shop_id 商户id
  14. * @property int|null $number 取餐码/序号
  15. * @property string|null $order_money 订单金额
  16. * @property string|null $pay_money 订单支付金额
  17. * @property int $goods_number 商品数量
  18. * @property int|null $table_number 桌号
  19. * @property int|null $diner_number 就餐人数
  20. * @property int $pay_type 支付类型1微信,1支付宝支付
  21. * @property string|null $pay_time 支付时间
  22. * @property string|null $pay_code 支付流水号
  23. * @property string|null $note 订单备注
  24. * @property int|null $is_del 是否删除 0否1是
  25. * @property \Illuminate\Support\Carbon|null $created_at
  26. * @property \Illuminate\Support\Carbon|null $updated_at
  27. * @property string|null $pack_price 打包费
  28. * @property string|null $shop_money 商家到账金额
  29. * @property string $service_num 平台交易手续费比例
  30. * @property string|null $service_money 交易手续费
  31. * @method static \Illuminate\Database\Eloquent\Builder|Order newModelQuery()
  32. * @method static \Illuminate\Database\Eloquent\Builder|Order newQuery()
  33. * @method static \Illuminate\Database\Eloquent\Builder|Order query()
  34. * @method static \Illuminate\Database\Eloquent\Builder|Order whereCreatedAt($value)
  35. * @method static \Illuminate\Database\Eloquent\Builder|Order whereDinerNumber($value)
  36. * @method static \Illuminate\Database\Eloquent\Builder|Order whereGoodsNumber($value)
  37. * @method static \Illuminate\Database\Eloquent\Builder|Order whereId($value)
  38. * @method static \Illuminate\Database\Eloquent\Builder|Order whereIsDel($value)
  39. * @method static \Illuminate\Database\Eloquent\Builder|Order whereMId($value)
  40. * @method static \Illuminate\Database\Eloquent\Builder|Order whereNote($value)
  41. * @method static \Illuminate\Database\Eloquent\Builder|Order whereNumber($value)
  42. * @method static \Illuminate\Database\Eloquent\Builder|Order whereOrderMoney($value)
  43. * @method static \Illuminate\Database\Eloquent\Builder|Order whereOrderSn($value)
  44. * @method static \Illuminate\Database\Eloquent\Builder|Order whereOrderStatus($value)
  45. * @method static \Illuminate\Database\Eloquent\Builder|Order whereOrderType($value)
  46. * @method static \Illuminate\Database\Eloquent\Builder|Order wherePackPrice($value)
  47. * @method static \Illuminate\Database\Eloquent\Builder|Order wherePayCode($value)
  48. * @method static \Illuminate\Database\Eloquent\Builder|Order wherePayMoney($value)
  49. * @method static \Illuminate\Database\Eloquent\Builder|Order wherePayTime($value)
  50. * @method static \Illuminate\Database\Eloquent\Builder|Order wherePayType($value)
  51. * @method static \Illuminate\Database\Eloquent\Builder|Order whereServiceMoney($value)
  52. * @method static \Illuminate\Database\Eloquent\Builder|Order whereServiceNum($value)
  53. * @method static \Illuminate\Database\Eloquent\Builder|Order whereShopId($value)
  54. * @method static \Illuminate\Database\Eloquent\Builder|Order whereShopMoney($value)
  55. * @method static \Illuminate\Database\Eloquent\Builder|Order whereTableNumber($value)
  56. * @method static \Illuminate\Database\Eloquent\Builder|Order whereUpdatedAt($value)
  57. * @mixin \Eloquent
  58. */
  59. class Order extends Model
  60. {
  61. /**
  62. * The table associated with the model.
  63. *
  64. * @var string
  65. */
  66. protected $table = 'order';
  67. /**
  68. * The primary key associated with the table.
  69. *
  70. * @var string
  71. */
  72. protected $primaryKey = 'id';
  73. /**
  74. * Indicates if the model should be timestamped.
  75. *
  76. * @var bool
  77. */
  78. public $timestamps = true;
  79. /**
  80. * 不能被批量赋值的属性
  81. *
  82. * @var array
  83. */
  84. protected $guarded = ['id', 'updated_at', 'created_at'];
  85. private $orderStatusEnum=[
  86. 1=>'待支付',
  87. 2=>'已完成',
  88. 3=>'已取消',
  89. 4=>'退款',
  90. ];
  91. private $refundStatusEnum=[
  92. 1=>'等待商家同意',
  93. 2=>'退款成功',
  94. 3=>'拒绝退款',
  95. ];
  96. private $payTypeEnum=[
  97. 1=>'微信',
  98. 2=>'支付宝',
  99. 3=>'余额支付',
  100. ];
  101. private $orderTypeEnum=[
  102. 1=>'堂食订单',
  103. 2=>'打包订单',
  104. ];
  105. /**
  106. * 为数组 / JSON 序列化准备日期。
  107. *
  108. * @param DateTimeInterface $date
  109. * @return string
  110. */
  111. protected function serializeDate(DateTimeInterface $date)
  112. {
  113. return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
  114. }
  115. /**
  116. * 序列化数据字典
  117. */
  118. function initializeModel(){
  119. if($this->{'order_status'}!==null){
  120. $this->{'order_status_str'}=empty($this->orderStatusEnum[$this->{'order_status'}])?'无':$this->orderStatusEnum[$this->{'order_status'}];
  121. }
  122. if($this->{'pay_type'}!==null){
  123. $this->{'pay_type_str'}=empty($this->payTypeEnum[$this->{'pay_type'}])?'无':$this->payTypeEnum[$this->{'pay_type'}];
  124. }
  125. if($this->{'order_type'}!==null){
  126. $this->{'order_type_str'}=empty($this->orderTypeEnum[$this->{'order_type'}])?'无':$this->orderTypeEnum[$this->{'order_type'}];
  127. }
  128. }
  129. }