feat:material_application dish
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -92,6 +92,9 @@ class MaterialService extends BaseService{
|
||||
if (!empty($processing)){
|
||||
$info->processing = $processing;
|
||||
}
|
||||
if($info->status == MaterialCode::AUDIT_REFUSE){
|
||||
$info->status = MaterialCode::UN_AUDIT;
|
||||
}
|
||||
$info->operator_id = $this->userId;
|
||||
|
||||
if (!$info->save()) throw new ErrException('申请修改失败');
|
||||
@@ -104,7 +107,7 @@ class MaterialService extends BaseService{
|
||||
$id = (int)$this->request->input('id');
|
||||
$info = $this->MaterialApplication->getInfoById($id);
|
||||
$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('申请删除失败');
|
||||
return $this->return->success();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user