Service.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\controller\api;
  3. use app\extra\basic\Base;
  4. use app\middleware\AuthMiddleware;
  5. use app\model\saas\SaasStore;
  6. use app\model\system\SystemUser;
  7. use LinFly\Annotation\Attributes\Route\Controller;
  8. use LinFly\Annotation\Attributes\Route\GetMapping;
  9. use LinFly\Annotation\Attributes\Route\Middleware;
  10. use LinFly\Annotation\Attributes\Route\PostMapping;
  11. use support\Request;
  12. use support\Response;
  13. #[Controller("/dy/service"),Middleware(AuthMiddleware::class)]
  14. class Service extends Base
  15. {
  16. /**
  17. * 获取客服列表-已聊过的
  18. * @param Request $request
  19. * @return Response|void
  20. */
  21. #[GetMapping("list")]
  22. public function getServiceList(Request $request)
  23. {
  24. try {
  25. } catch (\Throwable $throwable) {
  26. return error($throwable->getMessage());
  27. }
  28. }
  29. /**
  30. * 分配客服
  31. * @param Request $request
  32. * @return Response
  33. */
  34. #[PostMapping("shareout")]
  35. public function shareUser2Mer(Request $request): Response
  36. {
  37. try {
  38. $param = $request->all();
  39. $store = (new SaasStore)->where("poi_id",$param['poi'])->findOrEmpty();
  40. if ($store->isEmpty()) return error("店铺不存在");
  41. // 获取在线客服
  42. $service = (new SystemUser)->where("store_id",$param['poi'])->where("type",3)->where("is_line",1)->findOrEmpty();
  43. if ($service->isEmpty()) return $this->encode("ok",['store' => $store,'code' => 3]); // 无客服在线
  44. return $this->encode("ok",['store' => $store,'code' => 1]); // 客服在线
  45. } catch (\Throwable $throwable) {
  46. return error($throwable->getMessage());
  47. }
  48. }
  49. }