Commit 7d8e7c47 authored by zw's avatar zw

bug

parent 0cb2bb2a
...@@ -20,21 +20,30 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -20,21 +20,30 @@ class UPhoneFollowUpTemporary extends BaseModel
function __construct($site_id) function __construct($site_id)
{ {
$date = date("Y-m-d", time()); $date = date("Y-m-d", time());
$t_follow_up_task = new FollowUpTask();
if(!$t_follow_up_task->isExistTable($date, $site_id)){
return false;
}
$this->follow_up = Db($this->table."_".$site_id."_".$date); $this->follow_up = Db($this->table."_".$site_id."_".$date);
$this->siteId = $site_id; $this->siteId = $site_id;
$this->table_name_string = '`'.$this->table."_".$site_id."_".$date.'`'; $this->table_name_string = '`'.$this->table."_".$site_id."_".$date.'`';
} }
public function createTable(){
$date = date("Y-m-d", time());
$t_follow_up_task = new FollowUpTask();
if(!$t_follow_up_task->isExistTable($date, $this->siteId)){
return false;
}
return true;
}
/** /**
* 新增电话跟进-插入数据 * 新增电话跟进-插入数据
* @param $params * @param $params
* @return int|string * @return int|string
*/ */
public function savePhoneFollow($params) { public function savePhoneFollow($params) {
if(!$this->createTable()){
return null;
}
$arr = []; $arr = [];
if (isset($params["content"])) { if (isset($params["content"])) {
$arr["content"] = $params["content"]; $arr["content"] = $params["content"];
...@@ -92,6 +101,9 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -92,6 +101,9 @@ class UPhoneFollowUpTemporary extends BaseModel
} }
public function getFollowList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') { public function getFollowList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
if(!$this->createTable()){
return null;
}
return $this->follow_up->field($field) return $this->follow_up->field($field)
->where($params) ->where($params)
->order($order_) ->order($order_)
...@@ -110,6 +122,9 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -110,6 +122,9 @@ class UPhoneFollowUpTemporary extends BaseModel
* @return int|string * @return int|string
*/ */
public function insertDefaultFollow($agent_id, $user_id, $content, $type) { public function insertDefaultFollow($agent_id, $user_id, $content, $type) {
if(!$this->createTable()){
return null;
}
$data['agent_id'] = $agent_id; $data['agent_id'] = $agent_id;
$data['user_id'] = $user_id; $data['user_id'] = $user_id;
$data['content'] = $content; $data['content'] = $content;
...@@ -125,6 +140,9 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -125,6 +140,9 @@ class UPhoneFollowUpTemporary extends BaseModel
*/ */
public function getFollowTotal($params) public function getFollowTotal($params)
{ {
if(!$this->createTable()){
return null;
}
return $this->follow_up->where($params) return $this->follow_up->where($params)
->count(); ->count();
} }
...@@ -135,6 +153,9 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -135,6 +153,9 @@ class UPhoneFollowUpTemporary extends BaseModel
*/ */
public function getPhoneFollowData($field,$params,$order) public function getPhoneFollowData($field,$params,$order)
{ {
if(!$this->createTable()){
return null;
}
$result = $this->follow_up $result = $this->follow_up
->field($field) ->field($field)
->order($order) ->order($order)
...@@ -146,6 +167,9 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -146,6 +167,9 @@ class UPhoneFollowUpTemporary extends BaseModel
} }
public function getFollowListV2($site_id,$pageNo = 1, $pageSize = 15, $where, $filed = '`id`, `user_id`, `create_time`, `content`, `user_status`, `labels_id`, `agent_id`') { public function getFollowListV2($site_id,$pageNo = 1, $pageSize = 15, $where, $filed = '`id`, `user_id`, `create_time`, `content`, `user_status`, `labels_id`, `agent_id`') {
if(!$this->createTable()){
return null;
}
$start_index = ($pageNo - 1) * $pageSize; $start_index = ($pageNo - 1) * $pageSize;
$sql = "SELECT * FROM $sql = "SELECT * FROM
((SELECT ((SELECT
...@@ -167,6 +191,9 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -167,6 +191,9 @@ class UPhoneFollowUpTemporary extends BaseModel
} }
public function getFollowListV3($site_id,$pageNo = 1, $pageSize = 15, $where, $filed = '`id`, `user_id`, `create_time`, `content`, `user_status`, `labels_id`, `agent_id`') { public function getFollowListV3($site_id,$pageNo = 1, $pageSize = 15, $where, $filed = '`id`, `user_id`, `create_time`, `content`, `user_status`, `labels_id`, `agent_id`') {
if(!$this->createTable()){
return null;
}
$sql = Db::table('u_phone_follow_up_'.$site_id)->field($filed)->where($where)->buildSql(); $sql = Db::table('u_phone_follow_up_'.$site_id)->field($filed)->where($where)->buildSql();
$sql_string = $this->table($this->table_name_string)->field($filed)->where($where)->union([$sql], true)->buildSql(); $sql_string = $this->table($this->table_name_string)->field($filed)->where($where)->union([$sql], true)->buildSql();
$data = Db::table($sql_string. ' a') $data = Db::table($sql_string. ' a')
...@@ -179,6 +206,9 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -179,6 +206,9 @@ class UPhoneFollowUpTemporary extends BaseModel
} }
public function getUserFollowKey($field, $where, $order = 'id asc') { public function getUserFollowKey($field, $where, $order = 'id asc') {
if(!$this->createTable()){
return null;
}
return $this->UPhoneFollowUp->where($where) return $this->UPhoneFollowUp->where($where)
->order($order) ->order($order)
->value($field); ->value($field);
......
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