Commit d4c8c9f8 authored by hujun's avatar hujun

拨打电话未打跟进

parent 43e4b31c
...@@ -14,10 +14,12 @@ use app\api_broker\untils\RongDemo; ...@@ -14,10 +14,12 @@ use app\api_broker\untils\RongDemo;
use app\extra\RedisExt; use app\extra\RedisExt;
use app\model\AliYunPhone; use app\model\AliYunPhone;
use app\model\BindingPhone; use app\model\BindingPhone;
use app\model\AliYunSecretReport;
use app\model\SecretReport; use app\model\SecretReport;
use app\model\UPhoneFollowUp; use app\model\UPhoneFollowUp;
use app\model\UPhoneFollowUpTemporary; use app\model\UPhoneFollowUpTemporary;
use app\model\Users; use app\model\Users;
use app\model\AAgents;
use think\Log; use think\Log;
class CallPhoneService class CallPhoneService
...@@ -540,41 +542,50 @@ class CallPhoneService ...@@ -540,41 +542,50 @@ class CallPhoneService
*/ */
public function defaultFollowUp() public function defaultFollowUp()
{ {
$secret_model = new AliYunSecretReport();
/*$current_time = time(); $agent_model = new AAgents();
$time = $current_time - 3600; $current_time = time();
// $start_date = date('Y-m-d', $time); $end_time = $current_time - 3600;
$end_date = date('Y-m-d'); $start_time = $end_time - 3600;
$user_key = 'call_phone_user_' . $end_date;
$user_data = $this->redis->hKeys($user_key); $save_follow['content'] = '拨打电话,未打跟进。';
$content = '拨打电话,未打跟进。'; $follow_where['create_time'] = $bind_where['create_time'] = [
$follow_where['create_time'] = ['between', [date('Y-m-d H:i:s', $time), date('Y-m-d H:i:s')]]; 'between', [date('Y-m-d H:i:s', $start_time), date('Y-m-d H:i:s',$end_time)]
];
$bind_where['time'] = ['>', 0];
$num = $secret_model->getTotal($bind_where);
//用户 //用户
if (!empty($user_data)) { if ($num > 0) {
for ($i=1; $i <= $num; $i++) {
$secret_data = $secret_model->getList($i, 500, '', 'agents_id,users_id,create_time', $bind_where);
foreach ($secret_data as $key => $value) {
if (empty($value['agents_id']) || empty($value['users_id'])) {
continue;
}
foreach ($user_data as $k => $v) { $site_id = $agent_model->getAgentsById($value['agents_id'], 'site_id');
$call_time = $this->redis->hGet($user_key, $v); if (empty($site_id)) {
continue;
}
if ($current_time - $call_time > 3600) { $follow_model = new UPhoneFollowUpTemporary($site_id);
$array = explode('-', $v); $follow_where['user_id'] = $value['users_id'];
$follow_where['agent_id'] = $array[0]; $follow_where['agent_id'] = $value['agents_id'];
$follow_where['user_id'] = $array[1]; $count = $follow_model->getFollowTotal($follow_where);
if(empty($array[2])){
$this->redis->hDel($user_key, $v); if (empty($count)) {
} else { $save_follow['user_id'] = $value['users_id'];
$m_follow_up = new UPhoneFollowUpTemporary($array[2]); $save_follow['agent_id'] = $value['agents_id'];
$num = $m_follow_up->getFollowTotal($follow_where); $save_follow['user_status'] = -1;
if (empty($num) && !empty($array[1])) { $save_follow['type'] = 0;
//$agent_id, $user_id, $content, $type $save_follow['labels_id'] = 0;
$m_follow_up->insertDefaultFollow($array[0], $array[1], $content, 0); $save_follow['create_time'] = $value['create_time'];
$this->redis->hDel($user_key, $v); $follow_model->savePhoneFollow($save_follow);
}
} }
} }
} }
} }
return;*/ return;
} }
/** /**
......
...@@ -63,6 +63,9 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -63,6 +63,9 @@ class UPhoneFollowUpTemporary extends BaseModel
if (isset($params["user_status"])) { if (isset($params["user_status"])) {
$arr["user_status"] = $params["user_status"]; $arr["user_status"] = $params["user_status"];
} }
if (isset($params['create_time'])) {
$arr["create_time"] = $params["create_time"];
}
if (isset($this->siteId)) { if (isset($this->siteId)) {
switch ($this->siteId) { switch ($this->siteId) {
......
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