Commit 2d8e40c1 authored by hujun's avatar hujun

经纪人通话汇总

parent ce34f5fe
...@@ -36,7 +36,7 @@ class CellPhone extends Basic ...@@ -36,7 +36,7 @@ class CellPhone extends Basic
$expiration = _EXPIRATION; //过期时间 $expiration = _EXPIRATION; //过期时间
$phone_a = $this->params['phone_a'];//经纪人手机号 $phone_a = $this->params['phone_a'];//经纪人手机号
$phone_b = $this->params['phone_b'];//客户手机号 $phone_b = $this->params['phone_b'];//客户手机号
$record = empty($this->params['record'])? false:true; //是否录音 $record = empty($this->params['record'])? true:false; //是否录音
$bind = new AliYunPhone(); $bind = new AliYunPhone();
$phone_x = $bind->getAliYunPhone($phone_b); $phone_x = $bind->getAliYunPhone($phone_b);
...@@ -125,15 +125,15 @@ class CellPhone extends Basic ...@@ -125,15 +125,15 @@ class CellPhone extends Basic
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$report = new SecretReport(); $report = new SecretReport();
$field = 'agents_id,users_id,release_time,start_time,call_type,call_time'; $field = 'agents_id,users_id,release_time,start_time,call_type,call_time,time';
$where = []; $where = [];
if ($this->params['start_time']) { if ($this->params['start_time']) {
$where['call_time'] = ['>', $this->params['start_time']]; $where['create_time'] = ['> time', $this->params['start_time']];
} }
if ($this->params['end_time']) { if ($this->params['end_time']) {
$where['call_time'] = ['<', $this->params['end_time']]; $where['create_time'] = ['< time', $this->params['end_time']];
} }
if ($this->params['call_name']) { if ($this->params['call_name']) {
...@@ -151,7 +151,46 @@ class CellPhone extends Basic ...@@ -151,7 +151,46 @@ class CellPhone extends Basic
if ($this->params['client_name']) { if ($this->params['client_name']) {
$where['user_nick'] = ['LIKE', $this->params['client_name'].'%']; $where['user_nick'] = ['LIKE', $this->params['client_name'].'%'];
} }
$data = $report->getCallList($pageNo, 100, 'id asc', $field, $where);
$data = $report->getCallList($pageNo, $pageSize, 'id desc', $field, $where);
return $this->response($result['code'], $result['msg'], $data);
}
/**
* 经纪人通话汇总
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function callCollectList() {
$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 = 'a.id,b.phone,sum(time) as time,agents_id,call_type';
$where = [];
if ($this->params['start_time']) {
$where['create_time'] = ['> time', $this->params['start_time']];
}
if ($this->params['end_time']) {
$where['create_time'] = ['< time', $this->params['end_time']];
}
if ($this->params['agents_name']) {
$where['realName'] = ['LIKE', $this->params['agents_name'].'%'];
}
if ($this->params['phone']) {
$where['phone'] = [$this->params['phone']];
}
$data = $report->getCallCollect($pageNo, $pageSize, 'id desc', $field, $where);
return $this->response($result['code'], $result['msg'], $data); return $this->response($result['code'], $result['msg'], $data);
} }
} }
\ No newline at end of file
...@@ -63,24 +63,79 @@ class SecretReport extends Model ...@@ -63,24 +63,79 @@ class SecretReport extends Model
} else { } else {
$result[$k]['user_nick'] = ""; $result[$k]['user_nick'] = "";
} }
$result[$k]['time'] = $v->time;
$time_stamp = (strtotime($v->release_time) - strtotime($v->start_time));
$result['time'] = $time_stamp;
//主叫收费 //主叫收费
if ($v->call_type == 0) { if ($v->call_type == 0) {
if ($time_stamp <= 60) { if ($v->time <= 60) {
$time = 1; //不足一分钟按一分钟 $time = 1; //不足一分钟按一分钟
} else { } else {
$remainder = $time_stamp % 60; $remainder = $v->time % 60;
$time = 0; $time = 0;
if ($remainder != 0) { if ($remainder != 0) {
$time += 1; $time += 1;
} }
$time += floor($time_stamp/60); $time += floor($v->time/60);
} }
$result[$k]['price'] = $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分
}
}
return $result;
}
/**
* 经纪人拨打记录汇总
*
* @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 getCallCollect($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
$data = $this->field($field)->alias('a')
->join('agents b','a.agents_id=b.id','left')
->where($params)
->order($order_)
->limit($pageSize)
->group('agents_id')
->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'] = "";
}
$result[$k]['time'] = $time; $result[$k]['time'] = $v->time;
//主叫收费
if ($v->call_type == 0) {
if ($v->time <= 60) {
$time = 1; //不足一分钟按一分钟
} else {
$remainder = $v->time % 60;
$time = 0;
if ($remainder != 0) {
$time += 1;
}
$time += floor($v->time/60);
}
$result[$k]['price'] = $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分 $result[$k]['price'] = $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分
} else {
$result[$k]['price'] = "";
} }
} }
......
...@@ -29,7 +29,7 @@ class PrivacyNumber ...@@ -29,7 +29,7 @@ class PrivacyNumber
$post_data[0]['agents_id'] = Db::table('agents')->where('phone',$post_data[0]['phone_no'])->value('id'); $post_data[0]['agents_id'] = Db::table('agents')->where('phone',$post_data[0]['phone_no'])->value('id');
$post_data[0]['users_id'] = Db::table('u_users')->where('user_phone',$post_data[0]['peer_no'])->value('id'); $post_data[0]['users_id'] = Db::table('u_users')->where('user_phone',$post_data[0]['peer_no'])->value('id');
} }
$post_data[0]['time'] = strtotime($post_data[0]['release_time']) - strtotime($post_data[0]['start_time']);
$report = new SecretReport(); $report = new SecretReport();
$report->allowField(true)->save($post_data[0]); $report->allowField(true)->save($post_data[0]);
......
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