diff --git a/niucloud/app/listener/personnel/Student.php b/niucloud/app/listener/personnel/Student.php
index 7da20c3d..2d66d3c4 100644
--- a/niucloud/app/listener/personnel/Student.php
+++ b/niucloud/app/listener/personnel/Student.php
@@ -12,7 +12,6 @@
namespace app\listener\personnel;
-
use app\model\class_resources_rel\ClassResourcesRel;
use app\model\contract\Contract;
use app\model\contract_sign\ContractSign;
@@ -22,6 +21,7 @@ use app\model\customer_resources\CustomerResources;
use app\model\order_table\OrderTable;
use app\model\student_course_usage\StudentCourseUsage;
use app\model\student_courses\StudentCourses;
+use app\service\api\apiService\OrderTableService;
use think\facade\Db;
/**
@@ -43,12 +43,13 @@ class Student
}
}
- public function studentXiaoke($data){
+ public function studentXiaoke($data)
+ {
$courseSchedule = new CourseSchedule();
$studentCourses = new StudentCourses();
$student_course_usage = new StudentCourseUsage();
$schedule_info = $courseSchedule->where(['id' => $data['schedule_id']])->find();
- $studentCourses_info = $studentCourses->where(['student_id' => $data['student_id'],'course_id' => $schedule_info['course_id']])->find();
+ $studentCourses_info = $studentCourses->where(['student_id' => $data['student_id'], 'course_id' => $schedule_info['course_id']])->find();
$student_course_usage->insert([
'student_course_id' => $studentCourses_info['id'],
@@ -58,80 +59,13 @@ class Student
}
- public function studentAdd($order_info){
- $order = new OrderTable();
- $cust = new CustomerResources();
- $class_resources_rel = new ClassResourcesRel();
- $course = new Course();
- $studentCourses = new StudentCourses();
-
- $cust_info = $cust->where(['id' => $order_info['resource_id']])->find();
-
- // 1. 检查课程关联的合同
- $contract = new Contract();
- $contract_info = $contract
- ->alias("a")
- ->join(['school_course' => 'b'],'a.id = b.contract_id','left')
- ->where(['b.id' => $order_info['course_id']])
- ->field("a.id,a.contract_template")
- ->find();
-
- // 2. 建立合同签订关系(同时设置personnel_id和student_id)
- if ($contract_info) {
- $contract_sign = new ContractSign();
- $contract_sign->insert([
- 'contract_id' => $contract_info['id'],
- 'personnel_id' => $order_info['resource_id'], // 客户资源ID
- 'student_id' => $order_info['student_id'], // 学员ID
- 'sign_file' => $contract_info['contract_template'],
- 'type' => 2
- ]);
- }
-
- // 3. 获取课程信息
- $course_info = $course->where(['id' => $order_info['course_id']])->find();
-
- // 4. 查询学员是否有有效的课程安排
- $existing_course = $studentCourses
- ->where([
- 'student_id' => $order_info['student_id'],
- 'status' => 1 // 假设1表示正常状态
- ])
- // 有效课程条件:总课时+赠送课时 - 已用总课时 - 已用赠送课时 > 0 且 结束时间 > 当前时间
- ->where('(total_hours + gift_hours - use_total_hours - use_gift_hours) > 0')
- ->where('end_date > ?', [date('Y-m-d')])
- ->order('id', 'desc') // 按ID降序,取最新的一个
- ->find();
-
- // 5. 计算开始时间和结束时间
- if ($existing_course) {
- // 如果有有效课程,开始时间 = 最新课程的结束时间 + 1天,结束时间 = 开始时间 + duration天
- $start_date = date("Y-m-d", strtotime($existing_course['end_date'] . " +1 day"));
- $end_date = date("Y-m-d", strtotime($start_date . " +" . $course_info['duration'] . " days"));
- } else {
- // 如果没有有效课程,开始时间 = 当前时间,结束时间 = 当前时间 + duration天
- $start_date = date("Y-m-d");
- $end_date = date("Y-m-d", strtotime("+" . $course_info['duration'] . " days"));
+ public function studentAdd($order_info)
+ {
+ if ($order_info['order_status'] == 'paid') {
+ (new OrderTableService())->handlePaymentSuccess($order_info);
+ return true;
}
-
- // 6. 插入学员课程记录
- $student_course_id = $studentCourses->insertGetId([
- 'student_id' => $order_info['student_id'],
- 'course_id' => $order_info['course_id'],
- 'total_hours' => $course_info['session_count'],
- 'gift_hours' => $course_info['gift_session_count'],
- 'start_date' => $start_date,
- 'end_date' => $end_date,
- 'single_session_count' => $course_info['single_session_count'],
- 'resource_id' => $order_info['resource_id'],
- 'status' => 1 // 设置为正常状态
- ]);
-
- // 7. 更新订单表的course_plan_id
- $order->where(['id' => $order_info['id']])->update([
- 'course_plan_id' => $student_course_id
- ]);
-
+ return false;
}
diff --git a/niucloud/app/service/admin/person_course_schedule/PersonCourseScheduleService.php b/niucloud/app/service/admin/person_course_schedule/PersonCourseScheduleService.php
index eabea7ee..998c0279 100644
--- a/niucloud/app/service/admin/person_course_schedule/PersonCourseScheduleService.php
+++ b/niucloud/app/service/admin/person_course_schedule/PersonCourseScheduleService.php
@@ -231,11 +231,6 @@ class PersonCourseScheduleService extends BaseAdminService
}
return $data;
}
- public function xk(int $id){
- $data = $this->model->where([['id', '=', $id]])->find();
- event('Student', ['event_type' => 'xiaoke','data' => $data]);
- return true;
- }
public function getCustomerResourcesAll(){
$customerResourcesModel = new CustomerResources();
diff --git a/niucloud/app/service/api/apiService/OrderTableService.php b/niucloud/app/service/api/apiService/OrderTableService.php
index 77d83898..656bc2f9 100644
--- a/niucloud/app/service/api/apiService/OrderTableService.php
+++ b/niucloud/app/service/api/apiService/OrderTableService.php
@@ -169,15 +169,7 @@ class OrderTableService extends BaseApiService
// 如果订单状态变更为已支付,则执行完整的支付后处理流程
if ($data['order_status'] === 'paid') {
$orderArray = $order->toArray();
-
- // 1. 为学员分配课程
- $this->assignCourseToStudent($orderArray);
-
- // 2. 创建合同签署记录
- $this->createContractSign($orderArray);
-
- // 3. 创建支付记录
- $this->createPaymentRecord($orderArray);
+ $this->handlePaymentSuccess($orderArray);
}
return [
@@ -201,6 +193,20 @@ class OrderTableService extends BaseApiService
}
}
+ /**
+ * 处理支付成功后的业务
+ */
+ public function handlePaymentSuccess(array $orderArray)
+ {
+ // 1. 为学员分配课程
+ $this->assignCourseToStudent($orderArray);
+
+ // 2. 创建合同签署记录
+ $this->createContractSign($orderArray);
+
+ // 3. 创建支付记录
+ $this->createPaymentRecord($orderArray);
+ }
/**
* 支付成功后为学员分配课程
* @param array $orderData 订单数据
diff --git a/niucloud/app/service/api/student/CourseBookingService.php b/niucloud/app/service/api/student/CourseBookingService.php
index 30291a9d..78392a4d 100644
--- a/niucloud/app/service/api/student/CourseBookingService.php
+++ b/niucloud/app/service/api/student/CourseBookingService.php
@@ -36,25 +36,31 @@ class CourseBookingService extends BaseService
];
// 日期筛选
- if (!empty($params['date'])) {
+ if (!empty($params['date']) && $params['date'] !== 'undefined') {
$where[] = ['cs.course_date', '=', $params['date']];
}
// 日期范围筛选
- if (!empty($params['start_date']) && !empty($params['end_date'])) {
+ if (!empty($params['start_date']) && $params['start_date'] !== 'undefined' &&
+ !empty($params['end_date']) && $params['end_date'] !== 'undefined') {
$where[] = ['cs.course_date', 'between', [$params['start_date'], $params['end_date']]];
}
// 教练筛选
- if (!empty($params['coach_id'])) {
+ if (!empty($params['coach_id']) && $params['coach_id'] !== 'undefined') {
$where[] = ['cs.coach_id', '=', $params['coach_id']];
}
// 场地筛选
- if (!empty($params['venue_id'])) {
+ if (!empty($params['venue_id']) && $params['venue_id'] !== 'undefined') {
$where[] = ['cs.venue_id', '=', $params['venue_id']];
}
+ // 课程类型筛选
+ if (!empty($params['course_type']) && $params['course_type'] !== 'undefined') {
+ $where[] = ['c.course_type', '=', $params['course_type']];
+ }
+
// 查询可预约的课程安排
$availableCourses = Db::table('school_course_schedule cs')
->leftJoin('school_course c', 'cs.course_id = c.id')
diff --git a/uniapp/api/apiRoute.js b/uniapp/api/apiRoute.js
index 7d9c9109..5f523498 100644
--- a/uniapp/api/apiRoute.js
+++ b/uniapp/api/apiRoute.js
@@ -810,14 +810,26 @@ export default {
// 获取可预约课程列表
async getAvailableCourses(data = {}) {
try {
- const params = {
- date: data.date,
- start_date: data.start_date,
- end_date: data.end_date,
- coach_id: data.coach_id,
- venue_id: data.venue_id,
- course_type: data.course_type
- };
+ // 过滤掉undefined、null、空字符串的参数
+ const params = {};
+ if (data.date !== undefined && data.date !== null && data.date !== '') {
+ params.date = data.date;
+ }
+ if (data.start_date !== undefined && data.start_date !== null && data.start_date !== '') {
+ params.start_date = data.start_date;
+ }
+ if (data.end_date !== undefined && data.end_date !== null && data.end_date !== '') {
+ params.end_date = data.end_date;
+ }
+ if (data.coach_id !== undefined && data.coach_id !== null && data.coach_id !== '') {
+ params.coach_id = data.coach_id;
+ }
+ if (data.venue_id !== undefined && data.venue_id !== null && data.venue_id !== '') {
+ params.venue_id = data.venue_id;
+ }
+ if (data.course_type !== undefined && data.course_type !== null && data.course_type !== '') {
+ params.course_type = data.course_type;
+ }
const response = await http.get('/course-booking/available/' + data.student_id, params);
diff --git a/uniapp/pages-market/clue/class_arrangement_detail.vue b/uniapp/pages-market/clue/class_arrangement_detail.vue
index 0449e33e..961bde78 100644
--- a/uniapp/pages-market/clue/class_arrangement_detail.vue
+++ b/uniapp/pages-market/clue/class_arrangement_detail.vue
@@ -31,13 +31,9 @@
课程状态:{{ stu.courseStatus }}
上课情况:{{ stu.course_progress.used }}/{{ stu.course_progress.total }}节
到期时间:{{ stu.student_course_info.end_date || '未设置' }}
-
- 已签到
-
-
- 未签到
-
+ 已签到
+ 未签到
@@ -1212,6 +1208,27 @@
}
}
}
+
+ // 添加签到状态样式
+ .status-badge {
+ position: absolute;
+ top: 8rpx;
+ right: 8rpx;
+ padding: 4rpx 8rpx;
+ border-radius: 8rpx;
+ font-size: 20rpx;
+ font-weight: bold;
+
+ &.signed {
+ background-color: #29d3b4;
+ color: #fff;
+ }
+
+ &.unsigned {
+ background-color: #ffd86b;
+ color: #232323;
+ }
+ }
}
/* 弹窗样式 */
diff --git a/uniapp/pages-student/course-booking/index.vue b/uniapp/pages-student/course-booking/index.vue
index 5220e781..e74fcd83 100644
--- a/uniapp/pages-student/course-booking/index.vue
+++ b/uniapp/pages-student/course-booking/index.vue
@@ -322,11 +322,18 @@
try {
console.log('加载时段:', this.selectedDate)
+ // 构建请求参数,过滤undefined值
+ const params = {
+ student_id: this.studentId
+ };
+
+ // 只有当selectedDate有值时才传递
+ if (this.selectedDate && this.selectedDate !== '' && this.selectedDate !== 'undefined') {
+ params.date = this.selectedDate;
+ }
+
// 调用真实API
- const response = await apiRoute.getAvailableCourses({
- student_id: this.studentId,
- date: this.selectedDate
- })
+ const response = await apiRoute.getAvailableCourses(params)
if (response.code === 1) {
// 处理响应数据