diff --git a/admin/src/app/views/course_schedule/components/course-schedule-edit.vue b/admin/src/app/views/course_schedule/components/course-schedule-edit.vue
index 6ed96814..95340eed 100644
--- a/admin/src/app/views/course_schedule/components/course-schedule-edit.vue
+++ b/admin/src/app/views/course_schedule/components/course-schedule-edit.vue
@@ -113,8 +113,8 @@
- {{ t('yes') }}
- {{ t('no') }}
+ {{ t('yes') }}
+ {{ t('no') }}
diff --git a/admin/src/app/views/order_table/order_table.vue b/admin/src/app/views/order_table/order_table.vue
index fe0a8353..7b1c21c6 100644
--- a/admin/src/app/views/order_table/order_table.vue
+++ b/admin/src/app/views/order_table/order_table.vue
@@ -117,6 +117,8 @@
+
+
diff --git a/niucloud/app/service/api/apiService/CustomerResourcesService.php b/niucloud/app/service/api/apiService/CustomerResourcesService.php
index f8e67ea8..ca95574d 100644
--- a/niucloud/app/service/api/apiService/CustomerResourcesService.php
+++ b/niucloud/app/service/api/apiService/CustomerResourcesService.php
@@ -804,6 +804,8 @@ class CustomerResourcesService extends BaseApiService
->leftJoin('customer_resources cr', 'g.giver_id = cr.id')
->where('g.resource_id', $resource_id)
->where('g.delete_time', 0)
+ ->where('g.gift_status', 1)
+ ->where('g.order_id', 0)
->field([
'g.*',
'cr.name as giver_name',
diff --git a/niucloud/app/service/api/apiService/OrderTableService.php b/niucloud/app/service/api/apiService/OrderTableService.php
index dd6243b2..81897ea7 100644
--- a/niucloud/app/service/api/apiService/OrderTableService.php
+++ b/niucloud/app/service/api/apiService/OrderTableService.php
@@ -41,7 +41,7 @@ class OrderTableService extends BaseApiService
$limit = $page_params['limit'];
$model = new OrderTable();
-
+
//员工表id
if (!empty($where['staff_id'])) {
$model = $model->where('staff_id', $where['staff_id']);
@@ -51,7 +51,7 @@ class OrderTableService extends BaseApiService
if (!empty($where['resource_id'])) {
$model = $model->where('resource_id', $where['resource_id']);
}
-
+
//学生表id
if (!empty($where['student_id'])) {
$model = $model->where('student_id', $where['student_id']);
@@ -65,11 +65,11 @@ class OrderTableService extends BaseApiService
'personnel',
'studentCourses' // 添加学员课程关联
])
- ->order('created_at','desc') // 使用created_at排序
+ ->order('created_at', 'desc') // 使用created_at排序
->paginate([
- 'list_rows' => $limit,
- 'page' => $page,
- ])->toArray();
+ 'list_rows' => $limit,
+ 'page' => $page,
+ ])->toArray();
return $data;
}
@@ -129,7 +129,7 @@ class OrderTableService extends BaseApiService
];
}
}
-
+
$success = OrderTable::create($data);
// 如果订单创建成功且使用了赠品,更新赠品状态
@@ -177,12 +177,12 @@ class OrderTableService extends BaseApiService
'order_status' => $data['order_status'],
'updated_at' => date('Y-m-d H:i:s')
];
-
+
// 如果提供了支付单号,则更新
if (!empty($data['payment_id'])) {
$updateData['payment_id'] = $data['payment_id'];
}
-
+
// 如果订单状态为已支付,记录支付时间
if ($data['order_status'] === 'paid') {
$updateData['payment_time'] = date('Y-m-d H:i:s');
@@ -196,7 +196,7 @@ class OrderTableService extends BaseApiService
$orderArray = $order->toArray();
$this->handlePaymentSuccess($orderArray);
}
-
+
return [
'code' => 1,
'msg' => '订单状态更新成功',
@@ -235,6 +235,7 @@ class OrderTableService extends BaseApiService
// 4.处理赠品
$this->handleGift($orderArray);
}
+
/**
* 支付成功后为学员分配课程
* @param array $orderData 订单数据
@@ -246,7 +247,7 @@ class OrderTableService extends BaseApiService
$student_id = $orderData['student_id'];
$course_id = $orderData['course_id'];
$resource_id = $orderData['resource_id'];
-
+
if (empty($student_id) || empty($course_id)) {
\think\facade\Log::warning('学员分配课程失败:缺少学员ID或课程ID', $orderData);
return false;
@@ -271,33 +272,38 @@ class OrderTableService extends BaseApiService
$end_date = date('Y-m-d', strtotime('+' . $course['duration'] . ' days'));
if ($existingCourse) {
- // 如果已有课程记录,累加课时数量
- $updateData = [
- 'total_hours' => $existingCourse['total_hours'] + $course['session_count'],
- 'gift_hours' => $existingCourse['gift_hours'] + $course['gift_session_count'],
+ // 如果已有课程记录,计算新课程的开始时间
+ // 新课程从现有课程结束后的第二天开始
+ $new_start_date = date('Y-m-d', strtotime($existingCourse['end_date'] . ' +1 day'));
+ $new_end_date = date('Y-m-d', strtotime($new_start_date . ' +' . $course['duration'] . ' days'));
+
+ // 创建新的课程记录
+ $insertData = [
+ 'student_id' => $student_id,
+ 'course_id' => $course_id,
+ 'total_hours' => $course['session_count'],
+ 'gift_hours' => $course['gift_session_count'],
+ 'start_date' => $new_start_date,
+ 'end_date' => $new_end_date,
+ 'use_total_hours' => 0,
+ 'use_gift_hours' => 0,
+ 'single_session_count' => $course['single_session_count'],
+ 'status' => 1, // 激活状态
+ 'resource_id' => $resource_id,
+ 'created_at' => $now,
'updated_at' => $now
];
-
- // 如果原有课程已过期,更新有效期
- if ($existingCourse['end_date'] < $start_date) {
- $updateData['start_date'] = $start_date;
- $updateData['end_date'] = $end_date;
- } else {
- // 延长有效期
- $updateData['end_date'] = date('Y-m-d',
- strtotime($existingCourse['end_date'] . ' +' . $course['duration'] . ' days')
- );
- }
- $result = Db::table('school_student_courses')
- ->where('id', $existingCourse['id'])
- ->update($updateData);
-
- \think\facade\Log::info('学员课程更新成功', [
+ $result = Db::table('school_student_courses')->insert($insertData);
+
+ \think\facade\Log::info('学员课程新增成功', [
'student_id' => $student_id,
'course_id' => $course_id,
- 'added_hours' => $course['session_count'],
- 'added_gift_hours' => $course['gift_session_count']
+ 'existing_end_date' => $existingCourse['end_date'],
+ 'new_start_date' => $new_start_date,
+ 'new_end_date' => $new_end_date,
+ 'new_hours' => $course['session_count'],
+ 'new_gift_hours' => $course['gift_session_count']
]);
} else {
// 创建新的课程记录
@@ -317,15 +323,17 @@ class OrderTableService extends BaseApiService
'updated_at' => $now
];
- $result = Db::table('school_student_courses')->insert($insertData);
-
+ $result = Db::table('school_student_courses')->insert($insertData, true);
+ // 更新订单表
+ OrderTable::find($orderData['id'])->update(['course_plan_id' => $result]);
\think\facade\Log::info('学员课程创建成功', [
'student_id' => $student_id,
'course_id' => $course_id,
'total_hours' => $course['session_count'],
'gift_hours' => $course['gift_session_count'],
'start_date' => $start_date,
- 'end_date' => $end_date
+ 'end_date' => $end_date,
+ 'course_plan_id' => $result
]);
}
@@ -350,7 +358,7 @@ class OrderTableService extends BaseApiService
try {
$student_id = $orderData['student_id'];
$course_id = $orderData['course_id'];
-
+
if (empty($student_id) || empty($course_id)) {
\think\facade\Log::warning('创建合同签署记录失败:缺少学员ID或课程ID', $orderData);
return false;
@@ -384,12 +392,13 @@ class OrderTableService extends BaseApiService
'deleted_at' => 0
];
- $result = Db::table('school_contract_sign')->insert($insertData);
-
+ $result = Db::table('school_contract_sign')->insert($insertData, true);
+
if ($result) {
+ OrderTable::find($orderData['id'])->update(['contract_id' => $result]);
// 创建签署记录成功后,为甲乙双方生成数据源配置记录
$this->createDocumentDataSourceConfig($course['contract_id'], $orderData);
-
+
\think\facade\Log::info('合同签署记录创建成功', [
'student_id' => $student_id,
'contract_id' => $course['contract_id'],
@@ -456,7 +465,7 @@ class OrderTableService extends BaseApiService
if (!empty($insert_data)) {
$result = Db::table('school_document_data_source_config')->insertAll($insert_data);
-
+
if ($result) {
\think\facade\Log::info('文档数据源配置创建成功', [
'contract_id' => $contract_id,
@@ -464,7 +473,7 @@ class OrderTableService extends BaseApiService
'records_count' => count($insert_data)
]);
}
-
+
return $result ? true : false;
}
@@ -492,7 +501,7 @@ class OrderTableService extends BaseApiService
$payment_id = $orderData['payment_id'] ?? '';
$payment_type = $orderData['payment_type'] ?? '';
$order_amount = $orderData['order_amount'] ?? 0;
-
+
if (empty($order_id) || empty($payment_id)) {
\think\facade\Log::warning('创建支付记录失败:缺少订单ID或支付单号', $orderData);
return false;
@@ -507,7 +516,7 @@ class OrderTableService extends BaseApiService
}
}
$status = Db::table('school_pay')->where('out_trade_no', $payment_id)->find();
- if ($status){
+ if ($status) {
\think\facade\Log::warning('创建支付记录失败:支付单号已存在', ['order_id' => $order_id, 'payment_id' => $payment_id]);
return false;
}
@@ -535,7 +544,7 @@ class OrderTableService extends BaseApiService
];
$result = Db::table('school_pay')->insert($insertData);
-
+
if ($result) {
\think\facade\Log::info('支付记录创建成功', [
'order_id' => $order_id,
@@ -658,7 +667,7 @@ class OrderTableService extends BaseApiService
'resource_id' => $resource_id,
'error' => $e->getMessage()
]);
-
+
return [
'valid' => false,
'message' => '赠品验证异常: ' . $e->getMessage()
diff --git a/uniapp/api/apiRoute.js b/uniapp/api/apiRoute.js
index df45f129..78befef3 100644
--- a/uniapp/api/apiRoute.js
+++ b/uniapp/api/apiRoute.js
@@ -1860,6 +1860,14 @@ export default {
return { code: 1, data: {} }
},
+ // 根据订单获取合同信息
+ async getContractByOrder(data = {}) {
+ return await http.get('/contract/getByOrder', {
+ order_id: data.order_id,
+ student_id: data.student_id
+ })
+ },
+
//↓↓↓↓↓↓↓↓↓↓↓↓-----知识库管理相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓
// 获取知识文章列表
diff --git a/uniapp/components/bottom-popup/index.vue b/uniapp/components/bottom-popup/index.vue
index f601f990..16f21b33 100644
--- a/uniapp/components/bottom-popup/index.vue
+++ b/uniapp/components/bottom-popup/index.vue
@@ -108,7 +108,7 @@ export default {
left: 0;
width: 100vw;
height: 100vh;
- z-index: 1000;
+ z-index: 10;
pointer-events: auto;
}
diff --git a/uniapp/pages-market/clue/clue_info.vue b/uniapp/pages-market/clue/clue_info.vue
index b8d6d3ae..844e6bf3 100644
--- a/uniapp/pages-market/clue/clue_info.vue
+++ b/uniapp/pages-market/clue/clue_info.vue
@@ -1551,13 +1551,87 @@ export default {
${orderInfo.paid_at ? '支付时间:' + this.formatOrderTime(orderInfo.paid_at) : ''}
`.trim()
+ // 检查是否为已支付订单,显示不同的按钮
+ const isOrderPaid = order.status === 'paid'
+
+ const buttons = isOrderPaid ? ['知道了', '合同签署'] : ['知道了']
+
uni.showModal({
title: '订单详情',
content: detailText,
- showCancel: false,
- confirmText: '知道了'
+ showCancel: isOrderPaid,
+ cancelText: isOrderPaid ? '知道了' : '',
+ confirmText: isOrderPaid ? '合同签署' : '知道了',
+ success: (res) => {
+ if (res.confirm && isOrderPaid) {
+ // 点击了合同签署按钮
+ this.goToContractSign(order)
+ }
+ }
})
},
+
+ // 跳转到合同签署页面
+ goToContractSign(order) {
+ // 检查必要参数
+ const studentId = order.student_id || this.currentStudent?.id
+ const contractId = order._raw?.contract_id || order.contract_id
+
+ if (!studentId) {
+ uni.showToast({
+ title: '缺少学生信息',
+ icon: 'none'
+ })
+ return
+ }
+
+ if (!contractId) {
+ // 如果订单中没有合同ID,尝试从课程信息或其他地方获取
+ // 这里可能需要调用API获取合同信息
+ this.getContractByOrder(order, studentId)
+ return
+ }
+
+ // 跳转到合同签署页面
+ uni.navigateTo({
+ url: `/pages-student/contracts/sign?contract_id=${contractId}&student_id=${studentId}&contract_name=${encodeURIComponent(order.product_name + '合同')}`
+ })
+ },
+
+ // 根据订单获取合同信息
+ async getContractByOrder(order, studentId) {
+ try {
+ uni.showLoading({ title: '获取合同信息...' })
+
+ // 调用API获取订单对应的合同
+ const res = await apiRoute.getContractByOrder({
+ order_id: order._raw?.id || order.id,
+ student_id: studentId
+ })
+
+ uni.hideLoading()
+
+ if (res.code === 1 && res.data) {
+ const contractInfo = res.data
+ // 跳转到合同签署页面
+ uni.navigateTo({
+ url: `/pages-student/contracts/sign?contract_id=${contractInfo.contract_id}&student_id=${studentId}&contract_name=${encodeURIComponent(contractInfo.contract_name || order.product_name + '合同')}`
+ })
+ } else {
+ uni.showToast({
+ title: res.msg || '未找到相关合同',
+ icon: 'none'
+ })
+ }
+ } catch (error) {
+ uni.hideLoading()
+ console.error('获取合同信息失败:', error)
+ uni.showToast({
+ title: '获取合同信息失败',
+ icon: 'none'
+ })
+ }
+ },
// 获取订单状态文本
getOrderStatusText(status) {
diff --git a/uniapp/pages-student/orders/detail.vue b/uniapp/pages-student/orders/detail.vue
index 800b32c8..d1da7970 100644
--- a/uniapp/pages-student/orders/detail.vue
+++ b/uniapp/pages-student/orders/detail.vue
@@ -203,6 +203,8 @@
},
onLoad(options) {
+ console.log('订单详情页面接收参数:', options)
+
this.orderId = parseInt(options.id) || 0
this.studentId = parseInt(options.student_id) || 0
@@ -214,9 +216,21 @@
}
}
+ console.log('订单详情页面参数确认:', {
+ orderId: this.orderId,
+ studentId: this.studentId
+ })
+
if (this.orderId && this.studentId) {
- this.loadOrderDetail()
+ // 延迟加载确保页面完全显示
+ setTimeout(() => {
+ this.loadOrderDetail()
+ }, 100)
} else {
+ console.error('订单详情页面参数错误:', {
+ orderId: this.orderId,
+ studentId: this.studentId
+ })
uni.showToast({
title: '参数错误',
icon: 'none'
@@ -226,6 +240,14 @@
}, 1500)
}
},
+
+ onShow() {
+ console.log('订单详情页面显示')
+ },
+
+ onReady() {
+ console.log('订单详情页面准备完成')
+ },
methods: {
goBack() {
@@ -495,6 +517,8 @@
.main_box {
background: #f8f9fa;
min-height: 100vh;
+ position: relative;
+ z-index: 1;
}
// 自定义导航栏
diff --git a/uniapp/pages-student/orders/index.vue b/uniapp/pages-student/orders/index.vue
index 649ca280..db39516d 100644
--- a/uniapp/pages-student/orders/index.vue
+++ b/uniapp/pages-student/orders/index.vue
@@ -264,6 +264,8 @@
},
onLoad(options) {
+ console.log('订单列表页面加载,参数:', options)
+
// 优先从参数获取学员ID,如果没有则从用户信息获取
this.studentId = parseInt(options.student_id) || 0
@@ -275,6 +277,8 @@
}
}
+ console.log('订单列表页面学员ID确认:', this.studentId)
+
if (this.studentId) {
this.initPage()
} else {
@@ -289,6 +293,14 @@
}, 1500)
}
},
+
+ onShow() {
+ console.log('订单列表页面显示')
+ },
+
+ onReady() {
+ console.log('订单列表页面准备完成')
+ },
methods: {
goBack() {
@@ -595,11 +607,37 @@
}
try {
- // 直接跳转到订单详情页面,传递学员ID和订单ID
- uni.navigateTo({
- url: `/pages-student/orders/detail?id=${order.id}&student_id=${this.studentId}`
+ console.log('跳转订单详情,参数:', {
+ order_id: order.id,
+ student_id: this.studentId
})
+
+ // 先显示加载提示
+ uni.showLoading({
+ title: '正在加载...'
+ })
+
+ // 延迟跳转确保页面状态稳定
+ setTimeout(() => {
+ uni.hideLoading()
+ // 直接跳转到订单详情页面,传递学员ID和订单ID
+ uni.navigateTo({
+ url: `/pages-student/orders/detail?id=${order.id}&student_id=${this.studentId}`,
+ success: () => {
+ console.log('订单详情页面跳转成功')
+ },
+ fail: (error) => {
+ console.error('页面跳转失败:', error)
+ uni.showToast({
+ title: '页面跳转失败',
+ icon: 'none'
+ })
+ }
+ })
+ }, 100)
+
} catch (error) {
+ uni.hideLoading()
console.error('跳转订单详情失败:', error)
uni.showToast({
title: '跳转失败',
@@ -1118,7 +1156,7 @@
display: flex;
justify-content: center;
align-items: center;
- z-index: 1000;
+ z-index: 999;
.popup_content {
background: #fff;