Commit 01229586 authored by zw's avatar zw

pk

parent 91d56a2e
...@@ -22,10 +22,12 @@ class RankingList extends Basic{ ...@@ -22,10 +22,12 @@ class RankingList extends Basic{
public function getRandKingList(){ public function getRandKingList(){
$params = $this->params; $params = $this->params;
if(empty($params["position"]) || $params["position"] < 0 || $params["position"] > 5){ $params["position"] = 1;
$this->siteId = 10001;
if(!isset($params["position"]) || $params["position"] < 0 || $params["position"] > 5){
return $this->response("101","请求参数错误"); return $this->response("101","请求参数错误");
} }
$result = $this->service_->RankingList(0,"10001"); $result = $this->service_->RankingList( $params["position"],$this->siteId);
if(count($result) > 0){ if(count($result) > 0){
return $this->response("200","success",$result); return $this->response("200","success",$result);
} }
......
...@@ -16,11 +16,15 @@ class RankingListService ...@@ -16,11 +16,15 @@ class RankingListService
{ {
private $agentModel; private $agentModel;
private $agentTotalModel; private $agentTotalModel;
private $crewNum;
private $crewNumMax;
public function __construct() public function __construct()
{ {
$this->agentModel = new AAgents(); $this->agentModel = new AAgents();
$this->agentTotalModel = new TAgentTotalModel(); $this->agentTotalModel = new TAgentTotalModel();
$this->crewNum = 20;
$this->crewNumMax= 25;
} }
public function RankingList($position, $siteId) public function RankingList($position, $siteId)
...@@ -41,25 +45,40 @@ class RankingListService ...@@ -41,25 +45,40 @@ class RankingListService
} }
//分组 //分组
$total = count($resultArr); $total = count($resultArr);
$total_page = floor($total / 20);//加一了的 $total_page = floor($total / $this->crewNum);
$residue = $total % 20; $residue = $total % $this->crewNum;
if ($residue < 19) { $full = $total_page * ($this->crewNumMax-$this->crewNum);
$total_page = $total_page - 1; $x = $this->crewNum;
$y = $total_page;
if ($full < $residue) {
$y = $y + 1;
}else{
$x = ceil($residue/$total_page) + $this->crewNum;
} }
$result = []; $result = [];
$i = 0; $i = 0;
$k = 0; $k = 0;
foreach ($resultArr as $key => $item) { foreach ($resultArr as $key=>$item) {
$result[$i][$k++]= $item; echo "----";
if($i > ($total_page - $residue)){ echo $key;
if($k == 21){ dump($item);
echo "----";
/* if($y == $total_page){
if(($k == $x-1) && $i < (($residue % $total_page)-1) ){
$k = 0;
$i++;
}elseif($k == $x ){
$k = 0; $k = 0;
$i++; $i++;
} }
}elseif($k == 20){ }else{*/
$k = 0; if($k == $x ){
$i++; $k = 0;
$i++;
// }
} }
$result[$i][$k++] = $item;
} }
//循环分组后的数组,查询出各组本月业绩排行 //循环分组后的数组,查询出各组本月业绩排行
...@@ -81,6 +100,7 @@ class RankingListService ...@@ -81,6 +100,7 @@ class RankingListService
$sort_arr = $this->getSort($param_now); $sort_arr = $this->getSort($param_now);
$result[$index]= $sort_arr; $result[$index]= $sort_arr;
} }
dump($result);
return $result; return $result;
...@@ -91,4 +111,5 @@ class RankingListService ...@@ -91,4 +111,5 @@ class RankingListService
return $this->agentModel->getAgentsListByPK($fields, $params); return $this->agentModel->getAgentsListByPK($fields, $params);
} }
} }
\ 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