Commit 01229586 authored by zw's avatar zw

pk

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