添加 Order::subTotal 和 Order::getNextStatuses 方法
This commit is contained in:
parent
c60e32b401
commit
9fe2b28655
|
|
@ -13,6 +13,7 @@ namespace Beike\Models;
|
||||||
|
|
||||||
use Beike\Notifications\NewOrderNotification;
|
use Beike\Notifications\NewOrderNotification;
|
||||||
use Beike\Notifications\UpdateOrderNotification;
|
use Beike\Notifications\UpdateOrderNotification;
|
||||||
|
use Beike\Services\StateMachineService;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
@ -58,6 +59,13 @@ class Order extends Base
|
||||||
return $this->hasMany(OrderShipment::class);
|
return $this->hasMany(OrderShipment::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function subTotal()
|
||||||
|
{
|
||||||
|
$totals = $this->orderTotals;
|
||||||
|
|
||||||
|
return $totals->where('code', 'sub_total')->first();
|
||||||
|
}
|
||||||
|
|
||||||
public function getStatusFormatAttribute()
|
public function getStatusFormatAttribute()
|
||||||
{
|
{
|
||||||
return trans('order.' . $this->status);
|
return trans('order.' . $this->status);
|
||||||
|
|
@ -68,6 +76,17 @@ class Order extends Base
|
||||||
return currency_format($this->total, $this->currency_code, $this->currency_value);
|
return currency_format($this->total, $this->currency_code, $this->currency_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取该订单可以变更的状态
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function getNextStatuses()
|
||||||
|
{
|
||||||
|
return StateMachineService::getInstance($this)->nextBackendStatuses();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新订单通知
|
* 新订单通知
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue