Commit a7244d23 authored by hujun's avatar hujun

优化

parent 6d21a7ec
......@@ -17,13 +17,22 @@ use app\model\AAgents;
use app\model\AAgentsPhone;
use app\model\AliYunSecretReport;
use app\model\BindingPhone;
use app\model\SecretReport;
use think\Db;
use think\Log;
use think\Request;
class PrivacyNumber
{
private $redis;
private $m_bind;
private $m_secret_report;
public function __construct()
{
$this->redis = RedisExt::getRedis();
$this->m_secret_report = new AliYunSecretReport();
$this->m_bind = new BindingPhone();
}
/**
* 阿里大于隐私号码回调处理
*
......@@ -61,8 +70,7 @@ class PrivacyNumber
}
}
$report = new SecretReport();
$report->allowField(true)->save($post_data[0]);
$this->m_secret_report->allowField(true)->save($post_data[0]);
Log::write(json_encode($post_data[0]), 'AliYunSecretReport'); //记录日志
return json_encode([ 'code' => 0, 'msg' => '接收成功' ]);
}
......@@ -162,7 +170,7 @@ class PrivacyNumber
$binding_phone_id = [];
$phone_id = [];
$bind = new BindingPhone();
$redis = RedisExt::getRedis();
foreach ($bind_data['data'] as $k => $v) {
$agent_id = $m_agent->getAgentsByWhereColumn(['status'=>0, 'phone'=>$v['phone_a']], 'id');
if (empty($agent_id)) {
......@@ -184,7 +192,7 @@ class PrivacyNumber
foreach ($agent_id as $value) {
$call_key = 'call_'.$value.'_'.$v['phone_a'].'_'.$v['phone_b'].'_1';
$redis->del($call_key);
$this->redis->del($call_key);
}
} elseif ($v['type'] == 2 && !empty($v['mappingId'])) {
//释放容联云隐私号码
......@@ -210,7 +218,7 @@ class PrivacyNumber
foreach ($agent_id as $value) {
$call_key = 'call_'.$value.'_'.$v['phone_a'].'_'.$v['phone_b'].'_2';
$redis->del($call_key);
$this->redis->del($call_key);
}
}
}
......@@ -276,8 +284,8 @@ class PrivacyNumber
$date['agents_id'] = $agents_id;
$date['users_id'] = Db::table('u_users')->where('user_phone', $phone_b)->value('id');
}
$report = new SecretReport();
$report->allowField(true)->save($date);
$this->m_secret_report->allowField(true)->save($date);
$str = date('Y-m-d h:i:s') . ' 容联云话单' . var_export($params, true);
......@@ -297,10 +305,9 @@ class PrivacyNumber
public function rongRecordingInformUrl()
{
$params = Request::instance()->param();
$report = new SecretReport();
$where['call_id'] = $params['callId'];
$update['mp3_url'] = $params['recordUrl'];
$report->save($update, $where);
$this->m_secret_report->save($update, $where);
$str = date('Y-m-d h:i:s') . ' 容联云录音' . var_export($params, true);
Log::write($str, 'rongRecordingInformUrl'); //记录日志
return json_encode([ "statusCode" => '000000', 'msg' => '接收成功' ]);
......@@ -323,17 +330,16 @@ class PrivacyNumber
public function checkBindPhone()
{
set_time_limit(0);
$m_bind = new BindingPhone();
$where['a.status'] = 1;
$where['a.expiry_date'] = [ '<', date('Y-m-d H:i:s') ];
$select_data = $m_bind->getBindingPhoneList('a.id,a.aliYun_phone_id,a.phone_a,a.phone_b,a.type', $where);
$redis = RedisExt::getRedis();
$select_data = $this->m_bind->getBindingPhoneList('a.id,a.aliYun_phone_id,a.phone_a,a.phone_b,a.type', $where);
foreach ($select_data['data'] as $k => $v) {
$m_bind->unBindTable($v['id'], $v['aliYun_phone_id']);
$this->m_bind->unBindTable($v['id'], $v['aliYun_phone_id']);
$call_key = 'call_'.$v['phone_a'].'_'.$v['phone_b'].'_'.$v['type'];
$redis->del($call_key);
$this->redis->del($call_key);
}
return;
}
......
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