feat : catering

This commit is contained in:
2025-03-14 10:05:12 +08:00
parent 3aa241350c
commit 747e37fc86
11 changed files with 210 additions and 18 deletions

View File

@@ -13,6 +13,7 @@ namespace App\Service\Admin\Catering\Meal;
use App\Exception\ErrException;
use App\Model\OrderMealCateringLog;
use App\Model\Sku;
use App\Model\Spu;
use App\Service\Admin\Catering\CateringBaseService;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
@@ -70,20 +71,25 @@ class CycleListService extends CateringBaseService
return $this->return->success('success',['count' => $count]);
}
/**
* @var Spu
*/
#[Inject]
protected Spu $spuModel;
public function skuList()
{
$res = [
[
'id' => 1,
'name' => 'spu_name'
],
[
'id' => 2,
'name' => 'spu2_name'
]
];
$spuList = $this->spuModel->where('caterer_id',$this->adminId)->select(['title','sub_title','id as spu_id'])->get();
if (empty($skuList)) return $this->return->success('success',['list' => []]);
$spuList = $spuList->toArray();
return $this->return->success('success',$res);
$skuList = $this->skuModel->where('spu_id',array_column($spuList,'spu_id'))->pluck('id','spu_id');
foreach ($spuList as &$v) {
$v['sku_id'] = $skuList[$v['spu_id']] ?? 0;
}
return $this->return->success('success',['list' => $spuList]);
}
}