于宏哲PHP 1 year ago
parent
commit
6b35136c1f
  1. 18
      admin/components.d.ts
  2. 5
      niucloud/addon/zhjw/app/service/admin/schedules/SchedulesService.php
  3. 1
      niucloud/app/adminapi/controller/login/Login.php
  4. 124
      niucloud/app/api/controller/member/Member.php
  5. 23
      niucloud/app/api/route/member.php
  6. 28
      niucloud/app/common.php
  7. 3
      niucloud/app/service/admin/auth/LoginService.php
  8. 4
      niucloud/app/service/api/login/LoginService.php
  9. 313
      niucloud/app/service/api/member/MemberService.php

18
admin/components.d.ts

@ -10,6 +10,7 @@ declare module '@vue/runtime-core' {
Attachment: typeof import('./src/components/upload-attachment/attachment.vue')['default'] Attachment: typeof import('./src/components/upload-attachment/attachment.vue')['default']
DiyLink: typeof import('./src/components/diy-link/index.vue')['default'] DiyLink: typeof import('./src/components/diy-link/index.vue')['default']
Editor: typeof import('./src/components/editor/index.vue')['default'] Editor: typeof import('./src/components/editor/index.vue')['default']
ElAlert: typeof import('element-plus/es')['ElAlert']
ElAside: typeof import('element-plus/es')['ElAside'] ElAside: typeof import('element-plus/es')['ElAside']
ElAvatar: typeof import('element-plus/es')['ElAvatar'] ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb'] ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
@ -17,20 +18,26 @@ declare module '@vue/runtime-core' {
ElButton: typeof import('element-plus/es')['ElButton'] ElButton: typeof import('element-plus/es')['ElButton']
ElCalendar: typeof import('element-plus/es')['ElCalendar'] ElCalendar: typeof import('element-plus/es')['ElCalendar']
ElCard: typeof import('element-plus/es')['ElCard'] ElCard: typeof import('element-plus/es')['ElCard']
ElCarousel: typeof import('element-plus/es')['ElCarousel']
ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem']
ElCascader: typeof import('element-plus/es')['ElCascader'] ElCascader: typeof import('element-plus/es')['ElCascader']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
ElCol: typeof import('element-plus/es')['ElCol'] ElCol: typeof import('element-plus/es')['ElCol']
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElColorPicker: typeof import('element-plus/es')['ElColorPicker'] ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
ElContainer: typeof import('element-plus/es')['ElContainer'] ElContainer: typeof import('element-plus/es')['ElContainer']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
ElDialog: typeof import('element-plus/es')['ElDialog'] ElDialog: typeof import('element-plus/es')['ElDialog']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElDrawer: typeof import('element-plus/es')['ElDrawer'] ElDrawer: typeof import('element-plus/es')['ElDrawer']
ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
ElEmpty: typeof import('element-plus/es')['ElEmpty']
ElForm: typeof import('element-plus/es')['ElForm'] ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem'] ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader'] ElHeader: typeof import('element-plus/es')['ElHeader']
@ -39,18 +46,25 @@ declare module '@vue/runtime-core' {
ElImageViewer: typeof import('element-plus/es')['ElImageViewer'] ElImageViewer: typeof import('element-plus/es')['ElImageViewer']
ElInput: typeof import('element-plus/es')['ElInput'] ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElLink: typeof import('element-plus/es')['ElLink']
ElMain: typeof import('element-plus/es')['ElMain'] ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption'] ElOption: typeof import('element-plus/es')['ElOption']
ElOptionGroup: typeof import('element-plus/es')['ElOptionGroup']
ElPageHeader: typeof import('element-plus/es')['ElPageHeader'] ElPageHeader: typeof import('element-plus/es')['ElPageHeader']
ElPagination: typeof import('element-plus/es')['ElPagination'] ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover'] ElPopover: typeof import('element-plus/es')['ElPopover']
ElProgress: typeof import('element-plus/es')['ElProgress']
ElRadio: typeof import('element-plus/es')['ElRadio'] ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRate: typeof import('element-plus/es')['ElRate']
ElResult: typeof import('element-plus/es')['ElResult']
ElRow: typeof import('element-plus/es')['ElRow'] ElRow: typeof import('element-plus/es')['ElRow']
ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
ElSelect: typeof import('element-plus/es')['ElSelect'] ElSelect: typeof import('element-plus/es')['ElSelect']
ElSlider: typeof import('element-plus/es')['ElSlider']
ElStatistic: typeof import('element-plus/es')['ElStatistic'] ElStatistic: typeof import('element-plus/es')['ElStatistic']
ElStep: typeof import('element-plus/es')['ElStep'] ElStep: typeof import('element-plus/es')['ElStep']
ElSteps: typeof import('element-plus/es')['ElSteps'] ElSteps: typeof import('element-plus/es')['ElSteps']
@ -61,6 +75,8 @@ declare module '@vue/runtime-core' {
ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs'] ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag'] ElTag: typeof import('element-plus/es')['ElTag']
ElTimeline: typeof import('element-plus/es')['ElTimeline']
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
ElTimePicker: typeof import('element-plus/es')['ElTimePicker'] ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTree: typeof import('element-plus/es')['ElTree'] ElTree: typeof import('element-plus/es')['ElTree']

5
niucloud/addon/zhjw/app/service/admin/schedules/SchedulesService.php

@ -64,7 +64,10 @@ class SchedulesService extends BaseAdminService
{ {
$field = 'id,staff_id,class_id,courses_id,date_time,time_slot,task'; $field = 'id,staff_id,class_id,courses_id,date_time,time_slot,task';
$info = $this->model->field($field)->where($data)->findOrEmpty()->toArray(); $info = $this->model->field($field)->where($data)->findOrEmpty()->toArray();
$info['time_slot'] = explode(",",$info['time_slot']); if(isset($info['time_slot'])){
$info['time_slot'] = explode(",",$info['time_slot']);
}
return $info; return $info;
} }

1
niucloud/app/adminapi/controller/login/Login.php

@ -24,7 +24,6 @@ class Login extends BaseAdminController
*/ */
public function login() public function login()
{ {
$data = $this->request->params([ $data = $this->request->params([
[ 'username', '' ], [ 'username', '' ],
[ 'password', '' ], [ 'password', '' ],

124
niucloud/app/api/controller/member/Member.php

@ -11,6 +11,7 @@
namespace app\api\controller\member; namespace app\api\controller\member;
use app\service\admin\dict\DictService;
use app\service\api\login\AuthService; use app\service\api\login\AuthService;
use app\service\api\member\MemberLogService; use app\service\api\member\MemberLogService;
use app\service\api\member\MemberService; use app\service\api\member\MemberService;
@ -141,7 +142,8 @@ class Member extends BaseApiController
public function course_list(){ public function course_list(){
$data = $this->request->params([ $data = $this->request->params([
[ 'schedule_date', '' ], [ 'schedule_date', '' ],
['venue_id',''] ['venue_id',''],
['courses_id','']
]); ]);
return success(( new MemberService() )->course_list($data)); return success(( new MemberService() )->course_list($data));
} }
@ -228,5 +230,125 @@ class Member extends BaseApiController
return success(( new MemberService() )->ask_for_leave($data)); return success(( new MemberService() )->ask_for_leave($data));
} }
//发布作业
public function publish_job(){
$data = $this->request->params([
[ 'type', '' ],
[ 'courses_id', '' ],
[ 'content_type', '' ],
[ 'content', '' ],
[ 'content_text', '' ],
[ 'classes_id', '' ],
[ 'students_ids', '' ]
]);
return success(( new MemberService() )->publish_job($data));
}
//获取班级+学员联动
public function get_classes_list(){
return success(( new MemberService() )->get_classes_list());
}
//获取课程
public function get_courses_list(){
return success(( new MemberService() )->get_courses_list());
}
public function get_assignments_list(){
return success(( new MemberService() )->get_assignments_list());
}
public function get_campuses_list(){
return success(( new MemberService() )->get_campuses_list());
}
//添加线索
public function set_sales(){
$data = $this->request->params([
[ 'title', '' ],
[ 'student_phone', '' ],
[ 'student_name', '' ],
[ 'sex', '' ],
[ 'age', '' ],
[ 'campuses_id', '' ],
[ 'school_name', '' ],
[ 'grade', '' ],
[ 'class_id', '' ],
[ 'class_name', '' ],
[ 'source_channel', '' ],//来源渠道(字典选择)
[ 'customer_source', '' ],//客户来源(字典选择)
[ 'add_staff_id', '' ],
[ 'get_staff_id', '' ],
[ 'contact_name', '' ],
[ 'province_id', '' ],
[ 'city_id', '' ],
[ 'district_id', '' ],
[ 'full_address', '' ],
[ 'community_name', '' ],
[ 'customer_tags', '' ],
[ 'is_follow', 2 ],
[ 'follow_up_time', '' ],
[ 'follow_up_content', '' ],
[ 'staff_id', '' ],
['entry_type',''],
[ 'is_warn', 1 ],
[ 'reminder_method', '' ]
]);
return success(( new MemberService() )->set_sales($data));
}
public function getKeyInfo(string $type){
$res = (new DictService())->getKeyInfo($type);
return success($res);
}
public function create_follow(){
$data = $this->request->params([
[ 'sales_id', '' ],
[ 'staff_id', '' ],
[ 'entry_type', '' ],
[ 'follow_up_type', '' ],
[ 'follow_up_time', '' ],
[ 'audio_upload', '' ],
[ 'follow_up_content', '' ],
[ 'customer_status', '' ],
[ 'sign_up_contact_id', '' ],
[ 'is_warn', '' ],
[ 'reminder_method', '' ],
[ 'reminder_time', '' ]
]);
return success(( new MemberService() )->create_follow($data));
}
public function sales_list(){
return success(( new MemberService() )->sales_list());
}
public function create_task(){
$data = $this->request->params([
[ 'sales_id', '' ],
[ 'follow_up_time', '' ],
[ 'follow_up_content', '' ],
[ 'staff_id', '' ],
[ 'entry_type', '' ],
[ 'is_warn', '' ],
[ 'reminder_method', '' ]
]);
return success(( new MemberService() )->create_task($data));
}
public function my_client(){
$data = $this->request->params([
[ 'type', 0 ]
]);
return success(( new MemberService() )->my_client($data));
}
} }

23
niucloud/app/api/route/member.php

@ -131,6 +131,29 @@ Route::group('member', function () {
Route::post('member_edit', 'member.Member/member_edit'); Route::post('member_edit', 'member.Member/member_edit');
Route::post('ask_for_leave', 'member.Member/ask_for_leave'); Route::post('ask_for_leave', 'member.Member/ask_for_leave');
Route::post('publish_job', 'member.Member/publish_job');
Route::get('get_classes_list', 'member.Member/get_classes_list');
Route::get('get_courses_list', 'member.Member/get_courses_list');
Route::get('get_assignments_list', 'member.Member/get_assignments_list');
Route::get('sales_list', 'member.Member/sales_list');
Route::post('set_sales', 'member.Member/set_sales');
Route::get('get_campuses_list', 'member.Member/get_campuses_list');
Route::post('create_follow', 'member.Member/create_follow');
Route::post('create_task', 'member.Member/create_task');
Route::post('my_client', 'member.Member/my_client');
Route::get('dictionary/type/:type', 'member.Member/getKeyInfo');
})->middleware(ApiChannel::class) })->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class, true) ->middleware(ApiCheckToken::class, true)
->middleware(ApiLog::class); ->middleware(ApiLog::class);

28
niucloud/app/common.php

@ -1,5 +1,6 @@
<?php <?php
use app\service\admin\member\MemberService;
use think\Container; use think\Container;
use think\Response; use think\Response;
use think\facade\Lang; use think\facade\Lang;
@ -1028,7 +1029,12 @@ function get_last_time($time = null)
//role_id 1 学员 2教师 3教务 4教练 //role_id 1 学员 2教师 3教务 4教练
function get_user_type($member_id){ function get_user_type($member_id){
$role_id = (new \addon\zhjw\app\model\staff\Staff())->where(['member_id' => $member_id])->value("role_id"); $role_id = (new \addon\zhjw\app\model\staff\Staff())->where(['member_id' => $member_id])->value("type");
return $role_id;
}
function get_role_id($staff_id){
$role_id = (new \addon\zhjw\app\model\staff\Staff())->where(['id' => $staff_id])->value("role_id");
return $role_id; return $role_id;
} }
@ -1046,3 +1052,23 @@ function formatTimeRange($start, $end)
return $endDate->format('Y-m-d') . ' ' . $startDate->format('H:i') . ' - ' . $endDate->format('H:i'); return $endDate->format('Y-m-d') . ' ' . $startDate->format('H:i') . ' - ' . $endDate->format('H:i');
} }
function addMember($info){
$member_no = (new MemberService())->getMemberNo();
$data = [
'nickname' => $info['student_name'],
'mobile' => $info['student_phone'],
'member_no' => $member_no,
'init_member_no' => $member_no,
'password' => $info['student_phone'],
'headimg' => '',
'sex' => $info['sex']
];
$member_id = (new MemberService())->add($data);
return $member_id;
}

