where('name', 'like', '%门岗%'); })->get(); return $this->success($admin); } /** * @OA\Get( * path="/api/admin/gate/visit-list", * tags={"门岗-拜访记录"}, * summary="拜访记录", * description="", * @OA\Parameter(name="keyword", in="query", @OA\Schema(type="string"), required=false, description="关键词"), * @OA\Parameter(name="audit_status", in="query", @OA\Schema(type="string"), required=false, description="审核状态-1待学习0待审核1通过(待进厂)2驳回3已进厂4已离厂"), * @OA\Parameter(name="start_date", in="query", @OA\Schema(type="string"), required=false, description="开始日期"), * @OA\Parameter(name="end_date", in="query", @OA\Schema(type="string"), required=false, description="结束日期"), * @OA\Parameter(name="page_size", in="query", @OA\Schema(type="string"), required=false, description="每页显示的条数"), * @OA\Parameter(name="page", in="query", @OA\Schema(type="string"), required=false, description="页码"), * @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"), * @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"), * @OA\Parameter(name="code", in="query", @OA\Schema(type="string"), required=false, description="编码"), * @OA\Parameter(name="car_no", in="query", @OA\Schema(type="string"), required=false, description="停车牌"), * @OA\Parameter(name="person_no", in="query", @OA\Schema(type="string"), required=false, description="人牌"), * @OA\Parameter(name="is_export", in="query", @OA\Schema(type="string"), required=false, description="是否导出0否1是,默认0"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), * @OA\Response( * response="200", * description="暂无" * ) * ) */ public function visitList() { $all = request()->all(); $list = Visit::with('logs.admin','logs.user', 'visitTime', 'admin', 'visitArea', 'acceptAdmin.department', 'acceptAdminSignFile', 'acceptGoodsAdmin.department')->where(function ($query) use ($all) { if (isset($all['keyword'])) { $query->where('name', 'like', '%' . $all['keyword'] . '%'); } if (isset($all['audit_status'])) { $query->where('audit_status', $all['audit_status']); } if (isset($all['code'])) { $query->where('code', $all['code']); } if (isset($all['start_date']) && isset($all['end_date'])) { $query->whereBetween('date', [$all['start_date'], $all['end_date']]); } })->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')->paginate($all['page_size'] ?? 20);; return $this->success($list); } /** * @OA\Get( * path="/api/admin/gate/use-code", * tags={"门岗-核销"}, * summary="核销", * description="", * @OA\Parameter(name="admin_id", in="query", @OA\Schema(type="string"), required=false, description="管理员id"), * @OA\Parameter(name="code", in="query", @OA\Schema(type="string"), required=false, description="编码"), * @OA\Parameter(name="car_no", in="query", @OA\Schema(type="string"), required=false, description="停车牌"), * @OA\Parameter(name="person_no", in="query", @OA\Schema(type="string"), required=false, description="人牌"), * @OA\Parameter(name="type", in="query", @OA\Schema(type="string"), required=false, description="1进厂2离厂"), * @OA\Response( * response="200", * description="暂无" * ) * ) */ public function useCode() { $all = \request()->all(); $messages = [ 'code.required' => '编号必填', 'type.required' => '类型必填', 'admin_id.required' => '操作人必填' ]; $validator = Validator::make($all, [ 'code' => 'required', 'type' => 'required', 'admin_id' => 'required' ], $messages); if ($validator->fails()) { return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]); } $check = Visit::where('code', $all['code'])->first(); if (empty($check)) { return $this->fail([ResponseCode::ERROR_BUSINESS, '拜访记录不存在']); } $remark = '进厂'; if ($all['type'] == 2) { $remark = '离厂'; } $gateLog = GateLog::add($all['admin_id'], $all['code'], $remark); if ($all['type'] == 1) { Visit::where('code', $all['code'])->update(['audit_status' => 3]); } if ($all['type'] == 2) { Visit::where('code', $all['code'])->update(['audit_status' => 4]); } return $this->success($gateLog); } }