Browse Source

修改 bug

develop
王泽彦 5 months ago
parent
commit
9483cd128d
  1. 2
      docker-compose.yml
  2. 8
      niucloud/app/ExceptionHandle.php
  3. 3
      niucloud/app/api/controller/apiController/OrderTable.php
  4. 43
      niucloud/app/service/api/apiService/CoachStudentService.php
  5. 2
      niucloud/composer.json
  6. 6
      niucloud/config/log.php
  7. 4
      uniapp/api/apiRoute.js
  8. 12
      uniapp/components/order-list-card/index.vue

2
docker-compose.yml

@ -3,7 +3,7 @@ version: '3.8'
services:
# PHP 服务
php:
image: niucloud-php:8.2
image: niucloud-php:8.0
container_name: niucloud_php
volumes:
- ./niucloud:/var/www/html

8
niucloud/app/ExceptionHandle.php

@ -80,6 +80,14 @@ class ExceptionHandle extends Handle
*/
public function render($request, Throwable $e): Response
{
// 过滤 PHP 8.2 废弃警告 (Guzzle 兼容性问题)
if ($e instanceof \ErrorException &&
strpos($e->getMessage(), 'Creation of dynamic property') !== false) {
// 记录日志但不返回错误响应
Log::warning('Deprecated: ' . $e->getMessage());
return success('ok');
}
// 添加自定义异常处理机制
$massageData = env('app_debug', false) ? [
'file' => $e->getFile(),

3
niucloud/app/api/controller/apiController/OrderTable.php

@ -81,7 +81,7 @@ class OrderTable extends BaseApiService
$params = $request->params([
["payment_type", ""], // 付款类型必填验证
["course_id", ""], // 课程ID必填验证
["class_id", ""], // 班级ID必填验证
["class_id", 0], // 班级ID必填验证
["staff_id", ""], // 员工ID(可选)
["resource_id", ""], // 客户资源表ID必填验证
["order_type", ""], // 订单类型必填验证
@ -96,7 +96,6 @@ class OrderTable extends BaseApiService
$missing_params = [];
if(empty($params['payment_type'])) $missing_params[] = 'payment_type(支付方式)';
if(empty($params['course_id'])) $missing_params[] = 'course_id(课程ID)';
if(empty($params['class_id'])) $missing_params[] = 'class_id(班级ID)';
if(empty($params['resource_id'])) $missing_params[] = 'resource_id(客户资源ID)';
if(empty($params['order_type'])) $missing_params[] = 'order_type(订单类型)';
if(empty($params['student_id'])) $missing_params[] = 'student_id(学生ID)';

43
niucloud/app/service/api/apiService/CoachStudentService.php

@ -262,40 +262,17 @@ class CoachStudentService extends BaseApiService
->order('sc.created_at', 'desc')
->find();
// 获取学员对应的资源共享ID
// 获取学员对应的资源分配ID (resource_sharing_id)
$resourceSharingId = 0;
if (!empty($courseInfo) && !empty($courseInfo['resource_id'])) {
// 通过resource_id查找对应的资源共享记录,获取最新的一条
$resourceSharing = Db::table('school_resource_sharing')
->where('resource_id', $courseInfo['resource_id'])
->field('id')
->order('shared_at', 'desc')
->find();
if (!empty($resourceSharing)) {
$resourceSharingId = $resourceSharing['id'];
}
}
// 如果没有找到资源共享ID,尝试通过学员的user_id查找
if (empty($resourceSharingId)) {
// 获取学员的user_id
$student = Db::table('school_student')
->where('id', $studentId)
->field('user_id')
->find();
if (!empty($student['user_id'])) {
// 方法1:先尝试直接用user_id作为resource_id查找
$resourceSharing = Db::table('school_resource_sharing')
->where('resource_id', $student['user_id'])
->field('id')
->order('shared_at', 'desc')
->find();
if (!empty($resourceSharing)) {
$resourceSharingId = $resourceSharing['id'];
} else {
// 方法2:通过客户资源表查找
// 通过学员的user_id查找客户资源记录
$customerResource = Db::table('school_customer_resources')
->where('member_id', $student['user_id'])
->where('deleted_at', 0)
@ -304,17 +281,17 @@ class CoachStudentService extends BaseApiService
->find();
if (!empty($customerResource)) {
// 通过客户资源ID查找资源共享记录
$resourceSharing = Db::table('school_resource_sharing')
// 通过客户资源ID查找资源分配记录
// resource_sharing_id 是 school_resource_assignment 表的 id
$resourceAssignment = Db::table('school_resource_assignment')
->where('resource_id', $customerResource['id'])
->where('assignee_type', 'user')
->field('id')
->order('shared_at', 'desc')
->order('assigned_at', 'desc')
->find();
if (!empty($resourceSharing)) {
$resourceSharingId = $resourceSharing['id'];
}
}
if (!empty($resourceAssignment)) {
$resourceSharingId = $resourceAssignment['id'];
}
}
}

2
niucloud/composer.json

@ -44,7 +44,7 @@
"ext-bcmath": "*",
"ext-mbstring": "*",
"php-di/php-di": "v7.0.1",
"guzzlehttp/guzzle": "7.5",
"guzzlehttp/guzzle": "^7.8",
"yansongda/pay": "v3.6.3",
"symfony/psr-http-message-bridge": "v2.2.0",
"fastknife/ajcaptcha": "v1.2.1",

6
niucloud/config/log.php

@ -6,7 +6,7 @@
return [
// 默认日志记录通道
'default' => env('log.channel', 'file'),
// 日志记录级别
// 日志记录级别(空数组表示记录所有级别)
'level' => [],
// 日志类型记录的通道 ['error'=>'email',...]
'type_channel' => [],
@ -36,8 +36,8 @@ return [
'close' => false,
// 日志输出格式化
'format' => '[%s][%s] %s',
// 是否实时写入
'realtime_write' => false,
// 是否实时写入(改为true可以立即看到日志)
'realtime_write' => true,
],
// 其它日志通道配置
],

4
uniapp/api/apiRoute.js

@ -525,9 +525,9 @@ export default {
return await http.post('/updateOrderPaymentVoucher', data)
},
// 微信在线支付 - 创建支付订单
// 小程序支付 - 创建支付订单(使用校区配置)
async createWechatPayment(data = {}) {
return await http.post('/pay', data)
return await http.post('/pay/weappPay', data)
},
// 获取微信openid(使用code换取)

12
uniapp/components/order-list-card/index.vue

@ -579,16 +579,10 @@ export default {
console.log('发起微信支付 - 订单ID:', order._raw?.id || order.id)
console.log('发起微信支付 - OpenID:', openid.substring(0, 10) + '***')
//
// 使
const res = await apiRoute.createWechatPayment({
type: 'wechatpay',
trade_type: 'school_order_table',
trade_id: order._raw?.id || order.id,
openid: openid,
return_url: '',
quit_url: '',
buyer_id: '',
voucher: ''
order_id: order._raw?.id || order.id,
openid: openid
})
uni.hideLoading()

Loading…
Cancel
Save