feat:material_application dish
This commit is contained in:
@@ -53,4 +53,16 @@ class DishController
|
|||||||
{
|
{
|
||||||
return (new DishService())->list();
|
return (new DishService())->list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品删除
|
||||||
|
* @param DishRequest $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: "delete", methods: "POST")]
|
||||||
|
#[Scene(scene: "delete")]
|
||||||
|
public function dishDelete(dishRequest $request): array
|
||||||
|
{
|
||||||
|
return (new DishService())->delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ class DishRequest extends FormRequest
|
|||||||
protected array $scenes = [
|
protected array $scenes = [
|
||||||
'add' => ['dish_name','profile','pre_quantity','price','side_dish','flavor','cycle_id','city_id','kitchen_id'],
|
'add' => ['dish_name','profile','pre_quantity','price','side_dish','flavor','cycle_id','city_id','kitchen_id'],
|
||||||
'edit' => ['id','dish_name','profile','pre_quantity','price','side_dish','flavor'],
|
'edit' => ['id','dish_name','profile','pre_quantity','price','side_dish','flavor'],
|
||||||
'list' =>['limit']
|
'list' =>['limit'],
|
||||||
|
'delete' =>['id'],
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace App\Service\Api\Material;
|
|||||||
use App\Constants\Common\DishCode;
|
use App\Constants\Common\DishCode;
|
||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
use App\Model\Dish;
|
use App\Model\Dish;
|
||||||
|
use App\Model\MaterialApplication;
|
||||||
use App\Service\Api\BaseService;
|
use App\Service\Api\BaseService;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
|
|
||||||
@@ -19,6 +20,9 @@ class DishService extends BaseService
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected Dish $DishModel;
|
protected Dish $DishModel;
|
||||||
|
|
||||||
|
#[Inject]
|
||||||
|
protected MaterialApplication $MaterialApplication;
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -93,6 +97,23 @@ class DishService extends BaseService
|
|||||||
return $this->return->success();
|
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
|
public function list(): array
|
||||||
{
|
{
|
||||||
$limit = (int)$this->request->input('limit');
|
$limit = (int)$this->request->input('limit');
|
||||||
|
|||||||
@@ -92,6 +92,9 @@ class MaterialService extends BaseService{
|
|||||||
if (!empty($processing)){
|
if (!empty($processing)){
|
||||||
$info->processing = $processing;
|
$info->processing = $processing;
|
||||||
}
|
}
|
||||||
|
if($info->status == MaterialCode::AUDIT_REFUSE){
|
||||||
|
$info->status = MaterialCode::UN_AUDIT;
|
||||||
|
}
|
||||||
$info->operator_id = $this->userId;
|
$info->operator_id = $this->userId;
|
||||||
|
|
||||||
if (!$info->save()) throw new ErrException('申请修改失败');
|
if (!$info->save()) throw new ErrException('申请修改失败');
|
||||||
@@ -104,7 +107,7 @@ class MaterialService extends BaseService{
|
|||||||
$id = (int)$this->request->input('id');
|
$id = (int)$this->request->input('id');
|
||||||
$info = $this->MaterialApplication->getInfoById($id);
|
$info = $this->MaterialApplication->getInfoById($id);
|
||||||
$info->is_del = 2;
|
$info->is_del = 2;
|
||||||
if ($info->status == MaterialCode::ALL_OUT) throw new ErrException("已全部出库");
|
if ($info->status == MaterialCode::ALL_OUT || $info->status == MaterialCode::PART_OUT) throw new ErrException("已进行出库");
|
||||||
if (!$info->save()) throw new ErrException('申请删除失败');
|
if (!$info->save()) throw new ErrException('申请删除失败');
|
||||||
return $this->return->success();
|
return $this->return->success();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -410,6 +410,11 @@ Authorization: Bearer {{admin_token}}
|
|||||||
|
|
||||||
id=1&pre_quantity=300&price=12
|
id=1&pre_quantity=300&price=12
|
||||||
|
|
||||||
|
### 厨师删除菜品
|
||||||
|
POST {{host}}/api/dish/delete?id=1
|
||||||
|
Content-Type: application/x-www-form-urlencoded
|
||||||
|
Authorization: Bearer {{admin_token}}
|
||||||
|
|
||||||
### 厨师查看排菜
|
### 厨师查看排菜
|
||||||
GET {{host}}/api/dish/list?limit=10
|
GET {{host}}/api/dish/list?limit=10
|
||||||
content-type: application/json
|
content-type: application/json
|
||||||
@@ -437,4 +442,5 @@ Authorization: Bearer {{admin_token}}
|
|||||||
### 个人申请材料列表
|
### 个人申请材料列表
|
||||||
GET {{host}}/api/material/application_list?limit=10
|
GET {{host}}/api/material/application_list?limit=10
|
||||||
content-type: application/json
|
content-type: application/json
|
||||||
Authorization: Bearer {{admin_token}}
|
Authorization: Bearer {{admin_token}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user