Server.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /**
  3. * Author: luzheng.liu
  4. * Time: 2021/6/4 14:49
  5. */
  6. namespace app\api\controller;
  7. use app\api\BaseController;
  8. use app\api\model\CallServiceModel;
  9. use app\common\until\Until;
  10. class Server extends BaseController {
  11. /**
  12. * @OA\Post(path="/api/Server/callService",
  13. * tags={"服务管理"},
  14. * summary="叫服务",
  15. * @OA\RequestBody(
  16. * @OA\MediaType(
  17. * mediaType="multipart/form-data",
  18. * @OA\Schema(
  19. * @OA\Property(description="服务类型 1、茶水;2、水果;3、加钟", property="type", type="integer"),
  20. * @OA\Property(description="房间号", property="roomId", type="integer"),
  21. * @OA\Property(description="门店id", property="storeId", type="integer"),
  22. * required={"type","roomId","storeId"})
  23. * )
  24. * ),
  25. * @OA\Response(response="200", description="请求成功")
  26. * )
  27. */
  28. public function callService() {
  29. $input = Until::getInput();
  30. $rule = [
  31. 'type|服务类型' => 'require',
  32. 'roomId|房间号' => 'require',
  33. 'storeId|门店id' => 'require',
  34. ];
  35. Until::check($rule, $input);
  36. $model = new CallServiceModel();
  37. $callInfo = $model::where([
  38. 'store_id' => $input['storeId'],
  39. 'room_id' => $input['roomId'],
  40. 'server_type' => $input['type'],
  41. 'status' => CallServiceModel::NOT_DEAL
  42. ])->find();
  43. if (empty($callInfo)) {
  44. $model->insertGetId([
  45. 'store_id' => $input['storeId'],
  46. 'room_id' => $input['roomId'],
  47. 'server_type' => $input['type'],
  48. 'call_num' => 1
  49. ]);
  50. Until::output();
  51. }
  52. $model::where(['id' => $callInfo['id']])->inc('call_num')->update();
  53. Until::output();
  54. }
  55. /**
  56. * @OA\Post(path="/api/Server/callList",
  57. * tags={"服务管理"},
  58. * summary="叫服务列表(轮询这个接口)",
  59. * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
  60. * @OA\RequestBody(
  61. * @OA\MediaType(
  62. * mediaType="multipart/form-data",
  63. * @OA\Schema(
  64. * @OA\Property(description="房间号", property="roomId", type="integer"),
  65. * @OA\Property(description="门店id", property="storeId", type="integer"),
  66. * required={"storeId"})
  67. * )
  68. * ),
  69. * @OA\Response(response="200", description="请求成功")
  70. * )
  71. */
  72. public function callList() {
  73. $input = Until::getInput();
  74. $rule = [
  75. // 'roomId|房间号' => 'require',
  76. 'storeId|门店id' => 'require',
  77. ];
  78. Until::check($rule, $input);
  79. $model = new CallServiceModel();
  80. $where[] = ['store_id', '=', $input['storeId']];
  81. $where[] = ['status', '=', CallServiceModel::NOT_DEAL];
  82. if (!empty($input['roomId'])) {
  83. $where[] = ['room_id', '=', $input['roomId']];
  84. }
  85. $list = $model::where($where)->select();
  86. Until::output(['list' => $list]);
  87. }
  88. /**
  89. * @OA\Post(path="/api/Server/dealCall",
  90. * tags={"服务管理"},
  91. * summary="处理叫服务",
  92. * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
  93. * @OA\RequestBody(
  94. * @OA\MediaType(
  95. * mediaType="multipart/form-data",
  96. * @OA\Schema(
  97. * @OA\Property(description="房间号", property="roomId", type="integer"),
  98. * @OA\Property(description="门店id", property="storeId", type="integer"),
  99. * @OA\Property(description="服务类型 1、茶水;2、水果;3、加钟", property="type", type="integer"),
  100. * required={"type","roomId","storeId"})
  101. * )
  102. * ),
  103. * @OA\Response(response="200", description="请求成功")
  104. * )
  105. */
  106. public function dealCall() {
  107. $input = Until::getInput();
  108. $rule = [
  109. 'roomId|房间号' => 'require',
  110. 'storeId|门店id' => 'require',
  111. ];
  112. Until::check($rule, $input);
  113. $model = new CallServiceModel();
  114. $model::where([
  115. 'store_id' => $input['storeId'],
  116. 'room_id' => $input['roomId'],
  117. 'server_type' => $input['type'],
  118. ])->update(['status' => CallServiceModel::DEAL]);
  119. Until::output();
  120. }
  121. }