From 0baf8c3e13d00051fdfd7001f0230acd943bb293 Mon Sep 17 00:00:00 2001 From: "1213317725@qq.com" <1213317725@qq.com> Date: Sun, 22 Jun 2025 17:50:05 +0800 Subject: [PATCH] 1 --- .../campus_person_role/campus_person_role.vue | 4 +- .../components/campus-person-role-edit.vue | 4 +- .../views/course/components/course-edit.vue | 543 +++++++++--------- .../src/app/views/departments/departments.vue | 4 +- admin/src/app/views/xsyj/xsyj.vue | 489 +++++++++------- .../app/adminapi/controller/course/Course.php | 5 +- .../app/adminapi/controller/sys/System.php | 1 + .../controller/apiController/Personnel.php | 8 +- .../controller/apiController/Statistics.php | 99 ++-- niucloud/app/common.php | 22 + .../CampusPersonRoleService.php | 12 +- .../service/admin/course/CourseService.php | 1 - .../app/service/admin/sys/SystemService.php | 35 +- .../api/apiService/PersonnelService.php | 30 +- .../api/apiService/ResourceSharingService.php | 5 +- 15 files changed, 696 insertions(+), 566 deletions(-) diff --git a/admin/src/app/views/campus_person_role/campus_person_role.vue b/admin/src/app/views/campus_person_role/campus_person_role.vue index 6a0cc47d..904d06a3 100644 --- a/admin/src/app/views/campus_person_role/campus_person_role.vue +++ b/admin/src/app/views/campus_person_role/campus_person_role.vue @@ -218,10 +218,10 @@ let campusPersonRoleTable = reactive({ if(pageName == '市场人员列表'){ campusPersonRoleTable.searchParam.dept_id = 1; }else if(pageName == '销售人员列表'){ - campusPersonRoleTable.searchParam.dept_id = 2; + campusPersonRoleTable.searchParam.dept_id = 3; // campusPersonRoleTable.searchParam.role_id = 2; }else if(pageName == '教练管理'){ - campusPersonRoleTable.searchParam.role_id = 5; + campusPersonRoleTable.searchParam.dept_id = 2; } const searchFormRef = ref() diff --git a/admin/src/app/views/campus_person_role/components/campus-person-role-edit.vue b/admin/src/app/views/campus_person_role/components/campus-person-role-edit.vue index b9532959..c856899e 100644 --- a/admin/src/app/views/campus_person_role/components/campus-person-role-edit.vue +++ b/admin/src/app/views/campus_person_role/components/campus-person-role-edit.vue @@ -160,10 +160,10 @@ const initialFormData = { if(pageName == '市场人员列表'){ initialFormData.dept_id = 1; }else if(pageName == '销售人员列表'){ - initialFormData.dept_id = 2; + initialFormData.dept_id = 3; // campusPersonRoleTable.searchParam.role_id = 2; }else if(pageName == '教练管理'){ - initialFormData.dept_id = 3; + initialFormData.dept_id = 2; }else{ initialFormData.dept_id = 0; } diff --git a/admin/src/app/views/course/components/course-edit.vue b/admin/src/app/views/course/components/course-edit.vue index 6bdc07c0..dab6c264 100644 --- a/admin/src/app/views/course/components/course-edit.vue +++ b/admin/src/app/views/course/components/course-edit.vue @@ -1,319 +1,290 @@ + .diy-dialog-wrap .el-form-item__label { + height: auto !important; + } + \ No newline at end of file diff --git a/admin/src/app/views/departments/departments.vue b/admin/src/app/views/departments/departments.vue index 28c98635..0b3fef66 100644 --- a/admin/src/app/views/departments/departments.vue +++ b/admin/src/app/views/departments/departments.vue @@ -91,7 +91,7 @@ :show-overflow-tooltip="true" /> - - + -->
-
- -
- {{ pageName }} - 新增阶段 -
-
- - -
- 阶段名称 - 底薪 -
- - - - - - - - - - - - - - - - - - 新增规则 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 删除该阶段 - - - -
- 提交保存 -
-
-
+
+ +
+ {{ pageName }} + 新增阶段 +
+
+ + +
+ 阶段名称 + 底薪 +
+ + + + + + + + + + + + + + + + + + 新增规则 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 删除该阶段 + + + + + + + +

其他绩效配置

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ 提交保存 +
+
+
+ .collapse-title { + display: flex; + align-items: center; + justify-content: space-between; + width: 100%; + font-size: 14px; + font-weight: 500; + padding-right: 10px; + color: #333; + padding: 10px; + } + + .title-name { + width: 230px; + } + + .title-salary { + width: 110px; + text-align: center; + color: #7438d5; + } + + .arrow { + margin-left: auto; + color: #999; + font-size: 14px; + } + \ No newline at end of file diff --git a/niucloud/app/adminapi/controller/course/Course.php b/niucloud/app/adminapi/controller/course/Course.php index 338da54c..4c5650f7 100644 --- a/niucloud/app/adminapi/controller/course/Course.php +++ b/niucloud/app/adminapi/controller/course/Course.php @@ -68,7 +68,7 @@ class Course extends BaseAdminController ["internal_reminder", 0], ["customer_reminder", 0], ["remarks", ""], - ["gift_session_count ", ""], + ["gift_session_count", ""], ]); $this->validate($data, 'app\validate\course\Course.add'); @@ -94,8 +94,9 @@ class Course extends BaseAdminController ["customer_reminder", 0], ["remarks", ""], ["contract_id",""], - ["gift_session_count ",""], + ["gift_session_count",0], ]); + $this->validate($data, 'app\validate\course\Course.edit'); (new CourseService())->edit($id, $data); return success('EDIT_SUCCESS'); diff --git a/niucloud/app/adminapi/controller/sys/System.php b/niucloud/app/adminapi/controller/sys/System.php index 388f9a63..138d2c9b 100644 --- a/niucloud/app/adminapi/controller/sys/System.php +++ b/niucloud/app/adminapi/controller/sys/System.php @@ -127,6 +127,7 @@ class System extends BaseAdminController public function xsyj_config(){ $data = $this->request->post(); + return success(data: (new SystemService())->xsyj_config($data)); } diff --git a/niucloud/app/api/controller/apiController/Personnel.php b/niucloud/app/api/controller/apiController/Personnel.php index 96e18ff8..f1e3ad48 100644 --- a/niucloud/app/api/controller/apiController/Personnel.php +++ b/niucloud/app/api/controller/apiController/Personnel.php @@ -72,12 +72,14 @@ class Personnel extends BaseApiService $where = [ 'account_type' => $request->param('account_type', ''),//账号类型|teacher=老师,market=销售 'personnel_id' => $request->param('personnel_id', ''),//员工id + 'campus' => $request->param('campus', ''),//校区id ]; + $field = 'id,name'; $res = (new PersonnelService())->getAll($where,$field); - if(!$res){ - return fail('账户信息有误'); - } +// if(!$res){ +// return fail('账户信息有误'); +// } return success($res); } diff --git a/niucloud/app/api/controller/apiController/Statistics.php b/niucloud/app/api/controller/apiController/Statistics.php index b640f2b8..cff0ae12 100644 --- a/niucloud/app/api/controller/apiController/Statistics.php +++ b/niucloud/app/api/controller/apiController/Statistics.php @@ -13,6 +13,7 @@ namespace app\api\controller\apiController; use app\model\market_performance\MarketPerformance; use app\model\order_table\OrderTable; +use app\model\personnel\PersonnelSummary; use app\Request; use app\service\api\apiService\CommonService; use core\base\BaseApiService; @@ -249,6 +250,8 @@ class Statistics extends BaseApiService */ public function marketData(Request $request) { + $resourceSharing = new ResourceSharing(); + $customerResources = new CustomerResources(); $personnel_id = $request->param('personnel_id','');//员工表id $role_key_arr = $request->param('role_key_arr','');//array 角色key $role_key_arr = explode(',',$role_key_arr); @@ -258,59 +261,75 @@ class Statistics extends BaseApiService // $role_key_arr = ['sale'];//@todo 调试使用 + $assigned = 0; + $unassigned = 0; + $lastWeekNewTotal = 0; + $resource_list = $resourceSharing->where(['shared_by' => $personnel_id])->select(); + foreach($resource_list as $item){ + $sharedAt = strtotime($item['shared_at']); + $date = date("Y-m-d",$sharedAt); + if(isDateInThisWeek($date)){ + $assigned++; + } + + } + + $customer_list = $customerResources->where(['consultant' => $personnel_id])->select(); + foreach($customer_list as $item){ + if(!$resourceSharing->where(['resource_id' => $item['id']])->find()){ + if(isDateInThisWeek($item['create_date'])){ + $unassigned++; + } + } + if(isDateInLastWeek($item['create_date'])){ + $lastWeekNewTotal++; + } + + } + + $staff_list = []; + $personnel_summary = new PersonnelSummary(); + $staff_list = $personnel_summary + ->alias('a') + ->join(['school_campus_person_role' => 'b'],'a.campus_person_role_id = b.id','left') + ->join(['school_personnel' => 'c'],'b.person_id = c.id','left') + ->field("c.name,a.task_num as goal,a.complete_num as wx_yj") + ->select(); + if(in_array('market',$role_key_arr) || in_array('market_manager',$role_key_arr)){ + + + //市场人员统计数据(地推拉人头的) $data = [ 'role_type'=>'market_type',//角色类型|market_type=市场,sale_type=销售 - 'num_1' => ($assigned = rand(20, 150)),//本周已分配 - 'num_2' => ($unassigned = rand(5, 50)),//本周未分配 + 'num_1' => $assigned,//本周已分配 + 'num_2' => $unassigned,//本周未分配 'total_1' => ($newTotal = $assigned + $unassigned),//本周拉新总数 - 'total_2' => ($lastWeekNewTotal = rand(10, 100)),//上周拉新总数 - - 'num_1_rate' => min(100, round($assigned / $newTotal * 100, 2)),//已分配比例 - 'num_2_rate' => min(100, round($unassigned / $newTotal * 100, 2)),//未分配比例 - 'num_3_rate' => min(100, round($newTotal / max(1, $lastWeekNewTotal) * 100, 2)), // 本周拉新率(对比上周) - 'num_4_rate' => min(100, round($assigned / max(1, $lastWeekNewTotal) * 100, 2)), // 本周分配率(对比上周) - 'staff_list' => [ - ['name' => '张三', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '李四', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '王五', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '赵六', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '钱七', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '孙八', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '周九', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '吴十', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '郑十一', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '王十二', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ], + 'total_2' => $lastWeekNewTotal,//上周拉新总数 + + 'num_1_rate' => $newTotal ? min(100, round($assigned / $newTotal * 100, 2)) : 0,//已分配比例 + 'num_2_rate' => $newTotal ? min(100, round($unassigned / $newTotal * 100, 2)) : 0,//未分配比例 + 'num_3_rate' => $lastWeekNewTotal ? min(100, round($newTotal / max(1, $lastWeekNewTotal) * 100, 2)) : 0, // 本周拉新率(对比上周) + 'num_4_rate' => $lastWeekNewTotal ? min(100, round($assigned / max(1, $lastWeekNewTotal) * 100, 2)) : 0, // 本周分配率(对比上周) + 'staff_list' => $staff_list, ]; }elseif(in_array('sale',$role_key_arr) || in_array('sale_manager',$role_key_arr)){ //销售人员统计数据(买课的) $data = [ 'role_type'=>'sale',//角色类型|market_type=市场,sale_type=销售 - 'num_1' => ($assigned = rand(20, 150)),//本周已分配 - 'num_2' => ($unassigned = rand(5, 50)),//本周未分配 + 'num_1' => $assigned,//本周已分配 + 'num_2' => $unassigned,//本周未分配 'total_1' => ($newTotal = $assigned + $unassigned),//本周拉新总数 - 'total_2' => ($lastWeekNewTotal = rand(10, 100)),//上周拉新总数 - - 'num_1_rate' => min(100, round($assigned / $newTotal * 100, 2)),//已分配比例 - 'num_2_rate' => min(100, round($unassigned / $newTotal * 100, 2)),//未分配比例 - 'num_3_rate' => min(100, round($newTotal / max(1, $lastWeekNewTotal) * 100, 2)), // 本周拉新率(对比上周) - 'num_4_rate' => min(100, round($assigned / max(1, $lastWeekNewTotal) * 100, 2)), // 本周分配率(对比上周) - 'staff_list' => [ - ['name' => '张三', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '李四', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '王五', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '赵六', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '钱七', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '孙八', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '周九', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '吴十', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '郑十一', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ['name' => '王十二', 'goal' => rand(50, 200), 'wx_yj' => rand(30, 180)], - ], + 'total_2' => $lastWeekNewTotal,//上周拉新总数 + + 'num_1_rate' => $newTotal ? min(100, round($assigned / $newTotal * 100, 2)) : 0,//已分配比例 + 'num_2_rate' => $newTotal ? min(100, round($unassigned / $newTotal * 100, 2)) : 0,//未分配比例 + 'num_3_rate' => $lastWeekNewTotal ? min(100, round($newTotal / max(1, $lastWeekNewTotal) * 100, 2)) : 0, // 本周拉新率(对比上周) + 'num_4_rate' => $lastWeekNewTotal ? min(100, round($assigned / max(1, $lastWeekNewTotal) * 100, 2)) : 0, // 本周分配率(对比上周) + 'staff_list' => $staff_list, ]; }else{ return fail('角色权限不正确'); diff --git a/niucloud/app/common.php b/niucloud/app/common.php index 6549550c..4807fc8e 100644 --- a/niucloud/app/common.php +++ b/niucloud/app/common.php @@ -1271,3 +1271,25 @@ function get_role_type($role_id) /** * 获取顶级部门 */ + + +function isDateInThisWeek($date) { + $timestamp = strtotime($date); + + // 获取本周开始和结束时间戳(周一到周日) + $monday = strtotime('monday this week'); + $sunday = strtotime('sunday this week 23:59:59'); + + return $timestamp >= $monday && $timestamp <= $sunday; +} + +function isDateInLastWeek($date) { + $timestamp = strtotime($date); + + // 获取上周的周一(开始)和周日(结束) + $startOfLastWeek = strtotime('monday last week'); + $endOfLastWeek = strtotime('sunday last week 23:59:59'); + + return $timestamp >= $startOfLastWeek && $timestamp <= $endOfLastWeek; +} + diff --git a/niucloud/app/service/admin/campus_person_role/CampusPersonRoleService.php b/niucloud/app/service/admin/campus_person_role/CampusPersonRoleService.php index 4583a18f..c02226dd 100644 --- a/niucloud/app/service/admin/campus_person_role/CampusPersonRoleService.php +++ b/niucloud/app/service/admin/campus_person_role/CampusPersonRoleService.php @@ -48,9 +48,9 @@ class CampusPersonRoleService extends BaseAdminService $where[] = ['a.campus_id','=',$data['campus_id']]; } -// if($data['role_id']){ -// $where[] = ['a.role_id','=',$data['role_id']]; -// } + if($data['role_id']){ + $where[] = ['a.role_id','=',$data['role_id']]; + } if($data['dept_id']){ $where[] = ['a.dept_id','=',$data['dept_id']]; @@ -96,9 +96,12 @@ class CampusPersonRoleService extends BaseAdminService */ public function add(array $data) { + if($this->model->where(['person_id' => $data['person_id']])->find()){ return fail("重复操作"); } + $role = new SysRole(); + $data['dept_id'] = $role->where(['role_id' => $data['role_id']])->value("dept_id"); $res = $this->model->create($data); return success("操作成功"); @@ -122,6 +125,9 @@ class CampusPersonRoleService extends BaseAdminService $personnel_summary->where(['id' => $tasks['id']])->update(['task_num' => $tasks['task_num']]); } + $role = new SysRole(); + $data['dept_id'] = $role->where(['role_id' => $data['role_id']])->value("dept_id"); + $this->model->where([['id', '=', $id]])->update($data); return success("操作成功"); } diff --git a/niucloud/app/service/admin/course/CourseService.php b/niucloud/app/service/admin/course/CourseService.php index 3cb9b73e..46860183 100644 --- a/niucloud/app/service/admin/course/CourseService.php +++ b/niucloud/app/service/admin/course/CourseService.php @@ -84,7 +84,6 @@ class CourseService extends BaseAdminService */ public function edit(int $id, array $data) { - $this->model->where([['id', '=', $id]])->update($data); return true; } diff --git a/niucloud/app/service/admin/sys/SystemService.php b/niucloud/app/service/admin/sys/SystemService.php index 998ead47..a007b2a0 100644 --- a/niucloud/app/service/admin/sys/SystemService.php +++ b/niucloud/app/service/admin/sys/SystemService.php @@ -207,7 +207,15 @@ class SystemService extends BaseAdminService $config = new SysConfig(); $config->where(['config_key' => 'XSYJ'])->update([ - 'value' => json_encode($data) + 'value' => json_encode($data['stages']) + ]); + + $config->where(['config_key' => 'XSPJ'])->update([ + 'value' => json_encode($data['form']) + ]); + + $config->where(['config_key' => 'course_type'])->update([ + 'value' => json_encode($data['course_type']) ]); return true; @@ -215,11 +223,34 @@ class SystemService extends BaseAdminService public function get_xsyj_config(){ + $dict = new \app\model\dict\Dict(); $config = new SysConfig(); $data = $config->where(['config_key' => 'XSYJ'])->value("value"); - return $data; + $form = $config->where(['config_key' => 'XSPJ'])->value("value"); + + + $course_type = $config->where(['config_key' => 'course_type'])->value("value"); +// $course_type = json_decode($course_type, true); + + $dict_course_type = $dict->where(['key' => 'course_type'])->value("dictionary"); + + $dict_course_type = json_decode($dict_course_type, true); + + foreach ($dict_course_type as $k => $v) { + foreach ($course_type as $k1 => $v1) { + if($v['value'] == $v1['value']){ + $dict_course_type[$k]['num'] = $v1['num'] ?? 0; + } + } + + if(!isset($dict_course_type[$k]['num'])){ + $dict_course_type[$k]['num'] = 0; + } + } + + return ['data' => $data,'form' => $form,'course_type' => $dict_course_type]; } diff --git a/niucloud/app/service/api/apiService/PersonnelService.php b/niucloud/app/service/api/apiService/PersonnelService.php index 8ac1516e..30038471 100644 --- a/niucloud/app/service/api/apiService/PersonnelService.php +++ b/niucloud/app/service/api/apiService/PersonnelService.php @@ -192,8 +192,20 @@ class PersonnelService extends BaseApiService $campus_id = CampusPersonRole::where('person_id', $where['personnel_id']) ->distinct(true) ->column('campus_id'); - if ($campus_id) { + if ($campus_id[0]) { + + $person_id_arr = CampusPersonRole::whereIn('campus_id', $campus_id) + ->where(['dept_id' => 3]) + ->distinct(true) + ->column('person_id'); + if ($person_id_arr) { + //根据校区id获取校区下的全部员工 + $model = $model->whereIn('id', $person_id_arr); + } + }else{ + echo 123;die; $person_id_arr = CampusPersonRole::whereIn('campus_id', $campus_id) + ->where(['dept_id' => 3]) ->distinct(true) ->column('person_id'); if ($person_id_arr) { @@ -207,6 +219,22 @@ class PersonnelService extends BaseApiService $model = $model->where('account_type', $where['account_type']); } + if (!empty($where['campus'])) { +// $model = $model->where('campus', $where['campus']); + + $person_id_arr = CampusPersonRole::whereIn('campus_id', $where['campus']) + ->distinct(true) + ->where(['dept_id' => 3]) + ->column('person_id'); + + if ($person_id_arr) { + //根据校区id获取校区下的全部员工 + $model = $model->whereIn('id', $person_id_arr); + } + + } + + $res = $model->field($field) ->select() ->toArray();//员工信息 diff --git a/niucloud/app/service/api/apiService/ResourceSharingService.php b/niucloud/app/service/api/apiService/ResourceSharingService.php index 15dfa599..97c7b2ce 100644 --- a/niucloud/app/service/api/apiService/ResourceSharingService.php +++ b/niucloud/app/service/api/apiService/ResourceSharingService.php @@ -11,6 +11,7 @@ namespace app\service\api\apiService; +use app\model\campus\Campus; use app\model\campus_person_role\CampusPersonRole; use app\model\customer_resources\CustomerResources; use app\model\order_table\OrderTable; @@ -101,9 +102,11 @@ class ResourceSharingService extends BaseApiService 'page' => $page, ])->toArray(); - + $campus = new Campus(); foreach ($res['data'] as &$item){ $item['customerResource']['source_channel'] = get_dict_value('source',$item['customerResource']['source_channel']); + $item['customerResource']['campus_name'] = $campus->where(['id' =>$item['customerResource']['campus']])->value("campus_name"); + } return $res;