InventoryController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Http\ApiControllers;
  3. use App\Components\ApiResponse;
  4. use App\Http\Requests\AndroidGateRequest;
  5. use App\InventoryAccount;
  6. class InventoryController
  7. {
  8. use ApiResponse;
  9. /**
  10. * @api {get} /inventory/inventoryTasks 获取盘点任务数据
  11. * @apiName inventoryTasks
  12. * @apiGroup inventory
  13. *
  14. * @apiParam {int} page 页数
  15. * @apiParam {int} paginate 每页多少
  16. *
  17. * @apiSuccess {string} message 响应描述
  18. * @apiSuccess {int} status_code HTTP响应码
  19. * @apiSuccess {array} data 数据列表
  20. *
  21. * @apiSuccessExample {json} Success-Response:
  22. * HTTP/1.1 200 OK
  23. * {
  24. * "message": "请求成功",
  25. * "status_code": "200"
  26. * "data":[
  27. * {
  28. * "id"=>"宝时单号",
  29. * "created_at" =>"任务创建时间",
  30. * "end_at" =>"库位最后操作时间",
  31. * "owner_name"=>"货主名",
  32. * "type"=>"任务类型",
  33. * "total"=>"盘点任务数",
  34. * "processed"=>"盘点数",
  35. * }
  36. * ]
  37. * }
  38. */
  39. public function inventoryTasks(AndroidGateRequest $request)
  40. {
  41. $page = $request->input("page",1);
  42. $paginate = $request->input("paginate",20);
  43. $ownerIds=app('OwnerService')->getSelection();
  44. $inventories=InventoryAccount::query()->with('owner')
  45. ->orderBy('id','desc')
  46. ->whereIn('status',['待盘点','盘点中','复盘中'])
  47. ->whereIn('owner_id',$ownerIds)
  48. ->paginate($paginate,'*', 'page',$page)
  49. ->append(["owner_name"]);
  50. $this->response(['inventories'=>$inventories]);
  51. }
  52. }