Browse Source

修改 bug

master
王泽彦 8 months ago
parent
commit
e639761621
  1. 4
      admin/src/app/views/course_schedule/components/course-schedule-edit.vue
  2. 2
      admin/src/app/views/order_table/order_table.vue
  3. 2
      niucloud/app/service/api/apiService/CustomerResourcesService.php
  4. 101
      niucloud/app/service/api/apiService/OrderTableService.php
  5. 8
      uniapp/api/apiRoute.js
  6. 2
      uniapp/components/bottom-popup/index.vue
  7. 78
      uniapp/pages-market/clue/clue_info.vue
  8. 26
      uniapp/pages-student/orders/detail.vue
  9. 46
      uniapp/pages-student/orders/index.vue

4
admin/src/app/views/course_schedule/components/course-schedule-edit.vue

@ -113,8 +113,8 @@
<el-form-item :label="t('autoSchedule')" prop="auto_schedule"> <el-form-item :label="t('autoSchedule')" prop="auto_schedule">
<el-radio-group v-model="formData.auto_schedule"> <el-radio-group v-model="formData.auto_schedule">
<el-radio label="1">{{ t('yes') }}</el-radio> <el-radio :label="1">{{ t('yes') }}</el-radio>
<el-radio label="0">{{ t('no') }}</el-radio> <el-radio :label="0">{{ t('no') }}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>

2
admin/src/app/views/order_table/order_table.vue

@ -117,6 +117,8 @@
</div> </div>
<edit ref="editOrderTableDialog" @complete="loadOrderTableList" /> <edit ref="editOrderTableDialog" @complete="loadOrderTableList" />
</el-card> </el-card>

2
niucloud/app/service/api/apiService/CustomerResourcesService.php

