Commit 3d501c75 authored by zw's avatar zw

name

parent 957725d0
......@@ -555,8 +555,9 @@ Route::group('task', [
'updateLandlordLimit' => ['task/JobTask/updateLandlordLimit', ['method' => 'get']], //转换房东手机号
'test' => ['task/FollowUpTask/test', ['method' => 'get']],
'isExistTable' => ['task/FollowUpTask/isExistTable', ['method' => 'get']],
'test' => ['task/FollowUpTask/test', ['method' => 'get']],
'isExistTable' => ['task/FollowUpTask/isExistTable', ['method' => 'get']],
'moveFollowUpList' => ['task/FollowUpTask/moveFollowUpList', ['method' => 'get']],
]);
Route::group('broker', [
......
......@@ -4,6 +4,7 @@ namespace app\task\controller;
use app\extra\RedisExt;
use app\model\ASite;
use app\model\UPhoneFollowUp;
use app\model\UPhoneFollowUpTemporary;
/**
......@@ -17,15 +18,17 @@ class FollowUpTask
{
private $redis_;
private $table = 'u_phone_follow_up_';
private $siteModel;
public function __construct()
{
$this->redis_ = RedisExt::getRedis();
$this->siteModel = new ASite();
}
public function test()
{
$this->isExistTable("2019-01-10",10006);
$this->isExistTable("2019-01-10", 10006);
}
/**
......@@ -37,11 +40,8 @@ class FollowUpTask
*/
public function isExistTable($time, $siteId)
{
$siteModel = new ASite();
$site_field = 'city';
$site_params['id'] = $siteId;
$site_arr = $siteModel->findByOne($site_field,$site_params);
if(count($site_arr) <= 0){
$site_arr = $this->siteModel->findByOne('city', ["id" => $siteId]);
if (count($site_arr) <= 0) {
return false;
}
//todo 1.判断表是否存在,不存在则创建,
......@@ -62,12 +62,17 @@ class FollowUpTask
return true;//存在表
} else {
//创建表
return $this->createTemp($phoneFollowUpModel,$table_name);
return $this->createTemp($phoneFollowUpModel, $table_name);
}
}
}
public function createTemp($db,$tableName)
/**
* @param $db
* @param $tableName
* @return bool
*/
public function createTemp($db, $tableName)
{
if (!$tableName) {
return false;
......@@ -92,10 +97,47 @@ class FollowUpTask
KEY `idx_city` (`city`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8";
if(false !== $db->execute($sql)){
if (false !== $db->execute($sql)) {
return true;
} else {
return false;
return false;
}
}
/**
* 每天0.30执行移动操作
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/
public function moveFollowUpList()
{
$site_arr = $this->siteModel->getSite("id,name,city,is_del", ["is_del" => 0]);
if (count($site_arr) <= 0) {
return;
}
$date = date("Y-m-d",strtotime("-1 day"));
foreach ($site_arr as $item) {
$site_id = $item["id"];
//判断此站点是否执行过
if ($this->redis_->get("is_run_" . $date . "_" . $site_id) > 0) {
continue;
}
$table_name = $this->table . $site_id . "_" . $date;
$phoneFollowUpModel = new UPhoneFollowUpTemporary($site_id);
$isTable = $phoneFollowUpModel->query('SHOW TABLES LIKE "' . $table_name . '"');
if ($isTable) {
$sql = "INSERT into u_phone_follow_up_" . $site_id . "
(content,labels_id,user_id,agent_id,province,city,disc,type,create_time,update_time,user_status )
select content,labels_id,user_id,agent_id,province,city,disc,type,create_time,update_time,user_status
from `" . $table_name . "`";
$followUpModel = new UPhoneFollowUp($site_id);
if (false !== $followUpModel->execute($sql)) {
$this->redis_->set("is_run_" . $date . "_" . $site_id, 1, 24 * 3600);
}
}
}
}
}
\ No newline at end of file
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