diff --git a/app/Controller/Admin/DepotController.php b/app/Controller/Admin/DepotController.php index 69bfd3e..52e5ac8 100644 --- a/app/Controller/Admin/DepotController.php +++ b/app/Controller/Admin/DepotController.php @@ -68,7 +68,7 @@ class DepotController } /** - * 采购入库 + * 采购 * @param DepotRequest $request * @return array * @throws Exception @@ -79,4 +79,16 @@ class DepotController { return (new DepotService)->purchase(); } + + /** + * 采购列表 + * @param DepotRequest $request + * @return array + */ + #[RequestMapping(path: "purchase_list", methods: "GET")] + #[Scene(scene: "purchase_list")] + public function purchaseList(DepotRequest $request): array + { + return (new DepotService)->purchaseList(); + } } diff --git a/app/Request/Admin/DepotRequest.php b/app/Request/Admin/DepotRequest.php index a4b5212..0b59b9b 100644 --- a/app/Request/Admin/DepotRequest.php +++ b/app/Request/Admin/DepotRequest.php @@ -38,5 +38,6 @@ class DepotRequest extends FormRequest 'depot_edit' => ['id','name'], 'depot_delete' => ['id'], 'purchase' => ['depot_id','material_id','supplier_id','type','purchase_price','number','city_id','kitchen_id'], + 'purchase_list' => ['limit','query_id','query_kitchen_id'], ]; } diff --git a/app/Service/Admin/Depot/DepotService.php b/app/Service/Admin/Depot/DepotService.php index 6be8f5d..e68376d 100644 --- a/app/Service/Admin/Depot/DepotService.php +++ b/app/Service/Admin/Depot/DepotService.php @@ -31,6 +31,9 @@ class DepotService extends BaseService{ #[Inject] protected MaterialStock $MaterialStockModel; + #[Inject] + protected DepotPurchase $DepotPurchaseModel; + public function handle() { @@ -189,4 +192,27 @@ class DepotService extends BaseService{ } + public function purchaseList():array + { + $limit = (int)$this->request->input('limit', 10); + $id = (int)$this->request->input('query_id'); + $kitchenId = (int)$this->request->input('query_kitchen_id'); + + $list = $this->DepotPurchaseModel + ->leftJoin('material','depot_purchase.material_id','=','material.id') + ->leftJoin('supplier','depot_purchase.supplier_id','=','supplier.id') + ->leftJoin('depot','depot_purchase.depot_id','=','depot.id') + ->where('depot_purchase.is_del',DepotCode::IS_NO_DEL) + ->when($id,function ($query) use ($id) { + $query->where('depot_purchase.id',$id); + }) + ->when($kitchenId,function ($query) use ($kitchenId) { + $query->where('depot_purchase.kitchen_id',$kitchenId); + }) + ->paginate($limit,['depot_purchase.*','material.name as material_name','supplier.name as supplier_name','depot.name as depot_name']) + ->toArray(); + + return $this->return->success('success',$list); + } + } \ No newline at end of file diff --git a/sync/http/admin/auth.http b/sync/http/admin/auth.http index 1314783..2e22a85 100644 --- a/sync/http/admin/auth.http +++ b/sync/http/admin/auth.http @@ -377,3 +377,8 @@ GET {{host}}/admin/supplier/delete?id=1 Content-Type: application/x-www-form-urlencoded Authorization: Bearer {{admin_token}} +### 采购列表 +GET {{host}}/admin/depot/purchase_list?limit=10 +content-type: application/json +Authorization: Bearer {{admin_token}} +