From 77e8748d2ccb8f0ec5bec69a125e2d42893bb4aa Mon Sep 17 00:00:00 2001 From: lcc <805383944@qq.com> Date: Fri, 8 Aug 2025 14:07:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B9=B3=E5=AE=89=E5=A4=96?= =?UTF-8?q?=E5=91=BC=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controllers/plan/CallBack.php | 2 +- api/controllers/wxapp/licheb/Customers.php | 2 +- common/libraries/carHome/CallOut.php | 131 +++++++++++++++++++++ 3 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 common/libraries/carHome/CallOut.php diff --git a/api/controllers/plan/CallBack.php b/api/controllers/plan/CallBack.php index 318a0965..60660032 100644 --- a/api/controllers/plan/CallBack.php +++ b/api/controllers/plan/CallBack.php @@ -206,4 +206,4 @@ class CallBack extends CI_Controller debug_log("post: " . json_encode($post, JSON_UNESCAPED_UNICODE), $logPath, $this->logDir); echo '333'; } -} \ No newline at end of file +} diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 6ae83dc8..01a3cd52 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -1106,7 +1106,7 @@ class Customers extends Wxapp $customer_id = $this->customers_model->add($addData); if ($customer_id) { //初始门店更改-1,理车宝过滤 - $this->customers_model->update(['cs_biz_id' => -1], ["id" => $id]); +// $this->customers_model->update(['cs_biz_id' => -1], ["id" => $id]); //删除未回访计划 $this->mdCustomerVisitData->delete(['c_id' => $id, 'biz_id' => $re['biz_id'], 'status<>' => 2, 't_day >=' => date('Y-m-d')]); //同步客户标签 diff --git a/common/libraries/carHome/CallOut.php b/common/libraries/carHome/CallOut.php new file mode 100644 index 00000000..dfe2af60 --- /dev/null +++ b/common/libraries/carHome/CallOut.php @@ -0,0 +1,131 @@ +ci = &get_instance(); + $this->client = new Client(); + if (!is_product()) { //测试环境 + $this->baseUrl = 'http://202.105.128.251:18081/bas_car_home_ping_tai/car/v1/call'; + $this->aesKey = 'JKCDlCxTvwNumLQVAMQltfpuOSCSa6J9'; + } + } + + public function call() + { + try { + $agentPhoneNo = '18350451617'; + $customerPhoneNo = '13365081602'; + $enAgentPhoneNo = $this->aesEcbPkcs5Encrypt($agentPhoneNo, $this->aesKey); + $enCustomerPhoneNo = $this->aesEcbPkcs5Encrypt($customerPhoneNo, $this->aesKey); + $params = [ + 'orderId' => md5(time()), //必选 String 订单号 + 'agentPhoneNo' => $enAgentPhoneNo, //必选 String 坐席分机。坐席分机如采用AES加密,汽车之家系统传加密后的号码 + 'customerPhoneNo' => $enCustomerPhoneNo, //必选 String 客户手机号码。加密规则与坐席分机一致 +// 'agentId' => '', //备选 String 坐席工号(汽车之家上报开通的中兴平台唯一cti号码) +// 'agentUm' => '', //备选 String 坐席Um(汽车之家人员um账号) + 'displayedPhoneNo' => '0', //必选 String 外显号码(传“0”和空值均为云中继外显) + ]; + $reqParams = [ + 'ctiType' => $this->ctiType, + 'requestId' => time(), + 'para' => $params + ]; + $req = $this->send($this->baseUrl, $reqParams, self::METHOD_POST); + print_r($req); + } catch (\Exception $e) { + + } + } + + /** + * AES-ECB模式加密,使用PKCS5Padding填充 + * @param string $data 待加密的数据 + * @param string $key 加密密钥(16/24/32字节,对应AES-128/192/256) + * @return string 加密后的base64字符串 + */ + function aesEcbPkcs5Encrypt($data, $key) + { + // 检查密钥长度 + $keyLength = strlen($key); + if (!in_array($keyLength, [16, 24, 32])) { + throw new InvalidArgumentException("密钥长度必须是16、24或32字节"); + } + + // 根据密钥长度确定AES模式 + $cipher = 'AES-' . ($keyLength * 8) . '-ECB'; + + // 执行加密,OPENSSL_RAW_DATA表示输出原始二进制,默认使用PKCS5填充 + $encrypted = openssl_encrypt($data, $cipher, $key, OPENSSL_RAW_DATA, ''); + + // 返回base64编码结果(也可根据需要改为bin2hex输出16进制) + return bin2hex($encrypted); + } + + /** + * AES-ECB模式解密,对应HEX格式的加密数据 + * @param string $hexData 加密后的十六进制字符串 + * @param string $key 解密密钥(与加密密钥相同) + * @return string 解密后的原始数据 + */ + function aesEcbPkcs5DecryptFromHex($hexData, $key) + { + $keyLength = strlen($key); + if (!in_array($keyLength, [16, 24, 32])) { + throw new InvalidArgumentException("密钥长度必须是16、24或32字节"); + } + + $cipher = 'AES-' . ($keyLength * 8) . '-ECB'; + + // 先将十六进制转回二进制,再解密 + $decrypted = openssl_decrypt(hex2bin($hexData), $cipher, $key, OPENSSL_RAW_DATA, ''); + return $decrypted; + } + + public function send($url, $data = [], $type = self::METHOD_GET) + { + try { + $options = [ + 'headers' => [ + 'Content-Type' => 'application/json' + ], + ]; + if ($data) { + $options['json'] = $data; + } + $response = $this->client->request($type, $url, $options); +// $response = $this->client->post($url, [ +// 'form_params' => $data, +// // 可选:设置超时时间 +// 'timeout' => 5.0, +// ]); + return [$response->getBody()->getContents(), $options, $response->getStatusCode()]; + } catch (Exception $e) { + debug_log($e->getMessage() . ' URL: ' . $url . ' Data: ' . json_encode($data)); + throw $e; + } + } +} \ No newline at end of file