Commit 4dfc4e19 authored by zw's avatar zw

订单搜索

parent f57b8d50
...@@ -256,6 +256,28 @@ class OrderLog extends Basic ...@@ -256,6 +256,28 @@ class OrderLog extends Basic
} else { } else {
return $this->response("101", "request error"); return $this->response("101", "request error");
} }
}
public function searchOrder(){
$params = $this->params;
/* $params = array(
"type" => 3, //1.客户姓名 2.报备人电话 3.报备人姓名 4.商铺名称 5.商铺地址
"agent_id"=>1,
"search_keyword" => "123"
);*/
if(!isset($params["type"]) || !isset($params["agent_id"]) || !isset($params["search_keyword"])){
return $this->response("101","请求参数错误");
}
try{
$result = $this->service_->getSearchOrder($params);
if(count($result) > 0){
return $this->response("200","request success",$result);
}else{
return $this->response("200","request null");
}
}catch (Exception $e){
return $this->response("101","request error,msg:".$e);
}
} }
......
...@@ -256,5 +256,61 @@ class OrderLogService ...@@ -256,5 +256,61 @@ class OrderLogService
return $result; return $result;
} }
/**
* @param $params 1.客户姓名 2.报备人电话 3.报备人姓名 4.商铺名称 5.商铺地址
* @return array|false|\PDOStatement|string|\think\Collection
*/
public function getSearchOrder($params){
$condition = [];
$field = "a.id,a.order_no,a.f_id,a.house_id,a.house_title,b.report_agent_id,b.report_agent_phone,b.report_agent_name,
b.user_id,b.user_phone,b.user_name,b.predict_see_time";
switch ((int)$params["type"]){
case 1:
$condition["b.user_name"] = array( 'like', "%" . trim($params['search_keyword']) . "%" );
break;
case 2:
$condition["b.report_agent_phone"] = array( 'like', "%" . trim($params['search_keyword']) . "%" );
break;
case 3:
$condition["b.report_agent_name"] = array( 'like', "%" . trim($params['search_keyword']) . "%" );
break;
case 4:
$condition["b.house_title"] = array( 'like', "%" . trim($params['search_keyword']) . "%" );
break;
case 5:
// $condition["b.house_title"] = array( 'like', "%" . trim($params['search_keyword']) . "%" );
break;
default:
return ["code"=>"101","msg"=>"搜索类型错误"];
}
if(isset($params["agent_id"])){
$condition["b.report_agent_id"] = array("eq",$params["agent_id"]);
}
$orderModel = new OrderModel();
$result = $orderModel->searchOrder($field,$condition);
$ids_str = "";
foreach ($result as $k=>$v){
$result[$k]["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/','$1****$2',$v["user_phone"]);
$ids_str .= $v["id"] .",";
}
$ids_str = rtrim($ids_str, ",");
$reportService = new ReportService();
$sign_arr = $reportService->orderSign($ids_str);
foreach ($result as $k=>$v){
foreach ($sign_arr as $value){
if($v["id"] == $value["order_id"]){
$result[$k]["sign"] .= $reportService->signTitle($value["type"]).",";
}
}
}
return $result;
}
} }
\ No newline at end of file
...@@ -117,7 +117,7 @@ class ReportService ...@@ -117,7 +117,7 @@ class ReportService
return $this->orderModel->selectSign($ids_str); return $this->orderModel->selectSign($ids_str);
} }
private function signTitle($type){ public function signTitle($type){
switch ($type){ switch ($type){
case 2: case 2:
return "进场"; return "进场";
......
...@@ -91,4 +91,20 @@ class OrderModel extends Model ...@@ -91,4 +91,20 @@ class OrderModel extends Model
->select(); ->select();
} }
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function searchOrder($field,$params){
return $this->db_
->field($field)
->alias("a")
->join("o_report b","a.f_id = b.id","left")
->where($params)
->select();
}
} }
\ No newline at end of file
...@@ -272,6 +272,7 @@ Route::group('broker', [ ...@@ -272,6 +272,7 @@ Route::group('broker', [
'reportList' => ['api_broker/Report/reportList', [ 'method' => 'get' ] ], 'reportList' => ['api_broker/Report/reportList', [ 'method' => 'get' ] ],
'orderDetail' => ['api_broker/OrderLog/orderDetail', [ 'method' => 'get|post' ] ], 'orderDetail' => ['api_broker/OrderLog/orderDetail', [ 'method' => 'get|post' ] ],
'selectReportAll' => ['api_broker/OrderLog/selectReportAll', [ 'method' => 'get|post' ] ], 'selectReportAll' => ['api_broker/OrderLog/selectReportAll', [ 'method' => 'get|post' ] ],
'searchOrder' => ['api_broker/OrderLog/searchOrder', [ 'method' => 'get|post' ] ],
'token' => ['api_broker/broker/token', [ 'method' => 'get' ] ], 'token' => ['api_broker/broker/token', [ '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