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. 69
      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',

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

@ -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;
} }
@ -235,6 +235,7 @@ class OrderTableService extends BaseApiService
// 4.处理赠品 // 4.处理赠品
$this->handleGift($orderArray); $this->handleGift($orderArray);
} }
/** /**
* 支付成功后为学员分配课程 * 支付成功后为学员分配课程
* @param array $orderData 订单数据 * @param array $orderData 订单数据
@ -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
]; ];
// 如果原有课程已过期,更新有效期 $result = Db::table('school_student_courses')->insert($insertData);
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('学员课程新成功', [ \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
]); ]);
} }
@ -384,9 +392,10 @@ 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);
@ -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;
} }

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,14 +1551,88 @@ 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) {
const statusMap = { const statusMap = {

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'
@ -227,6 +241,14 @@
} }
}, },
onShow() {
console.log('订单详情页面显示')
},
onReady() {
console.log('订单详情页面准备完成')
},
methods: { methods: {
goBack() { goBack() {
uni.navigateBack() uni.navigateBack()
@ -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 {
@ -290,6 +294,14 @@
} }
}, },
onShow() {
console.log('订单列表页面显示')
},
onReady() {
console.log('订单列表页面准备完成')
},
methods: { methods: {
goBack() { goBack() {
uni.navigateBack() uni.navigateBack()
@ -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