Service.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Middleware;
  9. use LinFly\Annotation\Attributes\Route\PostMapping;
  10. use support\Request;
  11. use support\Response;
  12. #[Controller("/dy/service"),Middleware(AuthMiddleware::class)]
  13. class Service extends Base
  14. {
  15. /**
  16. * 分配客服
  17. * @param Request $request
  18. * @return Response
  19. */
  20. #[PostMapping("shareout")]
  21. public function shareUser2Mer(Request $request)
  22. {
  23. try {
  24. $param = $request->all();
  25. $store = (new SaasStore)->where("poi_id",$param['poi'])->findOrEmpty();
  26. if ($store->isEmpty()) return error("店铺不存在");
  27. // 获取在线客服
  28. $service = (new SystemUser)->where("store_id",$param['poi'])->where("type",3)->where("is_line",1)->findOrEmpty();
  29. if ($service->isEmpty()) return $this->encode("ok",['store' => $store,'code' => 3]); // 无客服在线
  30. } catch (\Throwable $throwable) {
  31. return error($throwable->getMessage());
  32. }
  33. }
  34. }