Commit 363976a3 authored by zhuwei's avatar zhuwei Committed by hujun

客户动态展示加搜索加客户详情

parent 6fa18eae
......@@ -12,6 +12,7 @@ namespace app\api_broker\controller;
use app\api\untils\JwtUntils;
use app\api_broker\extend\Basic;
use app\model\AAgents;
use app\model\GOperatingRecords;
use app\model\UPhoneFollowPp;
use app\model\Users;
use app\model\Agents;
......@@ -233,57 +234,38 @@ class Broker extends Basic
$user_id = $params['user_id'];
$UPhoneFollowPp = new UPhoneFollowPp();
// 查询数据集
if($searchdate){
$UPhoneFollowPp_res = $UPhoneFollowPp
->where('user_id',$user_id)
->where('content',$searchdate)
->limit($pagesize)
->page($pagenum)
->select();
$total =$UPhoneFollowPp
->where('user_id',$user_id)
->where('content',$searchdate)
->count();
}else{
$UPhoneFollowPp_res = $UPhoneFollowPp
->where('user_id',$user_id)
->limit($pagesize)
->page($pagenum)
->select();
$total =$UPhoneFollowPp
->where('user_id',$user_id)
->count();
}
$total = intval($total / $pagesize) + (($total % $pagesize == 0) ? 0 : 1);
// 查询电话跟进数据
$UPhoneFollowPp_res=$UPhoneFollowPp->select_useraction_search($user_id,$searchdate);
//var_dump($UPhoneFollowPp_res);
/*dump($total);
var_dump($user_res);
exit;*/
//dump($UPhoneFollowPp_res);
foreach($UPhoneFollowPp_res as $k=>$v){
$table= new Agents();
$Agents_res =$table->Agents_res($v['agent_id']);
//dump($Agents_res);
$UPhoneFollowPp_res[$k]['agentinfo']=$Agents_res?$Agents_res['realname'].'/'.$Agents_res['phone']:'未知';
$UPhoneFollowPp_res[$k]['user_pic']=HEADERIMGURL.$Agents_res['head_portrait'];
}
if ($UPhoneFollowPp_res) {
$user = new Users();
// 查询数据集
$user_res =$user
->where('id', $user_id)
->field('id as user_id,agent_id,sex,user_nick,user_pic,user_phone,create_time')
->find();
$user_res=json_decode(json_encode($user_res),true);//对象转数组
$user_res =$user->useraction_search_user_res($user_id);
//dump($user_res);
$user_res['user_pic']=HEADERIMGURL.$user_res['user_pic'];
$table= new Agents();
$Agents_res =$table
->where('id', $user_res['agent_id'])
->field('realname,phone')
->find();
$Agents_res=json_decode(json_encode($Agents_res),true);//对象转数组
$Agents_res =$table->Agents_res($v['agent_id']);
//dump($Agents_res);
$user_res['agentinfo']=$Agents_res?$Agents_res['realname'].'/'.$Agents_res['phone']:'未知';
return $this->response("200", "success!", ['user_info'=>$user_res,'user_date'=>$UPhoneFollowPp_res,'pagenum'=>$pagenum,'total'=>$total]);
$records = new GOperatingRecords();
$records_result = $records->user_history($user_id);
//dump($records_result);
//dump($user_id);
return $this->response("200", "success!", ['user_info'=>$user_res,'user_date'=>$UPhoneFollowPp_res,'user_history'=>$records_result]);
} else {
return $this->response("101", "失败!");
}
......
......@@ -206,5 +206,14 @@ class Agents extends Model
{
return $this->where($params)->count();
}
public function Agents_res($agent_id)
{
return db('agents')
->where('id', $agent_id)
->field('realname,phone,head_portrait')
->find();
}
}
......@@ -49,4 +49,15 @@ class GOperatingRecords extends BaseModel
return $result;
}
public function user_history($user_id)
{
return db('g_operating_records')
->where('user_id',$user_id)
->field('name,remark,create_time')
->order('create_time', 'desc')
->select();
}
}
\ No newline at end of file
......@@ -63,4 +63,34 @@ class UPhoneFollowPp extends BaseModel
->where($params)->count();
return $result;
}
public function select_useraction_search($user_id,$searchdate)
{
if($searchdate){
$UPhoneFollowPp_res = db('u_phone_follow_up')
->where('user_id',$user_id)
->where('content',$searchdate)
->order('create_time', 'desc')
//->limit($pagesize)
//->page($pagenum)
->select();
/*$total =$UPhoneFollowPp
->where('user_id',$user_id)
->where('content',$searchdate)
->count();*/
}else{
$UPhoneFollowPp_res = db('u_phone_follow_up')
->where('user_id',$user_id)
->order('create_time', 'desc')
//->limit($pagesize)
//->page($pagenum)
->select();
/*$total =$UPhoneFollowPp
->where('user_id',$user_id)
->count();*/
}
return $UPhoneFollowPp_res;
}
}
......@@ -226,6 +226,14 @@ class Users extends Model
return $r;
}
public function useraction_search_user_res($user_id)
{
return db('u_users')
->where('id', $user_id)
->field('id as user_id,agent_id,sex,user_nick,user_pic,user_phone,create_time')
->find();
}
/*public function user_search($phone_or_name,$Two_days_ago,$user_id,$pagesize,$pagenum) {
$data =$this ->where('user_nick|user_phone','like',"%$phone_or_name%")
->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
......
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