61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Admin\Catering\Option;
|
|
|
|
use App\Constants\Admin\CateringCode;
|
|
use App\Model\OrderOptionCateringLog;
|
|
use App\Service\Admin\Catering\CateringBaseService;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
use Psr\Container\NotFoundExceptionInterface;
|
|
|
|
class CycleListService extends CateringBaseService
|
|
{
|
|
/**
|
|
* @var OrderOptionCateringLog
|
|
*/
|
|
#[Inject]
|
|
protected OrderOptionCateringLog $orderOptionCateringLogModel;
|
|
|
|
/**
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
public function handle(): array
|
|
{
|
|
$cycleCateringLogs = $this->orderOptionCateringLogModel
|
|
->where('cycle_id',$this->cycleId)
|
|
->where('kitchen_id',$this->kitchenId)
|
|
->select(['site_id','quantity','status','id'])
|
|
->get();
|
|
|
|
$res = $this->buildResArr($cycleCateringLogs);
|
|
|
|
if (empty($res)) return $this->return->success('success',['list' => []]);
|
|
|
|
return $this->return->success('success',['list' => array_values($res)]);
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function remainCount(): array
|
|
{
|
|
$count = $this->orderOptionCateringLogModel
|
|
->where('cycle_id',$this->cycleId)
|
|
->where('kitchen_id',$this->kitchenId)
|
|
->where('status',CateringCode::CATERING_STATUS_UNDERWAY)
|
|
->sum('quantity') ?? 0;
|
|
|
|
return $this->return->success('success',['count' => $count]);
|
|
}
|
|
} |