Commit 655e3cee authored by zw's avatar zw

cache

parent 620be3c0
<?php
namespace app\app_broker\controller;
use app\api_broker\extend\Basic;
use app\index\service\RankingListService;
use app\model\AAgents;
use think\Request;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/11/12
* Time : 2:04 PM
* Intro: pk榜
*/
class RankingList extends Basic{
private $service_;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->service_ = new RankingListService();
}
/**
* 查询分区业绩pk by 个人
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getRandKingListByAgentId(){
header('Access-Control-Allow-Origin:*');
$params = $this->params;
/*$params["agent_id"] = 1;
$this->siteId = 10001;*/
if(!isset($params["agent_id"])){
return $this->response("101","请求参数错误");
}
$agentModel = new AAgents();
$agent_info = $agentModel->getAgentInfo("id,position",$params["agent_id"]);
if($agent_info["position"] == 5){
return $this->response("101","该经纪人没有分配职称");
}
$result = $this->service_->RankingList( $agent_info["position"],$this->siteId);
$agent_id = $params["agent_id"];
$data = [];
foreach ($result as $key=>$value){
$is_exits = false;
foreach ($value as $item){
if($item["id"] == $agent_id){
$is_exits = true;
}
}
if(!$is_exits){
unset($result[$key]);
}else{
$data["list"] = $value;
$data["grade"] = $key;
}
}
$data["position"] = $agent_info["position"];
if(count($result) > 0){
return $this->response("200","success",$data);
}
return $this->response("200","null");
}
/**
* 首页团队排名
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getStoreRandKingListByAgentId(){
header('Access-Control-Allow-Origin:*');
$params = $this->params;
/*$params["agent_id"] = 1;
$this->siteId = 10001;*/
if(!isset($params["agent_id"])){
return $this->response("101","请求参数错误");
}
$agentModel = new AAgents();
$agent_info = $agentModel->getAgentInfo("id,position,store_id",$params["agent_id"]);
if(count($agent_info) <= 0){
return $this->response("101","该经纪人不存在");
}
$result = $this->service_->StoreRankingList( $this->siteId);
$store_id = $agent_info["store_id"];
$data = [];
foreach ($result as $key=>$value){
$is_exits = false;
foreach ($value as $item){
if($item["id"] == $store_id){
$is_exits = true;
}
}
if(!$is_exits){
unset($result[$key]);
}else{
$data["list"] = $value;
$data["grade"] = $key;
}
}
if(count($result) > 0){
return $this->response("200","success",$data);
}
return $this->response("200","null");
}
}
\ No newline at end of file
......@@ -784,6 +784,10 @@ Route::group('broker', [
'commitCheck' => ['api_broker/DailyPaper/commitCheck', ['method' => 'get|post']],
'getPayLogImg' => ['api_broker/DailyPaper/getPayLogImg', ['method' => 'get|post']],
'getRandKingListByAgentId' => ['api_broker/RankingList/getRandKingListByAgentId', ['method' => 'GET|POST']],
'getStoreRandKingListByAgentId' => ['api_broker/RankingList/getStoreRandKingListByAgentId', ['method' => 'GET|POST']],
]);
//Route::miss('api/index/miss');//处理错误的url
\ 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