修改电话监听
This commit is contained in:
parent
2e42ee83f4
commit
d40c4b02fc
|
|
@ -32,6 +32,8 @@ class eslListen extends Command
|
|||
protected $recording_dir = 'recordings';
|
||||
public $url = null;
|
||||
public $hash_table = 'esl_listen';
|
||||
public $cdr_table = 'cdr';
|
||||
public $asr_table = 'asr';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
|
|
@ -154,7 +156,7 @@ class eslListen extends Command
|
|||
unset($halffile_b);
|
||||
|
||||
//更新B接听时间
|
||||
DB::table('cdr')->where('uuid',$otherUuid)->update([
|
||||
DB::table($this->cdr_table)->where('uuid',$otherUuid)->update([
|
||||
'bleg_answer_at' => date('Y-m-d H:i:s'),
|
||||
'record_file' => str_replace($this->fs_dir,$this->url,$fullfile),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
|
|
@ -163,7 +165,7 @@ class eslListen extends Command
|
|||
|
||||
}else{
|
||||
//更新A接听时间
|
||||
DB::table('cdr')->where('uuid',$uuid)->update([
|
||||
DB::table($this->cdr_table)->where('uuid',$uuid)->update([
|
||||
'aleg_answer_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
|
@ -187,8 +189,7 @@ class eslListen extends Command
|
|||
$data = json_decode(Redis::hget($this->hash_table,$uuid),true);
|
||||
$data['is_prologue'] += 1;
|
||||
if (isset($data['record_file'])&&file_exists($data['record_file'])){
|
||||
$table = 'asr';
|
||||
DB::table($table)->insert([
|
||||
DB::table($this->asr_table)->insert([
|
||||
'uuid' => $data['pid'],
|
||||
'leg_uuid' => $data['unique_id'],
|
||||
'start_at' => $data['start_time'],
|
||||
|
|
@ -217,17 +218,30 @@ class eslListen extends Command
|
|||
case 'CHANNEL_HANGUP_COMPLETE':
|
||||
if (Redis::hexists($this->hash_table,$uuid)){
|
||||
$data = json_decode(Redis::hget($this->hash_table,$uuid),true);
|
||||
Redis::hdel($this->hash_table, $uuid);
|
||||
$table = 'cdr';
|
||||
$cdr = DB::table($table)->where('uuid',$data['pid'])->whereNull('aleg_end_at')->first();
|
||||
Redis::hdel($this->hash_table, $data['pid']);
|
||||
Redis::hdel($this->hash_table, $data['unique_id']);
|
||||
$cdr = DB::table($this->cdr_table)
|
||||
>where(function ($q) use($uuid){
|
||||
return $q->where('aleg_uuid',$uuid)->orWhere('bleg_uuid',$uuid);
|
||||
})
|
||||
->whereNull('aleg_end_at')
|
||||
->first();
|
||||
if ($cdr != null){
|
||||
$callsec = $cdr->bleg_answer_at != null ? time()-strtotime($cdr->bleg_answer_at) : 0;
|
||||
if ($uuid == $data['pid']){ // A的挂断事件
|
||||
$callsec = $cdr->bleg_answer_at != null ? time()-strtotime($cdr->bleg_answer_at) : 0;
|
||||
}else{ // B的挂断事件
|
||||
$callsec = Arr::get($info,'variable_billsec',0);
|
||||
}
|
||||
$hanguptime = Arr::get($info,'variable_end_stamp',null);
|
||||
$hanguptime = $hanguptime != null ? urldecode($hanguptime) : null;
|
||||
|
||||
//更新通话时长
|
||||
DB::table($table)->where('uuid',$data['pid'])->update([
|
||||
'aleg_end_at' => date('Y-m-d H:i:s'),
|
||||
DB::table($this->cdr_table)->where('uuid',$data['pid'])->update([
|
||||
'aleg_end_at' => $hanguptime,
|
||||
'billsec' => $callsec,
|
||||
]);
|
||||
unset($callsec);
|
||||
unset($hanguptime);
|
||||
}
|
||||
unset($data);
|
||||
unset($table);
|
||||
|
|
@ -243,8 +257,8 @@ class eslListen extends Command
|
|||
}
|
||||
|
||||
public function setTable(){
|
||||
$this->cdr_table = 'cdr';
|
||||
$this->asr_table = 'asr';
|
||||
//$this->cdr_table = 'cdr'.date('Ym');
|
||||
//$this->asr_table = 'asr'.date('Ym');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue