Commit ba9a8f00 authored by clone's avatar clone

Merge branch 'chat_0705' into test

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