'require', 'blockCode|钟code' => 'require', ]; Until::check($rule, $input); ServerService::getRoomByCode($input['blockCode']); $model = new CallServiceModel(); $callInfo = $model::where([ 'store_id' => $input['storeId'], 'room_id' => $input['roomId'], 'server_type' => $input['type'], 'status' => CallServiceModel::NOT_DEAL ])->find(); if (empty($callInfo)) { $model->insertGetId([ 'store_id' => $input['storeId'], 'room_id' => $input['roomId'], 'server_type' => $input['type'], 'call_num' => 1 ]); Until::output(); } $model::where(['id' => $callInfo['id']])->inc('call_num')->update(); Until::output(); } /** * @OA\Post(path="/api/Server/callList", * tags={"服务管理"}, * summary="叫服务列表(轮询这个接口)", * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")), * @OA\RequestBody( * @OA\MediaType( * mediaType="multipart/form-data", * @OA\Schema( * @OA\Property(description="房间号", property="roomId", type="integer"), * @OA\Property(description="门店id", property="storeId", type="integer"), * required={"storeId"}) * ) * ), * @OA\Response(response="200", description="请求成功") * ) */ public function callList() { $input = Until::getInput(); $rule = [ // 'roomId|房间号' => 'require', 'storeId|门店id' => 'require', ]; Until::check($rule, $input); $model = new CallServiceModel(); $where[] = ['store_id', '=', $input['storeId']]; $where[] = ['status', '=', CallServiceModel::NOT_DEAL]; if (!empty($input['roomId'])) { $where[] = ['room_id', '=', $input['roomId']]; } $list = $model::where($where)->select(); Until::output(['list' => $list]); } /** * @OA\Post(path="/api/Server/dealCall", * tags={"服务管理"}, * summary="处理叫服务", * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")), * @OA\RequestBody( * @OA\MediaType( * mediaType="multipart/form-data", * @OA\Schema( * @OA\Property(description="房间号", property="roomId", type="integer"), * @OA\Property(description="门店id", property="storeId", type="integer"), * @OA\Property(description="服务类型 1、茶水;2、水果;3、加钟", property="type", type="integer"), * required={"type","roomId","storeId"}) * ) * ), * @OA\Response(response="200", description="请求成功") * ) */ public function dealCall() { $input = Until::getInput(); $rule = [ 'roomId|房间号' => 'require', 'storeId|门店id' => 'require', ]; Until::check($rule, $input); $model = new CallServiceModel(); $model::where([ 'store_id' => $input['storeId'], 'room_id' => $input['roomId'], 'server_type' => $input['type'], ])->update(['status' => CallServiceModel::DEAL]); Until::output(); } }