@ -804,6 +804,8 @@ class CustomerResourcesService extends BaseApiService
->leftJoin('customer_resources cr', 'g.giver_id = cr.id') ->leftJoin('customer_resources cr', 'g.giver_id = cr.id')
->where('g.resource_id', $resource_id) ->where('g.resource_id', $resource_id)
->where('g.delete_time', 0) ->where('g.delete_time', 0)
->where('g.gift_status', 1)
->where('g.order_id', 0)
->field([ ->field([
'g.*', 'g.*',
'cr.name as giver_name', 'cr.name as giver_name',

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

@ -41,7 +41,7 @@ class OrderTableService extends BaseApiService
$limit = $page_params['limit']; $limit = $page_params['limit'];
$model = new OrderTable(); $model = new OrderTable();
//员工表id //员工表id
if (!empty($where['staff_id'])) { if (!empty($where['staff_id'])) {
$model = $model->where('staff_id', $where['staff_id']); $model = $model->where('staff_id', $where['staff_id']);
@ -51,7 +51,7 @@ class OrderTableService extends BaseApiService
if (!empty($where['resource_id'])) { if (!empty($where['resource_id'])) {
$model = $model->where('resource_id', $where['resource_id']); $model = $model->where('resource_id', $where['resource_id']);
} }
//学生表id //学生表id
if (!empty($where['student_id'])) { if (!empty($where['student_id'])) {
$model = $model->where('student_id', $where['student_id']); $model = $model->where('student_id', $where['student_id']);
@ -65,11 +65,11 @@ class OrderTableService extends BaseApiService
'personnel', 'personnel',
'studentCourses' // 添加学员课程关联 'studentCourses' // 添加学员课程关联
]) ])
->order('created_at','desc') // 使用created_at排序 ->order('created_at', 'desc') // 使用created_at排序
->paginate([ ->paginate([
'list_rows' => $limit, 'list_rows' => $limit,
'page' => $page, 'page' => $page,
])->toArray(); ])->toArray();
return $data; return $data;
} }
@ -129,7 +129,7 @@ class OrderTableService extends BaseApiService
]; ];
} }
} }
$success = OrderTable::create($data); $success = OrderTable::create($data);
// 如果订单创建成功且使用了赠品,更新赠品状态 // 如果订单创建成功且使用了赠品,更新赠品状态
@ -177,12 +177,12 @@ class OrderTableService extends BaseApiService
'order_status' => $data['order_status'], 'order_status' => $data['order_status'],
'updated_at' => date('Y-m-d H:i:s') 'updated_at' => date('Y-m-d H:i:s')
]; ];
// 如果提供了支付单号,则更新 // 如果提供了支付单号,则更新
if (!empty($data['payment_id'])) { if (!empty($data['payment_id'])) {
$updateData['payment_id'] = $data['payment_id']; $updateData['payment_id'] = $data['payment_id'];
} }
// 如果订单状态为已支付,记录支付时间 // 如果订单状态为已支付,记录支付时间
if ($data['order_status'] === 'paid') { if ($data['order_status'] === 'paid') {
$updateData['payment_time'] = date('Y-m-d H:i:s'); $updateData['payment_time'] = date('Y-m-d H:i:s');
@ -196,7 +196,7 @@ class OrderTableService extends BaseApiService
$orderArray = $order->toArray(); $orderArray = $order->toArray();
$this->handlePaymentSuccess($orderArray); $this->handlePaymentSuccess($orderArray);
} }
return [ return [
'code' => 1, 'code' => 1,
'msg' => '订单状态更新成功', 'msg' => '订单状态更新成功',
@ -235,6 +235,7 @@ class OrderTableService extends BaseApiService
// 4.处理赠品 // 4.处理赠品
$this->handleGift($orderArray); $this->handleGift($orderArray);
} }
/** /**
* 支付成功后为学员分配课程 * 支付成功后为学员分配课程
* @param array $orderData 订单数据 * @param array $orderData 订单数据
@ -246,7 +247,7 @@ class OrderTableService extends BaseApiService
$student_id = $orderData['student_id']; $student_id = $orderData['student_id'];
$course_id = $orderData['course_id']; $course_id = $orderData['course_id'];
$resource_id = $orderData['resource_id']; $resource_id = $orderData['resource_id'];
if (empty($student_id) || empty($course_id)) { if (empty($student_id) || empty($course_id)) {
\think\facade\Log::warning('学员分配课程失败:缺少学员ID或课程ID', $orderData); \think\facade\Log::warning('学员分配课程失败:缺少学员ID或课程ID', $orderData);
return false; return false;
@ -271,33 +272,38 @@ class OrderTableService extends BaseApiService
$end_date = date('Y-m-d', strtotime('+' . $course['duration'] . ' days')); $end_date = date('Y-m-d', strtotime('+' . $course['duration'] . ' days'));
if ($existingCourse) { if ($existingCourse) {
// 如果已有课程记录,累加课时数量 // 如果已有课程记录,计算新课程的开始时间
$updateData = [ // 新课程从现有课程结束后的第二天开始
'total_hours' => $existingCourse['total_hours'] + $course['session_count'], $new_start_date = date('Y-m-d', strtotime($existingCourse['end_date'] . ' +1 day'));
'gift_hours' => $existingCourse['gift_hours'] + $course['gift_session_count'], $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 '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') $result = Db::table('school_student_courses')->insert($insertData);
->where('id', $existingCourse['id'])
->update($updateData); \think\facade\Log::info('学员课程新增成功', [
\think\facade\Log::info('学员课程更新成功', [
'student_id' => $student_id, 'student_id' => $student_id,
'course_id' => $course_id, 'course_id' => $course_id,
'added_hours' => $course['session_count'], 'existing_end_date' => $existingCourse['end_date'],
'added_gift_hours' => $course['gift_session_count'] '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 { } else {
// 创建新的课程记录 // 创建新的课程记录
@ -317,15 +323,17 @@ class OrderTableService extends BaseApiService
'updated_at' => $now '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('学员课程创建成功', [ \think\facade\Log::info('学员课程创建成功', [
'student_id' => $student_id, 'student_id' => $student_id,
'course_id' => $course_id, 'course_id' => $course_id,
'total_hours' => $course['session_count'], 'total_hours' => $course['session_count'],
'gift_hours' => $course['gift_session_count'], 'gift_hours' => $course['gift_session_count'],
'start_date' => $start_date, '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 { try {
$student_id = $orderData['student_id']; $student_id = $orderData['student_id'];
$course_id = $orderData['course_id']; $course_id = $orderData['course_id'];
if (empty($student_id) || empty($course_id)) { if (empty($student_id) || empty($course_id)) {
\think\facade\Log::warning('创建合同签署记录失败:缺少学员ID或课程ID', $orderData); \think\facade\Log::warning('创建合同签署记录失败:缺少学员ID或课程ID', $orderData);
return false; return false;
@ -384,12 +392,13 @@ class OrderTableService extends BaseApiService
'deleted_at' => 0 'deleted_at' => 0
]; ];
$result = Db::table('school_contract_sign')->insert($insertData); $result = Db::table('school_contract_sign')->insert($insertData, true);
if ($result) { if ($result) {
OrderTable::find($orderData['id'])->update(['contract_id' => $result]);
// 创建签署记录成功后,为甲乙双方生成数据源配置记录 // 创建签署记录成功后,为甲乙双方生成数据源配置记录
$this->createDocumentDataSourceConfig($course['contract_id'], $orderData); $this->createDocumentDataSourceConfig($course['contract_id'], $orderData);
\think\facade\Log::info('合同签署记录创建成功', [ \think\facade\Log::info('合同签署记录创建成功', [
'student_id' => $student_id, 'student_id' => $student_id,
'contract_id' => $course['contract_id'], 'contract_id' => $course['contract_id'],
@ -456,7 +465,7 @@ class OrderTableService extends BaseApiService
if (!empty($insert_data)) { if (!empty($insert_data)) {
$result = Db::table('school_document_data_source_config')->insertAll($insert_data); $result = Db::table('school_document_data_source_config')->insertAll($insert_data);
if ($result) { if ($result) {
\think\facade\Log::info('文档数据源配置创建成功', [ \think\facade\Log::info('文档数据源配置创建成功', [
'contract_id' => $contract_id, 'contract_id' => $contract_id,
@ -464,7 +473,7 @@ class OrderTableService extends BaseApiService
'records_count' => count($insert_data) 'records_count' => count($insert_data)
]); ]);
} }
return $result ? true : false; return $result ? true : false;
} }
@ -492,7 +501,7 @@ class OrderTableService extends BaseApiService
$payment_id = $orderData['payment_id'] ?? ''; $payment_id = $orderData['payment_id'] ?? '';
$payment_type = $orderData['payment_type'] ?? ''; $payment_type = $orderData['payment_type'] ?? '';
$order_amount = $orderData['order_amount'] ?? 0; $order_amount = $orderData['order_amount'] ?? 0;
if (empty($order_id) || empty($payment_id)) { if (empty($order_id) || empty($payment_id)) {
\think\facade\Log::warning('创建支付记录失败:缺少订单ID或支付单号', $orderData); \think\facade\Log::warning('创建支付记录失败:缺少订单ID或支付单号', $orderData);
return false; return false;
@ -507,7 +516,7 @@ class OrderTableService extends BaseApiService
} }
} }
$status = Db::table('school_pay')->where('out_trade_no', $payment_id)->find(); $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]); \think\facade\Log::warning('创建支付记录失败:支付单号已存在', ['order_id' => $order_id, 'payment_id' => $payment_id]);
return false; return false;
} }
@ -535,7 +544,7 @@ class OrderTableService extends BaseApiService
]; ];
$result = Db::table('school_pay')->insert($insertData); $result = Db::table('school_pay')->insert($insertData);
if ($result) { if ($result) {
\think\facade\Log::info('支付记录创建成功', [ \think\facade\Log::info('支付记录创建成功', [
'order_id' => $order_id, 'order_id' => $order_id,
@ -658,7 +667,7 @@ class OrderTableService extends BaseApiService
'resource_id' => $resource_id, 'resource_id' => $resource_id,
'error' => $e->getMessage() 'error' => $e->getMessage()
]); ]);
return [ return [
'valid' => false, 'valid' => false,
'message' => '赠品验证异常: ' . $e->getMessage() 'message' => '赠品验证异常: ' . $e->getMessage()

8
uniapp/api/apiRoute.js

@ -1860,6 +1860,14 @@ export default {
return { code: 1, data: {} } return { code: 1, data: {} }
}, },
// 根据订单获取合同信息
async getContractByOrder(data = {}) {
return await http.get('/contract/getByOrder', {
order_id: data.order_id,
student_id: data.student_id
})
},
//↓↓↓↓↓↓↓↓↓↓↓↓-----知识库管理相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓ //↓↓↓↓↓↓↓↓↓↓↓↓-----知识库管理相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓
// 获取知识文章列表 // 获取知识文章列表

2
uniapp/components/bottom-popup/index.vue

@ -108,7 +108,7 @@ export default {
left: 0; left: 0;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
z-index: 1000; z-index: 10;
pointer-events: auto; pointer-events: auto;
} }

78
uniapp/pages-market/clue/clue_info.vue

@ -1551,13 +1551,87 @@ export default {
${orderInfo.paid_at ? '支付时间:' + this.formatOrderTime(orderInfo.paid_at) : ''} ${orderInfo.paid_at ? '支付时间:' + this.formatOrderTime(orderInfo.paid_at) : ''}
`.trim() `.trim()
//
const isOrderPaid = order.status === 'paid'
const buttons = isOrderPaid ? ['知道了', '合同签署'] : ['知道了']
uni.showModal({ uni.showModal({
title: '订单详情', title: '订单详情',
content: detailText, content: detailText,
showCancel: false, showCancel: isOrderPaid,
confirmText: '知道了' 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) { getOrderStatusText(status) {

26
uniapp/pages-student/orders/detail.vue

@ -203,6 +203,8 @@
}, },
onLoad(options) { onLoad(options) {
console.log('订单详情页面接收参数:', options)
this.orderId = parseInt(options.id) || 0 this.orderId = parseInt(options.id) || 0
this.studentId = parseInt(options.student_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) { if (this.orderId && this.studentId) {
this.loadOrderDetail() //
setTimeout(() => {
this.loadOrderDetail()
}, 100)
} else { } else {
console.error('订单详情页面参数错误:', {
orderId: this.orderId,
studentId: this.studentId
})
uni.showToast({ uni.showToast({
title: '参数错误', title: '参数错误',
icon: 'none' icon: 'none'
@ -226,6 +240,14 @@
}, 1500) }, 1500)
} }
}, },
onShow() {
console.log('订单详情页面显示')
},
onReady() {
console.log('订单详情页面准备完成')
},
methods: { methods: {
goBack() { goBack() {
@ -495,6 +517,8 @@
.main_box { .main_box {
background: #f8f9fa; background: #f8f9fa;
min-height: 100vh; min-height: 100vh;
position: relative;
z-index: 1;
} }
// //

46
uniapp/pages-student/orders/index.vue

@ -264,6 +264,8 @@
}, },
onLoad(options) { onLoad(options) {
console.log('订单列表页面加载,参数:', options)
// ID // ID
this.studentId = parseInt(options.student_id) || 0 this.studentId = parseInt(options.student_id) || 0
@ -275,6 +277,8 @@
} }
} }
console.log('订单列表页面学员ID确认:', this.studentId)
if (this.studentId) { if (this.studentId) {
this.initPage() this.initPage()
} else { } else {
@ -289,6 +293,14 @@
}, 1500) }, 1500)
} }
}, },
onShow() {
console.log('订单列表页面显示')
},
onReady() {
console.log('订单列表页面准备完成')
},
methods: { methods: {
goBack() { goBack() {
@ -595,11 +607,37 @@
} }
try { try {
// IDID console.log('跳转订单详情,参数:', {
uni.navigateTo({ order_id: order.id,
url: `/pages-student/orders/detail?id=${order.id}&student_id=${this.studentId}` student_id: this.studentId
}) })
//
uni.showLoading({
title: '正在加载...'
})
//
setTimeout(() => {
uni.hideLoading()
// IDID
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) { } catch (error) {
uni.hideLoading()
console.error('跳转订单详情失败:', error) console.error('跳转订单详情失败:', error)
uni.showToast({ uni.showToast({
title: '跳转失败', title: '跳转失败',
@ -1118,7 +1156,7 @@
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
z-index: 1000; z-index: 999;
.popup_content { .popup_content {
background: #fff; background: #fff;

Loading…
Cancel
Save