Commit 0ef9a6d2 authored by zhuwei's avatar zhuwei

业绩查询 加上当天业绩

parent b687e857
......@@ -21,6 +21,37 @@ class Performance extends Basic
$this->service_ = new PerformanceService();
}
public function getSearchTimeType($start_day,$end_day)
{
//todo 1.今天之前,不包括今天
$search_time_type = 1;
if(
(date('Y-m-d',strtotime($start_day)) != date("Y-m-d", time()))
&&
(date('Y-m-d',strtotime($end_day)) != date("Y-m-d", time()))
){
$search_time_type = 1;
}
//todo 2.今天之前,包括今天
if(
(date('Y-m-d',strtotime($start_day)) != date("Y-m-d", time()))
&&
(date('Y-m-d',strtotime($end_day)) == date("Y-m-d", time()))
){
$search_time_type = 2;
}
//todo 3.就只查询今天
if(
(date('Y-m-d',strtotime($start_day)) == date("Y-m-d", time()))
&&
(date('Y-m-d',strtotime($end_day)) == date("Y-m-d", time()))
){
$search_time_type = 3;
}
return $search_time_type;
}
//TODO 区域业绩排行 District
/**
......@@ -40,14 +71,16 @@ class Performance extends Basic
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
//默认排序一周 2018-07-18改为本月
$end_day = !empty($params["end_day"]) ? $params["end_day"] : date("Y-m-d", time());
$start_day = !empty($params["start_day"]) ? $params["start_day"] : date("Y-m-01", time());
$end_day = !empty($params["end_day"]) ? $params["end_day"] : date("Y-m-d", time());
$father_id = !empty($params["father_id"]) ? $params["father_id"] : '' ;
$is_today = !empty($params["is_today"]) ? $params["is_today"] : 0 ;
//todo 业绩查询目前分三种情况
$search_time_type = $this->getSearchTimeType($start_day,$end_day);
$list = $this->service_->totalAgent($params["type"], $end_day, $start_day,$pageNo,$pageSize,$father_id,$is_today);
$list = $this->service_->totalAgent($params["type"], $end_day, $start_day,$pageNo,$pageSize,$father_id,$search_time_type);
//dump($list);
if (count($list) > 0) {
$result["list"] = $list['list'];
......@@ -84,10 +117,11 @@ class Performance extends Basic
$end_day = !empty($params["end_day"]) ? $params["end_day"] : date("Y-m-d", time());
$start_day = !empty($params["start_day"]) ? $params["start_day"] : date("Y-m-01", time());
$father_id = !empty($params["father_id"]) ? $params["father_id"] : '' ;
$is_today = !empty($params["is_today"]) ? $params["is_today"] : 0 ;
//todo 业绩查询目前分三种情况
$search_time_type = $this->getSearchTimeType($start_day,$end_day);
$list = $this->service_->totalAgent($params["type"], $end_day, $start_day,$pageNo,$pageSize,$father_id,$is_today);
$list = $this->service_->totalAgent($params["type"], $end_day, $start_day,$pageNo,$pageSize,$father_id,$search_time_type);
//dump($list);
if (count($list) > 0) {
$result["list"] = $list['list'];
......@@ -126,10 +160,11 @@ class Performance extends Basic
$end_day = !empty($params["end_day"]) ? $params["end_day"] : date("Y-m-d", time());
$start_day = !empty($params["start_day"]) ? $params["start_day"] : date("Y-m-01", time());
$father_id = !empty($params["father_id"]) ? $params["father_id"] : '' ;
$is_today = !empty($params["is_today"]) ? $params["is_today"] : 0 ;
//todo 业绩查询目前分三种情况
$search_time_type = $this->getSearchTimeType($start_day,$end_day);
$list = $this->service_->totalAgent($params["type"], $end_day, $start_day,$pageNo,$pageSize,$father_id,$is_today);
$list = $this->service_->totalAgent($params["type"], $end_day, $start_day,$pageNo,$pageSize,$father_id,$search_time_type);
//dump($list);
if (count($list) > 0) {
$result["list"] = $list['list'];
......
......@@ -51,7 +51,7 @@ class PerformanceService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function totalAgent($type, $yesterday, $end_day,$pageNo,$pageSize,$father_id,$is_today)
public function totalAgent($type, $yesterday, $end_day,$pageNo,$pageSize,$father_id,$search_time_type)
{
$where_ = [];
$where_['total_time'] = array( 'between', array( $end_day, $yesterday ) );
......@@ -106,7 +106,12 @@ class PerformanceService
$value["store_name"] = $info[0]["store_name"];
$value["district_name"] = $info[0]["district_name"];
if($is_today==1){
//todo 1.今天之前,不包括今天
//todo 2.今天之前,包括今天
//todo 3.就只查询今天
if($search_time_type != 1){//如果不等于1,说明需要计算当天的数据,用不用再说
//todo 计算当日业绩 performance_total
$where_ = [];
......@@ -114,33 +119,79 @@ class PerformanceService
//$where_["district_id"] = $district_id;
$where_["agent_id"] = $value["agent_id"];
$where_['total_time'] = array( 'between', array( $time . " 00:00:00", $time . " 23:59:59" ) );
// $obargain = new OBargainModel();
$obargain = new OBargainModel();
$obargain = new OBargainModel();
$performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收
$value["performance_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
if($search_time_type == 2){//如果等于2,说明需要把今天之前的数据跟今天的数据合并起来
//dump($search_time_type);
//dump('如果等于2,说明需要把今天之前的数据跟今天的数据合并起来');
$performance_total = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$value["performance_total"] = $value["performance_total"] + $performance_total;
}else{
//dump($search_time_type);
//dump('只查询今天的数据');
$value["performance_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
}
//todo 计算当日成交单数 bargain_sum
$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收
$value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
if($search_time_type == 2){
$bargain_sum_total = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$value["bargain_sum_total"] = $value["bargain_sum_total"] + $bargain_sum_total;
}else{
$value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
}
//todo 计算当日收款数 paylog
$receivedSum = $this->bargainModel->getAddBargainNum($where_, 2);//1表示业绩 2表示实收
$value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
if($search_time_type == 2){
$paylog_total = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
$value["paylog_total"] = $value["paylog_total"] + $paylog_total;
}else{
$value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
}
//todo 计算当日进场数 march_in_num
$addMarchInNum = $this->marchInModel->getAddMarchInNum($where_);
$value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
if($search_time_type == 2){
$march_in_num_total = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
$value["march_in_num_total"] = $value["march_in_num_total"] + $march_in_num_total;
}else{
$value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
}
//todo 计算当日报备数 look_at_num
$reportNum = $this->reportModel->getAddReportNum($where_);
$value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
if($search_time_type == 2){
$look_at_num_total = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
$value["look_at_num_total"] = $value["look_at_num_total"] + $look_at_num_total;
}else{
$value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
}
//todo 计算当日新增商铺数 add_house_num
$addHouseNum = $this->houseModel->getAddHouseNum($where_);
$value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
if($search_time_type == 2){
$add_house_num_total = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
$value["add_house_num_total"] = $value["add_house_num_total"] + $add_house_num_total;
}else{
$value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
}
//todo 计算当日新增客户数 add_user_num
$addUserNum = $this->userModel->getAddUserNum($where_);
$result["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
if($search_time_type == 2){
$add_user_num_total = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
$value["add_user_num_total"] = $value["add_user_num_total"] + $add_user_num_total;
}else{
$result["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
}
}
array_push($arr, $value);
......@@ -162,7 +213,7 @@ class PerformanceService
$params["status"] = 0; //只查询正常状态的经纪人
$value["team_num"] = $this->agentModel->getAgentsCountByStoreId($params);
if($is_today==1) {
if($search_time_type != 1) {//如果不等于1,说明需要计算当天的数据,用不用再说
//查询总监下面门店的所有经纪人
$params = [];
......@@ -186,30 +237,71 @@ class PerformanceService
$where_['create_time'] = array( 'between', array( $time . " 04:00:00", $time . " 23:59:59" ) );
$obargain = new OBargainModel();
$performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收
$value["performance_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
if($search_time_type == 2){//如果等于2,说明需要把今天之前的数据跟今天的数据合并起来
//dump($search_time_type);
//dump('如果等于2,说明需要把今天之前的数据跟今天的数据合并起来');
$performance_total = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$value["performance_total"] = $value["performance_total"] + $performance_total;
}else{
//dump($search_time_type);
//dump('只查询今天的数据');
$value["performance_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
}
//todo 计算当日成交单数 bargain_sum
$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收
$value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
if($search_time_type == 2){
$bargain_sum_total = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$value["bargain_sum_total"] = $value["bargain_sum_total"] + $bargain_sum_total;
}else{
$value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
}
//todo 计算当日收款数 paylog
$receivedSum = $this->bargainModel->getAddBargainNum($where_, 2);//1表示业绩 2表示实收
$value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
if($search_time_type == 2){
$paylog_total = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
$value["paylog_total"] = $value["paylog_total"] + $paylog_total;
}else{
$value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
}
//todo 计算当日进场数 march_in_num
$addMarchInNum = $this->marchInModel->getAddMarchInNum($where_);
$value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
if($search_time_type == 2){
$march_in_num_total = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
$value["march_in_num_total"] = $value["march_in_num_total"] + $march_in_num_total;
}else{
$value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
}
//todo 计算当日报备数 look_at_num
$reportNum = $this->reportModel->getAddReportNum($where_);
$value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
if($search_time_type == 2){
$look_at_num_total = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
$value["look_at_num_total"] = $value["look_at_num_total"] + $look_at_num_total;
}else{
$value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
}
//todo 计算当日新增商铺数 add_house_num
$addHouseNum = $this->houseModel->getAddHouseNum($where_);
$value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
if($search_time_type == 2){
$add_house_num_total = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
$value["add_house_num_total"] = $value["add_house_num_total"] + $add_house_num_total;
}else{
$value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
}
//todo 计算当日新增客户数 add_user_num
$addUserNum = $this->userModel->getAddUserNum($where_);
$result["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
if($search_time_type == 2){
$add_user_num_total = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
$value["add_user_num_total"] = $value["add_user_num_total"] + $add_user_num_total;
}else{
$result["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
}
}
array_push($arr, $value);
......@@ -230,8 +322,8 @@ class PerformanceService
$params["status"] = 0; //只查询正常状态的经纪人
$value["team_num"] = $this->agentModel->getAgentsCountByStoreId($params);
if($is_today==1) {
//dump($search_time_type);
if($search_time_type != 1) {//如果不等于1,说明需要计算当天的数据,用不用再说
//查询总监下面门店的所有经纪人
$params = [];
......@@ -255,30 +347,71 @@ class PerformanceService
$where_['create_time'] = array( 'between', array( $time . " 04:00:00", $time . " 23:59:59" ) );
$obargain = new OBargainModel();
$performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收
$value["performance_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
if($search_time_type == 2){//如果等于2,说明需要把今天之前的数据跟今天的数据合并起来
//dump($search_time_type);
//dump('如果等于2,说明需要把今天之前的数据跟今天的数据合并起来');
$performance_total = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$value["performance_total"] = $value["performance_total"] + $performance_total;
}else{
//dump($search_time_type);
//dump('只查询今天的数据');
$value["performance_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
}
//todo 计算当日成交单数 bargain_sum
$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收
$value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
if($search_time_type == 2){
$bargain_sum_total = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$value["bargain_sum_total"] = $value["bargain_sum_total"] + $bargain_sum_total;
}else{
$value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
}
//todo 计算当日收款数 paylog
$receivedSum = $this->bargainModel->getAddBargainNum($where_, 2);//1表示业绩 2表示实收
$value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
if($search_time_type == 2){
$paylog_total = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
$value["paylog_total"] = $value["paylog_total"] + $paylog_total;
}else{
$value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
}
//todo 计算当日进场数 march_in_num
$addMarchInNum = $this->marchInModel->getAddMarchInNum($where_);
$value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
if($search_time_type == 2){
$march_in_num_total = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
$value["march_in_num_total"] = $value["march_in_num_total"] + $march_in_num_total;
}else{
$value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
}
//todo 计算当日报备数 look_at_num
$reportNum = $this->reportModel->getAddReportNum($where_);
$value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
if($search_time_type == 2){
$look_at_num_total = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
$value["look_at_num_total"] = $value["look_at_num_total"] + $look_at_num_total;
}else{
$value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
}
//todo 计算当日新增商铺数 add_house_num
$addHouseNum = $this->houseModel->getAddHouseNum($where_);
$value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
if($search_time_type == 2){
$add_house_num_total = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
$value["add_house_num_total"] = $value["add_house_num_total"] + $add_house_num_total;
}else{
$value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
}
//todo 计算当日新增客户数 add_user_num
$addUserNum = $this->userModel->getAddUserNum($where_);
$result["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
if($search_time_type == 2){
$add_user_num_total = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
$value["add_user_num_total"] = $value["add_user_num_total"] + $add_user_num_total;
}else{
$result["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
}
}
array_push($arr, $value);
......
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