增加机器人提醒

This commit is contained in:
jianghanbo 2024-09-10 09:41:07 +08:00
parent de34ad7475
commit b8dd11b49e
6 changed files with 47 additions and 14 deletions

View File

@ -8,7 +8,7 @@ use app\model\Follows;
use app\model\Orders; use app\model\Orders;
use app\model\Logs; use app\model\Logs;
use app\model\ThirdMobileLogs; use app\model\ThirdMobileLogs;
use app\server\AliCloudApiService; use app\server\ThirdApiService;
use app\server\Orders as ServerOrders; use app\server\Orders as ServerOrders;
use stdClass; use stdClass;
use support\Log; use support\Log;
@ -143,7 +143,7 @@ class OrderController extends base
// 防止重复查询第三方接口 // 防止重复查询第三方接口
$mobileInfo = $localMobiles[$value['mobile']]; $mobileInfo = $localMobiles[$value['mobile']];
} else { } else {
$mobileInfo = (new AliCloudApiService())->getMobileArea($value['mobile']); $mobileInfo = (new ThirdApiService())->getMobileArea($value['mobile']);
$localMobiles[$value['mobile']] = $mobileInfo; $localMobiles[$value['mobile']] = $mobileInfo;
} }
} catch (\Exception $exception) { } catch (\Exception $exception) {

View File

@ -30,7 +30,7 @@ class Orders extends base
]; ];
const StatusName = ['待跟进', '跟进中', '已核销', '核销失败', '放弃跟单']; const StatusName = ['待跟进', '跟进中', '已核销', '核销失败', '放弃跟单'];
const OSS = [1 => '美团', '7' => '美团(新国旅)', 2 => '快手', 3 => '抖音(甄选)', '5' => '抖音(新国旅)', '6' => '同程', 4 => '全平台']; const OSS = [1 => '美团(甄选)', '7' => '美团(新国旅)', 2 => '快手', 3 => '抖音(甄选)', '5' => '抖音(新国旅)', '6' => '同程', 4 => '全平台'];
const timeType = ['create_time' => '添加记录时间', 'update_time' => '修改记录时间', 'last_follow' => '最后跟进时间', 'next_follow' => '下次跟进时间', 'travel_date' => '出行时间', 'create_at' => '下单时间']; const timeType = ['create_time' => '添加记录时间', 'update_time' => '修改记录时间', 'last_follow' => '最后跟进时间', 'next_follow' => '下次跟进时间', 'travel_date' => '出行时间', 'create_at' => '下单时间'];

View File

@ -516,10 +516,6 @@ class Douyin
} }
$body = curl_exec($ch); $body = curl_exec($ch);
curl_close($ch); curl_close($ch);
if ($this->os == 5) {
Log::info("抖音 os{$this->os} \n\n");
Log::info( "抖音 body{$body} \n\n");
}
if (!in_array($method, ['GET', 'POST'])) { if (!in_array($method, ['GET', 'POST'])) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($body, 0, $header_size); $header = substr($body, 0, $header_size);
@ -532,6 +528,13 @@ class Douyin
} }
return null; return null;
} }
return json_decode($body);
$res = json_decode($body);
if (!isset($res['status_code']) || $res['status_code'] != 0) {
Log::info("抖音 os{$this->os} \n\n");
Log::info( "抖音 body{$body} \n\n");
(new ThirdApiService())->weComNotice($this->os);
}
return $res;
} }
} }

View File

@ -150,12 +150,14 @@ class Meituan {
} }
$body = curl_exec($ch); $body = curl_exec($ch);
if ($this->os == 7) { curl_close($ch);
$res = json_decode($body);
if (!isset($res['code']) || $res['code'] != 0) {
Log::info('os:' . $this->os); Log::info('os:' . $this->os);
Log::info('http:' . $http); Log::info('http:' . $http);
Log::info('body:' . $body); Log::info('body:' . $body);
(new ThirdApiService())->weComNotice($this->os);
} }
curl_close($ch); return $res;
return json_decode($body);
} }
} }

View File

@ -1,13 +1,16 @@
<?php <?php
namespace app\server; namespace app\server;
use app\model\Orders;
use app\model\ThirdMobileLogs; use app\model\ThirdMobileLogs;
use support\Log; use support\Log;
/** /**
* 阿里云市场相关接口 * 阿里云市场相关接口
*/ */
class AliCloudApiService { class ThirdApiService {
private $notice = '%s token已过期请及时更换';
/** /**
* @param $mobile * @param $mobile
* @return array|mixed * @return array|mixed
@ -64,4 +67,23 @@ class AliCloudApiService {
list($header, $body) = explode("\r\n\r\n", curl_exec($curl), 2); list($header, $body) = explode("\r\n\r\n", curl_exec($curl), 2);
return json_decode($body, true); return json_decode($body, true);
} }
/**
* 发送企微提醒
* @param $message
* @return mixed
*/
public function weComNotice($os) {
$url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=e138b55c-2886-4729-922e-9a8c753f75ee';
$method = 'post';
$message = sprintf($this->notice, Orders::OSS[$os] ?? '');
$bodys = [
'msgtype' => 'text',
'text' => [
'content' => $message
]
];
return $this->curlRequest($url, $method, [], $bodys);
}
} }

View File

@ -106,7 +106,7 @@ class Tongcheng {
if (empty($list) || $list->code != 1000) { if (empty($list) || $list->code != 1000) {
$this->_getRetriesLock(); $this->_getRetriesLock();
$list = $this->_curl("/merchant/api/market-live/wxVideoV2/supplierOrderByPage", $params, 'POST'); $list = $this->_curl("/merchant/api/market-live/wxVideoV2/supplierOrderByPage", $params, 'POST');
if (empty($list) || $list->status_code != 0) { if (empty($list) || $list->code != 1000) {
Log::error('===查询时间:' . $start . '--' . $end . '====certificate_list: ' . json_encode($list)); Log::error('===查询时间:' . $start . '--' . $end . '====certificate_list: ' . json_encode($list));
throw new Exception("同程拉单失败,Err:" . json_encode($list)); throw new Exception("同程拉单失败,Err:" . json_encode($list));
} }
@ -268,6 +268,12 @@ class Tongcheng {
} }
return null; return null;
} }
return json_decode($body);
$res = json_decode($body);
if (!isset($res['code']) || $res['code'] != 1000) {
Log::info( "同城 body{$body} \n\n");
(new ThirdApiService())->weComNotice($this->os);
}
return $res;
} }
} }