feat : statement
This commit is contained in:
@@ -87,4 +87,56 @@ class Order extends Model
|
||||
'status' => OrderCode::PLAN
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cycleId
|
||||
* @param int $kitchenId
|
||||
* @return int|mixed|string
|
||||
*/
|
||||
public function getDiscountsByCycleIdAndKitchenId(int $cycleId, int $kitchenId): mixed
|
||||
{
|
||||
return $this->where('cycle_id',$cycleId)->where('kitchen_id',$kitchenId)->where('status',OrderCode::FINISH)->sum('discounts') ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cycleId
|
||||
* @param int $kitchenId
|
||||
* @return int|mixed|string
|
||||
*/
|
||||
public function getNetSalesByCycleIdAndKitchenId(int $cycleId, int $kitchenId): mixed
|
||||
{
|
||||
return $this->where('cycle_id',$cycleId)->where('kitchen_id',$kitchenId)->where('status',OrderCode::FINISH)->sum('actual_price') ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cycleId
|
||||
* @param int $kitchenId
|
||||
* @param int $type
|
||||
* @return int
|
||||
*/
|
||||
public function getOrderNumberByCycleIdAndKitchenId(int $cycleId, int $kitchenId,int $type): int
|
||||
{
|
||||
return $this
|
||||
->where('cycle_id',$cycleId)
|
||||
->where('kitchen_id',$kitchenId)
|
||||
->where('type',$type)
|
||||
->where('status',OrderCode::FINISH)
|
||||
->count() ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cycleId
|
||||
* @param int $kitchenId
|
||||
* @param int $type
|
||||
* @return int
|
||||
*/
|
||||
public function getCopiesByCycleIdAndKitchenId(int $cycleId, int $kitchenId,int $type): int
|
||||
{
|
||||
return $this
|
||||
->where('cycle_id',$cycleId)
|
||||
->where('kitchen_id',$kitchenId)
|
||||
->where('type',$type)
|
||||
->where('status',OrderCode::FINISH)
|
||||
->sum('copies') ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user