Commit 965a3e51 authored by zw's avatar zw

周pk

parent 5f758672
......@@ -32,9 +32,9 @@ class RankingList extends Basic{
*/
public function getRandKingList(){
$params = $this->params;
/* $params = array(
/* $params = array(
"position" => 1,//职称 1店长 2经理 3主任 4顾问 0新人
"pk_type" => 1//pk类型 1月pk 2周pk
"pk_type" => 2//pk类型 1月pk 2周pk
);
$this->siteId = 10001;*/
if(!isset($params["position"]) || $params["position"] < 0 || $params["position"] > 5){
......
......@@ -13,8 +13,6 @@ use app\model\TAgentTotalModel;
* Time : 2:06 PM
* Intro:
*/
class RankingListService
{
private $agentModel;
......@@ -51,20 +49,18 @@ class RankingListService
* pk业绩
* @param $position
* @param $siteId
* @param $pk_type
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function RankingList($position, $siteId,$pk_type)
public function RankingList($position, $siteId, $pk_type)
{
$begin_time = date('Y-m-01 00:00:00', strtotime('-3 month'));
$end_time = date("Y-m-d 23:59:59", strtotime(-date('d') . 'day'));
//周pk
if($pk_type == 2){
$begin_time = "2018-10-01";
$end_time = "2018-10-08";
}
$date = $this->getTotalDate($pk_type,1);
$begin_time = $date["begin_time"];
$end_time = $date["end_time"];
$params["a.site_id"] = $siteId;
$params["a.position"] = $position;
$params["a.status"] = array("in", "0,3");
......@@ -75,17 +71,15 @@ class RankingListService
}
//分组
$result = $this->group($resultArr,$siteId,$pk_type);
$result = $this->group($resultArr, $siteId, $pk_type);
//循环分组后的数组,查询出各组本月业绩排行
//本月
$sort_begin_time = date('Y-m-01', time());
$sort_end_time = date("Y-m-01", strtotime('+1 month'));
//周pk
if($pk_type == 2){
$sort_begin_time = "2018-11-01";
$sort_end_time = "2018-11-08";
}
//本月
$time = $this->getTotalDate($pk_type,2);
$sort_begin_time = $time["begin_time"];
$sort_end_time = $time["end_time"];
$param_now["a.site_id"] = $siteId;
$param_now["a.position"] = $position;
$param_now["a.status"] = array("in", "0,3");
......@@ -114,37 +108,32 @@ class RankingListService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function StoreRankingList($siteId,$pk_type){
public function StoreRankingList($siteId, $pk_type)
{
$begin_time = date('Y-m-01 00:00:00', strtotime('-3 month'));
$end_time = date("Y-m-d 23:59:59", strtotime(-date('d') . 'day'));
//周pk
if($pk_type == 2){
$begin_time = "2018-10-01";
$end_time = "2018-10-08";
}
$params["a.site_id"] = $siteId;
$params["a.status"] = 0;
$params["a.id"] = array("not in","5288,3742,5292");
$date = $this->getTotalDate($pk_type,1);
$begin_time = $date["begin_time"];
$end_time = $date["end_time"];
$params["a.site_id"] = $siteId;
$params["a.status"] = 0;
$params["a.id"] = array("not in", "5288,3742,5292");
$params['b.total_time'] = array('between', array($begin_time, $end_time));
$resultArr = $this->getStoreSort($params, $begin_time, $end_time, "",$notIds = "5288,3742,5292");
$resultArr = $this->getStoreSort($params, $begin_time, $end_time, "", $notIds = "5288,3742,5292");
if (count($resultArr) <= 0) {
return null;
}
//分组
$result = $this->group($resultArr,$siteId,$pk_type);
$result = $this->group($resultArr, $siteId, $pk_type);
//循环分组后的数组,查询出各组本月业绩排行
//本月
$sort_begin_time = date('Y-m-01', time());
$sort_end_time = date("Y-m-01", strtotime('+1 month'));
$time = $this->getTotalDate($pk_type,2);
$sort_begin_time = $time["begin_time"];
$sort_end_time = $time["end_time"];
if($pk_type == 2){
$sort_begin_time = "2018-11-01";
$sort_end_time = "2018-11-08";
}
$param_now["a.site_id"] = $siteId;
$param_now["a.status"] = 0;
......@@ -162,17 +151,47 @@ class RankingListService
return $result;
}
/**
* 统计时间
* @param $pk_type
* @return mixed
*/
private function getTotalDate($pk_type,$type)
{
if($type == 1){
$begin_time = date('Y-m-01 00:00:00', strtotime('-3 month'));
$end_time = date("Y-m-d 23:59:59", strtotime(-date('d') . 'day'));
}else{
$begin_time = date('Y-m-01', time());
$end_time = date("Y-m-01", strtotime('+1 month'));
}
//周pk
if ($pk_type == 2 && $type == 1) {
$begin_time = "2018-10-01";
$end_time = "2018-10-08";
}elseif($pk_type == 2 && $type == 2){
$begin_time = "2018-11-01";
$end_time = "2018-11-08";
}
$result["begin_time"] = $begin_time;
$result["end_time"] = $end_time;
return $result;
}
/**
* @param $resultArr
* @param $siteId
* @param $pk_type
* @return array
*/
private function group($resultArr,$siteId,$pk_type){
$crewNum_ = $this->crewNum[$siteId];
private function group($resultArr, $siteId, $pk_type)
{
$crewNum_ = $this->crewNum[$siteId];
$crewNumMax_ = $this->crewNumMax[$siteId];
if($pk_type == 2){
$crewNum_ = $this->weekNum[$siteId];
if ($pk_type == 2) {
$crewNum_ = $this->weekNum[$siteId];
$crewNumMax_ = $this->weekNumMax[$siteId];
}
......@@ -225,14 +244,14 @@ class RankingListService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function getStoreSort($params, $begin_time, $end_time, $ids,$notIds = "")
private function getStoreSort($params, $begin_time, $end_time, $ids, $notIds = "")
{
$storeModel = new AStore();
$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"], $begin_time, $end_time,$ids,$notIds);
$arr = $storeModel->getStoreListByPk1($params["a.site_id"], $begin_time, $end_time, $ids, $notIds);
return array_merge($have_performance_arr, $arr);
}
......@@ -261,7 +280,6 @@ class RankingListService
}
/**
* 个人业绩团队业绩前五
* @param $yesterday
......
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