Commit f36ee9e6 authored by hujun's avatar hujun

咨询经纪人V2

parent 1512f5d3
......@@ -111,6 +111,84 @@ class Broker extends Basic
return $this->response($data['status'], $data['msg'], $data['data']);
}
/**
* 咨询经纪人
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function indexV2()
{
header('Access-Control-Allow-Origin:*');
if (empty($this->params['house_id'])) {
$this->response(101, '参数错误');
}
$data['status'] = 101;
$data['data'] = $list = [];
$data['msg'] = '';
$agents = new AAgents();
$m_march = new OMarchInModel();
$m_evaluate = new Evaluate();
//查找30天带看最多的人
$report_fields = 'a.reception_id';
$report_where['b.house_id'] = $this->params['house_id'];
$report_where['a.create_time'] = ['between', [date('Y-m-d', strtotime("-30 day")) . ' 00:00:00', date('Y-m-d').' 23:59:59']];
$reception_id = $m_march->getMaxMarchInAgent($report_fields, $report_where);
$fields_agent = 'id,name,img,phone';
if (!empty($reception_id['reception_id'])) {
$march_agent = $agents->findByOne($fields_agent, [ 'id' => $reception_id['reception_id']]);
if (!empty($march_agent)){
$list[0] = $march_agent;
$list[0]['show_content'] = '我对本铺非常了解,最近带看本铺多次';
}
}
$fields = 'a.id,a.name,a.img,a.phone';
//客方
if (!empty($this->userId)) {
$client = $agents->getAgentUser($fields, [ 'a.id' => $this->userId, 'b.agent_id'=>['neq', $list[0]['id']]]); //客方
if (!empty($client)){
$list[1] = $client;
$list[1]['show_content'] = '帮助客户找更多,善于了解客户需求';
}
}
//独家方
$where['b.houses_id'] = $this->params['house_id'];
$where['b.is_del'] = $where['a.status'] = 0;
$where['a.id'] = ['not in', [$list[0]['id'], $list[2]['id']]];
$where['b.type'] = 3;
$house_agent = $agents->getAgentHouseType($fields, $where);
if (!empty($house_agent)){
$list[2] = $house_agent;
$list[2]['show_content'] = '本铺由我登记,熟悉房源信息';
}
foreach ($list as $k => $v) {
$list[$k]['head_portrait'] = AGENTHEADERIMGURL . $v['img'];
$evaluate_data = $m_evaluate->getAgentEvaluateFraction('count(id) as evaluate,sum(evaluate_grade) as evaluate_grade', ['agents_id'=>$v['id']]);
if ($evaluate_data[0]['evaluate_grade']) {
$evaluate_grade = floor(($evaluate_data[0]['evaluate_grade'] / 2) / $evaluate_data[0]['evaluate']);
} else {
$evaluate_grade = 0;
}
$list[$k]['evaluate_grade'] = $evaluate_grade;
$list[$k]['evaluate'] = $evaluate_data[0]['evaluate'];
unset($list[$k]['img']);
}
$data['data']['list'] = $list;
$data['status'] = 200;
return $this->response($data['status'], $data['msg'], $data['data']);
}
/**
* 评价经纪人
*
......
This diff is collapsed.
......@@ -1576,6 +1576,9 @@ class AAgents extends BaseModel
}
public function findByOne($field,$params) {
if (!isset($params['status'])) {
$where['status'] = 0;
}
$result = $this
->field($field)
->where($params)
......@@ -1590,4 +1593,37 @@ class AAgents extends BaseModel
return $return;
}
/**
* @param $field
* @param $where
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentUser($field, $where) {
$where['a.status'] = 0;
return $this->alias('a')
->field($field)
->join('u_users b','a.id = b.agent_id', 'left')
->where($where)
->find();
}
/**
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentHouseType($field, $where) {
return $this->alias('a')
->field($field)
->join('g_houses_to_agents b', 'a.id=b.agents_id', 'left')
->where($where)
->find();
}
}
\ No newline at end of file
......@@ -430,6 +430,7 @@ Route::group('api', [
//get broker
'getBroker' => ['api/broker/index', ['method' => 'get']], //获取当前商铺或街铺的经纪人评论信息列表
'getBrokerV2' => ['api/broker/indexV2', ['method' => 'get']], //获取当前商铺或街铺的经纪人评论信息列表
'test' => ['api/broker/testtest', ['method' => 'get']], //获取当前商铺或街铺的经纪人评论信息列表
'commentAndDeal' => ['api/broker/commentAndDeal', ['method' => 'get']], //获取当前经纪人的评价和交易列表
'brokerDetail' => ['api/broker/brokerDetail', ['method' => 'get']], //经纪人详情
......
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