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

+ 12 - 8
app/adminapi/service/WeCallService.php

@@ -15,6 +15,8 @@
 
 namespace app\adminapi\service;
 
+use app\common\model\dict\DictData;
+
 
 
 /**
@@ -27,14 +29,16 @@ class WeCallService
     protected $appKey;
     protected $appSecret;
     protected $taskId;
+    protected $status = 0;
 
     public function __construct()
     {
-        $config = config('custom.wecall');
+        $config = DictData::where('type_value', 'wecall')->column('value','name');
         if ($config) {
-            $this->appKey = $config['appKey'];
-            $this->appSecret = $config['appSecret'];
-            $this->taskId = $config['taskId'];
+            $this->appKey = isset($config['appKey']) ?? '';
+            $this->appSecret = isset($config['appSecret']) ?? '';
+            $this->taskId = isset($config['taskId']) ?? '';
+            $this->status = isset($config['status']) ?? 0;
         } 
     }
 
@@ -63,7 +67,7 @@ class WeCallService
      * 向外呼任务导入客户
      */
     public function importUser($customerList){
-        if (empty($this->appKey) || empty($this->appSecret) || empty($this->taskId)) {
+        if ($this->status == 0) {
             return false;
         }
         $requestBody = [
@@ -91,7 +95,7 @@ class WeCallService
      * 开启外呼任务(仅手动任务可调用)
      */
     public function startTask(){
-        if (empty($this->appKey) || empty($this->appSecret) || empty($this->taskId)) {
+        if ($this->status == 0) {
             return false;
         }
         $requestBody = [
@@ -116,7 +120,7 @@ class WeCallService
      * 停止外呼任务(仅手动任务可调用)
      */
     public function stopTask(){
-        if (empty($this->appKey) || empty($this->appSecret) || empty($this->taskId)) {
+        if ($this->status == 0) {
             return false;
         }
         $requestBody = [
@@ -153,9 +157,9 @@ class WeCallService
     {
         $taskId = $data['taskId'];
         $status = $data['status'];
-        $updateTime = $data['updateTime'];
         if ($taskId == $this->taskId && $status == 'COMPLETE') {
             // TODO 任务状态改变
+            $this->stopTask();
         }
     }
 

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

@@ -0,0 +1,30 @@
+<?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);
+        }
+    }
+
+}

+ 0 - 10
config/custom.php

@@ -5,14 +5,4 @@
 
 return [
     'cdn_url' => 'https://cdnweixiu.kyjlkj.com/',   //静态资源域名
-    //网易云商智能外呼配置
-    'wecall' => [
-        // 'appKey' => '6143f9037f8546f6b83be0498dc19258',
-        // 'appSecret' => 'cd1a1ec8089342a7a913b726013974c7',
-        // 'taskId' => 2462591,
-        'appKey' => '9db89ac3e679404c87b82697fcb321cc',
-        'appSecret' => 'f1511c3a49064070b4de1afd8abcd1d4',
-        'taskId' => 2472602,
-        
-    ],
 ];