Commit 50b56d8e authored by zw's avatar zw

pk

门店排行
parent f62d8ac7
......@@ -37,13 +37,21 @@ class RankingList extends Basic{
if(count($result) > 0){
return $this->response("200","success",$result);
}
return $this->response("200", "request null");
}
/**
* 门店业绩pk
* @return \think\Response
*/
public function getStoreRandKingList(){
$params = $this->params;
//$this->siteId = 10001;
$result = $this->service_->StoreRankingList( $this->siteId);
if(count($result) > 0){
return $this->response("200","success",$result);
}
return $this->response("200", "request null");
}
/**
......@@ -62,6 +70,22 @@ class RankingList extends Basic{
return '';
}
/**
* 导出门店pk榜
* @return string
*/
public function exportReportStore(){
$params = $this->params;
/* $params["position"] = 1;
$this->siteId = 10001;*/
$export = new ExportExcelUntil();
$result = $this->service_->StoreRankingList( $this->siteId);
$title = [ '部门ID', '门店名称', '业绩'];
$export->exportTables('门店PK明细表', $result, 3, '门店PK明细表', $title);
return '';
}
/**
* pk榜门店业绩和个人业绩排序显示前五
* @return \think\Response
......@@ -129,4 +153,46 @@ class RankingList extends Basic{
}
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(){
$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
......@@ -102,8 +102,8 @@ class Basic extends Controller
$this->userId = Session::get("userId");
if (!in_array($requestPath, $this->filterVerify)) {
$this->userVerify();
$this->userAuth($requestPath);
/* $this->userVerify();
$this->userAuth($requestPath);*/
}
//获取默认城市
......
......@@ -163,8 +163,7 @@ class RankingListService
$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["a.status"] = 0;
$param_now['b.total_time'] = array('between', array($begin_time, $end_time));
foreach ($result as $index => $item) {
$ids = "";
......@@ -182,12 +181,11 @@ class RankingListService
public function getStoreSort($params, $begin_time, $end_time, $ids)
{
$storeModel = new AStore();
$fields = "a.id,c.store_name,a.name,a.phone,SUM(b.performance) as performance";
$fields = "a.id,a.store_name,SUM(b.performance) as performance";
//查询出有业绩的经纪人
$have_performance_arr = $storeModel->getStoreListByPK($fields, $params);
//查询出无业绩的经纪人
$arr = $storeModel->getStoreListByPk1($params["a.site_id"], $params["a.position"], $begin_time, $end_time,
$ids);
$arr = $storeModel->getStoreListByPk1($params["a.site_id"], $begin_time, $end_time,$ids);
return array_merge($have_performance_arr, $arr);
}
......
......@@ -13,6 +13,7 @@ use think\Db;
class AStore extends BaseModel
{
protected $table = 'a_store';
/**
* 添加门店,绑定店长关系
*
......@@ -297,7 +298,7 @@ class AStore extends BaseModel
//echo $this->getLastSql();
return $data;
}
public function getStoreListByPk1($siteId,$position,$startTime,$endTime,$ids){
public function getStoreListByPk1($siteId,$startTime,$endTime,$ids){
$str_ids = " ";
if($ids){
$str_ids = " and a.id in ($ids)";
......
......@@ -359,10 +359,13 @@ Route::group('index', [
'setSite' => ['index/auth/setSite', ['method' => 'GET|POST']], //设置角色站点
'getRandKingList' => ['index/RankingList/getRandKingList', ['method' => 'GET|POST']], //设置角色站点
'exportReport' => ['index/RankingList/exportReport', ['method' => 'GET|POST']],
'selectPkSortByTime' => ['index/RankingList/selectPkSortByTime', ['method' => 'GET|POST']],
'getRandKingListByAgentId' => ['index/RankingList/getRandKingListByAgentId', ['method' => 'GET|POST']],
'getRandKingList' => ['index/RankingList/getRandKingList', ['method' => 'GET|POST']], //设置角色站点
'getStoreRandKingList' => ['index/RankingList/getStoreRandKingList', ['method' => 'GET|POST']],
'exportReport' => ['index/RankingList/exportReport', ['method' => 'GET|POST']],
'exportReportStore' => ['index/RankingList/exportReportStore', ['method' => 'GET|POST']],
'selectPkSortByTime' => ['index/RankingList/selectPkSortByTime', ['method' => 'GET|POST']],
'getRandKingListByAgentId' => ['index/RankingList/getRandKingListByAgentId', ['method' => 'GET|POST']],
'getStoreRandKingListByAgentId' => ['index/RankingList/getStoreRandKingListByAgentId', ['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