Browse Source

Merge branch 'master' of ssh://gitlab.frkj.cc:222/php/zhjwxt

master
王泽彦 10 months ago
parent
commit
7357c1304b
  1. 39
      niucloud/app/api/controller/apiController/ClassApi.php
  2. 18
      niucloud/app/api/controller/apiController/Common.php
  3. 120
      niucloud/app/api/controller/apiController/OrderTable.php
  4. 7
      niucloud/app/api/controller/apiController/ResourceSharing.php
  5. 20
      niucloud/app/api/route/route.php
  6. 3
      niucloud/app/model/customer_resources/CustomerResources.php
  7. 5
      niucloud/app/model/order_table/OrderTable.php
  8. 26
      niucloud/app/service/api/apiService/CommonService.php
  9. 128
      niucloud/app/service/api/apiService/OrderTableService.php
  10. 18
      niucloud/app/service/api/apiService/ResourceSharingService.php
  11. 11
      niucloud/app/service/api/apiService/TeachingResearchService.php
  12. 47
      niucloud/app/service/api/apiService/jlClassService.php

39
niucloud/app/api/controller/apiController/ClassApi.php

@ -69,6 +69,20 @@ class ClassApi extends BaseApiService
'id' => $id,
];
$res = (new PhysicalTestService())->getInfo($where);
$physicalTestReport = [];
if (isset($res['data']['physical_test_report'])) {
$value = $res['data']['physical_test_report'];
if (is_string($value)) {
if (strpos($value, ',') !== false) {
$physicalTestReport = array_map('trim', explode(',', $value));
} else {
$physicalTestReport = [$value];
}
} elseif (is_array($value)) {
$physicalTestReport = $value;
}
}
$res['data']['physical_test_report'] = $physicalTestReport;
if(!$res['code']){
return fail($res['msg']);
}
@ -96,19 +110,40 @@ class ClassApi extends BaseApiService
//添加作业
public function addJlPublishJob(Request $request)
{
$id = $this->member_id;
$data = $this->request->params([
["class_id",0],
["classes_id_name",''],
["content_text",''],
["description",''],
["content_type",''],
["course_id",0],
["course_id_name",''],
["student_id",''],
["students_ids_name",''],
["type",''],
["personnel_id",$id],
]);
if (isset($data['student_id'])) {
if (is_string($data['student_id']) && strpos($data['student_id'], ',') !== false) {
$studentIds = explode(',', $data['student_id']);
$studentIds = array_map('trim', $studentIds);
} elseif (is_array($data['student_id'])) {
$studentIds = $data['student_id'];
} else {
$studentIds = [(string)$data['student_id']];
}
$studentIds = array_map('intval', $studentIds);
} else {
$studentIds = [];
}
$data['student_id'] = $studentIds;
return success('操作成功', (new jlClassService())->addPublishJob($data));
}
//获取我的页面统计个数
public function getStatisticsInfo()
{
$id = $this->member_id;
return success('操作成功', (new jlClassService())->getStatisticsInfo($id));
}
}

18
niucloud/app/api/controller/apiController/Common.php

@ -92,5 +92,23 @@ class Common extends BaseApiService
return success($res['data']);
}
//获取全部课程列表
public function getCourseAll(Request $request)
{
$where = [];
$res = (new CommonService())->getCourseAllList($where);
return success($res);
}
//获取全部班级列表
public function getClassAll(Request $request)
{
$where = [
'status' => $request->param('status', '')
];
$res = (new CommonService())->getClassAllList($where);
return success($res);
}
}

120
niucloud/app/api/controller/apiController/OrderTable.php

