Commit 13f52839 authored by clone's avatar clone

bug

parent fb8a933e
...@@ -70,9 +70,9 @@ class Performance extends Basic ...@@ -70,9 +70,9 @@ class Performance extends Basic
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
"agent_id" => 10013, "agent_id" => 4,
"start_time" => "2018-04-11", "start_time" => "2018-04-12",
"end_time" => "2018-04-11", "end_time" => "2018-04-12",
"is_case" => 2,//1经纪人 2案场 "is_case" => 2,//1经纪人 2案场
"house_id" => 0 "house_id" => 0
);*/ );*/
...@@ -101,11 +101,11 @@ class Performance extends Basic ...@@ -101,11 +101,11 @@ class Performance extends Basic
{ {
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$params = $this->params; $params = $this->params;
/* $params = array( $params = array(
"agent_id" => 10014, "agent_id" => 4,
"start_time" => "2018-04-11", "start_time" => "2018-04-12",
"end_time" => "2018-04-11", "end_time" => "2018-04-12",
);*/ );
try { try {
$result = $this->service_->storePerformance($params["agent_id"], $params["start_time"], $params["end_time"]); $result = $this->service_->storePerformance($params["agent_id"], $params["start_time"], $params["end_time"]);
...@@ -124,7 +124,7 @@ class Performance extends Basic ...@@ -124,7 +124,7 @@ class Performance extends Basic
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
"agent_id" => 10013, "agent_id" => 4,
"start_time" => "2018-03-13", "start_time" => "2018-03-13",
"end_time" => "2018-04-10", "end_time" => "2018-04-10",
"is_case" => 2,//1经纪人 2案场 "is_case" => 2,//1经纪人 2案场
...@@ -157,16 +157,17 @@ class Performance extends Basic ...@@ -157,16 +157,17 @@ class Performance extends Basic
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
"agent_id" => 1, "agent_id" => 6,
"start_time" => "2018-03-10", "is_store" => 2,//1经纪人排行 2门店
"end_time" => "2018-03-23", "start_time" => "2018-04-12",
"end_time" => "2018-04-12",
);*/ );*/
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", "请求参数错误");
} }
try { try {
$result = $this->service_->storeSortByDistrictId($params["agent_id"], $params["start_time"], $params["end_time"]); $result = $this->service_->storeSortByDistrictId($params["agent_id"],$params["is_store"] , $params["start_time"], $params["end_time"]);
return $this->response("200", "request success", $result); return $this->response("200", "request success", $result);
} catch (Exception $exception) { } catch (Exception $exception) {
......
...@@ -183,7 +183,7 @@ class PerformanceService ...@@ -183,7 +183,7 @@ class PerformanceService
$ids .= $item["houses_id"] . ","; $ids .= $item["houses_id"] . ",";
} }
$ids = rtrim($ids, ","); $ids = rtrim($ids, ",");
if(!$ids){ //代表没有案场 if (!$ids) { //代表没有案场
return null; return null;
} }
$condition["house_ids"] = $ids; $condition["house_ids"] = $ids;
...@@ -233,7 +233,7 @@ class PerformanceService ...@@ -233,7 +233,7 @@ class PerformanceService
$ids .= $item["houses_id"] . ","; $ids .= $item["houses_id"] . ",";
} }
$ids = rtrim($ids, ","); $ids = rtrim($ids, ",");
if(!$ids){ //代表没有案场 if (!$ids) { //代表没有案场
return null; return null;
} }
$params["house_ids"] = $ids; $params["house_ids"] = $ids;
...@@ -328,7 +328,7 @@ class PerformanceService ...@@ -328,7 +328,7 @@ class PerformanceService
$verify = new VerifyService(); $verify = new VerifyService();
$agent_ids = $verify->getAgentsByAgentId($agent_id); $agent_ids = $verify->getAgentsByAgentId($agent_id);
$params["agent_id"] = array("in",$agent_ids); $params["agent_id"] = array( "in", $agent_ids );
$params['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $params['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$list = $this->sumDistrictPerformance($params); $list = $this->sumDistrictPerformance($params);
...@@ -354,30 +354,74 @@ class PerformanceService ...@@ -354,30 +354,74 @@ class PerformanceService
} }
public function storeSortByDistrictId($agent_id, $start_time, $end_time) /**
* @param $agent_id
* @param $is_store
* @param $start_time
* @param $end_time
* @return array|false|null|\PDOStatement|string|\think\Collection
*/
public function storeSortByDistrictId($agent_id, $is_store, $start_time, $end_time)
{ {
$result = $this->agentModel->searchAgentsByKeyword("id,store_id,district_id,level", [ "id" => $agent_id ]); $result = $this->agentModel->searchAgentsByKeyword("id,store_id,district_id,level", [ "id" => $agent_id ]);
dump($result);
if (count($result) <= 0) { if (count($result) <= 0) {
return null; return null;
} }
$field = "store_id,agent_id,sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,sum(march_in_num) as march_in_num, $field = "store_id,agent_id,sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,sum(march_in_num) as march_in_num,
sum(performance) as performance,sum(official_receipts) as official_receipts"; sum(performance) as performance,sum(official_receipts) as official_receipts";
$list = [];
$type = 0; $now_date = date("Y-m-d", time());
if ($result[0]["level"] == 20) {
$type = 1; if ($start_time == $now_date && $end_time == $now_date) {
$params["store_id"] = $result[0]["store_id"];
} elseif ($result[0]["level"] == 30 || $result[0]["level"] == 40) { $verify = new VerifyService();
$type = 2; $agent_ids = $verify->getAgentsByAgentId($agent_id);
$params["district_id"] = $result[0]["district_id"]; $params["id"] = array( "in", $agent_ids );
//todo 1.获取所有经纪人
$field = "id as agent_id,store_id";
$group = "";
if ($is_store == 2) {
$group = "store_id";
}
$list = $this->agentModel->getAgentsList($field, $params, $group);
foreach ($list as $key => $item) {
$totalParams['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$totalParams['agent_id'] = $item["agent_id"];
if ($is_store == 2) {
$agent_ids = $verify->getAgentsByAgentId($item["agent_id"]);
$totalParams['agent_id'] = array( "in", $agent_ids );
}
//房源
$addHouseNum = $this->houseModel->getAddHouseNum($totalParams);
$list[$key]["add_house_num"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
//客源
$addUserNum = $this->userModel->getAddUserNum($totalParams);
$list[$key]["add_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
//进场
$addMarchInNum = $this->marchInModel->getAddMarchInNum($totalParams);
$list[$key]["march_in_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
//业绩
$performanceSum = $this->bargainModel->getAddBargainNum($totalParams, 1);//1表示业绩 2表示实收
$list[$key]["performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
//实收
$receivedSum = $this->bargainModel->getAddBargainNum($totalParams, 2);//1表示业绩 2表示实收
$list[$key]["official_receipts"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
} }
$params['total_time'] = array( 'between', array( $start_time, $end_time ) );
} else {
$params['total_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$order = "total_time desc"; $order = "total_time desc";
$list = $this->totalModel->getTotalByAgentId($field, $params, $type, $order); $list = $this->totalModel->getTotalByAgentId($field, $params, $is_store, $order);
}
if (count($list) > 0) { if (count($list) > 0) {
foreach ($list as $key => $item) { foreach ($list as $key => $item) {
$fields = "a.name,b.store_name"; $fields = "a.name,b.store_name";
......
...@@ -765,4 +765,20 @@ class AAgents extends BaseModel ...@@ -765,4 +765,20 @@ class AAgents extends BaseModel
->page($pageNo) ->page($pageNo)
->select(); ->select();
} }
public function getAgentsList($field,$params,$group){
$where_ = [];
if($group == "store_id"){
$where_['level'] = array("in",[20,40]);
}
$result = Db::name($this->table)
->field($field)
->where($params)
->where($where_)
->group($group)
->select();
return $result;
}
} }
\ No newline at end of file
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