Commit 3b9c3e71 authored by hujun's avatar hujun

通话记录

parent 611f9707
......@@ -13,6 +13,7 @@ use app\api_broker\untils\PlsDemo;
use app\model\AliYunPhone;
use app\model\BindingPhone;
use app\model\SecretReport;
use think\Db;
class CellPhone extends Basic
......@@ -108,4 +109,49 @@ class CellPhone extends Basic
$this->params['phone_x'];
return $this->response($this->code, $this->msg);
}
/**
* 通话列表、搜索
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function callLog() {
$result['code'] = 200;
$result['msg'] = '';
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$report = new SecretReport();
$field = 'agents_id,users_id,release_time,start_time,call_type,call_time';
$where = [];
if ($this->params['start_time']) {
$where['call_time'] = ['>', $this->params['start_time']];
}
if ($this->params['end_time']) {
$where['call_time'] = ['<', $this->params['end_time']];
}
if ($this->params['call_name']) {
$where['realName'] = ['LIKE', $this->params['call_name'].'%'];
}
if ($this->params['call_phone']) {
$where['phone_a'] = [$this->params['call_phone']];
}
if ($this->params['client_phone']) {
$where['phone_b'] = [$this->params['client_phone']];
}
if ($this->params['client_name']) {
$where['user_nick'] = ['LIKE', $this->params['client_name'].'%'];
}
$data = $report->getCallList($pageNo, 100, 'id asc', $field, $where);
return $this->response($result['code'], $result['msg'], $data);
}
}
\ No newline at end of file
......@@ -2,11 +2,88 @@
namespace app\model;
use think\Db;
use think\Model;
class SecretReport extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'aliyun_secret_report';
protected $table = 'aliYun_secret_report';
/**
* 通话记录
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getCallList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
if ($params['realName'] || $params['user_nick']) {
$field .= ',a.id';
$data = $this->field($field)->alias('a')->join('agents b','a.agents_id=b.id','left')
->join('u_users c','a.users_id=c.id','left')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
} else {
$field .= ',id';
$data = $this->field($field)
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
$result = [];
foreach ($data as $k => $v) {
$result[$k] = $v;
if ($v->agents_id) {
$agents_data = Db::table('agents')->field('realName,father_id')->where('id',$v->agents_id)->find();
$result[$k]['agents_name'] = $agents_data['realName'];
$shop_data = Db::table('agents')->field('agentshopname,sub_shopname')->where('id',$agents_data['father_id'])->find();
$result[$k]['shop_name'] = $shop_data['sub_shopname'] ? $shop_data['agentshopname'].'-'.$shop_data['sub_shopname'] : $shop_data['agentshopname'];
} else {
$result[$k]['agents_name'] = "";
}
if ($v->users_id) {
$result[$k]['user_nick'] = Db::table('u_users')->where('id',$v->users_id)->value('user_nick');
} else {
$result[$k]['user_nick'] = "";
}
$time_stamp = (strtotime($v->release_time) - strtotime($v->start_time));
$result['time'] = $time_stamp;
//主叫收费
if ($v->call_type == 0) {
if ($time_stamp <= 60) {
$time = 1; //不足一分钟按一分钟
} else {
$remainder = $time_stamp % 60;
$time = 0;
if ($remainder != 0) {
$time += 1;
}
$time += floor($time_stamp/60);
}
$result[$k]['time'] = $time;
$result[$k]['price'] = $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分
}
}
return $result;
}
}
......@@ -236,6 +236,7 @@ Route::group('broker', [
'bindAXB' => [ 'api_broker/CellPhone/bindAXB', [ 'method' => 'post' ] ],//隐私号码
'agentsUnBind' => [ 'api_broker/CellPhone/agentsUnBind', [ 'method' => 'post' ] ],//解除绑定关系
'callLog' => [ 'api_broker/CellPhone/callLog', [ 'method' => 'get' ] ],//通话记录
]);
......
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