Commit fa9890b8 authored by hujun's avatar hujun

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

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