Commit c0971839 authored by hujun's avatar hujun

咨询经纪人换重构的表

parent 5c70db50
......@@ -2,6 +2,7 @@
namespace app\api\controller;
use app\api\extend\Basic;
use app\model\AAgents;
use app\model\Agents;
use app\model\Evaluate;
use app\model\EvaluateSign;
......@@ -18,9 +19,12 @@ use app\model\Remarks;
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 index() {
$params = $this->params;
......@@ -31,14 +35,14 @@ class Broker extends Basic{
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? PAGESIZE : $params['pageSize'];
$agents = new Agents();
$agents = new AAgents();
$data['msg'] = '';
$fields = 'a.id,realname,phone,COUNT(b.id) evaluate,sum(evaluate_grade) as evaluate_grade,a.head_portrait';
$fields = 'a.id,name,phone,COUNT(b.id) evaluate,sum(evaluate_grade) as evaluate_grade,a.img';
$list = $agents->getUser($pageNo, $pageSize, 'evaluate desc', $fields, '', $params['house_id']);
if ($list) {
foreach ($list as $k=>$v) {
$v->head_portrait = ADMIN_URL_TL.'user_header/'.$v->head_portrait;
$v->head_portrait = AGENTHEADERIMGURL.$v->img;
$list[$k] = $v->toArray();
if ($list[$k]['evaluate_grade']) {
......
......@@ -641,4 +641,46 @@ class AAgents extends BaseModel
->where('a.id', $agent_id)
->find();
}
/**
* 查询经纪人
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param $field
* @param $params
* @param string $house_id
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUser($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '')
{
if ($house_id == '') {
$data = $this->field($field)->alias('a')
->join('u_evaluate b', 'a.id = b.agents_id', 'left')
->where($params)
->group('a.id')
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
} else {
$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')
->where('c.houses_id',$house_id)
->where('type',1)
->where($params)
->group('a.id')
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
return $data;
}
}
\ No newline at end of file
......@@ -13,13 +13,16 @@ class Agents extends Model
/**
* 查询经纪人
*
* @param type $pageNo
* @param type $pageSize
* @param type $order_
* @param type $field
* @param type $params
* @param type $house_id 查询该街铺和商铺的经纪人评论信息
* @return type
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param $field
* @param $params
* @param string $house_id
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUser($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '')
{
......
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