@ -0,0 +1,120 @@
<?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 app\service\api\apiService\CourseService;
use app\service\api\apiService\OrderTableService;
use core\base\BaseApiService;
/**
* 订单-控制器相关接口
* Class Personnel
* @package app\api\controller\apiController
*/
class OrderTable extends BaseApiService
{
//订单-列表
public function index(Request $request)
{
$resource_id = $request->param('resource_id', '');//客户资源表school_customer_resources表id(两个参数2选1)
$staff_id = $request->param('staff_id', '');//员工表school_personnel表id(两个参数2选1)
if (empty($resource_id) && empty($staff_id)) {
return fail('缺少参数');
}
$where = [
'resource_id' => $resource_id,
'staff_id' => $staff_id,
];
$res = (new OrderTableService())->getList($where);
return success($res);
}
//订单-详情
public function info(Request $request)
{
$resource_id = $request->param('resource_id', '');//客户资源表school_customer_resources表id(两个参数2选1)
$staff_id = $request->param('staff_id', '');//员工表school_personnel表id(两个参数2选1)
if (empty($resource_id) && empty($staff_id)) {
return fail('缺少参数');
}
$where = [
'resource_id' => $resource_id,
'staff_id' => $staff_id,
];
$res = (new OrderTableService())->getInfo($where);
if (!$res['code']) {
return fail($res['msg']);
}
return success($res['data']);
}
//订单-创建
public function add(Request $request)
{
$params = $request->params([
["payment_type", ""], // 付款类型必填验证
["course_id", ""], // 课程ID必填验证
["class_id", ""], // 班级ID必填验证
["staff_id", ""], // 员工ID必填验证
["resource_id", ""], // 客户资源表ID必填验证
]);
foreach($params as $k=>$v){
if(empty($v)){
return fail('缺少参数');
}
}
$course = \app\model\course\Course::where('id', $params['course_id'])->find();
if (!$course) {
return fail('课程不存在');
}
$course = $course->toArray();
$order_amount = $course['price'];//课程的价格
$data = [
'payment_type' => $params['payment_type'],//付款类型: cash-现金支付, scan_code-扫码支付, subscription-订阅支付
'order_amount' => $order_amount,//订单金额
'course_id' => $params['course_id'],//课程ID
'class_id' => $params['class_id'],//班级ID
'staff_id' => $params['staff_id'],//员工表ID
'resource_id' => $params['resource_id'],//客户资源表id
];
$res = (new OrderTableService())->addData($data);
if (!$res['code']) {
return fail($res['msg']);
}
return success([]);
}
}

7
niucloud/app/api/controller/apiController/ResourceSharing.php

