feat: sku
This commit is contained in:
@@ -137,9 +137,7 @@ class GoodCache
|
||||
$spuIds = array_column($list, 'id');
|
||||
|
||||
$skuList = $this->skuModel->getListBySpuIds($spuIds);
|
||||
// ->whereIn('spu_id',$spuIds)
|
||||
// ->where('is_del',GoodCode::SKU_IS_NO_DEL)
|
||||
// ->get();
|
||||
|
||||
if (empty($skuList)) return $list;
|
||||
|
||||
$skuList = $skuList->toArray();
|
||||
@@ -160,8 +158,6 @@ class GoodCache
|
||||
];
|
||||
}
|
||||
|
||||
// $sku['image_list'] = $imageOneArr;
|
||||
|
||||
if (empty($skuListArr[$sku['spu_id']])) {
|
||||
$skuListArr[$sku['spu_id']] = [];
|
||||
}
|
||||
|
||||
@@ -7,19 +7,30 @@ use App\Service\Api\Good\MealListService;
|
||||
use App\Service\Api\Good\OptionalListService;
|
||||
use Hyperf\HttpServer\Annotation\Controller;
|
||||
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||
use Hyperf\Validation\Annotation\Scene;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
#[Controller(prefix: 'api/good')]
|
||||
class GoodController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @return array[]
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'optional',methods: 'GET')]
|
||||
public function optional()
|
||||
public function optional(): array
|
||||
{
|
||||
return (new OptionalListService)->handle();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'meal',methods: 'GET')]
|
||||
public function meal()
|
||||
public function meal(): array
|
||||
{
|
||||
return (new MealListService)->handle();
|
||||
}
|
||||
|
||||
@@ -10,12 +10,38 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Api\Good;
|
||||
|
||||
use App\Cache\Redis\Api\GoodCache;
|
||||
use App\Service\Api\BaseService;
|
||||
use App\Service\ServiceTrait\Common\CycleTrait;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class MealListService extends BaseService
|
||||
{
|
||||
public function handle()
|
||||
use CycleTrait;
|
||||
|
||||
/**
|
||||
* @var GoodCache
|
||||
*/
|
||||
#[Inject]
|
||||
protected GoodCache $goodCache;
|
||||
|
||||
/**
|
||||
* @return array|array[]
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
//todo Write logic
|
||||
$cycleId = $this->initTodayCycleId();
|
||||
|
||||
if (empty($cycleId)) return ['list' => []];
|
||||
|
||||
$this->goodCache->cycleId = (int)$cycleId;
|
||||
$this->goodCache->kitchenId = (int)$this->request->input('kitchen_id');
|
||||
$data = $this->goodCache->getMealGoodList();
|
||||
|
||||
return $this->return->success('success', ['list' => $data]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user