feat:material_application dish

This commit is contained in:
LAPTOP-7SGDREK0\shiweijun
2025-02-07 09:54:26 +08:00
parent fe8eb1d175
commit cc6f530c8e
5 changed files with 46 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ namespace App\Service\Api\Material;
use App\Constants\Common\DishCode;
use App\Exception\ErrException;
use App\Model\Dish;
use App\Model\MaterialApplication;
use App\Service\Api\BaseService;
use Hyperf\Di\Annotation\Inject;
@@ -19,6 +20,9 @@ class DishService extends BaseService
#[Inject]
protected Dish $DishModel;
#[Inject]
protected MaterialApplication $MaterialApplication;
public function handle()
{
@@ -93,6 +97,23 @@ class DishService extends BaseService
return $this->return->success();
}
public function delete(): array
{
$id = (int)$this->request->input('id');
$info = $this->DishModel->getInfoById($id);
$application = $this->MaterialApplication
->where('dish_id', $id)
->where('is_del', DishCode::IS_NO_DEL)
->first();
if (!empty($application)) throw new ErrException('该菜品存在申请材料');
$info->is_del = DishCode::IS_DELETE;
if (!$info->save()) throw new ErrException('菜品删除失败');
return $this->return->success();
}
public function list(): array
{
$limit = (int)$this->request->input('limit');