@ -28,9 +28,10 @@ class ResourceSharing extends BaseApiService
{
$user_id = $this->member_id;//当前登陆的用户id
$page = $request->param('page','1');//
$limit = $request->param('limit','10');//
$shared_by = $request->param('shared_by','');//共享人ID
$name = $request->param('name','');////客户资源表-姓名
$phone_number = $request->param('phone_number','');//客户资源表-手机号
$shared_at_str = $request->param('shared_at_str','');//共享时间|[开始时间(Y-m-d),结束时间(Y-m-d)]
$shared_at_arr = [];
if(!empty($shared_at_str)){
@ -42,6 +43,8 @@ class ResourceSharing extends BaseApiService
$where = [
'shared_by'=>$shared_by,
'shared_at_arr'=>$shared_at_arr,
'name'=>$name,
'phone_number'=>$phone_number,
];
$res= (new ResourceSharingService())->getList($where);
return success($res);

20
niucloud/app/api/route/route.php

@ -183,6 +183,11 @@ Route::group(function () {
//获取微信小程序openid
Route::post('common/getMiniWxOpenId', 'apiController.Common/getMiniWxOpenId');
//公共端-获取全部课程列表
Route::get('common/getCourseAll', 'apiController.Common/getCourseAll');
//公共端-获取全部班级列表
Route::get('common/getClassAll', 'apiController.Common/getClassAll');
@ -267,6 +272,12 @@ Route::group(function () {
//员工端-用户聊天-修改未读消息数量
Route::post('chat/editUnreadCount', 'apiController.Chat/editUnreadCount');
//员工端-订单管理-列表
Route::get('orderTable', 'apiController.OrderTable/index');
//员工端-订单管理-详情
Route::get('orderTable/info', 'apiController.OrderTable/info');
//员工端-订单管理-创建
Route::post('orderTable/add', 'apiController.OrderTable/add');
@ -278,6 +289,8 @@ Route::group(function () {
//添加作业
Route::get('class/Statistics/info', 'apiController.classApi/getStatisticsInfo');
//添加作业
Route::get('class/jlPublishJob/add', 'apiController.classApi/addJlPublishJob');
//添加作业-获取课程列表
@ -384,6 +397,13 @@ Route::group(function () {
//学生端-作业详情
Route::get('xy/assignment/info', 'apiController.Assignment/info');
//学生端-订单管理-列表
Route::get('xy/orderTable', 'apiController.OrderTable/index');
//学生端-订单管理-详情
Route::get('xy/orderTable/info', 'apiController.OrderTable/info');
//学生端-订单管理-创建
Route::post('xy/orderTable/add', 'apiController.OrderTable/add');

3
niucloud/app/model/customer_resources/CustomerResources.php

@ -89,7 +89,8 @@ class CustomerResources extends BaseModel
'updated_at' => '更新时间',
'deleted_at' => '逻辑删除时间',
'status' => '客户状态',
'member_label' => '资源标签'
'member_label' => '资源标签',
'member_id' => '客户登录标识'
];
public function orderTable()

5
niucloud/app/model/order_table/OrderTable.php

@ -78,19 +78,22 @@ class OrderTable extends BaseModel
//客户资源表-客户姓名
public function customerResources(){
return $this->hasOne(CustomerResources::class, 'id', 'resource_id')->joinType('left')->withField('name,id')->bind(['resource_id_name'=>'name']);
}
//课程表-课程名称
public function course(){
return $this->hasOne(Course::class, 'id', 'course_id')->joinType('left')->withField('course_name,id')->bind(['course_id_name'=>'course_name']);
}
//班级表-班级名称
public function classGrade(){
return $this->hasOne(ClassGrade::class, 'id', 'class_id')->joinType('left')->withField('class_name,id')->bind(['class_id_name'=>'class_name']);
}
//员工表-员工姓名
public function personnel(){
return $this->hasOne(Personnel::class, 'id', 'staff_id')->joinType('left')->withField('name,id')->bind(['staff_id_name'=>'name']);
}

26
niucloud/app/service/api/apiService/CommonService.php

@ -11,6 +11,8 @@
namespace app\service\api\apiService;
use app\model\class_grade\ClassGrade;
use app\model\course\Course;
use app\model\dict\Dict;
use app\model\member\Member;
use app\model\sys\SysConfig;
@ -265,5 +267,29 @@ class CommonService extends BaseApiService
];
}
//获取全部课程列表
public function getCourseAllList(array $where, string $field = '*')
{
$model = (new Course());
$res = $model->field($field)
->select()
->toArray();//员工信息
return $res;
}
//获取全部班级列表
public function getClassAllList(array $where, string $field = '*')
{
$model = (new ClassGrade());
if(!empty($where['status'])){
$model = $model->where('status',$where['status']);
}
$res = $model->field($field)
->select()
->toArray();//员工信息
return $res;
}
}

128
niucloud/app/service/api/apiService/OrderTableService.php

@ -0,0 +1,128 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址:https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\api\apiService;
use app\model\campus\Campus;
use app\model\campus_person_role\CampusPersonRole;
use app\model\chat_friends\ChatFriends;
use app\model\chat_messages\ChatMessages;
use app\model\dict\Dict;
use app\model\order_table\OrderTable;
use core\base\BaseApiService;
use think\facade\Db;
/**
* 订单管理-控制器服务层
* Class MemberService
* @package app\service\api\member
*/
class OrderTableService extends BaseApiService
{
public function __construct()
{
parent::__construct();
}
//查询列表
public function getList(array $where)
{
$page_params = $this->getPageParam();//获取请求参数中的页码+分页数
$page = $page_params['page'];
$limit = $page_params['limit'];
$model = new OrderTable();
//员工表id
if (!empty($where['staff_id'])) {
$model = $model->where('staff_id', $where['staff_id']);
}
//客户资源表id
if (!empty($where['resource_id'])) {
$model = $model->where('resource_id', $where['resource_id']);
}
$data = $model
->append([
'customerResources',
'course',
'classGrade',
'personnel'
])
->order('id','desc')
->paginate([
'list_rows' => $limit,
'page' => $page,
])->toArray();
return $data;
}
//查询详情
public function getInfo(array $where)
{
$model = new OrderTable();
//判断用没有员工id
if (!empty($where['staff_id'])) {
$model = $model->where('staff_id', $where['staff_id']);
}
//判断用没有客户资源id
if (!empty($where['resource_id'])) {
$model = $model->where('resource_id', $where['resource_id']);
}
$data = $model
->append([
'customerResources',
'course',
'classGrade',
'personnel'
])
->find();
if ($data) {
$data = $data->toArray();
$res = [
'code' => 1,
'msg' => '操作成功',
'data' => $data
];
return $res;
} else {
$res = [
'code' => 0,
'msg' => '暂无数据',
'data' => []
];
return $res;
}
}
//创建订单
public function addData(array $data)
{
$success = OrderTable::create($data);
$res = [
'code' => 1,
'msg' => '操作成功',
'data' => []
];
if (!$success) {
$res = [
'code' => 0,
'msg' => '操作失败',
'data' => []
];
}
return $res;
}
}

18
niucloud/app/service/api/apiService/ResourceSharingService.php

@ -12,6 +12,7 @@
namespace app\service\api\apiService;
use app\model\campus_person_role\CampusPersonRole;
use app\model\customer_resources\CustomerResources;
use app\model\order_table\OrderTable;
use app\model\resource_sharing\ResourceSharing;
use core\base\BaseApiService;
@ -47,8 +48,25 @@ class ResourceSharingService extends BaseApiService
->distinct(true)
->column('person_id');
$resource_id_arr = [];//客户资源表id
//客户资源表名字
if(!empty($where['name'])){
$resource_id = (new CustomerResources())->where('name', 'like', "%{$where['name']}%")->column('id');
$resource_id_arr = array_merge($resource_id_arr,$resource_id);
}
//客户资源表手机号
if(!empty($where['phone_number'])){
$resource_id = (new CustomerResources())->where('phone_number', 'like', "%{$where['phone_number']}%")->column('id');
$resource_id_arr = array_merge($resource_id_arr,$resource_id);
}
//去重
$resource_id_arr = array_unique($resource_id_arr);
$model = $this->model;
if($resource_id_arr){
$model = $model->whereIn('resource_id',$resource_id_arr);
}
if ((!empty($where['shared_by']) || isset($where['shared_by'])) && $where['shared_by'] !== '') {
$model = $model->where('shared_by', $where['shared_by']);

11
niucloud/app/service/api/apiService/TeachingResearchService.php

@ -59,12 +59,11 @@ class TeachingResearchService extends BaseApiService
$field = 'id,title,image,type,content,status,create_time,update_time,delete_time,table_type,user_permission,url,exam_papers_id';
$LessonCourseTeaching = new LessonCourseTeaching();
$info = $LessonCourseTeaching->field($field)->where([['id', "=", $id]])->findOrEmpty()->toArray();
if (is_array($info) && isset($info['type']) && $info['type'] == 2 && !empty($info['url']) && is_string($info['url'])) {
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
$domain = $_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? 'localhost';
$info['url'] = $protocol . $domain . '/' . $info['url'];
}
// if (is_array($info) && isset($info['type']) && $info['type'] == 2 && !empty($info['url']) && is_string($info['url'])) {
// $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
// $domain = $_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? 'localhost';
// $info['url'] = $protocol . $domain . '/' . $info['url'];
// }
return $info;
}

47
niucloud/app/service/api/apiService/jlClassService.php

@ -12,6 +12,7 @@
namespace app\service\api\apiService;
use app\model\class_grade\ClassGrade;
use app\model\course_schedule\CourseSchedule;
use app\model\student\Student;
use app\model\assignment\Assignment;
use app\model\course\Course;
@ -148,9 +149,51 @@ class jlClassService extends BaseApiService
public function addPublishJob($data)
{
$Assignment = new Assignment();
$res = $Assignment->create($data);
return $res;
foreach ($data['student_id'] as $v) {
$data['student_id'] = $v;
$Assignment->create($data);
}
return true;
}
public function getStatisticsInfo($id)
{
$CourseSchedule = new CourseSchedule();
$courseNum = $CourseSchedule->where('coach_id', $id)->count();
$classNum = $this->model->where('head_coach', $id)->count();
$studentInfo = $this->model->where('head_coach', $id)
->with(['classPersonnelRel' => function($query) {
$query->select();
}]);
$studentInfo = $studentInfo->select()->toArray();
$studentNum = 0;
foreach ($studentInfo as $v){
$studentNum += count($v['classPersonnelRel']);
}
// 获取当前时间戳
$now = time();
$firstDayOfMonth = date('Y-m-01', $now);
$lastDayOfMonth = date('Y-m-t', $now);
$classMonthNum = $this->model->where('head_coach', $id)->whereBetween('created_at', [$firstDayOfMonth, $lastDayOfMonth])->count();
$courseMonthNum = $CourseSchedule->where('coach_id', $id)->whereBetween('course_date', [$firstDayOfMonth, $lastDayOfMonth])->count();
$studentMonthInfo = $this->model->where('head_coach', $id)->whereBetween('created_at', [$firstDayOfMonth, $lastDayOfMonth])
->with(['classPersonnelRel' => function($query) {
$query->select();
}]);
$studentMonthInfo = $studentMonthInfo->select()->toArray();
$studentMonthNum = 0;
foreach ($studentMonthInfo as $v){
$studentMonthNum += count($v['classPersonnelRel']);
}
$arr = [
'courseNum' => $courseNum,
'classNum' => $classNum,
'studentNum' => $studentNum,
'classMonthNum' => $classMonthNum,
'courseMonthNum' => $courseMonthNum,
'studentMonthNum' => $studentMonthNum,
];
return $arr;
}
}

Loading…
Cancel
Save