| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- namespace App\Models;
- use DateTimeInterface;
- use Illuminate\Database\Eloquent\Model;
- /**
- * 外卖订单
- *
- * @property int $id 外卖订单id
- * @property string $order_sn 订单号
- * @property int $order_type 订单类型 1堂食订单 2打包订单
- * @property int $order_status 订单状态 1:待支付 2待接单 3拒单 4备餐中 5退款
- * @property int $m_id 买家id
- * @property int $shop_id 商户id
- * @property int|null $number 取餐码/序号
- * @property string|null $order_money 订单金额
- * @property string|null $pay_money 订单支付金额
- * @property int $goods_number 商品数量
- * @property int|null $table_number 桌号
- * @property int|null $diner_number 就餐人数
- * @property int $pay_type 支付类型1微信,1支付宝支付
- * @property string|null $pay_time 支付时间
- * @property string|null $pay_code 支付流水号
- * @property string|null $note 订单备注
- * @property int|null $is_del 是否删除 0否1是
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
- * @property string|null $pack_price 打包费
- * @property string|null $shop_money 商家到账金额
- * @property string $service_num 平台交易手续费比例
- * @property string|null $service_money 交易手续费
- * @method static \Illuminate\Database\Eloquent\Builder|Order newModelQuery()
- * @method static \Illuminate\Database\Eloquent\Builder|Order newQuery()
- * @method static \Illuminate\Database\Eloquent\Builder|Order query()
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereCreatedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereDinerNumber($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereGoodsNumber($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereId($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereIsDel($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereMId($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereNote($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereNumber($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereOrderMoney($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereOrderSn($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereOrderStatus($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereOrderType($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order wherePackPrice($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order wherePayCode($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order wherePayMoney($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order wherePayTime($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order wherePayType($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereServiceMoney($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereServiceNum($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereShopId($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereShopMoney($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereTableNumber($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Order whereUpdatedAt($value)
- * @mixin \Eloquent
- */
- class Order extends Model
- {
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'order';
- /**
- * The primary key associated with the table.
- *
- * @var string
- */
- protected $primaryKey = 'id';
- /**
- * Indicates if the model should be timestamped.
- *
- * @var bool
- */
- public $timestamps = true;
- /**
- * 不能被批量赋值的属性
- *
- * @var array
- */
- protected $guarded = ['id', 'updated_at', 'created_at'];
- private $orderStatusEnum=[
- 1=>'待支付',
- 2=>'已完成',
- 3=>'已取消',
- 4=>'退款',
- ];
- private $refundStatusEnum=[
- 1=>'等待商家同意',
- 2=>'退款成功',
- 3=>'拒绝退款',
- ];
- private $payTypeEnum=[
- 1=>'微信',
- 2=>'支付宝',
- 3=>'余额支付',
- ];
- private $orderTypeEnum=[
- 1=>'堂食订单',
- 2=>'打包订单',
- ];
- /**
- * 为数组 / JSON 序列化准备日期。
- *
- * @param DateTimeInterface $date
- * @return string
- */
- protected function serializeDate(DateTimeInterface $date)
- {
- return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
- }
- /**
- * 序列化数据字典
- */
- function initializeModel(){
- if($this->{'order_status'}!==null){
- $this->{'order_status_str'}=empty($this->orderStatusEnum[$this->{'order_status'}])?'无':$this->orderStatusEnum[$this->{'order_status'}];
- }
- if($this->{'pay_type'}!==null){
- $this->{'pay_type_str'}=empty($this->payTypeEnum[$this->{'pay_type'}])?'无':$this->payTypeEnum[$this->{'pay_type'}];
- }
- if($this->{'order_type'}!==null){
- $this->{'order_type_str'}=empty($this->orderTypeEnum[$this->{'order_type'}])?'无':$this->orderTypeEnum[$this->{'order_type'}];
- }
- }
- }
|