|
|
|
|
@ -14,6 +14,7 @@ class MeetRepository
|
|
|
|
|
public $account;
|
|
|
|
|
public $password;
|
|
|
|
|
public $companyId;
|
|
|
|
|
public $httpTimeout = 30;
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
@ -37,14 +38,13 @@ class MeetRepository
|
|
|
|
|
'password' => $this->password
|
|
|
|
|
];
|
|
|
|
|
try {
|
|
|
|
|
$result = httpCurl($url, 'GET', $params, $header);
|
|
|
|
|
$result = httpCurl($url, 'GET', $params, $header, $this->httpTimeout);
|
|
|
|
|
$result = json_decode($result, true);
|
|
|
|
|
if ($result['success']) {
|
|
|
|
|
if (is_array($result) && !empty($result['success'])) {
|
|
|
|
|
return $result['companyId'];
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return false;
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -62,7 +62,7 @@ class MeetRepository
|
|
|
|
|
'password' => md5($this->password)
|
|
|
|
|
];
|
|
|
|
|
try {
|
|
|
|
|
$resultJson = httpCurl($url, 'GET', $params, $header, 30);
|
|
|
|
|
$resultJson = httpCurl($url, 'GET', $params, $header, $this->httpTimeout);
|
|
|
|
|
$result = json_decode($resultJson, true);
|
|
|
|
|
if (!is_array($result) || empty($result['success']) || empty($result['data'])) {
|
|
|
|
|
return false;
|
|
|
|
|
@ -93,7 +93,13 @@ class MeetRepository
|
|
|
|
|
$startDateTime = new \DateTime($model->start_time);
|
|
|
|
|
$endDateTime = new \DateTime($model->end_time);
|
|
|
|
|
|
|
|
|
|
$meetOther = json_decode($appointmentConfig->room, true);
|
|
|
|
|
$meetOther = is_array($appointmentConfig->room)
|
|
|
|
|
? $appointmentConfig->room
|
|
|
|
|
: json_decode($appointmentConfig->room, true);
|
|
|
|
|
if (!is_array($meetOther) || empty($meetOther['code']) || empty($meetOther['address'])) {
|
|
|
|
|
$out = '会议室信息不完整,缺少 code 或 address';
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$url = $this->baseUrl . '/services/api/BookingService.aspx';
|
|
|
|
|
$header[] = 'Content-Type: application/json';
|
|
|
|
|
|
|
|
|
|
@ -132,24 +138,25 @@ class MeetRepository
|
|
|
|
|
|
|
|
|
|
$result = [];
|
|
|
|
|
$finally = 0;
|
|
|
|
|
$resultJson = '';
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$resultJson = httpCurl($url, 'GET', $params, $header);
|
|
|
|
|
$resultJson = httpCurl($url, 'GET', $params, $header, $this->httpTimeout);
|
|
|
|
|
$result = json_decode($resultJson, true);
|
|
|
|
|
|
|
|
|
|
if ($result['success']) {
|
|
|
|
|
if (is_array($result) && !empty($result['success'])) {
|
|
|
|
|
$finally = 1;
|
|
|
|
|
$allMeetIds[] = $result['data'];
|
|
|
|
|
$allResults[] = $result;
|
|
|
|
|
ThirdAppointmentLog::add($model->id, 0, $model->user_id, $url, $params, $result, $finally, '会议室预约-' . $currentDate->format('Y-m-d'));
|
|
|
|
|
} else {
|
|
|
|
|
$out = $resultJson;
|
|
|
|
|
ThirdAppointmentLog::add($model->id, 0, $model->user_id, $url, $params, $result, $finally, '会议室预约-' . $currentDate->format('Y-m-d'));
|
|
|
|
|
$out = is_string($resultJson) && $resultJson !== '' ? $resultJson : '爱预约请求超时或返回异常';
|
|
|
|
|
ThirdAppointmentLog::add($model->id, 0, $model->user_id, $url, $params, is_array($result) ? $result : $out, $finally, '会议室预约-' . $currentDate->format('Y-m-d'));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
$out = $e->getMessage();
|
|
|
|
|
ThirdAppointmentLog::add($model->id, 0, $model->user_id, $url, $params, $result, $finally, '会议室预约-' . $currentDate->format('Y-m-d'));
|
|
|
|
|
ThirdAppointmentLog::add($model->id, 0, $model->user_id, $url, $params, $result ?: $resultJson, $finally, '会议室预约-' . $currentDate->format('Y-m-d'));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -187,17 +194,16 @@ class MeetRepository
|
|
|
|
|
$result = [];
|
|
|
|
|
$finally = 0;
|
|
|
|
|
try {
|
|
|
|
|
$resultJson = httpCurl($url, 'GET', $params, $header);
|
|
|
|
|
$resultJson = httpCurl($url, 'GET', $params, $header, $this->httpTimeout);
|
|
|
|
|
$out = $resultJson;
|
|
|
|
|
$result = json_decode($resultJson, true);
|
|
|
|
|
if ($result['success']) {
|
|
|
|
|
if (is_array($result) && !empty($result['success'])) {
|
|
|
|
|
$finally = 1;
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
$out = $resultJson;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$out = is_string($resultJson) && $resultJson !== '' ? $resultJson : '爱预约取消请求超时或返回异常';
|
|
|
|
|
return false;
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
$out = $e->getMessage();
|
|
|
|
|
return false;
|
|
|
|
|
} finally {
|
|
|
|
|
@ -223,17 +229,16 @@ class MeetRepository
|
|
|
|
|
'end' => $endDate,
|
|
|
|
|
];
|
|
|
|
|
try {
|
|
|
|
|
$resultJson = httpCurl($url, 'GET', $params, $header);
|
|
|
|
|
$resultJson = httpCurl($url, 'GET', $params, $header, $this->httpTimeout);
|
|
|
|
|
$out = $resultJson;
|
|
|
|
|
$result = json_decode($resultJson, true);
|
|
|
|
|
if ($result['success']) {
|
|
|
|
|
if (is_array($result) && !empty($result['success'])) {
|
|
|
|
|
$out = $result['data'];
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
$out = $resultJson;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$out = is_string($resultJson) && $resultJson !== '' ? $resultJson : '爱预约查询超时或返回异常';
|
|
|
|
|
return false;
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
$out = $e->getMessage();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|