3
niucloud/app/service/admin/auth/LoginService.php

@ -45,6 +45,7 @@ class LoginService extends BaseAdminService
*/ */
public function login(string $username, string $password) public function login(string $username, string $password)
{ {
$config = (new ConfigService())->getConfig(); $config = (new ConfigService())->getConfig();
$is_captcha = $config['is_captcha']; $is_captcha = $config['is_captcha'];
if($is_captcha == 1){ if($is_captcha == 1){
@ -82,6 +83,8 @@ class LoginService extends BaseAdminService
// 获取站点布局 // 获取站点布局
$layout_config = (new CoreConfigService())->getConfig('SITE_LAYOUT'); $layout_config = (new CoreConfigService())->getConfig('SITE_LAYOUT');
$data['layout'] = empty($layout_config) ? 'default' : $layout_config['value']['key']; $data['layout'] = empty($layout_config) ? 'default' : $layout_config['value']['key'];
return $data; return $data;
} }

4
niucloud/app/service/api/login/LoginService.php

@ -77,9 +77,9 @@ class LoginService extends BaseApiService
$token_info = $this->createToken($member_info); $token_info = $this->createToken($member_info);
event("MemberLogin", $member_info); event("MemberLogin", $member_info);
$roleArr = [1=>3,2=>2,3=>1];
return [ return [
'userType' => $roleArr[$role_id], 'userType' => $role_id,
'token' => $token_info[ 'token' ], 'token' => $token_info[ 'token' ],
'expires_time' => $token_info[ 'params' ][ 'exp' ], 'expires_time' => $token_info[ 'params' ][ 'exp' ],
'mobile' => $member_info->mobile 'mobile' => $member_info->mobile

313
niucloud/app/service/api/member/MemberService.php

@ -12,8 +12,12 @@
namespace app\service\api\member; namespace app\service\api\member;
use addon\zhjw\app\model\assignments\Assignments; use addon\zhjw\app\model\assignments\Assignments;
use addon\zhjw\app\model\campuses\Campuses;
use addon\zhjw\app\model\classes\Classes; use addon\zhjw\app\model\classes\Classes;
use addon\zhjw\app\model\courses\Courses; use addon\zhjw\app\model\courses\Courses;
use addon\zhjw\app\model\follow_up_logs\FollowUpLogs;
use addon\zhjw\app\model\follow_up_reminders\FollowUpReminders;
use addon\zhjw\app\model\sales\Sales;
use addon\zhjw\app\model\schedules\Schedules; use addon\zhjw\app\model\schedules\Schedules;
use addon\zhjw\app\model\staff\Staff; use addon\zhjw\app\model\staff\Staff;
use addon\zhjw\app\model\students\Students; use addon\zhjw\app\model\students\Students;
@ -78,15 +82,17 @@ class MemberService extends BaseApiService
->findOrEmpty()->toArray(); ->findOrEmpty()->toArray();
$role_id = get_user_type($this->member_id); $role_id = get_user_type($this->member_id);
$staff = (new Staff())->where(['member_id' => $this->member_id])->find();
$info['staff_id'] = $staff['id'];
$info['headimg'] = $staff['header'];
$info['name'] = $staff['name'] ?? '';
$info['gender'] = $staff['gender'];
$info['phone'] = $staff['phone'];
$info['email'] = $staff['email'];
$info['role_id'] = $role_id;
if($role_id == 1){ if($role_id == 1){
//学员信息 //学员信息
$staff = (new Staff())->where(['member_id' => $this->member_id])->find();
$info['staff_id'] = $staff['id'];
$info['headimg'] = $staff['header'];
$info['name'] = $staff['name'] ?? '';
$info['gender'] = $staff['gender'];
$info['phone'] = $staff['phone'];
$info['email'] = $staff['email'];
$data = (new Students())->where(['user_id' => $staff['id']])->find(); $data = (new Students())->where(['user_id' => $staff['id']])->find();
$info['height'] = $data['height']; $info['height'] = $data['height'];
$info['weight'] = $data['weight']; $info['weight'] = $data['weight'];
@ -264,7 +270,7 @@ class MemberService extends BaseApiService
->where('a.start_date', '<=', $data['schedule_date']) ->where('a.start_date', '<=', $data['schedule_date'])
->where('a.end_date', '>=', $data['schedule_date']) ->where('a.end_date', '>=', $data['schedule_date'])
->where('a.status','<',3) ->where('a.status','<',3)
->whereRaw("FIND_IN_SET(?, a.max_students)", [$member_info['students_id']]) // ->whereRaw("FIND_IN_SET(?, a.max_students)", [$member_info['students_id']])
->field("a.id,a.status,a.venue_id,a.start_date,a.end_date,a.max_students,a.name,b.name as address,d.name as courses_name, ->field("a.id,a.status,a.venue_id,a.start_date,a.end_date,a.max_students,a.name,b.name as address,d.name as courses_name,
LENGTH(a.max_students) - LENGTH(REPLACE(a.max_students, ',', '')) + 1 as students_count,d.id as courses_id LENGTH(a.max_students) - LENGTH(REPLACE(a.max_students, ',', '')) + 1 as students_count,d.id as courses_id
") ")
@ -299,8 +305,13 @@ class MemberService extends BaseApiService
$venue_id = $this->get_venues_ids($data)[0]; $venue_id = $this->get_venues_ids($data)[0];
$where['c.id'] = $venue_id; $where['c.id'] = $venue_id;
} }
if($data['courses_id']){
$where['d.id'] = $data['courses_id'];
}
if($member_info['role_id'] == 1){
$schedules = $schedules->whereRaw("FIND_IN_SET(?, b.max_students)", [$member_info['students_id']]);
}
$where['a.date_time'] = $data['schedule_date']; $where['a.date_time'] = $data['schedule_date'];
$search_model = $schedules $search_model = $schedules
->alias("a") ->alias("a")
@ -308,12 +319,11 @@ class MemberService extends BaseApiService
->join(['school_venues' => 'c'],'b.venue_id = c.id','left') ->join(['school_venues' => 'c'],'b.venue_id = c.id','left')
->join(['school_courses' => 'd'],'a.courses_id = d.id','left') ->join(['school_courses' => 'd'],'a.courses_id = d.id','left')
->where($where) ->where($where)
->whereRaw("FIND_IN_SET(?, b.max_students)", [$member_info['students_id']])
->field("a.id,a.status,b.name as classes_name,a.date_time,a.time_slot,c.name as address,c.address as address_info,d.name as courses_name,d.id as courses_id,LENGTH(b.max_students) - LENGTH(REPLACE(b.max_students, ',', '')) + 1 as students_count,b.max_students"); ->field("a.id,a.status,b.name as classes_name,a.date_time,a.time_slot,c.name as address,c.address as address_info,d.name as courses_name,d.id as courses_id,LENGTH(b.max_students) - LENGTH(REPLACE(b.max_students, ',', '')) + 1 as students_count,b.max_students");
$list = $this->pageQuery($search_model, function ($item) use($member_info){ $list = $this->pageQuery($search_model, function ($item) use($member_info){
$where['a.students_id'] = $member_info['students_id']; // $where['a.students_id'] = $member_info['students_id'];
$where['a.courses_id'] = $item['courses_id']; $where['a.courses_id'] = $item['courses_id'];
$where['a.schedules_id'] = $item['id']; $where['a.schedules_id'] = $item['id'];
$item['sign_list'] = Db::name("zhjw_students_sign") $item['sign_list'] = Db::name("zhjw_students_sign")
@ -340,7 +350,6 @@ class MemberService extends BaseApiService
public function course_info($data){ public function course_info($data){
$member_info = $this->getInfo();
$schedules = new Schedules(); $schedules = new Schedules();
$where = []; $where = [];
$where['a.id'] = $data['id']; $where['a.id'] = $data['id'];
@ -377,6 +386,19 @@ class MemberService extends BaseApiService
}else{ }else{
$info['status'] = 1; $info['status'] = 1;
} }
$info['sign_status'] = Db::name("zhjw_students_sign")
->where(['schedules_id' => $data['id']])
->value("status") ?: 0;
$info['sign_list'] = Db::name("zhjw_students_sign")
->alias("a")
->join(['school_zhjw_students' => 'b'],'a.students_id = b.id','left')
->join(['school_staff' => 'c'],'b.user_id = c.id','left')
->where($where)
->order('a.create_time desc')
->field("a.*,c.name,c.header")
->select();
return $info; return $info;
} }
@ -470,18 +492,29 @@ class MemberService extends BaseApiService
public function assignments_list($data){ public function assignments_list($data){
$member_info = $this->getInfo(); $member_info = $this->getInfo();
$where = []; $where = [];
$where['student_id'] = $member_info['students_id']; $where['a.student_id'] = $member_info['students_id'];
if($data['status']){ if($data['status']){
$where['status'] = $data['status']; $where['a.status'] = $data['status'];
} }
$search_model = (new Assignments())->where($where)->order('create_time asc'); $search_model = (new Assignments())
->alias("a")
->join(['school_staff' => 'b'],'a.staff_id = b.id','left')
->where($where)
->field("a.*,b.name as coach_name,b.header as coach_pic")
->order('a.create_time asc');
return $this->pageQuery($search_model); return $this->pageQuery($search_model);
} }
public function assignments_info($data){ public function assignments_info($data){
$member_info = $this->getInfo(); $member_info = $this->getInfo();
$info = (new Assignments())->where(['student_id' => $member_info['students_id'],'id' => $data['id']])->find()->toArray();
$info = (new Assignments())
->alias("a")
->join(['school_staff' => 'b'],'a.staff_id = b.id','left')
->where(['a.student_id' => $member_info['students_id'],'a.id' => $data['id']])
->field("a.*,b.name as coach_name,b.header as coach_pic")
->find()->toArray();
return $info; return $info;
} }
@ -557,4 +590,252 @@ class MemberService extends BaseApiService
} }
public function publish_job(array $data){
$classes = new Classes();
$member_info = $this->getInfo();
$students_ids = [];
$insert['staff_id'] = $member_info['staff_id'];
$insert['courses_id'] = $data['courses_id'];
$insert['content_type'] = $data['content_type'];
$insert['content'] = $data['content'];
$insert['content_text'] = $data['content_text'];
$insert['submit_time'] = date("Y-m-d H:i:s", time());
$insert['create_time'] = time();
$insert['update_time'] = time();
$insert['class_id'] = $data['classes_id'];
if($data['type'] == 1){
//班级作业
$students_ids = $classes->where(['id' => $data['classes_id']])->value("max_students");
$students_ids = explode(",",$students_ids);
}else{
//学员作业
$students_ids = explode(",",$data['students_ids']);
}
if(!empty($students_ids)){
foreach ($students_ids as $k=>$v){
$insert['student_id'] = $v;
Db::name("zhjw_assignments")->insert($insert);
}
}
return "发布成功";
}
public function get_classes_list(){
$classes = new Classes();
$student = new Students();
$list = $classes->select()->toArray();
foreach ($list as $k=>$v){
$list[$k]['student_list'] = $student->where('id','in',$v['max_students'])->select();
}
return $list;
}
public function get_courses_list(){
$courses = new Courses();
$list = $courses->select()->toArray();
return $list;
}
public function get_campuses_list(){
$campuses = new Campuses();
$list = $campuses->select()->toArray();
return $list;
}
public function get_assignments_list(){
$assignments = new Assignments();
$member_info = $this->getInfo();
$search_model = $assignments
->alias("a")
->join(['school_classes' => 'b'],'a.class_id = b.id','left')
->join(['school_courses' => 'c'],'a.courses_id = c.id','left')
->where(['a.staff_id' => $member_info['staff_id']])
->field('a.type,a.staff_id, a.class_id, a.courses_id, COUNT(*) as count,a.submit_time,b.name as class_name,c.name as course_name')
->group('a.staff_id, a.class_id, a.courses_id')
->order("a.id desc");
$list = $this->pageQuery($search_model, function ($item) use($member_info){
$assignments = new Assignments();
$item['wc_count'] = $assignments
->where([
'class_id' => $item['class_id'],
'courses_id' => $item['courses_id'],
'status' => 3
])
->count();
$item['wcl'] = $item['wc_count'] / $item['count'] * 100;
$item['dpg'] = $assignments
->where([
'class_id' => $item['class_id'],
'courses_id' => $item['courses_id'],
'status' => 2
])
->count();
});
return $list;
}
public function set_sales(array $data){
$sales = new Sales();
$follow_up_logs = new FollowUpLogs();
$follow_up_reminders = new FollowUpReminders();
$sales_id = $sales->insertGetId([
'title' => $data['title'],
'user_id' => addMember($data),
'student_phone' => $data['student_phone'],
'student_name' => $data['student_name'],
'sex' => $data['sex'],
'age' => $data['age'],
'campuses_id' => $data['campuses_id'],
'school_name' => $data['school_name'],
'grade' => $data['grade'],
'class_id' => $data['class_id'],
'class_name' => $data['class_name'],
'source_channel' => $data['source_channel'],
'customer_source' => $data['customer_source'],
'add_staff_id' => $data['add_staff_id'],
'get_staff_id' => $data['get_staff_id'],
'contact_name' => $data['contact_name'],
'province_id' => $data['province_id'],
'city_id' => $data['city_id'],
'district_id' => $data['district_id'],
'full_address' => $data['full_address'],
'community_name' => $data['community_name'],
'customer_tags' => $data['customer_tags'],
'create_time' => time(),
'update_time' => time(),
]);
if($data['is_follow'] == 2){
$logs_id = $follow_up_logs->insertGetId([
'sales_id' => $sales_id,
'staff_id' => $data['staff_id'],
'role_id' => get_role_id($data['staff_id']),
'entry_type' => $data['entry_type'],
'follow_up_time' => $data['follow_up_time'],
'create_time' => time()
]);
if($data['is_warn'] == 1){
$follow_up_reminders->insertGetId([
'follow_up_logs_id' => $logs_id,
'reminder_time' => $data['follow_up_time'],
'reminder_method' => $data['follow_up_method'],
'task_status' => 1,
'create_time' => time()
]);
}
}
return "添加成功";
}
public function create_follow(array $data){
$follow_up_logs = new FollowUpLogs();
$follow_up_reminders = new FollowUpReminders();
$logs_id = $follow_up_logs->insertGetId([
'sales_id' => $data['sales_id'],
'staff_id' => $data['staff_id'],
'audio_upload' =>$data['audio_upload'],
'customer_status' => $data['customer_status'],
'sign_up_contact_id' => $data['sign_up_contact_id'],
'role_id' => get_role_id($data['staff_id']),
'entry_type' => $data['entry_type'],
'follow_up_time' => $data['follow_up_time'],
'create_time' => time()
]);
if($data['is_warn'] == 1){
$follow_up_reminders->insertGetId([
'follow_up_logs_id' => $logs_id,
'reminder_time' => $data['reminder_time'],
'reminder_method' => $data['follow_up_method'],
'task_status' => 1,
'create_time' => time()
]);
}
return "添加成功";
}
public function sales_list(){
$sales = new Sales();
$search_model = $sales->order("id desc");
return $this->pageQuery($search_model, function ($item, $key) {
});
}
public function create_task(array $data){
$follow_up_logs = new FollowUpLogs();
$follow_up_reminders = new FollowUpReminders();
$logs_id = $follow_up_logs->insertGetId([
'sales_id' => $data['sales_id'],
'staff_id' => $data['staff_id'],
'role_id' => get_role_id($data['staff_id']),
'entry_type' => $data['entry_type'],
'follow_up_time' => $data['follow_up_time'],
'create_time' => time()
]);
if($data['is_warn'] == 1){
$follow_up_reminders->insertGetId([
'follow_up_logs_id' => $logs_id,
'reminder_time' => $data['follow_up_time'],
'reminder_method' => $data['follow_up_method'],
'task_status' => 1,
'create_time' => time()
]);
}
return "添加成功";
}
public function my_client(array $data){
$sales = new Sales();
$where = [];
if($data['type'] == 1){
$where[] = ['is_status','=',1];
}
if($data['type'] == 2){
$seven_days_ago = date('Y-m-d H:i:s', strtotime('-7 days'));
$where[] = ['follow_up_time','<',$seven_days_ago];
}
if($data['type'] == 3){
$seven_days_ago = date('Y-m-d H:i:s', strtotime('-30 days'));
$where[] = ['follow_up_time','<',$seven_days_ago];
$where[] = ['is_status','=',1];
}
$search_model = $sales->where($where)->order("id desc");
return $this->pageQuery($search_model, function ($item, $key) {
$follow_up_logs = new FollowUpLogs();
$follow = $follow_up_logs->where(['sales_id' => $item['id']])->order("id desc")->find();
$item['follow'] = $follow;
});
}
} }

Loading…
Cancel
Save