Server.php 4.4 KB

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