feat : spu

This commit is contained in:
2025-07-24 09:49:00 +08:00
parent 408a2bfa2b
commit 4d0e3907b2
3 changed files with 17 additions and 2 deletions

View File

@@ -156,6 +156,9 @@ class SpuService extends BaseService
if (!empty($info)) throw new ErrException('该菜品在当前城市已存在');
$imageId = $this->request->input('image_id');
$this->updateOssObjects([$imageId]);
$insertModel = new Spu();
@@ -170,6 +173,7 @@ class SpuService extends BaseService
$insertModel->saleable = $this->request->input('saleable');
$insertModel->type = $this->request->input('type');
$insertModel->sort = $this->request->input('sort');
$insertModel->image_id = $imageId;
$insertModel->favorable = GoodCode::NOT_FAVORABLE;
if (!$insertModel->save()) throw new ErrException('添加菜品失败');
@@ -233,6 +237,8 @@ class SpuService extends BaseService
$this->checkInfo();
$kitchenId = (int)$this->request->input('kitchen_id');
$oldKitchenId = (int)$info->kitchen_id;
@@ -245,6 +251,12 @@ class SpuService extends BaseService
$info->saleable = $this->request->input('saleable');
$info->type = $this->request->input('type');
$info->sort = $this->request->input('sort');
$requestOssId = $this->request->input('image_id',0);
if ($requestOssId != $info->image_id) {
$info->image_id = $requestOssId;
$this->updateOssObjects([$requestOssId]);
$this->updateOssObjectsDisable([$info->image_ids]);
}
if (!$info->save()) throw new ErrException('修改菜品失败');