Commit b8471731 authored by zhuwei's avatar zhuwei

业绩

parent 259549dd
......@@ -235,14 +235,38 @@ class StatementService
if ($user_type == 2) {//如果是总监
//todo 判断是日报还是周报
if ($day_or_week == 'day') {//日报
//dump($day_or_week);
//todo 本月业绩
$where_ = [];
$start_time = date("Y-m-01", time());
$end_time = date("Y-m-d", time());
//$where_["district_id"] = $district_id;
$where_["agent_id"] = $conditions["agent_id"];
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$obargain = new OBargainModel();
$performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收
$result["director_performance_month"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
//todo 完成单数
$where_ = [];
$start_time = date("Y-m-01", time());
$end_time = date("Y-m-d", time());
// $where_["district_id"] = $district_id;
$where_["agent_id"] = $conditions["agent_id"];
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收
$result["director_bargain_sum_store"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
} else {//周报
//todo 本月业绩
$where_ = [];
$start_time = date("Y-m-01", time());
$end_time = date("Y-m-d", strtotime("-1 day"));
$where_["district_id"] = $district_id;
$end_time = date("Y-m-d", time());
// $where_["district_id"] = $district_id;
$where_["agent_id"] = $conditions["agent_id"];
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$obargain = new OBargainModel();
$performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收
......@@ -252,7 +276,8 @@ class StatementService
$where_ = [];
$start_time = date("Y-m-d", strtotime("-14 day"));
$end_time = date("Y-m-d", strtotime("-7 day"));
$where_["district_id"] = $district_id;
// $where_["district_id"] = $district_id;
$where_["agent_id"] = $conditions["agent_id"];
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$obargain = new OBargainModel();
......@@ -262,7 +287,8 @@ class StatementService
$where_ = [];
$start_time = date("Y-m-d", strtotime("-7 day"));
$end_time = date("Y-m-d", time());
$where_["district_id"] = $district_id;
// $where_["district_id"] = $district_id;
$where_["agent_id"] = $conditions["agent_id"];
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$obargain = new OBargainModel();
......@@ -273,7 +299,9 @@ class StatementService
$where_ = [];
$start_time = date("Y-m-01", time());
$end_time = date("Y-m-d", time());
$where_["district_id"] = $district_id;
// $where_["district_id"] = $district_id;
$where_["agent_id"] = $conditions["agent_id"];
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收
......@@ -361,6 +389,8 @@ class StatementService
//dump($results);
$last_week_total = 0;
foreach ($results as $key => $value) {
// dump($value);
$last_week_total += $value["agent_num"];
$paramArr["store_id"] = $value["store_id"];
......@@ -375,20 +405,37 @@ class StatementService
}
if ($day_or_week == 'week') {
//查询总监下面门店的所有经纪人
$params=[];
$params["store_id"] = $value["store_id"];
$params["status"] = 0; //只查询正常状态的经纪人
$agentsArr = $this->agentModel->getAgentsByStoreId($params);
$agent_total = count($agentsArr);
if ($agent_total > 0) {
$agentIds = "";
foreach ($agentsArr as $key1 => $value1) {
$agentIds .= $value1["id"] . ",";
}
$agentIds = rtrim($agentIds, ",");//经纪人ID集合
}//查询总监下面门店的所有经纪人 end
//todo 本月业绩
$where_=[];
$start_time = date("Y-m-01", time());
$end_time = date("Y-m-d", strtotime("-1 day"));;
$where_["store_id"] = $value["store_id"];
$end_time = date("Y-m-d", time());
$where_["agent_id"] = array( "in", $agentIds );
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$obargain = new OBargainModel();
//dump($where_);
$performanceSum = $obargain->getAddBargainNum($where_, 1);//1表示业绩 2表示实收
$results[$key]["director_performance_month"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
//todo 上周业绩
$where_ = [];
$start_time = date("Y-m-d", strtotime("-14 day"));
$end_time = date("Y-m-d", strtotime("-7 day"));
$where_["store_id"] = $value["store_id"];
$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表示实收
$results[$key]["director_last_week_performance_num"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
......@@ -396,7 +443,7 @@ class StatementService
$where_ = [];
$start_time = date("Y-m-d", strtotime("-7 day"));
$end_time = date("Y-m-d", time());
$where_["store_id"] = $value["store_id"];
$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表示实收
$results[$key]["director_week_performance_num"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
......@@ -405,7 +452,7 @@ class StatementService
$where_ = [];
$start_time = date("Y-m-01", time());
$end_time = date("Y-m-d", time());
$where_["store_id"] = $value["store_id"];
$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_, 3);//1表示业绩 2表示实收
......
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