dongxiaoqin 1 год назад
Родитель
Сommit
b720411dc1

+ 4 - 5
app/adminapi/service/WeCallService.php

@@ -144,11 +144,10 @@ class WeCallService
     /**
      * 数据回调接口
      */
-    public function notify($body) {
-        $body = json_decode($body, true);
-        if ($body && isset($body['dataType'])) {
-            if ($body['dataType'] == 'ROBOT_TASK_STATUS_CHANGE') {
-                $this->taskStatusChange($body['data']);
+    public function notify($params) {
+        if ($params && isset($params['dataType'])) {
+            if ($params['dataType'] == 'ROBOT_TASK_STATUS_CHANGE') {
+                $this->taskStatusChange($params['data']);
             }    
         }
     }

+ 31 - 0
app/api/controller/notify/WeCallController.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace app\api\controller\notify;
+
+use app\adminapi\service\WeCallService;
+use app\api\controller\BaseApiController;
+
+/**
+ * 网易云商外呼任务回调接口
+ * Class WeCallController
+ * @package app\api\controller\notify
+ */
+class WeCallController extends BaseApiController
+{
+
+    public array $notNeedLogin = ['notify'];
+
+    public function notify()
+    {
+        $params = $this->request->param();
+        if (!empty($params['dataType']) && $params['dataType'] == 'ROBOT_TASK_STATUS_CHANGE') {
+            // 任务状态变更回调
+            $weCallService = new WeCallService();
+            $weCallService->notify($params);
+        }
+        
+        return $this->success('success');
+       
+    }
+
+}

+ 0 - 30
app/api/controller/notify/WeCallNotifyController.php

@@ -1,30 +0,0 @@
-<?php
-
-namespace app\api\controller\notify;
-
-use app\api\controller\BaseApiController;
-use think\facade\Log;
-
-/**
- * 网易云商外呼任务回调接口
- * Class WeCallNotifyController
- * @package app\api\controller\notify
- */
-class WeCallNotifyController extends BaseApiController
-{
-
-    public array $notNeedLogin = ['notify'];
-
-    public function notify(): void
-    {
-        $params = $this->request->param();
-        Log::write(json_encode($this->request->param()));
-
-        if($this->request->param()){
-            $url = 'https://u.baidu.com/oauth/accessToken';
-            $result = http_request($url,$this->request->param(),['Content-Type'=>'application/json;charset:utf-8;']);
-            Log::write($result);
-        }
-    }
-
-}