123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- /**
- * Author: luzheng.liu
- * Time: 2021/6/4 14:49
- */
- namespace app\api\controller;
- use app\api\BaseController;
- use app\api\model\CallServiceModel;
- use app\common\service\ServerService;
- use app\common\until\Until;
- class Server extends BaseController {
- /**
- * @OA\Post(path="/api/Server/callService",
- * tags={"服务管理"},
- * summary="叫服务",
- * @OA\RequestBody(
- * @OA\MediaType(
- * mediaType="multipart/form-data",
- * @OA\Schema(
- * @OA\Property(description="服务类型 1、茶水;2、水果;3、加钟", property="type", type="integer"),
- * @OA\Property(description="钟code", property="blockCode", type="string"),
- * required={"type","blockCode"})
- * )
- * ),
- * @OA\Response(response="200", description="请求成功")
- * )
- */
- public function callService() {
- var_dump(2);
- $input = Until::getInput();
- $rule = [
- 'type|服务类型' => '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();
- }
-
- }
|