13 changed files with 579 additions and 14 deletions
@ -0,0 +1,119 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\api\controller\apiController; |
|||
|
|||
use app\dict\member\MemberLoginTypeDict; |
|||
use app\model\member\Member; |
|||
use app\Request; |
|||
use app\service\api\apiService\CustomerResourcesService; |
|||
use app\service\api\login\LoginService; |
|||
use core\base\BaseApiService; |
|||
|
|||
/** |
|||
* 学员登陆控制器相关接口 |
|||
* Class Personnel |
|||
* @package app\api\controller\apiController |
|||
*/ |
|||
class customerResourcesAuth extends BaseApiService |
|||
{ |
|||
|
|||
//获取字典 |
|||
public function login(Request $request) |
|||
{ |
|||
$phone = $request->param('phone', ''); //手机号 |
|||
$password = $request->param('password', ''); //密码 |
|||
$openid = $request->param('openid', ''); //微信小程序openid |
|||
|
|||
if (empty($phone)) { |
|||
return fail('请输入手机号'); |
|||
} |
|||
if (empty($password)) { |
|||
return fail('请输入密码'); |
|||
} |
|||
|
|||
$member_info = Member::where('mobile', $phone)->find();//查账户表信息是否存在 |
|||
|
|||
|
|||
if (!$member_info) { |
|||
return fail('账户手机号有误'); |
|||
} |
|||
|
|||
$customerResources = \app\model\customer_resources\CustomerResources::where('member_id', $member_info['member_id'])->find();//查客户资源表信息是否存在 |
|||
if (!$customerResources) { |
|||
return fail('账户信息有误'); |
|||
} |
|||
|
|||
//创建密码 |
|||
//$a = create_password($password); |
|||
//验证密码 |
|||
if (!check_password($password, $member_info->password)) { |
|||
return fail('手机号或密码不正确'); |
|||
} |
|||
|
|||
|
|||
$res = (new LoginService())->login($member_info, MemberLoginTypeDict::MOBILE); |
|||
if (!$res) { |
|||
return fail('账户信息有误'); |
|||
} |
|||
$res['user_type'] = '3';//用户类型|3=学员 |
|||
return success($res); |
|||
} |
|||
|
|||
//学生详情 |
|||
public function info(){ |
|||
$member_id = $this->member_id; |
|||
$where = [ |
|||
'member_id'=>$member_id |
|||
]; |
|||
$res = (new CustomerResourcesService())->getInfo($where); |
|||
if (!$res['code']) { |
|||
return fail($res['msg']); |
|||
} |
|||
return success($res['data']); |
|||
} |
|||
|
|||
//学生详情-修改 |
|||
public function edit(Request $request){ |
|||
$member_id = $this->member_id; |
|||
$where = [ |
|||
'member_id'=>$member_id |
|||
]; |
|||
$data = [ |
|||
'headimg' => $request->param('headimg', ''), |
|||
'name' => $request->param('name', ''), |
|||
'gender' => $request->param('gender', ''), |
|||
'age' => $request->param('age', ''), |
|||
'phone_number' => $request->param('phone_number', ''), |
|||
]; |
|||
|
|||
// 验证必填字段 |
|||
if (empty($data['name'])) { |
|||
return fail('姓名不能为空'); |
|||
} |
|||
if (empty($data['gender'])) { |
|||
return fail('性别不能为空'); |
|||
} |
|||
if (empty($data['age'])) { |
|||
return fail('年龄不能为空'); |
|||
} |
|||
if (empty($data['phone_number'])) { |
|||
return fail('手机号不能为空'); |
|||
} |
|||
|
|||
$res = (new CustomerResourcesService())->editInfo($where,$data); |
|||
if (!$res['code']) { |
|||
return fail($res['msg']); |
|||
} |
|||
return success([]); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\api\controller\apiController; |
|||
|
|||
use app\Request; |
|||
use app\service\api\apiService\CampusService; |
|||
use app\service\api\apiService\ChatService; |
|||
use app\service\api\apiService\CommonService; |
|||
use core\base\BaseApiService; |
|||
|
|||
/** |
|||
* 测试控制器相关接口 |
|||
* Class Personnel |
|||
* @package app\api\controller\apiController |
|||
*/ |
|||
class Test extends BaseApiService |
|||
{ |
|||
|
|||
//测试控制器Demo |
|||
public function index(Request $request) |
|||
{ |
|||
$personnel_id = $request->param('personnel_id', '');//员工人力资源表id(两个参数2选1) |
|||
$customer_resources_id = $request->param('customer_resources_id', '');//学生资源表id(两个参数2选1) |
|||
if (empty($personnel_id) && empty($customer_resources_id)) { |
|||
return fail('缺少参数'); |
|||
} |
|||
|
|||
$where = [ |
|||
'personnel_id' => $personnel_id, |
|||
'customer_resources_id' => $customer_resources_id, |
|||
]; |
|||
|
|||
$res = (new ChatService())->getChatFriendsPage($where); |
|||
|
|||
return success($res); |
|||
} |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\api\controller\apiController; |
|||
|
|||
use app\Request; |
|||
use core\base\BaseApiService; |
|||
|
|||
/** |
|||
* 学生用户反馈控制器相关接口 |
|||
* Class Personnel |
|||
* @package app\api\controller\apiController |
|||
*/ |
|||
class UserFeedback extends BaseApiService |
|||
{ |
|||
|
|||
//学生用户反馈-添加 |
|||
public function add(Request $request) |
|||
{ |
|||
// 接受参数 |
|||
$user_id = $request->post('user_id', ''); // 用户ID(对应school_customer_resources表id) |
|||
$feedback_text = $request->post('feedback_text', ''); // 反馈内容 |
|||
$attachment_url = $request->post('attachment_url', null); // 附件URL(OSS对象存储),允许为空 |
|||
|
|||
|
|||
//验证必填 |
|||
if (empty($user_id) || empty($feedback_text)) { |
|||
return fail('必填参数不能为空'); |
|||
} |
|||
|
|||
$data = [ |
|||
'user_id' => $user_id, |
|||
'feedback_text' => $feedback_text, |
|||
'attachment_url' => $attachment_url ?? null, |
|||
]; |
|||
|
|||
$add = \app\model\user_feedback\UserFeedback::create($data); |
|||
|
|||
if (!$add) { |
|||
return fail('添加失败'); |
|||
} |
|||
|
|||
return success([]); |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\model\class_personnel_rel; |
|||
|
|||
use core\base\BaseModel; |
|||
use think\model\concern\SoftDelete; |
|||
use think\model\relation\HasMany; |
|||
use think\model\relation\HasOne; |
|||
use app\model\student\Student; |
|||
use app\model\student_courses\StudentCourses; |
|||
use app\model\class_grade\ClassGrade; |
|||
|
|||
use app\model\customer_resources\CustomerResources; |
|||
|
|||
use app\model\campus\Campus; |
|||
|
|||
class ClassPersonnelRel extends BaseModel |
|||
{ |
|||
|
|||
|
|||
|
|||
/** |
|||
* 数据表主键 |
|||
* @var string |
|||
*/ |
|||
protected $pk = 'id'; |
|||
|
|||
/** |
|||
* 模型名称 |
|||
* @var string |
|||
*/ |
|||
protected $name = 'class_personnel_rel'; |
|||
|
|||
|
|||
public function student(){ |
|||
return $this->hasOne(Student::class, 'id', 'source_id'); |
|||
} |
|||
|
|||
public function studentCourses(){ |
|||
return $this->hasOne(StudentCourses::class, 'student_id', 'source_id')->joinType('left')->withField('end_date,student_id')->bind(['end_date'=>'end_date']); |
|||
} |
|||
|
|||
public function studentCoursesInfo(){ |
|||
return $this->hasOne(StudentCourses::class, 'student_id', 'source_id'); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,102 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\service\api\apiService; |
|||
|
|||
use app\model\class_grade\ClassGrade; |
|||
use core\base\BaseApiService; |
|||
|
|||
/** |
|||
* 考勤管理服务层 |
|||
* Class MemberService |
|||
* @package app\service\api\member |
|||
*/ |
|||
class jlClassService extends BaseApiService |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
$this->model = (new ClassGrade()); |
|||
} |
|||
|
|||
//列表 |
|||
public function list($id,$data) |
|||
{ |
|||
$order = 'id desc'; |
|||
$where = []; |
|||
if ($data['name'] !== '') { |
|||
$where[] = ['name','like','%'.$data['name'].'%']; |
|||
} |
|||
$search_model = $this->model->where('head_coach', $id)->where($where)->order($order) |
|||
->with(['classPersonnelRel' => function($query) { |
|||
$query->with(['student' => function($query) { |
|||
$query->with(['customerResources' => function($query) { |
|||
$query->with(['member' => function($query) { |
|||
$query->select(); |
|||
}]); |
|||
}]); |
|||
},'studentCourses']); |
|||
|
|||
},'personnelAll']); |
|||
$list = $this->pageQuery($search_model); |
|||
foreach ($list['data'] as &$v){ |
|||
if (count($v['classPersonnelRel']) > 0) { |
|||
$now = time(); |
|||
$count = 0; |
|||
foreach ($v['classPersonnelRel'] as $item) { |
|||
if (isset($item['end_date'])) { |
|||
$endTime = strtotime($item['end_date']); |
|||
if ($endTime > $now && $endTime <= $now + 7 * 86400) { |
|||
$count++; |
|||
} |
|||
} |
|||
} |
|||
$v['end_count'] = $count; |
|||
} else { |
|||
$v['end_count'] = 0; |
|||
} |
|||
} |
|||
return $list; |
|||
} |
|||
|
|||
|
|||
public function info($data) |
|||
{ |
|||
$search_model = $this->model->where('id', $data) |
|||
->with(['classPersonnelRel' => function($query) { |
|||
$query->with(['student' => function($query) { |
|||
$query->with(['customerResources' => function($query) { |
|||
$query->with(['member' => function($query) { |
|||
$query->select(); |
|||
}]); |
|||
}]); |
|||
},'studentCourses','studentCoursesInfo']); |
|||
},'personnelAll', 'personnelName']); |
|||
$list = $search_model->find(); |
|||
if (count($list['classPersonnelRel']) > 0) { |
|||
$now = time(); |
|||
$count = 0; |
|||
foreach ($list['classPersonnelRel'] as $item) { |
|||
if (isset($item['end_date'])) { |
|||
$endTime = strtotime($item['end_date']); |
|||
if ($endTime > $now && $endTime <= $now + 7 * 86400) { |
|||
$count++; |
|||
} |
|||
} |
|||
} |
|||
$v['end_count'] = $count; |
|||
} else { |
|||
$v['end_count'] = 0; |
|||
} |
|||
return $list; |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue