Commit 974e5efc authored by hujun's avatar hujun

通话金额计算修改

parent 1b9c3461
......@@ -158,25 +158,8 @@ class SecretReport extends Model
$result[$k]['time'] = $v->time;
//主叫收费
if ($v->call_type == 0) {
if ($v->time > 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元/分
} else {
$result[$k]['price'] = 0;
}
if ($v['call_type'] == 0) {
$result[$k]['price'] = $this->getTotalPrice($v['agents_id']);
} else {
$result[$k]['price'] = 0;
}
......@@ -198,4 +181,35 @@ class SecretReport extends Model
->group('agents_id')
->count();
}
/**
* @param $agents_id
* @return int
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getTotalPrice($agents_id) {
$data = $this->field('id,time')->where([
'agents_id' => $agents_id,
'call_type' => 0,
'time' => ['<>',0]
])->select();
$price = 0;
foreach ($data as $k=>$v) {
if ($v['time'] <= 60) {
$time = 1; //不足一分钟按一分钟
} else {
$remainder = $v['time'] % 60;
$time = 0;
if ($remainder != 0) {
$time += 1;
}
$time += floor($v->time/60);
}
$price += $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分
}
return $price;
}
}
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