Commit 73e675f9 authored by hujun's avatar hujun

30天带看

parent 2fee6c70
......@@ -8,6 +8,7 @@ use app\model\AAgents;
use app\model\Evaluate;
use app\model\EvaluateSign;
use app\model\OBargainModel;
use app\model\OReportModel;
/**
* Description of Agents
......@@ -49,6 +50,17 @@ class Broker extends Basic
$agent_client = $agents->getAgentClient($fields, [ 'c.id' => $this->userId, 'a.status'=>0 ]);
}
//查找30天带看最多的人
$m_report = new OReportModel();
$report_fields = 'COUNT( a.report_agent_id ) AS num,a.report_agent_id ';
$report_where['b.house_id'] = $params['house_id'];
$report_where['a.create_time'] = ['between', [date('Y-m-d'), date('Y-m-d', strtotime("-30 day"))]];
$report_agent_id = $m_report->getMaxReportAgent($report_fields, $report_where);
if (!empty($report_agent_id['report_agent_id'])) {
$report_agent = $agents->getUser(1, 1, '', $fields, [ 'c.id' => $report_agent_id['report_agent_id'], 'a.status'=>0 ]);
}
$where['c.houses_id'] = $params['house_id'];
$where['c.is_del'] = 0;
$where['a.status'] = 0;
......@@ -58,6 +70,10 @@ class Broker extends Basic
array_unshift($list, $agent_client);
}
if (!empty($report_agent[0]['id'])) {
array_unshift($list, $report_agent[0]);
}
if (!empty($list)) {
foreach ($list as $k => $v) {
$v['head_portrait'] = AGENTHEADERIMGURL . $v['img'];
......
......@@ -895,4 +895,21 @@ class OReportModel extends Model
//echo $this->getLastSql();
return $data;
}
/**
* @param $field
* @param $where
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getMaxReportAgent($field, $where) {
return $this->alias('a')
->field($field)
->join('o_order b', 'a.id = b.f_id', 'left')
->where($where)
->group('a.report_agent_id ')
->find();
}
}
\ 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