Commit 2f9a4292 authored by zw's avatar zw

全部带看记录搜索

parent a398dce9
...@@ -515,19 +515,33 @@ class OrderLog extends Basic ...@@ -515,19 +515,33 @@ class OrderLog extends Basic
public function searchOrder() public function searchOrder()
{ {
$params = $this->params; $params = $this->params;
/* $params = array( $params = array(
"type" => 1, //0.客户电话 1.客户姓名,去掉 2.报备人电话 3.报备人姓名 4.商铺名称 5.商铺地址 6客户编号 7商铺编号 "type" => 1, //0.客户电话 1.客户姓名,去掉 2.报备人电话 3.报备人姓名 4.商铺名称 5.商铺地址 6客户编号 7商铺编号
"agent_id" => 4022, "agent_id" => 4022,
"search_keyword" => "程" "is_all" => 1,//0自己的,1全部
);*/ "search_keyword" => "程",
"page_no"=>1,
"page_size"=>15
);
if (!isset($params["type"]) || !isset($params["agent_id"]) || empty($params["search_keyword"])) { if (!isset($params["type"]) || !isset($params["agent_id"]) || empty($params["search_keyword"])) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }
if(($params["type"] == 6 || $params["type"] == 7) && !preg_match("/^\d*$/",$params["search_keyword"])){ if(($params["type"] == 6 || $params["type"] == 7) && !preg_match("/^\d*$/",$params["search_keyword"])){
return $this->response("101", "客户编号或商铺编号错误"); return $this->response("101", "客户编号或商铺编号错误");
} }
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
try { try {
$result = $this->service_->getSearchOrder($params); $result = [];
if(isset($params["is_all"]) && $params["is_all"] == 1){
$result = $this->service_->getSearchOrderByAll($params,$pageNo,$pageSize);
}else{
$result = $this->service_->getSearchOrder($params,$pageNo,$pageSize);
}
if (count($result) > 0) { if (count($result) > 0) {
return $this->response("200", "request success", $result); return $this->response("200", "request success", $result);
} else { } else {
......
...@@ -931,11 +931,16 @@ class OrderLogService ...@@ -931,11 +931,16 @@ class OrderLogService
return $result; return $result;
} }
/** /**
* @param $params 1.客户姓名 2.报备人电话 3.报备人姓名 4.商铺名称 5.商铺地址 * @param $params 0.客户电话 1.客户姓名,去掉 2.报备人电话 3.报备人姓名 4.商铺名称 5.商铺地址 6客户编号 7商铺编号
* @return array|false|\PDOStatement|string|\think\Collection * @param $pageNo
* @param $pageSize
* @return mixed
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/ */
public function getSearchOrder($params) public function getSearchOrder($params,$pageNo,$pageSize)
{ {
$condition = $where_ = "1=1 "; $condition = $where_ = "1=1 ";
$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, $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,
...@@ -994,7 +999,76 @@ class OrderLogService ...@@ -994,7 +999,76 @@ class OrderLogService
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$result = $orderModel->searchOrder($field, $condition, $where_); $result = $orderModel->searchOrder($field, $condition, $where_,$pageNo,$pageSize);
$ids_str = "";
if (count($result) <= 0) {
return null;
} else {
foreach ($result as $k => $v) {
$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;
}
}
/**
* @param $params 1.客户姓名 2.报备人电话 3.报备人姓名 4.商铺名称 5.商铺地址
* @return mixed
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/
public function getSearchOrderByAll($params,$pageNo,$pageSize)
{
$condition = $where_ = "1=1 ";
$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 0:
$condition .= "and b.user_phone like '%" . trim($params['search_keyword']) . "%' ";
break;
case 1:
$condition .= "and b.user_name like '%" . trim($params['search_keyword']) . "%' ";
break;
case 2:
$condition .= "and b.report_agent_phone like '%" . trim($params['search_keyword']) . "%' ";
break;
case 3:
$condition .= "and b.report_agent_name like '%" . trim($params['search_keyword']) . "%' ";
break;
case 4:
$condition .= "and a.house_title like '%" . trim($params['search_keyword']) . "%' ";
break;
case 5:
//todo 列表没有显示商铺地址 和产品沟通暂时搁置
//$condition["c.house_title"] = array( 'like', "%" . trim($params['search_keyword']) . "%" );
break;
case 6://客户编号
$condition .= "and b.user_id = " . trim($params['search_keyword']);
break;
case 7://商铺编号
$condition .= "and a.house_id = " . trim($params['search_keyword']);
break;
default:
return ["code" => "101", "msg" => "搜索类型错误"];
}
$orderModel = new OrderModel();
$result = $orderModel->searchOrder($field, $condition, $where_,$pageNo,$pageSize);
$ids_str = ""; $ids_str = "";
if (count($result) <= 0) { if (count($result) <= 0) {
......
...@@ -115,9 +115,9 @@ class OrderModel extends Model ...@@ -115,9 +115,9 @@ class OrderModel extends Model
* @throws \think\db\exception\BindParamException * @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function searchOrder($field, $params, $where_) public function searchOrder($field, $params, $where_,$pageNo,$pageSize)
{ {
$start_index = ($pageNo - 1) * $pageSize;
$sql = "SELECT * FROM $sql = "SELECT * FROM
( (
( (
...@@ -139,7 +139,7 @@ class OrderModel extends Model ...@@ -139,7 +139,7 @@ class OrderModel extends Model
WHERE WHERE
$where_ $where_
) )
) AS aaa order by aaa.id desc"; ) AS aaa order by aaa.id desc LIMIT $start_index,$pageSize";
$result = $this->db_->query($sql); $result = $this->db_->query($sql);
return $result; return $result;
......
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