Commit 6c4f82c6 authored by clone's avatar clone

业绩模块

parent a24631ba
...@@ -57,16 +57,20 @@ class Performance extends Basic ...@@ -57,16 +57,20 @@ class Performance extends Basic
} }
/**
* 个人业绩
* @return \think\Response
*/
public function agentPerformanceBySearch() public function agentPerformanceBySearch()
{ {
$params = $this->params; $params = $this->params;
$params = array( /* $params = array(
"agent_id" => 1, "agent_id" => 1,
"start_time" => "2018-03-23", "start_time" => "2018-03-23",
"end_time" => "2018-03-23", "end_time" => "2018-03-23",
"is_case" => 2,//1经纪人 2案场 "is_case" => 2,//1经纪人 2案场
"house_id" => 22 "house_id" => 0
); );*/
if (!isset($params["agent_id"]) || !isset($params["start_time"]) || !isset($params["end_time"])) { if (!isset($params["agent_id"]) || !isset($params["start_time"]) || !isset($params["end_time"])) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }
...@@ -79,4 +83,28 @@ class Performance extends Basic ...@@ -79,4 +83,28 @@ class Performance extends Basic
return $this->response("200", "request success", $result); return $this->response("200", "request success", $result);
} }
public function orderNoLIst(){
$params = $this->params;
$params = array(
"agent_id" => 1,
"start_time" => "2018-03-23",
"end_time" => "2018-03-23",
"is_case" => 2,//1经纪人 2案场
"house_id" => 0,
"type" => 1 // 1带看 2进场 3收款 4成交报告
);
if (!isset($params["agent_id"]) || !isset($params["start_time"]) || !isset($params["end_time"]) || !isset($params["type"]) ) {
return $this->response("101", "请求参数错误");
}
$house_id = 0;
if (isset($params["house_id"])) {
$house_id = $params["house_id"];
}
$result = $this->service_->orderList($params["agent_id"], $params["start_time"], $params["end_time"],
$params["is_case"], $house_id , $params["type"]);
return $this->response("200", "request success", $result);
}
} }
...@@ -136,14 +136,22 @@ class PerformanceService ...@@ -136,14 +136,22 @@ class PerformanceService
} }
public function personagePerformance($agent_id, $start_time, $end_time, $is_case,$house_id) /**
* @param $agent_id
* @param $start_time
* @param $end_time
* @param $is_case
* @param $house_id
* @return array|mixed|null
*/
public function personagePerformance($agent_id, $start_time, $end_time, $is_case, $house_id)
{ {
$field = "agent_id,sum(look_at_num) as look_at_num,sum(march_in_num) as march_in_num , sum(paylog) as paylog , $field = "agent_id,sum(look_at_num) as look_at_num,sum(march_in_num) as march_in_num , sum(paylog) as paylog ,
sum(bargain_sum) as bargain_sum"; sum(bargain_sum) as bargain_sum";
$result = []; $result = [];
switch ($is_case){ switch ($is_case) {
case 1: case 1:
$now_date = date("Y-m-d", time()); $now_date = date("Y-m-d", time());
if ($start_time == $now_date && $end_time == $now_date) { if ($start_time == $now_date && $end_time == $now_date) {
...@@ -161,22 +169,70 @@ class PerformanceService ...@@ -161,22 +169,70 @@ class PerformanceService
} }
break; break;
case 2: //案场 case 2: //案场
if($house_id > 0){ // 如果有传楼盘id证明是筛选 $house_id_arr = [];
$condition["house_ids"] = $house_id;
}else{ if ($house_id > 0) { // 如果有传楼盘id证明是筛选
$vService = new VerifyService(); $condition["house_ids"] = $house_id;
$house_id_arr = $vService->getCaseHouseIdByAgentId($agent_id); } else {
$ids = ""; $vService = new VerifyService();
foreach ($house_id_arr as $item){ $house_id_arr = $vService->getCaseHouseIdByAgentId($agent_id);
$ids .= $item["houses_id"] .","; $ids = "";
foreach ($house_id_arr as $item) {
$ids .= $item["houses_id"] . ",";
}
$ids = rtrim($ids, ",");
$condition["house_ids"] = $ids;
}
$condition['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$result = $this->nowTimeSum($condition);
if (count($result) > 0 && $house_id == 0) {
$result["house_arr"] = $house_id_arr;
}
break;
}
if (count($result) > 0) {
return $result;
} else {
return null;
}
}
public function orderList($agent_id, $start_time, $end_time, $is_case, $house_id, $type)
{
$result = [];
switch ($is_case) {
case 1:
$params["agent_id"] = $agent_id;
$params['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$result = $this->nowTimeSum($params);
break;
case
2: //案场
$house_id_arr = [];
if ($house_id > 0) { // 如果有传楼盘id证明是筛选
$condition["house_ids"] = $house_id;
} else {
$vService = new VerifyService();
$house_id_arr = $vService->getCaseHouseIdByAgentId($agent_id);
$ids = "";
foreach ($house_id_arr as $item) {
$ids .= $item["houses_id"] . ",";
} }
$ids = rtrim($ids, ","); $ids = rtrim($ids, ",");
$condition["house_ids"] = $ids; $condition["house_ids"] = $ids;
} }
$condition['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $condition['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$result = $this->nowTimeSum($condition); $result = $this->nowTimeSum($condition);
if(count($result) > 0 ){ if (count($result) > 0 && $house_id == 0) {
$result["house_arr"] = $house_id_arr; $result["house_arr"] = $house_id_arr;
} }
break; break;
......
...@@ -152,7 +152,7 @@ class GHousesToAgents extends BaseModel ...@@ -152,7 +152,7 @@ class GHousesToAgents extends BaseModel
->where($params) ->where($params)
->select(); ->select();
echo Db::name($this->table)->getLastSql(); // echo Db::name($this->table)->getLastSql();
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