Commit 8e75ebba authored by zhuwei's avatar zhuwei Committed by zw

优化

parent 2943cccc
...@@ -782,6 +782,7 @@ class StatementService ...@@ -782,6 +782,7 @@ class StatementService
* @param $agent_level * @param $agent_level
* @param $store_id * @param $store_id
* @param $district_id * @param $district_id
* @return mixed
*/ */
public function selectStatementForDistrictWithWeek($agent_id, $agent_level, $store_id, $district_id) public function selectStatementForDistrictWithWeek($agent_id, $agent_level, $store_id, $district_id)
{ {
...@@ -835,67 +836,57 @@ class StatementService ...@@ -835,67 +836,57 @@ class StatementService
$agent_result = $this->agentModel->getAgentsByStoreIdV2($conditions_); $agent_result = $this->agentModel->getAgentsByStoreIdV2($conditions_);
foreach ($agent_result as $k => $v) { foreach ($agent_result as $k => $v) {
$district_list_[] = $this->selectStatementForDistrictWithWeek_($v);
}
$result["district_list"] = $district_list_; $district_list['store_id'] = $v['store_id'];
return $result; $district_list['name'] = $v['name'];
} $district_list['store_name'] = $v['store_name'];
/** $agent_res = $this->getAgentIDsByDistrictId($v['store_id'], 1);
* 总监周报获取总监旗下门店报告 $conditions['agent_id'] = array( "in", $agent_res['agent_ids'] );
* @param $store_info
* @return mixed
*/
public function selectStatementForDistrictWithWeek_($store_info)
{
$district_list['store_id'] = $store_info['store_id'];
$district_list['name'] = $store_info['name'];
$district_list['store_name'] = $store_info['store_name'];
$agent_res = $this->getAgentIDsByDistrictId($store_info['store_id'], 1); /*上周时间*/
$conditions['agent_id'] = array( "in", $agent_res['agent_ids'] ); $start_time = date("Y-m-d", strtotime("-14 day"));
$end_time = date("Y-m-d", strtotime("-7 day"));
$conditions['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
/*上周时间*/ // 上周业绩
$start_time = date("Y-m-d", strtotime("-14 day")); $performanceSum = $this->bargainModel->getAddBargainNum($conditions, 1);//1表示业绩 2表示实收
$end_time = date("Y-m-d", strtotime("-7 day")); $district_list["performance_for_last_week"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$conditions['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); // 上周人数
$params['id'] = array( "in", $agent_res['agent_ids'] );
// 上周业绩 $params['create_time'] = $conditions['create_time'] ;
$performanceSum = $this->bargainModel->getAddBargainNum($conditions, 1);//1表示业绩 2表示实收 $agentsCount = $this->agentModel->getAgentsCountByStoreId($params);
$district_list["performance_for_last_week"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $district_list["team_num_for_last_week"] = isset($agentsCount) ? $agentsCount : 0;
// 上周人数
$params['id'] = array( "in", $agent_res['agent_ids'] );
$params['create_time'] = $conditions['create_time'] ; /*本周时间*/
$agentsCount = $this->agentModel->getAgentsCountByStoreId($params); $start_time = date("Y-m-d", strtotime("-7 day"));
$district_list["team_num_for_last_week"] = isset($agentsCount) ? $agentsCount : 0; $end_time = date("Y-m-d", time());
$conditions['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
// 本周业绩
/*本周时间*/ $performanceSum = $this->bargainModel->getAddBargainNum($conditions, 1);//1表示业绩 2表示实收
$start_time = date("Y-m-d", strtotime("-7 day")); $district_list["performance_for_week"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$end_time = date("Y-m-d", time()); // 本周人数
$conditions['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $params['id'] = array( "in", $agent_res['agent_ids'] );
// 本周业绩 $params['create_time'] = $conditions['create_time'] ;
$performanceSum = $this->bargainModel->getAddBargainNum($conditions, 1);//1表示业绩 2表示实收 $agentsCount = $this->agentModel->getAgentsCountByStoreId($params);
$district_list["performance_for_week"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $district_list["team_num_for_week"] = isset($agentsCount) ? $agentsCount : 0;
// 本周人数
$params['id'] = array( "in", $agent_res['agent_ids'] ); /*本月时间*/
$params['create_time'] = $conditions['create_time'] ; $start_time = date("Y-m-01", time());
$agentsCount = $this->agentModel->getAgentsCountByStoreId($params); $end_time = date("Y-m-d", time());
$district_list["team_num_for_week"] = isset($agentsCount) ? $agentsCount : 0; $conditions['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
// 本月业绩
/*本月时间*/ $performanceSum = $this->bargainModel->getAddBargainNum($conditions, 1);//1表示业绩 2表示实收
$start_time = date("Y-m-01", time()); $district_list["performance_for_month"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$end_time = date("Y-m-d", time()); // 本月完成单数
$conditions['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $performanceSum = $this->bargainModel->getAddBargainNumV2($conditions, 3);//1表示业绩 2表示实收
// 本月业绩 $district_list["bargain_sum_for_month"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$performanceSum = $this->bargainModel->getAddBargainNum($conditions, 1);//1表示业绩 2表示实收
$district_list["performance_for_month"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
// 本月完成单数
$performanceSum = $this->bargainModel->getAddBargainNumV2($conditions, 3);//1表示业绩 2表示实收
$district_list["bargain_sum_for_month"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
return $district_list; $district_list_[] = $district_list;
}
$result["district_list"] = $district_list_;
return $result;
} }
/** /**
......
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