Commit 0f421b77 authored by hujun's avatar hujun

咨询经纪人客方显示在第一个位置

parent ae87a3f6
......@@ -11,7 +11,7 @@ use app\model\Remarks;
/**
* Description of Agents
*
* @user :hujun
* @user :hu jun
* @date :2017-12-11
* @time :11:15:05
* Intro :
......@@ -29,22 +29,22 @@ class Broker extends Basic{
public function index() {
$params = $this->params;
$data['status'] = 101;
$data['data'] = array();
$data['data'] = [];
$data['msg'] = '';
if ($params['house_id']) {
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? PAGESIZE : $params['pageSize'];
$agents = new AAgents();
$data['msg'] = '';
$fields = 'a.id,name,phone,COUNT(b.id) evaluate,sum(evaluate_grade) as evaluate_grade,a.img';
$fields = 'a.id,name,phone,COUNT(b.id) evaluate,sum(evaluate_grade) as evaluate_grade,a.img,d.id as user_id';
$list = $agents->getUser($pageNo, $pageSize, 'evaluate desc', $fields, '', $params['house_id']);
if ($list) {
if (!empty($list)) {
foreach ($list as $k=>$v) {
$v->head_portrait = AGENTHEADERIMGURL.$v->img;
$list[$k] = $v->toArray();
$v['head_portrait'] = AGENTHEADERIMGURL.$v['img'];
if ($list[$k]['evaluate_grade']) {
$evaluate_grade = floor(($list[$k]['evaluate_grade']/2)/$list[$k]['evaluate']);
} else {
......@@ -62,13 +62,15 @@ class Broker extends Basic{
} else {
$data['msg'] = 'house_id 为空';
}
return $this->response($data['status'], $data['msg'], $data['data'] );
}
/**
* 评价经纪人
*
* @return type
* @return \think\Response
* @throws \Exception
*/
public function appraiser() {
$params = $this->params;
......@@ -194,7 +196,10 @@ class Broker extends Basic{
/**
* 经纪人详情
*
* @return type
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function brokerDetail() {
......
......@@ -21,7 +21,7 @@ class TransferHouseInfo extends Controller
*/
public function table() {
Db::table('g_houses')->execute('TRUNCATE `g_houses`');
Db::table('g_houses_to_agents')->execute('TRUNCATE `g_houses_to_agents`');
// Db::table('g_houses_to_agents')->execute('TRUNCATE `g_houses_to_agents`');
Db::table('houseinfo_exts')->execute('TRUNCATE `g_houses_ext`');
$num = Db::table('houseinfos')->order('id desc')->value('id');
$regions = new Regions();
......@@ -217,33 +217,36 @@ class TransferHouseInfo extends Controller
$agent_data = Db::table('agents')->field('id,house_ids,house_ids2')->where('level in(2,5)')->select();
$agent_house_data = [];
foreach ($agent_data as $k=>$v) {
$key=0;
foreach ($agent_data as $k=>$v) {
if (!empty($v['house_ids'])) {
$house_ids_arr = explode(',',$v['house_ids']);
$house_ids_arr = array_unique($house_ids_arr);
foreach ($house_ids_arr as $kk => $vv) {
$agent_house_data[$key]['houses_id'] = $vv;
$agent_house_data[$key]['agents_id'] = $v['id'];
$agent_house_data[$key]['type'] = 1;
$agent_house_data_arr[$key] = $vv.'-|-'.$v['id'];
$key++;
}
}
if (!empty($v['house_ids2'])) {
$house_ids_arr = explode(',',$v['house_ids2']);
$house_ids_arr = array_unique($house_ids_arr);
foreach ($house_ids_arr as $kkk => $vvv) {
$agent_house_data[$key]['houses_id'] = $vvv;
$agent_house_data[$key]['agents_id'] = $v['id'];
$agent_house_data[$key]['type'] = 1;
$agent_house_data_arr[$key] = $vvv.'-|-'.$v['id'];
$key++;
}
}
if (!empty($agent_house_data)) {
$result[] = Db::table('g_houses_to_agents')->insertAll($agent_house_data);
}
$agent_house_data_arr = array_unique($agent_house_data_arr); //去重
foreach ($agent_house_data_arr as $k=>$v) {
$data_house_arr = explode('-|-',$v);
$agent_house_data[$k]['houses_id'] = $data_house_arr[0];
$agent_house_data[$k]['agents_id'] = $data_house_arr[1];
}
dump($result);die;
$result = Db::table('g_houses_to_agents')->insertAll($agent_house_data);
dump($result);
}
}
\ No newline at end of file
......@@ -732,8 +732,9 @@ class AAgents extends BaseModel
$data = $this->field($field)->alias('a')
->join('u_evaluate b', 'a.id = b.agents_id', 'left')
->join('g_houses_to_agents c', 'a.id=c.agents_id', 'left')
->join('u_users d','a.id = d.agent_id', 'left')
->where('c.houses_id', $house_id)
->where('type', 1)
->where('c.type', 1)
->where($params)
->group('a.id')
->order($order_)
......@@ -767,7 +768,15 @@ class AAgents extends BaseModel
->select();
}
/**
* @param $field
* @param $params
* @param $group
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentsList($field,$params,$group){
$where_ = [];
if($group == "store_id"){
......@@ -782,4 +791,27 @@ class AAgents extends BaseModel
return $result;
}
/**
* 获取用户的客方经纪人
*
* @param string $field
* @param array $params
* @param int $house_id
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUserAgent($field = '', $params = [], $house_id = 0) {
$data = $this->field($field)->alias('a')
->join('u_evaluate b', 'a.id = b.agents_id', 'left')
->join('g_houses_to_agents c', 'a.id=c.agents_id', 'left')
->join('u_users d','a.id = d.agent_id', 'left')
->where('c.houses_id', $house_id)
->where('c.type', 1)
->where($params)
->find();
return $data;
}
}
\ 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