Commit 1b3674d5 authored by zhuwei's avatar zhuwei

业绩

parent 2767cdbf
...@@ -55,6 +55,8 @@ class StatementService ...@@ -55,6 +55,8 @@ class StatementService
$field = "id,store_id,district_id,level,name,phone,sex,status"; $field = "id,store_id,district_id,level,name,phone,sex,status";
$agent_result = $this->agentModel->getAgentById($field, [ "agent_id" => $agent_id ]); $agent_result = $this->agentModel->getAgentById($field, [ "agent_id" => $agent_id ]);
//dump($agent_result);
if (count($agent_result) <= 0) { if (count($agent_result) <= 0) {
return null; return null;
} }
...@@ -70,8 +72,7 @@ class StatementService ...@@ -70,8 +72,7 @@ class StatementService
$conditions["agent_id"] = $agent_id; $conditions["agent_id"] = $agent_id;
$conditions['create_time'] = array( 'between', array( $time_start, $time_end ) ); $conditions['create_time'] = array( 'between', array( $time_start, $time_end ) );
//dump($user_type); return $this->selectStatement($conditions, $user_type, $store_id, $district_id, $day_or_week,$agent_id);
return $this->selectStatement($conditions, $user_type, $store_id, $district_id, $day_or_week);
} }
...@@ -83,7 +84,7 @@ class StatementService ...@@ -83,7 +84,7 @@ class StatementService
* @param $district_id * @param $district_id
* @return array * @return array
*/ */
private function selectStatement($conditions, $user_type, $store_id, $district_id, $day_or_week) private function selectStatement($conditions, $user_type, $store_id, $district_id, $day_or_week,$agent_id)
{ {
$result = $params = []; $result = $params = [];
...@@ -94,7 +95,7 @@ class StatementService ...@@ -94,7 +95,7 @@ class StatementService
case 1: case 1:
//todo 统计门店下的所有经纪人 //todo 统计门店下的所有经纪人
$params["store_id"] = $store_id; $params["store_id"] = $store_id;
$params["level"] = array( "neq", "30" ); //$params["level"] = array( "neq", "30" );
$params["status"] = 0; //只查询正常状态的经纪人 $params["status"] = 0; //只查询正常状态的经纪人
break; break;
case 2: case 2:
...@@ -137,17 +138,20 @@ class StatementService ...@@ -137,17 +138,20 @@ class StatementService
//本月业绩 //本月业绩
$start_time = date("Y-m-01", time()); $start_time = date("Y-m-01", time());
$end_time = date("Y-m-d", strtotime("-1 day")); $end_time = date("Y-m-d", time());
if ($user_type == 2) {//如果是总监 if ($user_type == 2) {//如果是总监 $conditions["agent_id"]
$where_["agent_id"] = array( "in", $agentIds );
} else {
$where_["district_id"] = $district_id; $where_["district_id"] = $district_id;
} else if ($user_type == 0){
$where_["agent_id"] = $conditions["agent_id"];
}else{
$where_["agent_id"] = array( "in", $agentIds );
} }
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
//dump($where_);
$obargain = new OBargainModel(); $obargain = new OBargainModel();
$performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收 $performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收
$result["performance_month"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result["performance_month"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
//本周业绩 //本周业绩
...@@ -156,18 +160,27 @@ class StatementService ...@@ -156,18 +160,27 @@ class StatementService
$performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收 $performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收
$result["performance_week"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result["performance_week"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
//本周客源
$start_time = date("Y-m-d", strtotime("-7 day"));
$where_['create_time'] = [ 'between', [ $start_time . " 00:00:00", $end_time . " 23:59:59" ] ];
$addUserNum = $this->userModel->getAddUserNum($where_);
$result["add_user_num_week"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
//本月完成单数 //本月完成单数
$start_time = date("Y-m-01", time()); $start_time = date("Y-m-01", time());
$end_time = date("Y-m-d", strtotime("-1 day")); $end_time = date("Y-m-d", time());
if ($user_type == 2) {//如果是总监 if ($user_type == 2) {//如果是总监 $conditions["agent_id"]
$where_["agent_id"] = array( "in", $agentIds );
} else {
$where_["district_id"] = $district_id; $where_["district_id"] = $district_id;
} else if ($user_type == 0){
$where_["agent_id"] = $conditions["agent_id"];
}else{
$where_["agent_id"] = array( "in", $agentIds );
} }
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
// dump($where_);
$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收 $performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收
$result["bargain_sum"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result["bargain_sum"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
//exit;
//客源 //客源
$addUserNum = $this->userModel->getAddUserNum($where_); $addUserNum = $this->userModel->getAddUserNum($where_);
...@@ -176,13 +189,19 @@ class StatementService ...@@ -176,13 +189,19 @@ class StatementService
//当日业绩 //当日业绩
$start_time = date("Y-m-d", time()); $start_time = date("Y-m-d", time());
$end_time = $start_time; $end_time = $start_time;
$where_["agent_id"] = array( "in", $agentIds ); if ($user_type == 0){
$where_["agent_id"] = $conditions["agent_id"];
}else{
$where_["agent_id"] = array( "in", $agentIds );
}
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收 $performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收
$result["performance_day"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result["performance_day"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
//当日客源 //当日客源
// dump($where_);
// dump($where_);
$addUserNum = $this->userModel->getAddUserNum($where_); $addUserNum = $this->userModel->getAddUserNum($where_);
$result["add_user_num_day"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0; $result["add_user_num_day"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
...@@ -191,9 +210,9 @@ class StatementService ...@@ -191,9 +210,9 @@ class StatementService
$where_ = []; $where_ = [];
$start_time = date("Y-m-d", time()); $start_time = date("Y-m-d", time());
$end_time = $start_time; $end_time = $start_time;
$where_["agent_id"] = $store_id; $where_["agent_id"] = $agent_id;
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
// dump($where_);
$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收 $performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收
$result["bargain_sum_store"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result["bargain_sum_store"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
...@@ -202,10 +221,10 @@ class StatementService ...@@ -202,10 +221,10 @@ class StatementService
$where_ = []; $where_ = [];
$start_time = date("Y-m-d", time()); $start_time = date("Y-m-d", time());
$end_time = $start_time; $end_time = $start_time;
$where_["agent_id"] = $store_id; $where_["agent_id"] = $agent_id;
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
//dump($where_);
$reportNum = $this->reportModel->getAddReportNum($params); $reportNum = $this->reportModel->getAddReportNum($where_);
$result["look_at_num_day_store"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0; $result["look_at_num_day_store"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
//todo //todo
......
...@@ -668,12 +668,14 @@ class OBargainModel extends Model ...@@ -668,12 +668,14 @@ class OBargainModel extends Model
$where_["b.house_id"] = array( "in", $params["house_ids"] ); $where_["b.house_id"] = array( "in", $params["house_ids"] );
} }
return Db::table($this->table) $return = Db::table($this->table)
->field($field) ->field($field)
->alias("a") ->alias("a")
->join("o_order b", "a.order_id = b.id", "left") ->join("o_order b", "a.order_id = b.id", "left")
->where($where_) ->where($where_)
->select(); ->select();
//dump($this->getLastSql());
return $return;
} }
public function getReceived($params) public function getReceived($params)
......
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