From 39924b57808fd5c354de6f4abf88bf7420d6d7ae Mon Sep 17 00:00:00 2001 From: "LAPTOP-7SGDREK0\\shiweijun" <411582373@qq.com> Date: Tue, 18 Feb 2025 17:15:00 +0800 Subject: [PATCH] fix:dish --- app/Model/Dish.php | 4 ++-- app/Request/Admin/DishRequest.php | 4 ++-- app/Request/Admin/MaterialRequest.php | 2 +- app/Request/Api/DishRequest.php | 4 ++-- app/Service/Admin/Material/DishService.php | 11 +++++------ app/Service/Admin/Material/MaterialService.php | 6 +++--- app/Service/Api/Material/DishService.php | 9 ++++----- sync/http/admin/auth.http | 2 +- 8 files changed, 20 insertions(+), 22 deletions(-) diff --git a/app/Model/Dish.php b/app/Model/Dish.php index 92d2a2d..6f4d583 100644 --- a/app/Model/Dish.php +++ b/app/Model/Dish.php @@ -16,7 +16,7 @@ use Hyperf\DbConnection\Model\Model; * @property string $price * @property string $side_dish * @property string $flavor - * @property int $cycle_id + * @property string $date * @property int $city_id * @property int $kitchen_id * @property int $chef_id @@ -39,7 +39,7 @@ class Dish extends Model /** * The attributes that should be cast to native types. */ - protected array $casts = ['id' => 'integer', 'pre_quantity' => 'integer', 'cycle_id' => 'integer', 'city_id' => 'integer','kitchen_id' => 'integer', 'chef_id' => 'integer', 'is_del' => 'integer']; + protected array $casts = ['id' => 'integer', 'pre_quantity' => 'integer', 'city_id' => 'integer','kitchen_id' => 'integer', 'chef_id' => 'integer', 'is_del' => 'integer']; const string CREATED_AT = 'create_time'; diff --git a/app/Request/Admin/DishRequest.php b/app/Request/Admin/DishRequest.php index 6d6e918..8356b37 100644 --- a/app/Request/Admin/DishRequest.php +++ b/app/Request/Admin/DishRequest.php @@ -26,7 +26,7 @@ class DishRequest extends FormRequest 'query_id' => 'sometimes|integer', 'query_dish_name' => 'sometimes|string', 'query_city_id' => 'sometimes|integer|exists:system_city,id', - 'query_date_id' => 'sometimes|integer|exists:cycle,id', + 'query_date' => 'sometimes', 'query_status' => 'sometimes|integer', 'query_chef_id' => 'sometimes|integer', @@ -34,6 +34,6 @@ class DishRequest extends FormRequest } protected array $scenes = [ - 'list' => ['limit','query_id','query_dish_name','query_city_id','query_date_id','query_status','query_chef_id'], + 'list' => ['limit','query_id','query_dish_name','query_city_id','query_date','query_status','query_chef_id'], ]; } diff --git a/app/Request/Admin/MaterialRequest.php b/app/Request/Admin/MaterialRequest.php index ffb14ea..b7a89ae 100644 --- a/app/Request/Admin/MaterialRequest.php +++ b/app/Request/Admin/MaterialRequest.php @@ -41,6 +41,6 @@ class MaterialRequest extends FormRequest 'material_edit' => ['id','category_id', 'name', 'standard', 'unit', 'bar_code','status'], 'material_delete' => ['id'], 'materialStock_list' => ['limit','query_name','query_materialId','query_depotId','query_supplierId','query_kitchenId'], - 'chef_cost_list' => ['limit','chef_name','cycle_id','query_kitchen_id'], + 'chef_cost_list' => ['limit','chef_name','date','query_kitchen_id'], ]; } diff --git a/app/Request/Api/DishRequest.php b/app/Request/Api/DishRequest.php index 800c289..4b4fb95 100644 --- a/app/Request/Api/DishRequest.php +++ b/app/Request/Api/DishRequest.php @@ -24,7 +24,7 @@ class DishRequest extends FormRequest return [ 'limit' => 'required|integer', 'dish_name' => 'sometimes|string', - 'cycle_id' => 'sometimes|integer|exists:cycle,id', + 'date' => 'sometimes', 'city_id' => 'sometimes|integer|exists:system_city,id', 'kitchen_id' => 'sometimes|integer|exists:kitchen,id', @@ -32,7 +32,7 @@ class DishRequest extends FormRequest } 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','date','city_id','kitchen_id'], 'edit' => ['id','dish_name','profile','pre_quantity','price','side_dish','flavor'], 'list' =>['limit'], 'delete' =>['id'], diff --git a/app/Service/Admin/Material/DishService.php b/app/Service/Admin/Material/DishService.php index 6582db3..b61d0d1 100644 --- a/app/Service/Admin/Material/DishService.php +++ b/app/Service/Admin/Material/DishService.php @@ -32,12 +32,11 @@ class DishService extends BaseService $id = (int)$this->request->input('query_id'); $cityId = (int)$this->request->input('query_city_id',0); $dishName = $this->request->input('query_dish_name'); - $dateId = (int)$this->request->input('query_date_id'); + $date = $this->request->input('query_date'); $status = (int)$this->request->input('query_status'); $chefId = (int)$this->request->input('query_chef_id',0); $list = $this->DishModel - ->leftJoin('cycle','dish.cycle_id','=','cycle.id') ->where('is_del',DishCode::IS_NO_DEL) ->when($id > 0, function ($query) use ($id) { $query->where('id', $id); @@ -48,8 +47,8 @@ class DishService extends BaseService ->when($dishName, function ($query) use ($dishName) { $query->where('dish', 'like', "$dishName%"); }) - ->when($dateId, function ($query) use ($dateId) { - $query->where('cycle_id', $dateId); + ->when($date, function ($query) use ($date) { + $query->where('date', $date); }) ->when($status, function ($query) use ($status) { $query->where('status', $status); @@ -57,8 +56,8 @@ class DishService extends BaseService ->when($chefId, function ($query) use ($chefId) { $query->where('chef_id', $chefId); }) - ->orderBy('cycle.dates','desc') - ->paginate($limit,['dish.*','cycle.dates'])->toArray(); + ->orderBy('date','desc') + ->paginate($limit)->toArray(); return $this->return->success('success',$list); } diff --git a/app/Service/Admin/Material/MaterialService.php b/app/Service/Admin/Material/MaterialService.php index ca5e856..bf8b2c1 100644 --- a/app/Service/Admin/Material/MaterialService.php +++ b/app/Service/Admin/Material/MaterialService.php @@ -151,7 +151,7 @@ class MaterialService extends BaseService{ { $limit = (int)$this->request->input('limit', 10); $chefName = $this->request->input('chef_name'); - $cycleId = (int)$this->request->input('cycle_id'); + $date = $this->request->input('date'); $kitchenId = (int)$this->request->input('query_kitchen_id'); $list = $this->MaterialApplicationModel @@ -164,8 +164,8 @@ class MaterialService extends BaseService{ ->when(!empty($chefName), function ($query) use ($chefName) { $query->where('admin_user.chinese_name', $chefName); }) - ->when(!empty($cycleId), function ($query) use ($cycleId) { - $query->where('dish.cycle_id', $cycleId); + ->when(!empty($date), function ($query) use ($date) { + $query->where('dish.date', $date); }) ->when(!empty($kitchenId), function ($query) use ($kitchenId) { $query->where('material_application.kitchen_id', $kitchenId); diff --git a/app/Service/Api/Material/DishService.php b/app/Service/Api/Material/DishService.php index c698307..6b26756 100644 --- a/app/Service/Api/Material/DishService.php +++ b/app/Service/Api/Material/DishService.php @@ -39,7 +39,7 @@ class DishService extends BaseService $price = (double)$this->request->input('price'); $side_dish = $this->request->input('side_dish'); $flavor = $this->request->input('flavor'); - $cycle_id = (int)$this->request->input('cycle_id'); + $date = $this->request->input('date'); $city_id = (int)$this->request->input('city_id'); $kitchen_id = (int)$this->request->input('kitchen_id'); $chef_id = $this->userId; @@ -51,7 +51,7 @@ class DishService extends BaseService $dish ->price = $price; $dish ->side_dish = $side_dish; $dish ->flavor = $flavor; - $dish ->cycle_id = $cycle_id; + $dish ->date = $date; $dish ->city_id = $city_id; $dish ->kitchen_id = $kitchen_id; $dish ->chef_id = $chef_id; @@ -119,10 +119,9 @@ class DishService extends BaseService $limit = (int)$this->request->input('limit'); $chef_id = $this->userId; $list = $this->DishModel - ->leftJoin('cycle','dish.cycle_id','=','cycle.id') ->where('chef_id', $chef_id) - ->orderBy('cycle.dates','desc') - ->paginate($limit,['dish.*','cycle.dates'])->toArray(); + ->orderBy('date','desc') + ->paginate($limit)->toArray(); return $this->return->success('success',$list); } diff --git a/sync/http/admin/auth.http b/sync/http/admin/auth.http index 5db909a..13703f0 100644 --- a/sync/http/admin/auth.http +++ b/sync/http/admin/auth.http @@ -409,7 +409,7 @@ POST {{host}}/api/dish/add Content-Type: application/x-www-form-urlencoded Authorization: Bearer {{admin_token}} -dish_name=排骨饭&profile=加水&pre_quantity=500&price=15&side_dish=33333&flavor=清淡&cycle_id=1&city_id=1&kitchen_id=1 +dish_name=排骨饭&profile=加水&pre_quantity=500&price=15&side_dish=33333&flavor=清淡&date=2025-01-02&city_id=1&kitchen_id=1 ### 厨师修改菜品 POST {{host}}/api/dish/edit