Commit 2afbe5b7 authored by zw's avatar zw

pk

parent 611808d4
...@@ -22,9 +22,9 @@ class RankingList extends Basic{ ...@@ -22,9 +22,9 @@ class RankingList extends Basic{
public function getRandKingList(){ public function getRandKingList(){
$params = $this->params; $params = $this->params;
if(empty($params["position"]) || $params["position"] < 0){ /* if(empty($params["position"]) || $params["position"] < 0){
return $this->response("101","请求参数错误"); return $this->response("101","请求参数错误");
} }*/
$result = $this->service_->RankingList(0,"10001"); $result = $this->service_->RankingList(0,"10001");
if(count($result["list"]) > 0){ if(count($result["list"]) > 0){
return $this->response("200","success",$result); return $this->response("200","success",$result);
......
...@@ -28,31 +28,67 @@ class RankingListService ...@@ -28,31 +28,67 @@ class RankingListService
//todo 1.查询出此职称的经纪人 获取10月份某个职称的排行 职称 1店长 2经理 3主任 4顾问 0新人 //todo 1.查询出此职称的经纪人 获取10月份某个职称的排行 职称 1店长 2经理 3主任 4顾问 0新人
//todo 2.根据上月的业绩排行获取本月业绩排行, //todo 2.根据上月的业绩排行获取本月业绩排行,
//todo 3.根据此职称的总经纪人数分组 //todo 3.根据此职称的总经纪人数分组
$fields = "a.id,a.store_id,a.district_id,SUM(b.performance) as performance";
$params["a.site_id"] = $siteId;
$params["a.position"] = $position;
$params["a.status"] = array("in", "0,3");
$begin_time = date('Y-m-01 00:00:00', strtotime('-1 month')); $begin_time = date('Y-m-01 00:00:00', strtotime('-1 month'));
$end_time = date("Y-m-d 23:59:59", strtotime(-date('d') . 'day')); $end_time = date("Y-m-d 23:59:59", strtotime(-date('d') . 'day'));
$params["a.site_id"] = $siteId;
$params["a.position"] = $position;
$params["a.status"] = array("in", "0,3");
$params['b.total_time'] = array('between', array($begin_time, $end_time)); $params['b.total_time'] = array('between', array($begin_time, $end_time));
$resultArr = $this->getSort($params);
$resultArr = $this->agentModel->getAgentsListByPK($fields, $params);
if (count($resultArr) <= 0) { if (count($resultArr) <= 0) {
return false; return false;
} }
//分组 //分组
$total = count($resultArr); $total = count($resultArr);
$total_page = ceil($total / 20);//加一了的 $total_page = floor($total / 20);//加一了的
$residue = $total % 20; $residue = $total % 20;
if ($residue < 19) { if ($residue < 19) {
$total_page = $total_page - 1; $total_page = $total_page - 1;
} }
$result["list"] = $resultArr; $result = [];
$result["total_page"] = $total_page; $i = 0;
$result["residue"] = $residue; $k = 0;
return $result; foreach ($resultArr as $key => $item) {
$result[$i][$k++]= $item;
if($i > ($total_page - $residue)){
if($k == 21){
$k = 0;
$i++;
}
}elseif($k == 20){
$k = 0;
$i++;
}
}
//循环分组后的数组,查询出各组本月业绩排行
//本月
$begin_time = date('Y-m-01', time());
$end_time = date("Y-m-01", strtotime('+1 month'));
$param_now["a.site_id"] = $siteId;
$param_now["a.position"] = $position;
$param_now["a.status"] = array("in", "0,3");
$param_now['b.total_time'] = array('between', array($begin_time, $end_time));
foreach ($result as $index=>$item){
$ids = "";
foreach ($item as $key=>$value){
$ids .= $value["id"] . ",";
}
$ids = rtrim($ids, ",");
$param_now["a.id"] = array("in",$ids);
$sort_arr = $this->getSort($param_now);
$result[$index]= $sort_arr;
}
dump($result);
} }
public function getSort($params){
$fields = "a.id,a.store_id,a.district_id,SUM(b.performance) as performance";
return $this->agentModel->getAgentsListByPK($fields, $params);
}
} }
\ No newline at end of file
...@@ -321,7 +321,7 @@ class TAgentTotalModel extends Model ...@@ -321,7 +321,7 @@ class TAgentTotalModel extends Model
->group("agent_id") ->group("agent_id")
->order("performance desc") ->order("performance desc")
->select(); ->select();
echo $this->getLastSql(); //echo $this->getLastSql();
return $data; return $data;
} }
} }
\ 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