Commit 65ae0e0a authored by hujun's avatar hujun

统计通话时间优化

parent a0900ce3
......@@ -18,6 +18,7 @@ use app\model\AAgentsPhone;
use app\model\AliYunSecretReport;
use app\model\BindingPhone;
use app\model\TAgentTotalCallModel;
use app\model\Users;
use think\Db;
use think\Log;
use think\Request;
......@@ -28,12 +29,16 @@ class PrivacyNumber
private $m_bind;
private $m_secret_report;
private $m_agent;
private $m_agent_phone;
private $m_user;
public function __construct()
{
$this->redis = RedisExt::getRedis();
$this->m_secret_report = new AliYunSecretReport();
$this->m_bind = new BindingPhone();
$this->m_agent = new AAgents();
$this->m_agent_phone = new AAgentsPhone();
$this->m_user = new Users();
}
/**
......@@ -78,6 +83,52 @@ class PrivacyNumber
return json_encode([ 'code' => 0, 'msg' => '接收成功' ]);
}
/**
* 阿里大于隐私号码回调处理
*
* @return string
*/
public function addReportV2()
{
$post_data = Request::instance()->param();
foreach ($post_data as $k=>$v) {
$save_data = $v;
$save_data['report_id'] = $post_data[0]['id'];
unset($save_data['id']); //阿里大于返回是的id改为report_id
if ($v['phone_no']) {
$agent_where['phone'] = $v['phone_no'];
$agent_where['status'] = 0;
$agent_where['password'] = ['NOT NULL'];
$agent_id = $this->m_agent->getAgentsByWhere($agent_where, 'id');
if (empty($agent_id)) {
$phone_where['phone'] = $v['phone_no'];
$phone_where['status'] = 0;
$agent_id = $this->m_agent_phone->getAgentsByWhere($phone_where, 'agents_id');
}
$save_data['agents_id'] = $agent_id;
$save_data['users_id'] = $this->m_user->getUserByWhereValue(['user_phone'=>$save_data['peer_no']], 'id');
}
$call_time = strtotime($save_data['release_time']) - strtotime($save_data['start_time']);
$save_data['time'] = $call_time;
if ($call_time > 0) {
$end_date = date('Y-m-d H:i:s', time());
$start_date = date('Y-m-d H:i:s', strtotime("-1 day"));
$num = $this->m_secret_report->getCallNumber($post_data[0]['phone_no'], $post_data[0]['peer_no'], $start_date, $end_date);
if (empty($num)) {
$m_service = new ClientService();
$m_service->saveCallNumByUserId($save_data['users_id']);
}
}
$this->m_secret_report->allowField(true)->save($save_data);
}
Log::write(json_encode($post_data[0]), 'AliYunSecretReport'); //记录日志
return json_encode([ 'code' => 0, 'msg' => '接收成功' ]);
}
/**
* 下载录音 高峰期 一般是早上9-11点 下午2-4点
*
......@@ -399,7 +450,7 @@ class PrivacyNumber
}
$where['create_time'] = ['between', [$yesterday .' 00:00:00', $yesterday . ' 23:59:59']];
$where['call_time'] = ['between', [$yesterday .' 00:00:00', $yesterday . ' 23:59:59']];
$where['time'] = ['>', 0];
$total = $this->m_secret_report->getListGroupCount($where, 'phone_no');
......@@ -492,8 +543,8 @@ class PrivacyNumber
* 历史数据
*/
public function oldTotalAgentCall() {
// $month = ['2018-03','2018-04','2018-05','2018-06','2018-07','2018-08','2018-09','2018-10','2018-11'];
$month = ['2018-11'];
$month = ['2018-03','2018-04','2018-05','2018-06','2018-07','2018-08','2018-09','2018-10','2018-11'];
// $month = ['2018-11'];
foreach ($month as $v) {
$firstday = date('Y-m-01', strtotime($v));
......
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