Commit 3b6d628b authored by hujun's avatar hujun

sql

parent e7be63f1
...@@ -121,7 +121,7 @@ class HomePageLog extends Basic ...@@ -121,7 +121,7 @@ class HomePageLog extends Basic
big_log(json_encode($where_)); big_log(json_encode($where_));
$result = $this->phoneFollowUpTemporary->getFollowList($pageNo, $pageSize, $order_ = 'id desc', $field, $where_); $result = $this->phoneFollowUpTemporary->getFollowList($pageNo, $pageSize, $order_ = 'id desc', $field, $where_);
} else { } else {
$result = $this->phoneFollowUpTemporary->getFollowListV2($this->siteId,$pageNo, $pageSize, $where, $field); $result = $this->phoneFollowUpTemporary->getFollowListV3($this->siteId,$pageNo, $pageSize, $where, $field);
} }
$clientService = new ClientService(); $clientService = new ClientService();
foreach ($result as $key => $value) { foreach ($result as $key => $value) {
......
...@@ -106,7 +106,7 @@ class PhoneFollowUpService ...@@ -106,7 +106,7 @@ class PhoneFollowUpService
if ($start_time >= $date && $start_time <= $date . " 23:59:59" ) { if ($start_time >= $date && $start_time <= $date . " 23:59:59" ) {
$data = $this->phoneFollowUpTemporary->getFollowList($page_no, $page_size, $order_ = 'id desc', $field, $where); $data = $this->phoneFollowUpTemporary->getFollowList($page_no, $page_size, $order_ = 'id desc', $field, $where);
} else { } else {
$data = $this->phoneFollowUpTemporary->getFollowListV2($this->siteId,$page_no, $page_size, $where, $field); $data = $this->phoneFollowUpTemporary->getFollowListV3($this->siteId,$page_no, $page_size, $where, $field);
} }
$s_user_service = new UserService(); $s_user_service = new UserService();
......
...@@ -13,14 +13,15 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -13,14 +13,15 @@ class UPhoneFollowUpTemporary extends BaseModel
{ {
protected $table = 'u_phone_follow_up'; protected $table = 'u_phone_follow_up';
protected $UPhoneFollowUp; protected $follow_up;
protected $siteId; protected $siteId;
protected $table_name_string; protected $table_name_string;
function __construct($site_id) function __construct($site_id)
{ {
$site_id = 10001;
$date = date("Y-m-d", time()); $date = date("Y-m-d", time());
$this->UPhoneFollowUp = 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.'`';
} }
...@@ -83,12 +84,12 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -83,12 +84,12 @@ class UPhoneFollowUpTemporary extends BaseModel
$arr["disc"] = '黄埔区'; $arr["disc"] = '黄埔区';
} }
$result = $this->UPhoneFollowUp->insert($arr); $result = $this->follow_up->insert($arr);
return $result; return $result;
} }
public function getFollowList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') { public function getFollowList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->UPhoneFollowUp->field($field) return $this->follow_up->field($field)
->where($params) ->where($params)
->order($order_) ->order($order_)
->limit($pageSize) ->limit($pageSize)
...@@ -110,7 +111,7 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -110,7 +111,7 @@ class UPhoneFollowUpTemporary extends BaseModel
$data['user_id'] = $user_id; $data['user_id'] = $user_id;
$data['content'] = $content; $data['content'] = $content;
$data['type'] = $type; $data['type'] = $type;
return $this->UPhoneFollowUp->insertGetId($data); return $this->follow_up->insertGetId($data);
} }
/** /**
...@@ -121,7 +122,7 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -121,7 +122,7 @@ class UPhoneFollowUpTemporary extends BaseModel
*/ */
public function getFollowTotal($params) public function getFollowTotal($params)
{ {
return $this->UPhoneFollowUp->where($params) return $this->follow_up->where($params)
->count(); ->count();
} }
...@@ -131,7 +132,7 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -131,7 +132,7 @@ class UPhoneFollowUpTemporary extends BaseModel
*/ */
public function getPhoneFollowData($field,$params,$order) public function getPhoneFollowData($field,$params,$order)
{ {
$result = $this->UPhoneFollowUp $result = $this->follow_up
->field($field) ->field($field)
->order($order) ->order($order)
->where($params) ->where($params)
...@@ -159,7 +160,21 @@ class UPhoneFollowUpTemporary extends BaseModel ...@@ -159,7 +160,21 @@ class UPhoneFollowUpTemporary extends BaseModel
$where $where
) ) as aa ORDER BY `id` DESC limit $start_index,$pageSize"; ) ) as aa ORDER BY `id` DESC limit $start_index,$pageSize";
return $this->UPhoneFollowUp->execute($sql); return $this->follow_up->execute($sql);
}
public function getFollowListV3($site_id,$pageNo = 1, $pageSize = 15, $where, $filed = '`id`, `user_id`, `create_time`, `content`, `user_status`, `labels_id`, `agent_id`') {
$sql = $this->follow_up->field($filed)->where($where)->buildSql();
$sql_temp = $this->follow_up->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,$sql_temp)->buildSql();
$data = Db::table($sql_string. ' a')
->where($where)
->limit($pageSize)
->page($pageNo)
->select();
return $data;
} }
public function getUserFollowKey($field, $where, $order = 'id asc') { public function getUserFollowKey($field, $where, $order = 'id asc') {
......
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