Commit 66166503 authored by clone's avatar clone

bug

parent 03edd457
...@@ -37,22 +37,21 @@ class Performance extends Basic ...@@ -37,22 +37,21 @@ 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" => 80, "agent_id" => 80,
"type" => 3, //1表示个人业绩排行 2门店 3区域 "type" => 3, //1表示个人业绩排行 2门店 3区域
"end_day" => "", "end_day" => "",
"start_day" =>"" "start_day" =>""
);*/ );*/
if (!isset($params["agent_id"]) || !isset($params["type"])) { if (!isset($params["agent_id"]) || !isset($params["type"])) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }
//默认排序一周 2018-07-18改为本月 //默认排序一周 2018-07-18改为本月
$end_day = !empty($params["end_day"]) ? $params["end_day"] : date("Y-m-d", strtotime("+1 day")); $end_day = !empty($params["end_day"]) ? $params["end_day"] : date("Y-m-d", time());
$start_day = !empty($params["start_day"]) ? $params["start_day"] : date("Y-m-01", time()); $start_day = !empty($params["start_day"]) ? $params["start_day"] : date("Y-m-01", time());
$list = $this->service_->totalAgent($params["agent_id"], $params["type"], $start_day, $end_day);
$list = $this->service_->totalAgent($params["agent_id"], $params["type"], $end_day, $start_day);
if (count($list) > 0) { if (count($list) > 0) {
$result["list"] = $list; $result["list"] = $list;
$result["start_time"] = $start_day; $result["start_time"] = $start_day;
...@@ -71,13 +70,13 @@ class Performance extends Basic ...@@ -71,13 +70,13 @@ 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" => 9, "agent_id" => 9,
"start_time" => "2018-06-20", "start_time" => "2018-06-20",
"end_time" => "2018-06-20", "end_time" => "2018-06-20",
"is_case" => 1,//1经纪人 2案场 "is_case" => 1,//1经纪人 2案场
"house_id" => 0 "house_id" => 0
);*/ );*/
if (!isset($params["agent_id"]) || !isset($params["start_time"]) || !isset($params["end_time"]) || !isset($params["is_case"])) { if (!isset($params["agent_id"]) || !isset($params["start_time"]) || !isset($params["end_time"]) || !isset($params["is_case"])) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }
...@@ -103,11 +102,11 @@ class Performance extends Basic ...@@ -103,11 +102,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" => 5739, "agent_id" => 5739,
"start_time" => "2018-06-25", "start_time" => "2018-06-25",
"end_time" => "2018-06-25", "end_time" => "2018-06-25",
);*/ );*/
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"]);
return $this->response("200", "request success", $result); return $this->response("200", "request success", $result);
......
...@@ -35,16 +35,16 @@ class PerformanceService ...@@ -35,16 +35,16 @@ class PerformanceService
public function __construct() public function __construct()
{ {
$this->totalModel = new TAgentTotalModel(); $this->totalModel = new TAgentTotalModel();
$this->agentModel = new AAgents(); $this->agentModel = new AAgents();
$this->houseModel = new GHouses(); $this->houseModel = new GHouses();
$this->userModel = new Users(); $this->userModel = new Users();
$this->bargainModel = new OBargainModel(); $this->bargainModel = new OBargainModel();
$this->reportModel = new OReportModel(); $this->reportModel = new OReportModel();
$this->marchInModel = new OMarchInModel(); $this->marchInModel = new OMarchInModel();
$this->payLogModel = new OPayLogModel(); $this->payLogModel = new OPayLogModel();
$this->gHousesImgModel = new GHousesImgs(); $this->gHousesImgModel = new GHousesImgs();
$this->superviseModel = new ASuperviseModel(); $this->superviseModel = new ASuperviseModel();
} }
/** /**
...@@ -65,8 +65,8 @@ class PerformanceService ...@@ -65,8 +65,8 @@ class PerformanceService
$agent_info = $agent_info[0]; $agent_info = $agent_info[0];
} }
$where_ = []; $where_ = [];
$where_['a.create_time'] = array( 'between', array( $end_day, $yesterday ) ); $where_['a.create_time'] = array( 'between', array( $yesterday . " 00:00:00", $end_day . " 23:59:59" ) );
$field = "b.id as agent_id,b.store_id,b.district_id,sum(a.scale_fee) as performance_total"; $field = "b.id as agent_id,b.store_id,b.district_id,sum(a.scale_fee) as performance_total";
$order = "performance_total desc"; $order = "performance_total desc";
...@@ -126,7 +126,6 @@ class PerformanceService ...@@ -126,7 +126,6 @@ class PerformanceService
} }
/** /**
* 个人业绩 * 个人业绩
* @param $agent_id * @param $agent_id
...@@ -141,11 +140,11 @@ class PerformanceService ...@@ -141,11 +140,11 @@ class PerformanceService
$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) {*/
$params["agent_id"] = $agent_id; $params["agent_id"] = $agent_id;
$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" ) );
$result = $this->nowTimeSum($params, 1); $result = $this->nowTimeSum($params, 1);
/*} else { /*} else {
$field = "agent_id,sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num, $field = "agent_id,sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,
sum(performance) as performance,sum(official_receipts) as official_receipts,sum(look_at_num) as look_at_num, sum(performance) as performance,sum(official_receipts) as official_receipts,sum(look_at_num) as look_at_num,
...@@ -339,29 +338,29 @@ class PerformanceService ...@@ -339,29 +338,29 @@ class PerformanceService
//$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) {
$verify = new VerifyService(); $verify = new VerifyService();
$agent_ids = $verify->getAgentsByAgentId($agent_id); $agent_ids = $verify->getAgentsByAgentId($agent_id);
$where_["agent_id"] = array( "in", $agent_ids ); $where_["agent_id"] = array( "in", $agent_ids );
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$list = $this->sumDistrictPerformance($where_); $list = $this->sumDistrictPerformance($where_);
// dump($list);exit; // dump($list);exit;
/* } else { /* } else {
$field = "sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num, $field = "sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,
sum(performance) as performance,sum(official_receipts) as official_receipts,sum(look_at_num) as look_at_num, sum(performance) as performance,sum(official_receipts) as official_receipts,sum(look_at_num) as look_at_num,
sum(march_in_num) as march_in_num,sum(paylog) as paylog,sum(supervision_num) as supervision_num"; sum(march_in_num) as march_in_num,sum(paylog) as paylog,sum(supervision_num) as supervision_num";
$params['total_time'] = array( 'between', array( $start_time, $end_time ) ); $params['total_time'] = array( 'between', array( $start_time, $end_time ) );
$list = $this->totalModel->getTotalByAgentId($field, $params, $type, ""); $list = $this->totalModel->getTotalByAgentId($field, $params, $type, "");
// dump($list); // dump($list);
if (count($list) > 0) { if (count($list) > 0) {
$list = $list[0]; $list = $list[0];
} }
}*/ }*/
if (count($list) > 0) { if (count($list) > 0) {
return $list; return $list;
...@@ -392,68 +391,68 @@ class PerformanceService ...@@ -392,68 +391,68 @@ class PerformanceService
$params["agent_id"] = array( "in", $agent_ids ); $params["agent_id"] = array( "in", $agent_ids );
$list = []; $list = [];
/* $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) {*/
$param["id"] = array( "in", $agent_ids ); $param["id"] = array( "in", $agent_ids );
// 1.获取所有经纪人 // 1.获取所有经纪人
$field = "id as agent_id,store_id"; $field = "id as agent_id,store_id";
$group = ""; $group = "";
if ($is_store == 2) {
$group = "store_id";
}
$list = $this->agentModel->getAgentsList($field, $param, $group);
//dump($list);
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) { if ($is_store == 2) {
$group = "store_id"; $agent_ids = $verify->getAgentsByAgentId($item["agent_id"]);
$totalParams['agent_id'] = array( "in", $agent_ids );
} }
$list = $this->agentModel->getAgentsList($field, $param, $group); //房源
//dump($list); $addHouseNum = $this->houseModel->getAddHouseNum($totalParams);
foreach ($list as $key => $item) { $list[$key]["add_house_num"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
$totalParams['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); //客源
$totalParams['agent_id'] = $item["agent_id"]; $addUserNum = $this->userModel->getAddUserNum($totalParams);
if ($is_store == 2) { $list[$key]["add_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
$agent_ids = $verify->getAgentsByAgentId($item["agent_id"]); //进场
$totalParams['agent_id'] = array( "in", $agent_ids );
} $addMarchInNum = $this->marchInModel->getAddMarchInNum($totalParams);
//房源 $list[$key]["march_in_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
$addHouseNum = $this->houseModel->getAddHouseNum($totalParams); //业绩
$list[$key]["add_house_num"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0; $performanceSum = $this->bargainModel->getAddBargainNum($totalParams, 1);//1表示业绩 2表示实收
//客源 $list[$key]["performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$addUserNum = $this->userModel->getAddUserNum($totalParams); //实收
$list[$key]["add_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0; $receivedSum = $this->bargainModel->getAddBargainNum($totalParams, 2);//1表示业绩 2表示实收
//进场 $list[$key]["official_receipts"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
$addMarchInNum = $this->marchInModel->getAddMarchInNum($totalParams); $sum = $list[$key]["add_house_num"] + $list[$key]["add_user_num"] + $list[$key]["march_in_num"] +
$list[$key]["march_in_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0; $list[$key]["performance"]
//业绩 + $list[$key]["official_receipts"];
$performanceSum = $this->bargainModel->getAddBargainNum($totalParams, 1);//1表示业绩 2表示实收 if ($sum <= 0) {
$list[$key]["performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; unset($list[$key]);
//实收
$receivedSum = $this->bargainModel->getAddBargainNum($totalParams, 2);//1表示业绩 2表示实收
$list[$key]["official_receipts"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
$sum = $list[$key]["add_house_num"] + $list[$key]["add_user_num"] + $list[$key]["march_in_num"] +
$list[$key]["performance"]
+ $list[$key]["official_receipts"];
if ($sum <= 0) {
unset($list[$key]);
}
} }
}
/* } else { /* } else {
$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";
$params['total_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $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, $is_store, $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) {
if($is_store == 2){ if ($is_store == 2) {
$fields = "a.name,b.store_name"; $fields = "a.name,b.store_name";
}else{ } else {
$fields = "c.name,b.store_name"; $fields = "c.name,b.store_name";
} }
$where_["a.store_id"] = $item["store_id"]; $where_["a.store_id"] = $item["store_id"];
...@@ -512,7 +511,7 @@ class PerformanceService ...@@ -512,7 +511,7 @@ class PerformanceService
//dump($payLogNum); //dump($payLogNum);
// 监督 // 监督
$result["supervision_num"] = $this->superviseModel->getSuperviseListCount( $params); $result["supervision_num"] = $this->superviseModel->getSuperviseListCount($params);
return $result; return $result;
} }
...@@ -741,7 +740,7 @@ class PerformanceService ...@@ -741,7 +740,7 @@ class PerformanceService
$where_["agent_id"] = $params["agent_id"]; $where_["agent_id"] = $params["agent_id"];
$where_["create_time"] = $params["create_time"]; $where_["create_time"] = $params["create_time"];
$receivedList = $this->bargainModel->getReceivedList($page_no, $page_size, $field, $where_); $receivedList = $this->bargainModel->getReceivedList($page_no, $page_size, $field, $where_);
return [ "code" => 200, "date" => $receivedList ]; return [ "code" => 200, "date" => $receivedList ];
} }
......
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