Commit f606ff05 authored by zw's avatar zw

冻结经纪人

parent 5a07c181
...@@ -388,15 +388,17 @@ class AAgents extends BaseModel ...@@ -388,15 +388,17 @@ class AAgents extends BaseModel
public function selectFollowUpNumByAgent( $field = "a.id",$table,$params,$num) public function selectFollowUpNumByAgent( $field = "a.id",$table,$params,$num)
{ {
$where["district_id"] = array( 'not in', array( '13', '14', '15' ) ); $params["district_id"] = array( 'not in', array( '13', '14', '15' ) );
return Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->alias("a") ->alias("a")
->join( $table." as b" ,"a.id = b.agent_id","right") ->join( "$table b" ,"a.id = b.agent_id","left")
->where($params) ->where($params)
->group("b.agent_id") ->group("a.id")
->having("count > $num") ->having("count < $num")
->select(); ->select();
//echo $this->getLastSql();
return $result;
} }
/** /**
......
...@@ -7,6 +7,7 @@ namespace app\task\controller; ...@@ -7,6 +7,7 @@ namespace app\task\controller;
* Date: 2019/2/27 * Date: 2019/2/27
* Time: 16:05 * Time: 16:05
*/ */
use app\extra\RedisExt;
use app\model\AAgents; use app\model\AAgents;
use app\model\ASite; use app\model\ASite;
...@@ -15,36 +16,51 @@ class FrostAgentTask{ ...@@ -15,36 +16,51 @@ class FrostAgentTask{
private $table = 'u_phone_follow_up_'; private $table = 'u_phone_follow_up_';
private $date ; private $date ;
private $siteModel; private $siteModel;
private $redis_;
function __construct() function __construct()
{ {
$this->agentsModel = new AAgents(); $this->agentsModel = new AAgents();
$this->date = date("Y-m-d",strtotime("-1 day")); $this->date = date("Y-m-d",strtotime("-1 day"));
$this->siteModel = new ASite(); $this->siteModel = new ASite();
$this->redis_ = RedisExt::getRedis();
} }
public function frostAgent(){ public function frostAgent(){
//select count(1) as count,a.phone from a_agents a RIGHT JOIN u_phone_follow_up_10001 b on a.id = b.agent_id
//GROUP BY b.agent_id HAVING count >15 ; $num = $this->redis_->get("s_agent_suspend");
//大于30不合理,容错
if($num < 0 && $num >30){
return;
}
$site_arr = $this->siteModel->getSite("id,name,city,is_del", ["is_del" => 0]); $site_arr = $this->siteModel->getSite("id,name,city,is_del", ["is_del" => 0]);
if (count($site_arr) <= 0) { if (count($site_arr) <= 0) {
return; return;
} }
$field = "count(1) as count,a.id"; $field = "count(1) as count,a.id";
$params["a.status"] = 0; $params["a.status"] = 0;
$params["a.level"] = 10; $params["a.level"] = 10;
foreach ($site_arr as $item) { foreach ($site_arr as $item) {
$table_name = $this->table . $item["id"] . "_" . $this->date; $table_name = $this->table . $item["id"] . "_" . $this->date;
$params["a.site_id"] = $item["id"]; $params["a.site_id"] = $item["id"];
$agent_arr = $this->agentsModel->selectFollowUpNumByAgent( $field,$table_name,$params,15); $agent_arr = $this->agentsModel->selectFollowUpNumByAgent( $field,$table_name,$params,$num);
//execute_update
$this->execute_update($agent_arr); if(count($agent_arr) > 0){
$this->execute_update($agent_arr);
}
} }
} }
private function execute_update($agent_arr){ private function execute_update($agent_arr){
dump($agent_arr); $ids = "";
foreach ($agent_arr as $item) {
$ids .= $item["id"] . ",";
}
$ids = rtrim($ids, ",");
$this->agentsModel->saveStatus("status","5",$ids);
} }
......
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