Commit bc21af52 authored by hujun's avatar hujun

容联云绑定接口修改

parent 6be7b462
...@@ -177,9 +177,7 @@ class CallPhoneService ...@@ -177,9 +177,7 @@ class CallPhoneService
$type = 'YunTongXunBindAxb'; $type = 'YunTongXunBindAxb';
$bind->recordBindPhone($call_phone['phone'], $phone_a, $phone_b, $record, $this->expiry_date, $this->subs_id, $this->request_id, $this->mapping_id, $this->is_privacy, $this->release); $bind->recordBindPhone($call_phone['phone'], $phone_a, $phone_b, $record, $this->expiry_date, $this->subs_id, $this->request_id, $this->mapping_id, $this->is_privacy, $this->release);
$bind->commit();
} else { } else {
$bind->rollback();
$result['msg'] = $call_phone['msg']; $result['msg'] = $call_phone['msg'];
} }
} }
...@@ -322,7 +320,6 @@ class CallPhoneService ...@@ -322,7 +320,6 @@ class CallPhoneService
* 容联云号码绑定 * 容联云号码绑定
* *
* @return mixed * @return mixed
* @throws \think\exception\PDOException
*/ */
public function yunTongXun() public function yunTongXun()
{ {
...@@ -334,33 +331,25 @@ class CallPhoneService ...@@ -334,33 +331,25 @@ class CallPhoneService
$record = 'false'; $record = 'false';
} }
$aliYunPhone = new AliYunPhone(); $area = $this->getAreaCode();
$phone_x = $aliYunPhone->getAliYunPhoneAll($this->phone_a, $this->phone_b, $this->is_privacy, [], $this->city); //获取未绑定隐号 $result = $yun_tong_xun->setNumber($this->phone_a, $this->phone_b, $area, $this->expiry_date, $record);
$result = $yun_tong_xun->setNumber($this->phone_a, $this->phone_b, $phone_x['data']['phone_x'], $phone_x['data']['area'], $this->expiry_date, $record);
/*绑定成功*/ /*绑定成功*/
if ($result['statusCode'] == '000000') { if ($result['statusCode'] == '000000') {
$data['status'] = 'success'; $data['status'] = 'success';
$data['msg'] = '绑定成功。'; $data['msg'] = '绑定成功。';
$data['phone'] = $phone_x['data']['phone_x']; $data['phone'] = $result['data']['xNumber'];
$this->mapping_id = $result['data']['mappingId']; $this->mapping_id = $result['data']['mappingId'];
} else { } else {
$phone_x_arr[] = $phone_x['data']['phone_x']; //剔除绑定失败的中间号
//尝试5次再绑定 //尝试5次再绑定
for ($i = 0; $i < 5; $i++) { for ($i = 0; $i < 5; $i++) {
$phone_x = $aliYunPhone->getAliYunPhoneAll($this->phone_a, $this->phone_b, $this->is_privacy, $phone_x_arr, $this->city); //获取未绑定隐号 $result = $yun_tong_xun->setNumber($this->phone_a, $this->phone_b, $area, $this->expiry_date, $record);
$result = $yun_tong_xun->setNumber($this->phone_a, $this->phone_b, $phone_x['data']['phone_x'], $phone_x['data']['area'], $this->expiry_date, $record);
if ($result['statusCode'] == '000000') { if ($result['statusCode'] == '000000') {
$data['status'] = 'success'; $data['status'] = 'success';
$data['msg'] = '绑定成功。'; $data['msg'] = '绑定成功。';
$data['phone'] = $phone_x['data']['phone_x']; $data['phone'] = $result['data']['xNumber'];
$this->mapping_id = $result['data']['mappingId']; $this->mapping_id = $result['data']['mappingId'];
break; break;
} else {
$phone_x_arr[] = $phone_x['data']['phone_x']; //剔除绑定失败的中间号
} }
} }
...@@ -480,4 +469,24 @@ class CallPhoneService ...@@ -480,4 +469,24 @@ class CallPhoneService
return; return;
} }
/**
* 根据城市返回区号
*
* @return string
*/
public function getAreaCode()
{
switch ($this->city) {
case '上海' :
$code = '021';
break;
case '杭州' :
$code = '0571';
break;
default :
$code = '021';
}
return $code;
}
} }
\ No newline at end of file
...@@ -125,7 +125,7 @@ class RongDemo ...@@ -125,7 +125,7 @@ class RongDemo
} }
/** /**
* AXB绑定 * AXB绑定,指定X
* @param $aNumber * @param $aNumber
* @param $bNumber * @param $bNumber
* @param $xNumber * @param $xNumber
...@@ -134,7 +134,7 @@ class RongDemo ...@@ -134,7 +134,7 @@ class RongDemo
* @param $yx_time * @param $yx_time
* @return string * @return string
*/ */
public function setNumber($aNumber, $bNumber, $xNumber, $areaCode, $yx_time = '604800', $record) public function setNumberX($aNumber, $bNumber, $xNumber, $areaCode, $yx_time = '604800', $record)
{ {
$data = $this->components; $data = $this->components;
$time = date('YmdHis', time()); $time = date('YmdHis', time());
...@@ -161,6 +161,44 @@ class RongDemo ...@@ -161,6 +161,44 @@ class RongDemo
return $result; return $result;
} }
/**
* AXB绑定,不指定X
* @param $aNumber
* @param $bNumber
* @param $areaCode
* @param $record
* @param $yx_time
* @return string
*/
public function setNumber($aNumber, $bNumber, $areaCode, $yx_time = '604800', $record)
{
$data = $this->components;
$time = date('YmdHis', time());
$sign = $this->sigParameter($time); /*签名*/
$url = $this->url('axb', 'providenumber', 'cu01', $sign);/*url*/
$Authorization = $this->Authorization($time);/*认证信息*/
$post_data = [
'appId' => $data['appId'],
'aNumber' => $aNumber,
'bNumber' => $bNumber,
'xNumberRestrict' => '1', //‘0’无限制 '1':指定区号,'2':跟随aNumber,'3':跟随bNumber
'defaultAreaCode' => '021', //默认区号,当指定的区号没有号码可分配时,则按照默认区号分配号码。
'areaCode' => $areaCode, //区号
'mappingDuration' => strtotime($yx_time) . '',
'icDisplayFlag' => 3, //"0"显示真实号码"1"显示中间号"2"aNumbe侧"3" bNumber侧默认"1"
'needRecord' => $record,
'smscode' => 1, //'0'不支持短信‘1’支持短信
'cdrNotifyUrl' => CURRENT_URL . 'task/rongBilledInformUrl',
'callStateNotifyUrl' => CURRENT_URL . 'task/rongStatusInformUrl',
'recordNotifyUrl' => CURRENT_URL . 'task/rongRecordingInformUrl',
'userData' => $aNumber . '-' . $bNumber //记录a和b号码,回调使用
];
$result = json_decode($this->sendCurl($url, $post_data, $Authorization), true);
$result['code_msg'] = $this->getCodeString($result['statusCode']);
return $result;
}
/** /**
* AXB 解绑 * AXB 解绑
* @param $mappingId * @param $mappingId
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment