修改私域专题报名同步

This commit is contained in:
lcc
2024-08-08 11:46:51 +08:00
parent 010082067a
commit bb5ea189cc
6 changed files with 129 additions and 30 deletions
+42 -3
View File
@@ -5,6 +5,7 @@ class SsApi
{
const CF_PLATFORM = "SYSTOPIC";
const CLUES_METHOD = 'openApi/clues';
const STATUS_METHOD = 'openApi/status';
private $app_id = '1c156bb57cd6984a';
private $sign_key = '71fd71173b776766a2ae1209d9a2c2ed';
private $api_url = 'https://api.haodian.cn/hd/app/'; //空间站报名数据接口
@@ -55,15 +56,15 @@ class SsApi
debug_log("[info]#请求地址:" . $url, $this->log_path);
debug_log("[info]#请求参数:" . json_encode($data, JSON_UNESCAPED_UNICODE), $this->log_path);
$response = $client->post($url, $options);
$body = $response->getBody();
debug_log("[info]#返回信息:" . $response->getBody(), $this->log_path);
if ($response->getStatusCode() != 200) {
debug_log("[error]#" . $response->getStatusCode(), $this->log_path);
return ['code' => 0, 'msg' => '网络错误:' . $response->getStatusCode()];
}
$reqInfo = json_decode($response->getBody());
if ($reqInfo->code != 200) {
return ['code' => 0, 'msg' => '保存失败:' . $reqInfo->msg];
if (!$reqInfo || $reqInfo->code != 200) {
$msg = $reqInfo ? $reqInfo->msg : '';
return ['code' => 0, 'msg' => '保存失败:' . $msg];
}
return ['code' => 1, 'msg' => '保存成功'];
} catch (Exception $e) {
@@ -72,6 +73,44 @@ class SsApi
}
}
public function getStatus($out_ids)
{
if(is_array($out_ids)){
$out_ids = implode(',',$out_ids);
}
$data = [
'out_ids' => $out_ids,
'cf_platform' => self::CF_PLATFORM,
'nonce_str' => random_string('alpha'),
'app_id' => $this->app_id,
];
$data['sign'] = $this->sign($data);
$client = new GuzzleHttp\Client();
$options = [
\GuzzleHttp\RequestOptions::HEADERS => ['Content-Type' => 'application/json'],
\GuzzleHttp\RequestOptions::JSON => $data,
];
$url = $this->api_url . self::STATUS_METHOD;
try {
debug_log("[info]#请求地址:" . $url, $this->log_path);
debug_log("[info]#请求参数:" . json_encode($data, JSON_UNESCAPED_UNICODE), $this->log_path);
$response = $client->post($url, $options);
debug_log("[info]#返回信息:" . $response->getBody(), $this->log_path);
if ($response->getStatusCode() != 200) {
debug_log("[error]#" . $response->getStatusCode(), $this->log_path);
return ['code' => 0, 'msg' => '网络错误:' . $response->getStatusCode()];
}
$reqInfo = json_decode($response->getBody(), true);
if (!$reqInfo || $reqInfo['code'] != 200) {
$msg = $reqInfo ? $reqInfo['msg'] : '';
return ['code' => 0, 'msg' => '保存失败:' . $msg];
}
return ['code' => 1, 'msg' => '保存成功', 'data' => $reqInfo['data']];
} catch (Exception $e) {
debug_log("[error]#" . $e->getMessage(), $this->log_path);
return ['code' => 0, 'msg' => $e->getMessage()];
}
}
private function sign($param)
{
@@ -9,6 +9,10 @@ class Market_sytopic_enroll_model extends HD_Model
const ENROLL_DEAL_PUSH_CLUE = 1; // 提交狸车线索池
const ENROLL_DEAL_PUSH_CUSTOMER = 2; // 提交狸车客户池
const STATUS_PENDING = 0; //待处理
const STATUS_SUCCESS = 1; //已成交
const STATUS_INVALID = 2; //无效
public function __construct()
{
parent::__construct($this->table_name, 'default');
@@ -47,7 +51,7 @@ class Market_sytopic_enroll_model extends HD_Model
if (!$res) {
return ['code' => 0, 'msg' => '提交失败'];
}
if(is_numeric($res)){ //数据同步到空间站
if (is_numeric($res)) { //数据同步到空间站
$this->load->library('market/sytopic_enroll_entity');
$this->sytopic_enroll_entity->synEnroll($res);
}
@@ -57,9 +61,9 @@ class Market_sytopic_enroll_model extends HD_Model
public function statusCn()
{
$statusArray = [
0 => '待确认',
1 => '已确认',
2 => '无效'
self::STATUS_PENDING => '待确认',
self::STATUS_SUCCESS => '已成交',
self::STATUS_INVALID => '无效'
];
return $statusArray;
}