Commit 63daf8c1 authored by clone's avatar clone

新增分佣经纪人搜索

parent b719bca0
...@@ -206,6 +206,35 @@ class OrderLog extends Basic ...@@ -206,6 +206,35 @@ class OrderLog extends Basic
return $this->response("101", "request faild"); return $this->response("101", "request faild");
} }
/**
* 成交报告客户搜索
* @return \think\Response
*/
public function searchBargainAgents()
{
$params = $this->params;
/* $params = array(
"type" => 1,//0盘方,1客方,2反签,3独家,4合作方
"order_id" => 1,
);*/
if (!isset($params["type"]) || !isset($params["order_id"])) {
return $this->response("101", "请求参数错误");
}
try {
$list = $this->service_->searchBargainAgents($params["type"], $params["order_id"]);
if (count($list) > 0) {
return $this->response("200", "request success", $list);
} else {
return $this->response("200", "request null");
}
} catch (Exception $e) {
return $this->response("101", "request error,msg:" . $e);
}
}
/** /**
* 详情页 * 详情页
......
...@@ -5,6 +5,7 @@ namespace app\api_broker\service; ...@@ -5,6 +5,7 @@ namespace app\api_broker\service;
use app\api\untils\GeTuiUntils; use app\api\untils\GeTuiUntils;
use app\model\AAgents; use app\model\AAgents;
use app\model\FollowUpLogModel; use app\model\FollowUpLogModel;
use app\model\GHousesToAgents;
use app\model\OBargainModel; use app\model\OBargainModel;
use app\model\OMarchInModel; use app\model\OMarchInModel;
use app\model\OPayLogModel; use app\model\OPayLogModel;
...@@ -324,13 +325,13 @@ class OrderLogService ...@@ -324,13 +325,13 @@ class OrderLogService
if (count($bargainData) > 0) { if (count($bargainData) > 0) {
foreach ($bargainData as $k => $v) { foreach ($bargainData as $k => $v) {
$type = "无效"; $type = "无效";
if($v["user_status"] == 0){ if ($v["user_status"] == 0) {
$type = "求租"; $type = "求租";
}elseif($v["user_status"] == 1){ } elseif ($v["user_status"] == 1) {
$type = "已租"; $type = "已租";
} }
$v["step_name"] = "phone_follow_up"; $v["step_name"] = "phone_follow_up";
$v["step"] = "电话跟进:".$v['content']."【". $type ."】"; $v["step"] = "电话跟进:" . $v['content'] . "【" . $type . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
...@@ -341,14 +342,14 @@ class OrderLogService ...@@ -341,14 +342,14 @@ class OrderLogService
if (count($bargainData) > 0) { if (count($bargainData) > 0) {
foreach ($bargainData as $k => $v) { foreach ($bargainData as $k => $v) {
$type = "无效"; $type = "无效";
if($v["user_status"] == 0){ if ($v["user_status"] == 0) {
$type = "求租"; $type = "求租";
}elseif($v["user_status"] == 1){ } elseif ($v["user_status"] == 1) {
$type = "已租"; $type = "已租";
} }
$v["step_name"] = "follow_up"; $v["step_name"] = "follow_up";
$v["step"] = "跟进:".$v['content']."【". $type ."】"; $v["step"] = "跟进:" . $v['content'] . "【" . $type . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -356,7 +357,7 @@ class OrderLogService ...@@ -356,7 +357,7 @@ class OrderLogService
$field_report = "a.id,a.create_time,b.id as order_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name"; $field_report = "a.id,a.create_time,b.id as order_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$reportData = $oReportModel->selectReportByUserId($field_report, [ "user_id" => $user_id ]); $reportData = $oReportModel->selectReportByUserId($field_report, [ "user_id" => $user_id ]);
if (count($result) <= 0 && count($reportData) <= 0) { if (count($result) <= 0 && count($reportData) <= 0) {
return []; return [];
} }
...@@ -364,7 +365,7 @@ class OrderLogService ...@@ -364,7 +365,7 @@ class OrderLogService
//报备 //报备
foreach ($reportData as $k => $v) { foreach ($reportData as $k => $v) {
$v["step_name"] = "report"; $v["step_name"] = "report";
$v["step"] = "报备【".$v['house_title']."】"; $v["step"] = "报备【" . $v['house_title'] . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
$order_ids .= $v["order_id"] . ","; $order_ids .= $v["order_id"] . ",";
...@@ -374,8 +375,8 @@ class OrderLogService ...@@ -374,8 +375,8 @@ class OrderLogService
$report_ids = rtrim($report_ids, ","); $report_ids = rtrim($report_ids, ",");
} }
$orderParams["order_id"] = array( "in", $order_ids ); $orderParams["order_id"] = array( "in", $order_ids );
$orderParams["house_title"] = array( "like" , "%" . trim($search) . "%" ); $orderParams["house_title"] = array( "like", "%" . trim($search) . "%" );
$reportParams["report_id"] = array( "in", $report_ids ); $reportParams["report_id"] = array( "in", $report_ids );
...@@ -385,7 +386,7 @@ class OrderLogService ...@@ -385,7 +386,7 @@ class OrderLogService
if (count($marchInData) > 0) { if (count($marchInData) > 0) {
foreach ($marchInData as $k => $v) { foreach ($marchInData as $k => $v) {
$v["step_name"] = "march_in"; $v["step_name"] = "march_in";
$v["step"] = "进场【".$v['house_title']."】"; $v["step"] = "进场【" . $v['house_title'] . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -396,11 +397,11 @@ class OrderLogService ...@@ -396,11 +397,11 @@ class OrderLogService
if (count($followUpLogData) > 0) { if (count($followUpLogData) > 0) {
foreach ($followUpLogData as $k => $v) { foreach ($followUpLogData as $k => $v) {
$v["step_name"] = "follow_up_log"; $v["step_name"] = "follow_up_log";
$v["step"] = "跟进"; $v["step"] = "跟进";
$v = $this->convertFollowUp($v); $v = $this->convertFollowUp($v);
$v["explain_img"] = CHAT_IMG_URL . $v["explain_img"]; $v["explain_img"] = CHAT_IMG_URL . $v["explain_img"];
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -410,7 +411,7 @@ class OrderLogService ...@@ -410,7 +411,7 @@ class OrderLogService
if (count($payLogData) > 0) { if (count($payLogData) > 0) {
foreach ($payLogData as $k => $v) { foreach ($payLogData as $k => $v) {
$v["step_name"] = "pay_log"; $v["step_name"] = "pay_log";
$v["step"] = "收款【".$v['house_title']."】"; $v["step"] = "收款【" . $v['house_title'] . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -419,11 +420,11 @@ class OrderLogService ...@@ -419,11 +420,11 @@ class OrderLogService
$field_refund = "a.id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name"; $field_refund = "a.id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$refundData = $oRefundModel->getRefundByOrderId($field_refund, $orderParams); $refundData = $oRefundModel->getRefundByOrderId($field_refund, $orderParams);
if (count($refundData) > 0) { if (count($refundData) > 0) {
foreach ($refundData as $k => $v) { foreach ($refundData as $k => $v) {
$v["step_name"] = "refund"; $v["step_name"] = "refund";
$v["step"] = "退款【".$v['house_title']."】"; $v["step"] = "退款【" . $v['house_title'] . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -434,13 +435,12 @@ class OrderLogService ...@@ -434,13 +435,12 @@ class OrderLogService
if (count($bargainData) > 0) { if (count($bargainData) > 0) {
foreach ($bargainData as $k => $v) { foreach ($bargainData as $k => $v) {
$v["step_name"] = "bargain"; $v["step_name"] = "bargain";
$v["step"] = "成交报告【".$v['house_title']."】"; $v["step"] = "成交报告【" . $v['house_title'] . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
return $this->sortByTime($result); return $this->sortByTime($result);
} }
...@@ -690,4 +690,60 @@ class OrderLogService ...@@ -690,4 +690,60 @@ class OrderLogService
} }
} }
/**
* 成交报告客户搜索
* @param $type
* @param $order_id
* @return false|null|\PDOStatement|string|\think\Collection
*/
public function searchBargainAgents($type, $order_id)
{
$orderModel = new OrderModel();
$field = "a.id,a.order_no,a.house_id,a.house_title,b.id as report_id,b.user_id,c.user_nick,c.user_phone,
c.user_pic,c.sex";
$where_["order_id"] = $order_id;
$result = $orderModel->selectOrderDetail($field, $where_);
//dump($result);
if (count($result) <= 0) {
return null;
}
$houseAgents = new GHousesToAgents();
$field = "b.id,b.phone,b.name";
switch ($type) {//0盘方,1客方,2反签,3独家,4合作方
case 0:
$params["a.house_id"] = $result["house_id"];
$params["a.type"] = 2;
$params["b.status"] = 0;
$list = $houseAgents->getAgentsByHouseId($field, $params);
break;
case 1:
$userModel = new Users();
$params["a.id"] = $result["user_id"];
$params["b.status"] = 0;
$list = $userModel->getAgentByUserId($field, $params);
break;
case 2: //反签 == 报备人
$reportModel = new OReportModel();
$params["a.order_id"] = $result["id"];
$params["b.status"] = 0;
$list = $reportModel->getAgentByOrderId($field, $params);
break;
case 3:
$params["a.house_id"] = $result["house_id"];
$params["a.type"] = 3;
$params["b.status"] = 0;
$list = $houseAgents->getAgentsByHouseId($field, $params);
break;
case 4:
break;
default:
return null;
}
return $list;
}
} }
\ No newline at end of file
...@@ -161,8 +161,13 @@ class GHousesToAgents extends BaseModel ...@@ -161,8 +161,13 @@ class GHousesToAgents extends BaseModel
} }
public function getAgentsByHouseId($houseId){ public function getAgentsByHouseId($field,$params){
return Db::name($this->table)
->field($field)
->alias("a")
->join("a_agents b","a.agent_id = b.id","left")
->where($params)
->select();
} }
/** /**
......
...@@ -396,4 +396,13 @@ class OReportModel extends Model ...@@ -396,4 +396,13 @@ class OReportModel extends Model
$agent_data = $this->db->table('a_agents')->field('id,device_id')->where('id', $agent_id)->find(); $agent_data = $this->db->table('a_agents')->field('id,device_id')->where('id', $agent_id)->find();
return $agent_data; return $agent_data;
} }
public function getAgentByOrderId($field,$params){
return Db::name($this->table)
->field($field)
->alias("a")
->join("a_agents b","a.agent_id = b.id","left")
->where($params)
->select();
}
} }
\ No newline at end of file
...@@ -418,4 +418,13 @@ class Users extends Model ...@@ -418,4 +418,13 @@ class Users extends Model
->where($where) ->where($where)
->find(); ->find();
} }
public function getAgentByUserId($field,$params){
return Db::name($this->table)
->field($field)
->alias("a")
->join("a_agents b","a.agent_id=b.id","left")
->where($params)
->select();
}
} }
...@@ -369,6 +369,8 @@ Route::group('broker', [ ...@@ -369,6 +369,8 @@ Route::group('broker', [
'searchAgents' => ['api_broker/OrderLog/searchAgents', [ 'method' => 'get' ] ], 'searchAgents' => ['api_broker/OrderLog/searchAgents', [ 'method' => 'get' ] ],
'searchBargainList' => ['api_broker/OrderLog/searchBargainList', [ 'method' => 'get' ] ], 'searchBargainList' => ['api_broker/OrderLog/searchBargainList', [ 'method' => 'get' ] ],
'searchBargainAgents' => ['api_broker/OrderLog/searchBargainAgents', [ 'method' => 'get' ] ],
'appAgentAuth' => ['api_broker/Report/appAgentAuth', [ 'method' => 'get' ] ], 'appAgentAuth' => ['api_broker/Report/appAgentAuth', [ '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