Commit c8dc6f9e authored by hujun's avatar hujun

model

parent 3fb4a335
......@@ -226,8 +226,9 @@ class Remark extends Basic
$code = 101;
$list = [];
}
$data['list'] = $list;
$data['total'] = 40000;
$data['data']['list'] = $list;
$data['data']['total'] = 40000;
return $this->response($code, $msg, $data);
}
......
......@@ -59,33 +59,30 @@ class PhoneFollowUpService
}
return ['code'=>'101','data'=>$msg];
}
$where = ' 1=1 ';
if (empty($start_time) || empty($end_time)) {
return ['code'=>'101','data'=>'时间不能为空'];
} else {
$where['create_time'] = ['between', [$start_time . ' 00:00:00', $end_time . ' 23:59:59']];
$where .= ' AND create_time BETWEEN "'.$start_time.' 00:00:00" AND "'.$end_time. ' 23:59:59"';
}
$data = [];
if (isset($params['user_id'])) {
$where['user_id'] = $params['user_id'];
$where .= " AND user_id= {$params['user_id']}";
}
if (isset($params['agent_id'])) {
$where['agent_id'] = $params['agent_id'];
$where .= " AND agent_id = {$params['agent_id']}";
}
if (!empty($params['store_id'])) {
$agent_where['store_id'] = $params['remark_store_id'];
unset($params['store_id']);
}
if (!empty($params['district_id'])) {
$agent_where['district_id'] = $params['district_id'];
unset($params['district_id']);
}
if (!empty($agent_where)) {
$m_agent = new AAgents();
$agent_id = $m_agent->getAgentsByWhereColumn($agent_where, 'id');
......@@ -93,27 +90,17 @@ class PhoneFollowUpService
if (empty($agent_id)) {
return $data;
} else {
$where['agent_id'] = ['in', $agent_id];
$where .= " AND agent_id in {implode(',', $agent_id)}";
}
}
$date = time();
$start_time = strtotime($start_time);
$end_time = strtotime($end_time);
$data = $this->phoneFollowUpTemporary->getFollowList($page_no, $page_size, $order_ = 'id desc', $field, $where);
$num = count($data);
if (empty($data) || $num < $page_size) {
$count = (int)$page_size - (int)$data;
if ($count > 0) {
$new_count = $this->phoneFollowUpTemporary->getFollowTotal($where);
// $count = $new_count
$old_data = $this->phoneFollowUp->getFollowList(1, $count, $order_ = 'id desc', $field, $where);
//拼接数据
foreach ($old_data as $v) {
$data[$count] = $v;
$count++;
}
} else {
$data = $this->phoneFollowUp->getFollowList($page_no, $page_size, $order_ = 'id desc', $field, $where);
}
if ($start_time == $end_time && $start_time < $date) {
$data = $this->phoneFollowUpTemporary->getFollowListV2($page_no, $page_size, $where, $field);
} else {
$data = $this->phoneFollowUp->getFollowList($page_no, $page_size, $order_ = 'id desc', $field, $where);
}
$s_user_service = new UserService();
......@@ -128,7 +115,6 @@ class PhoneFollowUpService
$data[$k]['is_outpace_call_num'] = $s_user_Log_service->userDetailIsOutpaceCallNum($v['user_id'],$user_res['user_phone'], $agent_id);
}
return ['code'=>'200','data'=>$data];
}
......
......@@ -15,12 +15,14 @@ class UPhoneFollowUpTemporary extends BaseModel
protected $UPhoneFollowUp;
protected $siteId;
protected $table_name_string;
function __construct($site_id)
{
$date = date("Y-m-d", time());
$this->UPhoneFollowUp = Db($this->table."_".$site_id."_".$date);
$this->siteId = $site_id;
$this->table_name_string = '`'.$this->table."_".$site_id."_".$date.'`';
}
/**
......@@ -139,4 +141,25 @@ class UPhoneFollowUpTemporary extends BaseModel
//dump($this->getLastSql());
return $result;
}
public function getFollowListV2($pageNo = 1, $pageSize = 15, $where, $filed = '`id`, `user_id`, `create_time`, `content`, `user_status`, `labels_id`, `agent_id`') {
$start_index = ($pageNo - 1) * $pageSize;
$sql = "SELECT * FROM
((SELECT
$filed
FROM
$this->table_name_string
WHERE
$where)
UNION
(SELECT
$filed
FROM
u_phone_follow_up_10001
WHERE
$where
) ) as aa ORDER BY `id` DESC limit $start_index,$pageSize";
return $this->UPhoneFollowUp->query($sql);
}
}
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