feat : catering
This commit is contained in:
59
app/Service/Admin/Catering/Meal/CycleListService.php
Normal file
59
app/Service/Admin/Catering/Meal/CycleListService.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Catering\Meal;
|
||||
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\DriverSequence;
|
||||
use App\Model\OrderMealCateringLog;
|
||||
use App\Model\Site;
|
||||
use App\Model\Sku;
|
||||
use App\Service\Admin\Catering\CateringBaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class CycleListService extends CateringBaseService
|
||||
{
|
||||
/**
|
||||
* @var OrderMealCateringLog $orderMealCateringLogModel
|
||||
*/
|
||||
#[Inject]
|
||||
protected OrderMealCateringLog $orderMealCateringLogModel;
|
||||
|
||||
/**
|
||||
* @var Sku
|
||||
*/
|
||||
#[Inject]
|
||||
protected Sku $skuModel;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
$skuInfo = $this->skuModel->getInfoById((int)$this->request->input('sku_id'));
|
||||
if (empty($skuInfo)) throw new ErrException('该套餐不存在,请刷新后重试');
|
||||
|
||||
$cycleCateringLogs = $this->orderMealCateringLogModel
|
||||
->where('cycle_id',$this->cycleId)
|
||||
->where('sku_id',$skuInfo->id)
|
||||
->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)]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user