Commit fa9890b8 authored by hujun's avatar hujun

记录客户拨打经纪手机号时间间隔

parent c50506b7
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace app\api\controller; namespace app\api\controller;
use app\api\extend\Basic; use app\api\extend\Basic;
use app\api_broker\service\VerifyRepetitionService;
use app\model\AAgents; use app\model\AAgents;
use app\model\Evaluate; use app\model\Evaluate;
use app\model\EvaluateSign; use app\model\EvaluateSign;
...@@ -251,12 +252,18 @@ class Broker extends Basic ...@@ -251,12 +252,18 @@ class Broker extends Basic
$data['msg'] = ''; $data['msg'] = '';
if ($this->params['agent_id'] > 0) { if ($this->params['agent_id'] > 0) {
$m_agents = new AAgents();
$agents_data = $m_agents->getAgentInfo('id,update_time,call_number', $this->params['agent_id']);
$insert_data['update_time'] = $agents_data['update_time']; $redis = new VerifyRepetitionService();
$insert_data['call_number'] = $agents_data['call_number'] + 1; $is = $redis->verifyStart(2, $this->params['agent_id'], $this->userId);
$data['data'] = $m_agents->editData($insert_data, $agents_data['id']);
if ($is) {
$m_agents = new AAgents();
$agents_data = $m_agents->getAgentInfo('id,update_time,call_number', $this->params['agent_id']);
$insert_data['update_time'] = $agents_data['update_time'];
$insert_data['call_number'] = $agents_data['call_number'] + 1;
$data['data'] = $m_agents->editData($insert_data, $agents_data['id']);
}
} else { } else {
$data['status'] = 101; $data['status'] = 101;
......
<?php <?php
namespace app\api_broker\service; namespace app\api_broker\service;
use app\extra\RedisExt; use app\extra\RedisExt;
/** /**
...@@ -9,38 +11,42 @@ use app\extra\RedisExt; ...@@ -9,38 +11,42 @@ use app\extra\RedisExt;
* Time : 10:28 * Time : 10:28
* Intro: * Intro:
*/ */
class VerifyRepetitionService
class VerifyRepetitionService { {
private $redis_; private $redis_;
const MARCH_IN_KEY = "_march_in_"; const MARCH_IN_KEY = "_march_in_";
const TIME_OUT = 60; // 超时时间1分钟 const CALL_NUMBER = "_call_number_";
const TIME_OUT = 120; // 超时时间1分钟
public function __construct() public function __construct()
{ {
$this->redis_ = RedisExt::getRedis(); $this->redis_ = RedisExt::getRedis();
} }
public function verifyStart(int $type,int $agent_id,int $order_id) : bool { public function verifyStart(int $type, int $agent_id, int $order_id): bool
{
if(!$this->redis_){ if (!$this->redis_) {
return true; return true;
} }
$key = ""; $key = "";
switch ($type){ switch ($type) {
case 1: //进场 case 1: //进场
$key = self::MARCH_IN_KEY; $key = self::MARCH_IN_KEY;
break; break;
case 2: case 2:
$key = self::CALL_NUMBER;
break; break;
case 3: case 3:
break; break;
default: default:
} }
if($this->redis_->get($agent_id.$key.$order_id)){
if ($this->redis_->get($agent_id . $key . $order_id)) {
return false; return false;
}else{ } else {
$this->redis_->set($agent_id.$key.$order_id,1,self::TIME_OUT); $this->redis_->set($agent_id . $key . $order_id, 1, self::TIME_OUT);
return true; return true;
} }
......
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