Commit 41e77800 authored by zhuwei's avatar zhuwei

日报修改

parent 861a30ba
...@@ -631,11 +631,10 @@ class StatementService ...@@ -631,11 +631,10 @@ class StatementService
{ {
$time_ = date("Y-m-d", time()); $time_ = date("Y-m-d", time());
$agent_res = $this->getAgentIDsByDistrictId($store_id,$agent_level,0);
$agent_res = $this->getAgentIDsByDistrictId($store_id,$agent_level); ############################## 当日数据 ################################################
$conditions['agent_id'] = array( "in", $agent_res['agent_ids'] ); $conditions['agent_id'] = array( "in", $agent_res['agent_ids'] );
$conditions['create_time'] = array( 'between', array( $time_ . " 00:00:00", $time_ . " 23:59:59" ) ); $conditions['create_time'] = array( 'between', array( $time_ . " 00:00:00", $time_ . " 23:59:59" ) );
// 房源 // 房源
$result["team_house_num"] = $this->housesToAgents->getAddHouseNumByAgentId($conditions); $result["team_house_num"] = $this->housesToAgents->getAddHouseNumByAgentId($conditions);
...@@ -645,13 +644,13 @@ class StatementService ...@@ -645,13 +644,13 @@ class StatementService
$addMarchInNum = $this->marchInModel->getAddMarchInNum($conditions); $addMarchInNum = $this->marchInModel->getAddMarchInNum($conditions);
$result["team_follow_up_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0; $result["team_follow_up_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
// 业绩 // 业绩
$performanceSum = $this->bargainModel->getAddBargainNum($conditions, 1);//1表示业绩 2表示实收 $performanceSum = $this->bargainModel->getAddBargainNumV3($conditions, 1);//1表示业绩 2表示实收
$result["team_performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result["team_performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
// 实收 // 实收
$performanceSum = $this->bargainModel->getAddBargainNum($conditions, 2);//1表示业绩 2表示实收 $performanceSum = $this->bargainModel->getAddBargainNum($conditions, 2);//1表示业绩 2表示实收
$result["team_real_performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result["team_real_performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
// 本月-业绩 ############################## 本月数据 ################################################
$start_time = date("Y-m-01", time()); $start_time = date("Y-m-01", time());
$end_time = date("Y-m-d", time()); $end_time = date("Y-m-d", time());
$conditions['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $conditions['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
...@@ -664,19 +663,16 @@ class StatementService ...@@ -664,19 +663,16 @@ class StatementService
$addMarchInNum = $this->marchInModel->getAddMarchInNum($conditions); $addMarchInNum = $this->marchInModel->getAddMarchInNum($conditions);
$result["team_month_follow_up_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0; $result["team_month_follow_up_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
// 业绩 // 业绩
$performanceSum = $this->bargainModel->getAddBargainNum($conditions, 1);//1表示业绩 2表示实收 $performanceSum = $this->bargainModel->getAddBargainNumV3($conditions, 1);//1表示业绩 2表示实收
$result["team_month_performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result["team_month_performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
// 实收666666666666 // 实收666666666666
$performanceSum = $this->bargainModel->getAddBargainNum($conditions, 2);//1表示业绩 2表示实收 $performanceSum = $this->bargainModel->getAddBargainNum($conditions, 2);//1表示业绩 2表示实收
$result["team_month_real_performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result["team_month_real_performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
// 本月-成交单数 // 本月-成交单数
$performanceSum = $this->bargainModel->getAddBargainNumV2($conditions, 3);//1表示业绩 2表示实收 $performanceSum = $this->bargainModel->getAddBargainNumV2($conditions, 3);//1表示业绩 2表示实收
$result["team_month_bargain_sum"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result["team_month_bargain_sum"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
/**查询店长个人数据**/ ############################## 店长个人数据 ################################################
#店长个人
$time_ = date("Y-m-d", time()); $time_ = date("Y-m-d", time());
$conditions['agent_id'] = $agent_id; $conditions['agent_id'] = $agent_id;
$conditions['create_time'] = array( 'between', array( $time_ . " 00:00:00", $time_ . " 23:59:59" ) ); $conditions['create_time'] = array( 'between', array( $time_ . " 00:00:00", $time_ . " 23:59:59" ) );
...@@ -694,7 +690,7 @@ class StatementService ...@@ -694,7 +690,7 @@ class StatementService
$result["self_phone_follow_up_num"] = $m_phone_follow_up->getFollowTotal($conditions); $result["self_phone_follow_up_num"] = $m_phone_follow_up->getFollowTotal($conditions);
/**查询店长旗下业务员数据**/ /**查询店长旗下业务员数据**/
$agent_res = $this->getAgentIDsByDistrictId($store_id,$agent_level,1);
foreach ($agent_res['store_list'] as $k => $v) { foreach ($agent_res['store_list'] as $k => $v) {
$conditions['agent_id'] = $v["id"]; $conditions['agent_id'] = $v["id"];
// 房源 // 房源
...@@ -705,7 +701,7 @@ class StatementService ...@@ -705,7 +701,7 @@ class StatementService
$addMarchInNum = $this->marchInModel->getAddMarchInNum($conditions); $addMarchInNum = $this->marchInModel->getAddMarchInNum($conditions);
$agent_res['store_list'][$k]["follow_up_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0; $agent_res['store_list'][$k]["follow_up_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
// 业绩 // 业绩
$performanceSum = $this->bargainModel->getAddBargainNum($conditions, 1);//1表示业绩 2表示实收 $performanceSum = $this->bargainModel->getAddBargainNumV3($conditions, 1);//1表示业绩 2表示实收
$agent_res['store_list'][$k]["performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $agent_res['store_list'][$k]["performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
} }
$result["store_list"] = $agent_res['store_list']; $result["store_list"] = $agent_res['store_list'];
...@@ -962,9 +958,10 @@ class StatementService ...@@ -962,9 +958,10 @@ class StatementService
* 查询门店或者区域下所有经纪人id * 查询门店或者区域下所有经纪人id
* @param $district_or_store_id * @param $district_or_store_id
* @param $type * @param $type
* @return string * @param int $agent_list_type
* @return mixed
*/ */
public function getAgentIDsByDistrictId($district_or_store_id,$type) public function getAgentIDsByDistrictId($district_or_store_id,$type,$agent_list_type=0)
{ {
//查询总监下面门店的所有经纪人 //查询总监下面门店的所有经纪人
$params = []; $params = [];
...@@ -973,12 +970,18 @@ class StatementService ...@@ -973,12 +970,18 @@ class StatementService
}else{ }else{
$params["district_id"] = $district_or_store_id; $params["district_id"] = $district_or_store_id;
} }
$params["status"] = 0; //只查询正常状态的经纪人
if($agent_list_type == 0){//业绩统计 需要包括 0正常 1长假 2离职
$params["status"] = array('in','0,1,2');
}else{//员工列表只显示 0正常
$params["status"] = 0;
}
$agentModel = new AAgents(); $agentModel = new AAgents();
$agentsArr = $agentModel->getAgentsByStoreId($params); $agentsArr = $agentModel->getAgentsByStoreId($params);
$agent_total = count($agentsArr); $agent_total = count($agentsArr);
if ($agent_total > 0) {
$agentIds = ""; $agentIds = "";
if ($agent_total > 0) {
foreach ($agentsArr as $key1 => $value1) { foreach ($agentsArr as $key1 => $value1) {
$agentIds .= $value1["id"] . ","; $agentIds .= $value1["id"] . ",";
} }
......
...@@ -825,6 +825,45 @@ class OBargainModel extends Model ...@@ -825,6 +825,45 @@ class OBargainModel extends Model
->select(); ->select();
return $return; return $return;
} }
public function getAddBargainNumV3($params, $type)
{
$where_ = [];
$field = "";
$join = [];
if ($type == 1) {
$field = "sum(scale_fee) as num";
$where_["a.status"] = array( "in", '10,11,13');
} elseif ($type == 2) {
$field = "sum(practical_fee) as num";
} elseif ($type == 3) {
$field = "count(1) as num";
$where_["a.role"] = 3;//必须是反签方
$where_["a.status"] = array( "in", '10,11,13');
}
if (isset($params["agent_id"])) {
$where_["a.agent_id"] = $params["agent_id"];
}
if (isset($params["create_time"])) {
$where_["a.create_time"] = $params["create_time"];
}
if (isset($params["house_ids"])) {
$where_["b.house_id"] = array( "in", $params["house_ids"] );
array_push($join, [ ' o_order b', 'a.order_id = b.id', 'left' ]);
}
$return = Db::table($this->table)
->field($field)
->alias("a")
->join($join)
->where($where_)
->select();
return $return;
}
/** /**
* @param $params * @param $params
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
......
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