Commit 40890ffb authored by hujun's avatar hujun

记录客户拨打经纪人次数

parent f275a0ab
<?php <?php
namespace app\api\controller; namespace app\api\controller;
use app\api\extend\Basic; use app\api\extend\Basic;
use app\api_broker\service\PushMessageService;
use app\model\AAgents; use app\model\AAgents;
use app\model\Agents;
use app\model\Evaluate; use app\model\Evaluate;
use app\model\EvaluateSign; use app\model\EvaluateSign;
use app\model\OBargainModel; use app\model\OBargainModel;
use app\model\Remarks;
/** /**
* Description of Agents * Description of Agents
...@@ -18,7 +16,8 @@ use app\model\Remarks; ...@@ -18,7 +16,8 @@ use app\model\Remarks;
* @time :11:15:05 * @time :11:15:05
* Intro : * Intro :
*/ */
class Broker extends Basic{ class Broker extends Basic
{
/** /**
* 咨询经纪人 * 咨询经纪人
...@@ -28,13 +27,14 @@ class Broker extends Basic{ ...@@ -28,13 +27,14 @@ class Broker extends Basic{
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function index() { public function index()
$params = $this->params; {
$data['status'] = 101; $params = $this->params;
$data['status'] = 101;
$data['data'] = []; $data['data'] = [];
$data['msg'] = ''; $data['msg'] = '';
if ($params['house_id']) { if ($params['house_id']) {
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo']; $pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? PAGESIZE : $params['pageSize']; $pageSize = empty($params['pageSize']) ? PAGESIZE : $params['pageSize'];
...@@ -45,22 +45,22 @@ class Broker extends Basic{ ...@@ -45,22 +45,22 @@ class Broker extends Basic{
$agent_client = 0; $agent_client = 0;
if (!empty($this->userId) && ($this->params['source'] != 'B-APP')) { if (!empty($this->userId) && ($this->params['source'] != 'B-APP')) {
$agent_client = $agents->getAgentClient($fields, ['c.id'=>$this->userId]); $agent_client = $agents->getAgentClient($fields, [ 'c.id' => $this->userId ]);
} }
$where['c.houses_id'] = $params['house_id']; $where['c.houses_id'] = $params['house_id'];
$where['c.is_del'] = 0; $where['c.is_del'] = 0;
$list = $agents->getUser($pageNo, $pageSize, 'evaluate desc', $fields, $where); $list = $agents->getUser($pageNo, $pageSize, 'evaluate desc', $fields, $where);
if (!empty($agent_client['id'])) { if (!empty($agent_client['id'])) {
array_unshift($list, $agent_client); array_unshift($list, $agent_client);
} }
if (!empty($list)) { if (!empty($list)) {
foreach ($list as $k=>$v) { foreach ($list as $k => $v) {
$v['head_portrait'] = AGENTHEADERIMGURL.$v['img']; $v['head_portrait'] = AGENTHEADERIMGURL . $v['img'];
if ($list[$k]['evaluate_grade']) { if ($list[$k]['evaluate_grade']) {
$evaluate_grade = floor(($list[$k]['evaluate_grade']/2)/$list[$k]['evaluate']); $evaluate_grade = floor(($list[$k]['evaluate_grade'] / 2) / $list[$k]['evaluate']);
} else { } else {
$evaluate_grade = 0; $evaluate_grade = 0;
} }
...@@ -69,15 +69,15 @@ class Broker extends Basic{ ...@@ -69,15 +69,15 @@ class Broker extends Basic{
} }
} }
$data['data']['list'] = $list; $data['data']['list'] = $list;
$data['data']['pageNo'] = $pageNo; $data['data']['pageNo'] = $pageNo;
$data['data']['pageSize'] = $pageSize; $data['data']['pageSize'] = $pageSize;
$data['status'] = 200; $data['status'] = 200;
} else { } else {
$data['msg'] = 'house_id 为空'; $data['msg'] = 'house_id 为空';
} }
return $this->response($data['status'], $data['msg'], $data['data'] ); return $this->response($data['status'], $data['msg'], $data['data']);
} }
/** /**
...@@ -86,10 +86,11 @@ class Broker extends Basic{ ...@@ -86,10 +86,11 @@ class Broker extends Basic{
* @return \think\Response * @return \think\Response
* @throws \Exception * @throws \Exception
*/ */
public function appraiser() { public function appraiser()
$params = $this->params; {
$params = $this->params;
$data['status'] = 101; $data['status'] = 101;
$data['data'] = array(); $data['data'] = [];
$data['msg'] = ''; $data['msg'] = '';
if (empty($params['agents_id'])) { if (empty($params['agents_id'])) {
...@@ -107,8 +108,8 @@ class Broker extends Basic{ ...@@ -107,8 +108,8 @@ class Broker extends Basic{
return $this->response($data['status'], 'source is null'); return $this->response($data['status'], 'source is null');
} }
$date = date('Y-m-d H:i:s'); $date = date('Y-m-d H:i:s');
$id_arr = array(); $id_arr = [];
if (isset($params['sign_name'])) { if (isset($params['sign_name'])) {
$evaluate_sign = new EvaluateSign(); $evaluate_sign = new EvaluateSign();
foreach ($params['sign_name'] as $v) { foreach ($params['sign_name'] as $v) {
...@@ -128,21 +129,21 @@ class Broker extends Basic{ ...@@ -128,21 +129,21 @@ class Broker extends Basic{
$evaluate = new Evaluate(); $evaluate = new Evaluate();
$evaluate->save([ $evaluate->save([
'user_id' => $this->userId, 'user_id' => $this->userId,
'agents_id' => $params['agents_id'], 'agents_id' => $params['agents_id'],
'source' => $params['source'], 'source' => $params['source'],
'record_id' => $params['record_id'], 'record_id' => $params['record_id'],
'evaluate_grade' => $params['evaluate_grade'], 'evaluate_grade' => $params['evaluate_grade'],
'evaluate_content' => $params['evaluate_content'], 'evaluate_content' => $params['evaluate_content'],
'evaluate_sign' => implode(',', $id_arr), 'evaluate_sign' => implode(',', $id_arr),
'create_time' => $date, 'create_time' => $date,
'update_time' => $date, 'update_time' => $date,
'is_show' => 0, 'is_show' => 0,
'house_id' => $params['house_id'] 'house_id' => $params['house_id']
]); ]);
if ($evaluate->id) { if ($evaluate->id) {
$data['data'] = ['id'=> $evaluate->id]; $data['data'] = [ 'id' => $evaluate->id ];
$data['status'] = 200; $data['status'] = 200;
$data['msg'] = '评价成功'; $data['msg'] = '评价成功';
} else { } else {
...@@ -160,41 +161,42 @@ class Broker extends Basic{ ...@@ -160,41 +161,42 @@ class Broker extends Basic{
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function commentAndDeal() { public function commentAndDeal()
$params = $this->params; {
$params = $this->params;
$data['status'] = 200; $data['status'] = 200;
$data['data'] = array(); $data['data'] = [];
$data['msg'] = ''; $data['msg'] = '';
if ($params['agent_id']) { if ($params['agent_id']) {
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo']; $pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? PAGESIZE : $params['pageSize']; $pageSize = empty($params['pageSize']) ? PAGESIZE : $params['pageSize'];
$bargain = new OBargainModel(); $bargain = new OBargainModel();
$evaluate = new Evaluate(); $evaluate = new Evaluate();
$fields_evaluate = 'house_id,user_id,user_nick,user_phone,user_pic,evaluate_grade,evaluate_content,'; $fields_evaluate = 'house_id,user_id,user_nick,user_phone,user_pic,evaluate_grade,evaluate_content,';
$fields_evaluate .= 'evaluate_sign,a.create_time,record_id,a.source,a.house_id,c.external_address'; $fields_evaluate .= 'evaluate_sign,a.create_time,record_id,a.source,a.house_id,c.external_address';
$bargain_fields = 'a.id,a.price,a.create_time as singntime,d.external_title as title,d.rent_type,d.shop_sign,shop_area_start as room_area,c.house_id'; $bargain_fields = 'a.id,a.price,a.create_time as singntime,d.external_title as title,d.rent_type,d.shop_sign,shop_area_start as room_area,c.house_id';
switch ($params['type']) { switch ($params['type']) {
case 0: case 0:
//评价列表信息 //评价列表信息
$result['evaluate'] = $evaluate->getEvaluate($pageNo, $pageSize, 'a.id desc', $fields_evaluate, '', $params['agent_id']); $result['evaluate'] = $evaluate->getEvaluate($pageNo, $pageSize, 'a.id desc', $fields_evaluate, '', $params['agent_id']);
//成交记录 //成交记录
$result['journalAccounts'] = $bargain->getBargainOrderList($pageNo, $pageSize, '', $bargain_fields, ['a.agent_id'=>$this->params['agent_id']]); $result['journalAccounts'] = $bargain->getBargainOrderList($pageNo, $pageSize, '', $bargain_fields, [ 'a.agent_id' => $this->params['agent_id'] ]);
$data['data'] = $result; $data['data'] = $result;
break; break;
case 1: case 1:
//评价列表信息 //评价列表信息
$result['evaluate'] = $evaluate->getEvaluate($pageNo, $pageSize, 'a.id desc', $fields_evaluate, '', $params['agent_id']); $result['evaluate'] = $evaluate->getEvaluate($pageNo, $pageSize, 'a.id desc', $fields_evaluate, '', $params['agent_id']);
$data['data'] = $result; $data['data'] = $result;
break; break;
case 2: case 2:
//成交记录 //成交记录
$result['journalAccounts'] = $bargain->getBargainOrderList($pageNo, $pageSize, '', $bargain_fields, ['a.agent_id'=>$this->params['agent_id']]); $result['journalAccounts'] = $bargain->getBargainOrderList($pageNo, $pageSize, '', $bargain_fields, [ 'a.agent_id' => $this->params['agent_id'] ]);
$data['data'] = $result; $data['data'] = $result;
break; break;
default: default:
$data['stauts'] = 101; $data['stauts'] = 101;
...@@ -204,7 +206,7 @@ class Broker extends Basic{ ...@@ -204,7 +206,7 @@ class Broker extends Basic{
} else { } else {
$data['msg'] = 'agent_id is null'; $data['msg'] = 'agent_id is null';
} }
return $this->response($data['status'], $data['msg'], $data['data']); return $this->response($data['status'], $data['msg'], $data['data']);
} }
...@@ -216,27 +218,51 @@ class Broker extends Basic{ ...@@ -216,27 +218,51 @@ class Broker extends Basic{
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function brokerDetail() { public function brokerDetail()
{
$data['status'] = 200; $data['status'] = 200;
$data['data'] = array(); $data['data'] = [];
$data['msg'] = ''; $data['msg'] = '';
if ($this->params['agent_id']) { if ($this->params['agent_id']) {
$agents = new AAgents(); $agents = new AAgents();
$data['data'] = $agents->agentsDetail($this->params['agent_id']); $data['data'] = $agents->agentsDetail($this->params['agent_id']);
} else { } else {
$data['status'] = 101; $data['status'] = 101;
$data['msg'] = 'agent_id is null'; $data['msg'] = 'agent_id is null';
} }
return $this->response($data['status'], $data['msg'], $data['data']); return $this->response($data['status'], $data['msg'], $data['data']);
} }
public function testtest() { /**
$push = new PushMessageService(); * 记录客户拨打经纪人次数
// $push->pushReportMessage(2362,3670,1); *
// $push->pushMarchInMessage(26964); * @return \think\Response
$push->pushBargainMessage(26989); * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function recordCallNum()
{
$data['status'] = 200;
$data['data'] = [];
$data['msg'] = '';
if ($this->params['agent_id'] > 0) {
$m_agents = new AAgents();
$agents_data = $m_agents->getAgentInfo('id,update_time,call_number', $this->params['agent_id']);
$insert_data['update_time'] = $agents_data['update_time'];
$insert_data['call_number'] = $agents_data['call_number'] + 1;
$data['data'] = $m_agents->editData($insert_data, $agents_data['id']);
} else {
$data['status'] = 101;
$data['msg'] = 'agent_id is null';
}
return $this->response($data['status'], $data['msg'], $data['data']);
} }
} }
...@@ -312,11 +312,6 @@ class AAgents extends BaseModel ...@@ -312,11 +312,6 @@ class AAgents extends BaseModel
return $this->save([ 'password' => md5($pwd) ], [ 'id' => $id ]); return $this->save([ 'password' => md5($pwd) ], [ 'id' => $id ]);
} }
public function saveList()
{
}
/** /**
* 分页列表 * 分页列表
* @param int $p * @param int $p
...@@ -343,13 +338,16 @@ class AAgents extends BaseModel ...@@ -343,13 +338,16 @@ class AAgents extends BaseModel
return $data; return $data;
} }
/** /**
* 统计任务获取经纪人列表 * 统计任务获取经纪人列表
*
* @param int $pageNo * @param int $pageNo
* @param int $pageSize * @param int $pageSize
* @param string $field * @param string $field
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function getAgentsListByTask($pageNo = 1, $pageSize = 15, $field = "id") public function getAgentsListByTask($pageNo = 1, $pageSize = 15, $field = "id")
{ {
...@@ -358,7 +356,6 @@ class AAgents extends BaseModel ...@@ -358,7 +356,6 @@ class AAgents extends BaseModel
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
->select(); ->select();
} }
/** /**
...@@ -373,8 +370,12 @@ class AAgents extends BaseModel ...@@ -373,8 +370,12 @@ class AAgents extends BaseModel
/** /**
* 批量获取经纪人 * 批量获取经纪人
*
* @param $params * @param $params
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function getAgentsByStoreId($params) public function getAgentsByStoreId($params)
{ {
...@@ -386,7 +387,13 @@ class AAgents extends BaseModel ...@@ -386,7 +387,13 @@ class AAgents extends BaseModel
return $result; return $result;
} }
/**
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function countAgentNum($params) public function countAgentNum($params)
{ {
$where_ = $whereOr_ = []; $where_ = $whereOr_ = [];
...@@ -413,7 +420,14 @@ class AAgents extends BaseModel ...@@ -413,7 +420,14 @@ class AAgents extends BaseModel
} }
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentsInfoByAgentId($field, $params) public function getAgentsInfoByAgentId($field, $params)
{ {
$where_ = []; $where_ = [];
...@@ -444,6 +458,13 @@ class AAgents extends BaseModel ...@@ -444,6 +458,13 @@ class AAgents extends BaseModel
} }
/**
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getStoreOrDistrict($params){ public function getStoreOrDistrict($params){
$result = Db::table($this->table) $result = Db::table($this->table)
->field("id,name,img") ->field("id,name,img")
...@@ -453,6 +474,14 @@ class AAgents extends BaseModel ...@@ -453,6 +474,14 @@ class AAgents extends BaseModel
return $result; return $result;
} }
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function searchAgentsByKeyword($field, $params) public function searchAgentsByKeyword($field, $params)
{ {
...@@ -508,13 +537,15 @@ class AAgents extends BaseModel ...@@ -508,13 +537,15 @@ class AAgents extends BaseModel
->value('id'); ->value('id');
} }
/** /**
* 根据id检查是否有权限 * 根据id检查是否有权限
* *
* @param $agents_id * @param $agents_id
* @param $rule * @param $rule
* @return mixed * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function agentsAuthIds($agents_id, $rule) public function agentsAuthIds($agents_id, $rule)
{ {
......
...@@ -264,6 +264,7 @@ Route::group('api', [ ...@@ -264,6 +264,7 @@ Route::group('api', [
'brokerDetail' => [ 'api/broker/brokerDetail', [ 'method' => 'get' ] ], //经纪人详情 'brokerDetail' => [ 'api/broker/brokerDetail', [ 'method' => 'get' ] ], //经纪人详情
//post broker //post broker
'appraiser' => [ 'api/broker/appraiser', [ 'method' => 'post' ] ], //评价经纪人 'appraiser' => [ 'api/broker/appraiser', [ 'method' => 'post' ] ], //评价经纪人
'recordCallNum' => [ 'api/broker/recordCallNum', [ 'method' => 'post' ] ], //记录拨打经纪人号码
//get member //get member
'logout' => [ 'api/member/logout', [ 'method' => 'get' ] ], 'logout' => [ 'api/member/logout', [ '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