Commit 6a0c43c1 authored by zw's avatar zw

pk

parent 210a48e5
<?php
namespace app\index;
use app\api\service\RankingListService;
namespace app\index\controller;
use app\index\extend\Basic;
use app\index\service\RankingListService;
use think\Request;
/**
......@@ -20,7 +21,13 @@ class RankingList extends Basic{
}
public function getRandKingList(){
$siteId = $this->siteId;
$this->service_->RankingList(0,$siteId);
$params = $this->params;
if(empty($params["position"]) || $params["position"] < 0){
return $this->response("101","请求参数错误");
}
$result = $this->service_->RankingList(0,"10001");
if(count($result["list"]) > 0){
return $this->response("200","success",$result);
}
}
}
\ No newline at end of file
<?php
namespace app\api\service;
namespace app\index\service;
use app\model\AAgents;
use app\model\TAgentTotalModel;
......@@ -28,21 +28,31 @@ class RankingListService
//todo 1.查询出此职称的经纪人 获取10月份某个职称的排行 职称 1店长 2经理 3主任 4顾问 0新人
//todo 2.根据上月的业绩排行获取本月业绩排行,
//todo 3.根据此职称的总经纪人数分组
$fields = "id,store_id,district_id";
$params["site_id"] = $siteId;
$params["position"] = $position;
$params["status"] = array("in", "0,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'));
$end_time = date("Y-m-d 23:59:59", strtotime(-date('d') . 'day'));
$params['b.total_time'] = array('between', array($begin_time, $end_time));
$resultArr = $this->agentModel->getAgentsListByPK($fields, $params);
if (count($resultArr) <= 0) {
return false;
}
$ids = "";
foreach ($resultArr as $item) {
$ids .= $item["id"] . ",";
}
$ids = rtrim($ids, ",");
//分组
$total = count($resultArr);
$total_page = ceil($total / 20);//加一了的
$this->agentTotalModel->getSortPerformance();
$residue = $total % 20;
if ($residue < 19) {
$total_page = $total_page - 1;
}
$result["list"] = $resultArr;
$result["total_page"] = $total_page;
$result["residue"] = $residue;
return $result;
}
}
\ No newline at end of file
......@@ -419,10 +419,14 @@ class AAgents extends BaseModel
*/
public function getAgentsListByPK( $field = "id",$params)
{
$params["district_id"] = array( 'not in', array( '13', '14', '15' ) );
$params["a.district_id"] = array( 'not in', array( '13', '14', '15' ) );
return Db::table($this->table)
->field($field)
->alias("a")
->join("t_agent_total b","a.id=b.agent_id","left")
->where($params)
->group("b.agent_id")
->order("performance desc")
->select();
}
......
......@@ -314,7 +314,14 @@ class TAgentTotalModel extends Model
}
public function getSortPerformance(){
public function getSortPerformance($field ,$params){
$data = $this->db_
->field($field)
->where($params)
->group("agent_id")
->order("performance desc")
->select();
echo $this->getLastSql();
return $data;
}
}
\ No newline at end of file
......@@ -349,6 +349,9 @@ Route::group('index', [
'inspectionRecordAll' => ['index/Report/inspectionRecordAll', ['method' => 'GET']], //全部约带看
'setSite' => ['index/auth/setSite', ['method' => 'GET|POST']], //设置角色站点
'getRandKingList' => ['index/RankingList/getRandKingList', ['method' => 'GET|POST']], //设置角色站点
]);
......
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