Commit b38806b1 authored by hujun's avatar hujun

容联云号码绑定修改

parent d93c3844
......@@ -163,6 +163,7 @@ class CallPhoneService
$result['phone'] = $call_phone['phone'];
$result['msg'] = $call_phone['msg'];
$type = 'AliYunBindAxb';
$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);
} else {
$result['msg'] = $call_phone['msg'];
}
......@@ -174,15 +175,15 @@ class CallPhoneService
$result['phone'] = $call_phone['phone'];
$result['msg'] = $call_phone['msg'];
$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->commit();
} else {
$bind->rollback();
$result['msg'] = $call_phone['msg'];
}
}
if ($result['status'] == 'success') {
$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);
}
Log::write(json_encode($result), $type); //记录日志
} catch (\Exception $e) {
$data['status'] = 'failed';
......@@ -320,6 +321,7 @@ class CallPhoneService
* 容联云号码绑定
*
* @return mixed
* @throws \think\exception\PDOException
*/
public function yunTongXun()
{
......
......@@ -68,6 +68,7 @@ class AliYunPhone extends BaseModel
* @param array $phone_x
* @param $city
* @return mixed
* @throws \think\exception\PDOException
*/
public function getAliYunPhoneAll($phone_a, $phone_b, $type = 1, $phone_x = [], $city)
{
......@@ -92,31 +93,31 @@ class AliYunPhone extends BaseModel
$where_bind_a['b.phone_x'] = [ 'NOT IN', $phone_x];
$where_bind_b['b.phone_x'] = [ 'NOT IN', $phone_x];
}
try {
$this->startTrans();
//找到与phone_a绑定的隐私号码
$where_bind_a['a.phone_a'] = $phone_a;
$where_bind_a['a.status'] = 1;
$where_bind_a['b.type'] = $type;
$id_arr_a = $m_bind->getBindingPhoneList('b.id', $where_bind_a, true);
//找到phone_b绑定的隐私号码
$where_bind_b['a.phone_b'] = $phone_b;
$where_bind_b['a.status'] = 1;
$where_bind_b['b.type'] = $type;
$id_arr_b = $m_bind->getBindingPhoneList('b.id', $where_bind_b, true);
$id_merge = array_merge($id_arr_a['data'], $id_arr_b['data']);
foreach ($id_merge as $k => $v) {
$id[$k] = $v['id'];//去除phone_a已经绑定的号码
}
//找到与phone_a绑定的隐私号码
$where_bind_a['a.phone_a'] = $phone_a;
$where_bind_a['a.status'] = 1;
$where_bind_a['b.type'] = $type;
$id_arr_a = $m_bind->getBindingPhoneList('b.id', $where_bind_a);
//找到phone_b绑定的隐私号码
$where_bind_b['a.phone_b'] = $phone_b;
$where_bind_b['a.status'] = 1;
$where_bind_b['b.type'] = $type;
$id_arr_b = $m_bind->getBindingPhoneList('b.id', $where_bind_b);
$id_merge = array_merge($id_arr_a['data'], $id_arr_b['data']);
foreach ($id_merge as $k => $v) {
$id[$k] = $v['id'];//去除phone_a已经绑定的号码
}
$id = empty($id) ? 0 : $id;
$where_phone['status'] = 0;
$where_phone['type'] = $type;
$where_phone['bind_num'] = ['<', 201];
$id = empty($id) ? 0 : $id;
$where_phone['status'] = 0;
$where_phone['type'] = $type;
$where_phone['bind_num'] = ['<', 201];
try {
if (empty($id)) {
$result['data'] = $this->field('id,phone_x,area')->where($where_phone)->find();
} else {
......@@ -125,6 +126,7 @@ class AliYunPhone extends BaseModel
}
$result['status'] = 'successful';
} catch (\Exception $e) {
$this->commit();
$result['status'] = 'fail';
$result['msg'] = $e->getMessage();
}
......
......@@ -112,15 +112,17 @@ class BindingPhone extends BaseModel
*
* @param $field
* @param $where
* @param bool $is_lock
* @return mixed
*/
public function getBindingPhoneList($field, $where)
public function getBindingPhoneList($field, $where, $is_lock = false)
{
$data['data'] = [];
try {
$data['data'] = $this->field($field)->alias('a')
->join('aliYun_phone b', 'a.aliYun_phone_id = b.id', 'left')
->where($where)
->lock($is_lock)
->select();
$data['status'] = 'successful';
} catch (\Exception $e) {
......
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