diff --git a/niucloud/app/api/controller/apiController/Statistics.php b/niucloud/app/api/controller/apiController/Statistics.php new file mode 100644 index 00000000..4e3ea205 --- /dev/null +++ b/niucloud/app/api/controller/apiController/Statistics.php @@ -0,0 +1,157 @@ +param('personnel_id','');//员工表id + $role_key_arr = $request->param('role_key_arr','');//array 角色key + $role_key_arr = explode(',',$role_key_arr); + if(empty($personnel_id)|| empty($role_key_arr)){ + return fail('缺少参数'); + } + $firstDayOfMonth = date('m月01日'); // 获取本月第一天 + $lastDayOfMonth = date('m月t日'); // 获取本月最后一天 + $dateRange = "{$firstDayOfMonth}-{$lastDayOfMonth}"; // 拼接日期范围字符串 + +// $role_key_arr = ['sale']; + + if(in_array('market',$role_key_arr) || in_array('market_manager',$role_key_arr)){ + //市场人员统计数据(地推拉人头的) + $data = [ + 'date_range'=>$dateRange,//拼接日期范围字符串 + 'role_type'=>'market_type',//角色类型|market_type=市场,sale_type=销售 + //本月 + 'month' => [ + 'new_total' => ($newTotal = rand(100, 500)),//拉新总人数 + 'new_total_rate' => min(100, round($newTotal / 1000 * 100, 2)),//拉新总人数比例(不超过100%) + 'assigned_sales' => ($assignedSales = rand(50, 300)),//已分配给销售的人数 + 'assigned_sales_rate' => min(100, round($assignedSales / $newTotal * 100, 2)),//已分配给销售的人数比例(不超过100%) + 'yesterday_new' => ($yesterdayNew = rand(5, 50)),//昨日拉新 + 'yesterday_new_rate' => min(100, round($yesterdayNew / $newTotal * 100, 2)),//昨日拉新比例(不超过100%) + 'today_new' => ($todayNew = rand(1, 20)),//今日拉新 + 'today_new_rate' => min(100, round($todayNew / $newTotal * 100, 2)),//今日拉新比例(不超过100%) + ], + //上月 + 'last_month' => [ + 'new_total' => ($lastNewTotal = rand(80, 400)),//拉新总人数 + 'new_total_rate' => min(100, round($lastNewTotal / 800 * 100, 2)),//拉新总人数比例(不超过100%) + 'assigned_sales' => ($lastAssignedSales = rand(40, 250)),//已分配给销售的人数 + 'assigned_sales_rate' => min(100, round($lastAssignedSales / $lastNewTotal * 100, 2)),//已分配给销售的人数比例(不超过100%) + 'yesterday_new' => ($lastYesterdayNew = rand(3, 40)),//昨日拉新人数 + 'yesterday_new_rate' => min(100, round($lastYesterdayNew / $lastNewTotal * 100, 2)),//昨日拉新人数比例(不超过100%) + 'today_new' => ($lastTodayNew = rand(1, 15)),//今日拉新人数 + 'today_new_rate' => min(100, round($lastTodayNew / $lastNewTotal * 100, 2)),//今日拉新人数比例(不超过100%) + ] + ]; + }elseif(in_array('sale',$role_key_arr) || in_array('sale_manager',$role_key_arr)){ + //销售人员统计数据(买课的) + $data = [ + 'date_range'=>$dateRange,//拼接日期范围字符串 + 'role_type'=>'sale_type',//角色类型|market_type=市场,sale_type=销售 infoData.month + //本月 + 'month' => [ + 'assigned_clients' => ($assigned = rand(50, 300)),//分配给我的客户人数 + 'contacted_clients' => ($contacted = rand(20, 150)),//已沟通的客户人数 + 'contact_rate' => min(100, round($contacted / $assigned * 100, 2)),//沟通率(不超过100%) + 'unconverted_clients' => ($unconverted = rand(10, 50)),//已沟通但没成交的客户人数 + 'unconverted_rate' => min(100, round($unconverted / $contacted * 100, 2)),//未成交率(不超过100%) + 'renewal_clients' => ($renewal = rand(5, 30)),//待续费的客户人数 + 'renewal_rate' => min(100, round($renewal / $assigned * 100, 2)),//待续费率(不超过100%) + 'closed_clients' => ($closed = rand(1, 20)),//已关单的客户人数 + 'closed_rate' => min(100, round($closed / $contacted * 100, 2)),//关单率(不超过100%) + 'conversion_rate' => min(100, round($closed / $assigned * 100, 2)),//整体转化率(不超过100%) + ], + //上月 + 'last_month' => [ + 'assigned_clients' => ($lastAssigned = rand(40, 250)),//分配给我的客户人数 + 'contacted_clients' => ($lastContacted = rand(15, 120)),//已沟通的客户人数 + 'contact_rate' => min(100, round($lastContacted / $lastAssigned * 100, 2)),//沟通率(不超过100%) + 'unconverted_clients' => ($lastUnconverted = rand(8, 40)),//已沟通但没成交的客户人数 + 'unconverted_rate' => min(100, round($lastUnconverted / $lastContacted * 100, 2)),//未成交率(不超过100%) + 'renewal_clients' => ($lastRenewal = rand(3, 25)),//待续费的客户人数 + 'renewal_rate' => min(100, round($lastRenewal / $lastAssigned * 100, 2)),//待续费率(不超过100%) + 'closed_clients' => ($lastClosed = rand(1, 15)),//已关单的客户人数 + 'closed_rate' => min(100, round($lastClosed / $lastContacted * 100, 2)),//关单率(不超过100%) + 'conversion_rate' => min(100, round($lastClosed / $lastAssigned * 100, 2)),//整体转化率(不超过100%) + ] + ]; + }else{ + return fail('角色权限不正确'); + } + + + return success($data); + } + + /** + * 员工端统计(销售)-获取销售数据页统计 + */ + public function marketData(Request $request) + { + $userRole = 'sale';////sale=普通销售,sale_manager=销售主管,market=市场员工,market_manager=市场主管,teacher=教练员工,teacher_manager=教练主管 + if($userRole == 'sale'){ + //销售人员统计数据 + $data = [ + //本月 + 'month' => [], + //上月 + 'last_month' => [] + ]; + }else{ + //市场人员统计数据 + $data = [ + //本月 + 'month' => [], + //上月 + 'last_month' => [] + ]; + } + return success($data); + } + + /** + * 员工端统计(销售)-获取个人中新页统计 + */ + public function marketMy(Request $request) + { + $userRole = 'sale';////sale=普通销售,sale_manager=销售主管,market=市场员工,market_manager=市场主管,teacher=教练员工,teacher_manager=教练主管 + if($userRole == 'sale'){ + //销售人员统计数据 + $data = [ + + ]; + }else{ + //市场人员统计数据 + $data = [ + //业绩单人数已签单人数已签 + ]; + } + return success($data); + } + +} diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index 23d89641..2c7f02cd 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -215,6 +215,14 @@ Route::group(function () { //员工端-获取全部人员列表 Route::get('personnel/getPersonnelAll', 'apiController.Personnel/getPersonnelAll'); + + //员工端统计(销售)-获取销售首页数据统计 + Route::get('statistics/marketHome', 'apiController.Statistics/marketHome'); + //员工端统计(销售)-获取销售数据页统计 + Route::get('statistics/marketData', 'apiController.Statistics/marketData'); + //员工端统计(销售)-获取个人中新页统计 + Route::get('statistics/marketMy', 'apiController.Statistics/marketMy'); + //客户资源-添加 Route::post('customerResources/add', 'apiController.CustomerResources/add'); //客户资源-编辑 diff --git a/niucloud/app/service/api/apiService/StatisticsService.php b/niucloud/app/service/api/apiService/StatisticsService.php new file mode 100644 index 00000000..fbc027cc --- /dev/null +++ b/niucloud/app/service/api/apiService/StatisticsService.php @@ -0,0 +1,33 @@ +