作者 赵彬吉

update

@@ -10,6 +10,7 @@ use App\Models\Subscribe\Smtp; @@ -10,6 +10,7 @@ use App\Models\Subscribe\Smtp;
10 use App\Models\Workchat\MessagePush; 10 use App\Models\Workchat\MessagePush;
11 use App\Services\Aside\ProjectAssociation\ProjectAssociationServices; 11 use App\Services\Aside\ProjectAssociation\ProjectAssociationServices;
12 use Illuminate\Console\Command; 12 use Illuminate\Console\Command;
  13 +use Illuminate\Http\Client\ConnectionException;
13 use Illuminate\Support\Facades\Config; 14 use Illuminate\Support\Facades\Config;
14 use Illuminate\Support\Facades\Mail; 15 use Illuminate\Support\Facades\Mail;
15 16
@@ -44,6 +45,8 @@ class WorkchatMessageSend extends Command @@ -44,6 +45,8 @@ class WorkchatMessageSend extends Command
44 ProjectAssociationServices::getInstance()->sendMessage($task->friend_id, $task->content, $task->content_type); 45 ProjectAssociationServices::getInstance()->sendMessage($task->friend_id, $task->content, $task->content_type);
45 $this->output('推送消息' . $task->id . '成功'); 46 $this->output('推送消息' . $task->id . '成功');
46 $task->status = MessagePush::STATUS_SUCCESS; 47 $task->status = MessagePush::STATUS_SUCCESS;
  48 + }catch (ConnectionException $e){
  49 + $this->output('推送消息' . $task->id . '超时');
47 }catch (\Exception $e){ 50 }catch (\Exception $e){
48 $this->output('推送消息' . $task->id . '失败:' . $e->getMessage()); 51 $this->output('推送消息' . $task->id . '失败:' . $e->getMessage());
49 $task->status = MessagePush::STATUS_ERROR; 52 $task->status = MessagePush::STATUS_ERROR;
@@ -168,14 +168,7 @@ class ProjectAssociationServices extends BaseService @@ -168,14 +168,7 @@ class ProjectAssociationServices extends BaseService
168 } 168 }
169 $param['sign'] = $this->getSign($param); 169 $param['sign'] = $this->getSign($param);
170 $url = 'https://hub.ai.cc/api/globalso_ai_customer_service/chatroom_list'; 170 $url = 'https://hub.ai.cc/api/globalso_ai_customer_service/chatroom_list';
171 -// $result = Http::withoutVerifying()->post($url, $param)->json();  
172 - $client = new \GuzzleHttp\Client();  
173 - $result = $client->request('POST', $url, [  
174 - 'proxy' => env('CURL_PROXY'),  
175 - 'json' => $param,  
176 - 'verify' => false,  
177 - ])->getBody()->getContents();  
178 - $result = json_decode($result, true); 171 + $result = Http::withoutVerifying()->post($url, $param)->json();
179 if(empty($result) || $result['status'] != 200){ 172 if(empty($result) || $result['status'] != 200){
180 return []; 173 return [];
181 } 174 }
@@ -196,17 +189,7 @@ class ProjectAssociationServices extends BaseService @@ -196,17 +189,7 @@ class ProjectAssociationServices extends BaseService
196 ]; 189 ];
197 $param['sign'] = $this->getSign($param); 190 $param['sign'] = $this->getSign($param);
198 $url = 'https://hub.ai.cc/api/globalso_ai_customer_service/send_msg'; 191 $url = 'https://hub.ai.cc/api/globalso_ai_customer_service/send_msg';
199 -  
200 -// $result = Http::withoutVerifying()->post($url, $param)->json();  
201 -  
202 - $client = new \GuzzleHttp\Client();  
203 - $result = $client->request('POST', $url, [  
204 - 'proxy' => env('CURL_PROXY'),  
205 - 'json' => $param,  
206 - 'verify' => false,  
207 - ])->getBody()->getContents();  
208 - $result = json_decode($result, true);  
209 - 192 + $result = Http::withoutVerifying()->timeout(10)->post($url, $param)->json();
210 if(empty($result) || $result['status'] != 200){ 193 if(empty($result) || $result['status'] != 200){
211 throw new \Exception($result['message'] ?? ''); 194 throw new \Exception($result['message'] ?? '');
212 } 195 }