|
|
@ -11,6 +11,7 @@ |
|
|
|
|
|
|
|
|
namespace app\api\controller\apiController; |
|
|
namespace app\api\controller\apiController; |
|
|
|
|
|
|
|
|
|
|
|
use app\model\campus_person_role\CampusPersonRole; |
|
|
use app\model\market_performance\MarketPerformance; |
|
|
use app\model\market_performance\MarketPerformance; |
|
|
use app\model\order_table\OrderTable; |
|
|
use app\model\order_table\OrderTable; |
|
|
use app\model\personnel\PersonnelSummary; |
|
|
use app\model\personnel\PersonnelSummary; |
|
|
@ -252,6 +253,7 @@ class Statistics extends BaseApiService |
|
|
{ |
|
|
{ |
|
|
$resourceSharing = new ResourceSharing(); |
|
|
$resourceSharing = new ResourceSharing(); |
|
|
$customerResources = new CustomerResources(); |
|
|
$customerResources = new CustomerResources(); |
|
|
|
|
|
$campus_person_role = new CampusPersonRole(); |
|
|
$personnel_id = $request->param('personnel_id','');//员工表id |
|
|
$personnel_id = $request->param('personnel_id','');//员工表id |
|
|
$role_key_arr = $request->param('role_key_arr','');//array 角色key |
|
|
$role_key_arr = $request->param('role_key_arr','');//array 角色key |
|
|
$role_key_arr = explode(',',$role_key_arr); |
|
|
$role_key_arr = explode(',',$role_key_arr); |
|
|
@ -264,18 +266,25 @@ class Statistics extends BaseApiService |
|
|
$assigned = 0; |
|
|
$assigned = 0; |
|
|
$unassigned = 0; |
|
|
$unassigned = 0; |
|
|
$lastWeekNewTotal = 0; |
|
|
$lastWeekNewTotal = 0; |
|
|
$resource_list = $resourceSharing->where(['shared_by' => $personnel_id])->select(); |
|
|
// $resource_list = $resourceSharing->where(['shared_by' => $personnel_id])->select(); |
|
|
foreach($resource_list as $item){ |
|
|
// foreach($resource_list as $item){ |
|
|
$sharedAt = strtotime($item['shared_at']); |
|
|
// $sharedAt = strtotime($item['shared_at']); |
|
|
$date = date("Y-m-d",$sharedAt); |
|
|
// $date = date("Y-m-d",$sharedAt); |
|
|
if(isDateInThisWeek($date)){ |
|
|
// if(isDateInThisWeek($date)){ |
|
|
$assigned++; |
|
|
// $assigned++; |
|
|
} |
|
|
// } |
|
|
|
|
|
// |
|
|
} |
|
|
// } |
|
|
|
|
|
|
|
|
$customer_list = $customerResources->where(['consultant' => $personnel_id])->select(); |
|
|
$customer_list = $customerResources->where(['consultant' => $personnel_id])->select(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($customer_list as $item){ |
|
|
foreach($customer_list as $item){ |
|
|
|
|
|
if($resourceSharing->where(['resource_id' => $item['id']])->find()){ |
|
|
|
|
|
if(isDateInThisWeek($item['create_date'])){ |
|
|
|
|
|
$assigned++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if(!$resourceSharing->where(['resource_id' => $item['id']])->find()){ |
|
|
if(!$resourceSharing->where(['resource_id' => $item['id']])->find()){ |
|
|
if(isDateInThisWeek($item['create_date'])){ |
|
|
if(isDateInThisWeek($item['create_date'])){ |
|
|
$unassigned++; |
|
|
$unassigned++; |
|
|
@ -287,19 +296,35 @@ class Statistics extends BaseApiService |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$staff_list = []; |
|
|
$staff_list = $campus_person_role |
|
|
$personnel_summary = new PersonnelSummary(); |
|
|
->alias("a") |
|
|
$staff_list = $personnel_summary |
|
|
->join(['school_personnel' => 'c'],'a.person_id = c.id','left') |
|
|
->alias('a') |
|
|
->where([ |
|
|
->join(['school_campus_person_role' => 'b'],'a.campus_person_role_id = b.id','left') |
|
|
['a.dept_id','in',1] |
|
|
->join(['school_personnel' => 'c'],'b.person_id = c.id','left') |
|
|
]) |
|
|
->field("c.name,a.task_num as goal,a.complete_num as wx_yj") |
|
|
->field("c.id,c.name") |
|
|
->select(); |
|
|
->select(); |
|
|
|
|
|
|
|
|
if(in_array('market',$role_key_arr) || in_array('market_manager',$role_key_arr)){ |
|
|
$staff_list = $staff_list->toArray(); // 转换成数组 |
|
|
|
|
|
$customer_list = $customerResources->select(); |
|
|
|
|
|
$goal = count($customer_list); |
|
|
|
|
|
$staff_map = []; |
|
|
|
|
|
foreach($staff_list as &$staff){ |
|
|
|
|
|
$staff['goal'] = $goal; |
|
|
|
|
|
$staff['wx_yj'] = 0; |
|
|
|
|
|
$staff_map[$staff['id']] = &$staff; // 现在可以引用赋值了 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach ($customer_list as $val){ |
|
|
|
|
|
if(isset($staff_map[$val['consultant']])){ |
|
|
|
|
|
$staff_map[$val['consultant']]['wx_yj']++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
unset($staff); // 清除引用 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(in_array('market',$role_key_arr) || in_array('market_manager',$role_key_arr)){ |
|
|
|
|
|
|
|
|
//市场人员统计数据(地推拉人头的) |
|
|
//市场人员统计数据(地推拉人头的) |
|
|
$data = [ |
|
|
$data = [ |
|
|
'role_type'=>'market_type',//角色类型|market_type=市场,sale_type=销售 |
|
|
'role_type'=>'market_type',//角色类型|market_type=市场,sale_type=销售 |
|
|
|