From 3b91a6f78b379d8cba33a1912075806de8df974b Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Fri, 13 Jun 2025 11:50:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(ResourceSharing):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E8=B5=84=E6=BA=90=E5=85=B1=E4=BA=AB=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 ResourceSharing 控制器中添加了 name 和 phone_number 参数 - 在 CustomerResources 模型中添加了 member_id 字段 - 在 ResourceSharingService 服务中实现了根据客户姓名和手机号筛选资源共享记录的功能 --- .../apiController/ResourceSharing.php | 7 +++++-- .../customer_resources/CustomerResources.php | 3 ++- .../api/apiService/ResourceSharingService.php | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/niucloud/app/api/controller/apiController/ResourceSharing.php b/niucloud/app/api/controller/apiController/ResourceSharing.php index e87b153c..b2eb8cc6 100644 --- a/niucloud/app/api/controller/apiController/ResourceSharing.php +++ b/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); diff --git a/niucloud/app/model/customer_resources/CustomerResources.php b/niucloud/app/model/customer_resources/CustomerResources.php index 30a93c58..cee4efec 100644 --- a/niucloud/app/model/customer_resources/CustomerResources.php +++ b/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() diff --git a/niucloud/app/service/api/apiService/ResourceSharingService.php b/niucloud/app/service/api/apiService/ResourceSharingService.php index 7024ab7f..58a672f9 100644 --- a/niucloud/app/service/api/apiService/ResourceSharingService.php +++ b/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']); From 03c3ab95a9809cd22894854dce5348296dfaeffb Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Fri, 13 Jun 2025 17:43:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(api):=20=E6=B7=BB=E5=8A=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD=E5=92=8C=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增订单管理相关接口和功能,包括订单列表、详情和创建 - 添加获取全部课程列表和班级列表的公共接口 - 在路由中注册新接口 - 实现订单管理的服务层逻辑 --- .../api/controller/apiController/Common.php | 18 +++ .../controller/apiController/OrderTable.php | 120 ++++++++++++++++ niucloud/app/api/route/route.php | 12 ++ niucloud/app/model/order_table/OrderTable.php | 5 +- .../service/api/apiService/CommonService.php | 26 ++++ .../api/apiService/OrderTableService.php | 128 ++++++++++++++++++ 6 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 niucloud/app/api/controller/apiController/OrderTable.php create mode 100644 niucloud/app/service/api/apiService/OrderTableService.php diff --git a/niucloud/app/api/controller/apiController/Common.php b/niucloud/app/api/controller/apiController/Common.php index 7bccd8bd..9d2f4873 100644 --- a/niucloud/app/api/controller/apiController/Common.php +++ b/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); + } + } diff --git a/niucloud/app/api/controller/apiController/OrderTable.php b/niucloud/app/api/controller/apiController/OrderTable.php new file mode 100644 index 00000000..08b2065f --- /dev/null +++ b/niucloud/app/api/controller/apiController/OrderTable.php @@ -0,0 +1,120 @@ +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([]); + } +} diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index 8d542f04..b0d47cd4 100644 --- a/niucloud/app/api/route/route.php +++ b/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,13 @@ 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'); + diff --git a/niucloud/app/model/order_table/OrderTable.php b/niucloud/app/model/order_table/OrderTable.php index 04532570..2c2d28c3 100644 --- a/niucloud/app/model/order_table/OrderTable.php +++ b/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']); } diff --git a/niucloud/app/service/api/apiService/CommonService.php b/niucloud/app/service/api/apiService/CommonService.php index 1f0e82cf..2e31b14a 100644 --- a/niucloud/app/service/api/apiService/CommonService.php +++ b/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; + } + + } diff --git a/niucloud/app/service/api/apiService/OrderTableService.php b/niucloud/app/service/api/apiService/OrderTableService.php new file mode 100644 index 00000000..09989091 --- /dev/null +++ b/niucloud/app/service/api/apiService/OrderTableService.php @@ -0,0 +1,128 @@ +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; + } +} From 1a8c90142731fc1f071dec54a35b850e76a7d31a Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Fri, 13 Jun 2025 17:56:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat(api):=20=E6=B7=BB=E5=8A=A0=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E7=AB=AF=E8=AE=A2=E5=8D=95=E7=AE=A1=E7=90=86=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增学生端订单管理列表接口 - 新增学生端订单管理详情接口 - 新增学生端订单管理创建接口 --- niucloud/app/api/route/route.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index b0d47cd4..b283bfb9 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -396,6 +396,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'); +