61 lines
1.2 KiB
PHP
61 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class BargainOrder extends Model
|
|
{
|
|
use HasFactory;
|
|
use HasDateTimeFormatter;
|
|
|
|
protected $casts = [
|
|
'expire_at'=> 'datetime',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'order_id', 'remark',
|
|
];
|
|
|
|
public const ORDER_STATUS_WAIT = 0;
|
|
public const ORDER_STATUS_START = 1;
|
|
public const ORDER_STATUS_FINISHED = 2;
|
|
|
|
public function activity()
|
|
{
|
|
return $this->belongsTo(BargainActivity::class, 'activity_id');
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
public function userInfo()
|
|
{
|
|
return $this->belongsTo(UserInfo::class, 'user_id', 'user_id');
|
|
}
|
|
|
|
public function logs()
|
|
{
|
|
return $this->hasMany(BargainOrderLog::class, 'order_id');
|
|
}
|
|
|
|
public function sku()
|
|
{
|
|
return $this->hasOne(ProductSku::class, 'id', 'sku_id');
|
|
}
|
|
|
|
public function mallOrder()
|
|
{
|
|
return $this->belongsTo(Order::class, 'order_id');
|
|
}
|
|
|
|
public function isFinished()
|
|
{
|
|
return $this->status == static::ORDER_STATUS_FINISHED;
|
|
}
|
|
}
|