|
@@ -38,10 +38,12 @@ class Course extends Api{
|
|
|
// 接收参数
|
|
|
$ordersProductId = request('orders_product_id','');
|
|
|
$scheduleId = request('schedule_id','');
|
|
|
+ $courseId = request('course_id','');
|
|
|
//订单课程预约信息
|
|
|
- $ordersProductInfo = $OrdersProduct->query()->where('id','=',$ordersProductId)->first();
|
|
|
+ $ordersProductInfo = $OrdersProduct->query()->whereColumn('course_number','>','reservation_number')->where('course_id','=',$courseId)->first();
|
|
|
+
|
|
|
if (!$ordersProductInfo)
|
|
|
- return json_send(['code'=>'error','msg'=>'订单课程不存在','data'=>['error'=>'订单课程不存在']]);
|
|
|
+ return json_send(['code'=>'406','msg'=>'您还没购买课程','data'=>['error'=>'您还没购买课程']]);
|
|
|
if ($ordersProductInfo['course_number'] <= $ordersProductInfo['reservation_number'])
|
|
|
return json_send(['code'=>'error','msg'=>'您购买的课程节数已用完','data'=>['error'=>'您购买的课程节数已用完']]);
|
|
|
//上课表信息
|
|
@@ -116,12 +118,13 @@ class Course extends Api{
|
|
|
// 检查登录
|
|
|
$uid = $this->checkLogin();
|
|
|
// 接收参数
|
|
|
- $status = request('status',2);
|
|
|
+ $status = request('status',0);
|
|
|
$limit = request('limit',10);
|
|
|
// 显示
|
|
|
- $map[] = ['orders.custom_uid','=',$uid];
|
|
|
+ //$map[] = ['orders.custom_uid','=',$uid];
|
|
|
+ $map = [];
|
|
|
// 查询状态
|
|
|
- if( $status ) $map[] = ['orders.status','=',$status];
|
|
|
+ if( $status ) $map[] = ['status','=',$status];
|
|
|
$select = [
|
|
|
'orders_product.id as orders_product_id',
|
|
|
'orders_product.pay_total','orders_product.status',
|
|
@@ -139,13 +142,16 @@ class Course extends Api{
|
|
|
'course.image',
|
|
|
];
|
|
|
// 查询订单课程
|
|
|
- $Paginator = $orders->query()
|
|
|
- ->join('orders_product','orders_product.order_id','=','orders.id')
|
|
|
- ->join('course','orders_product.course_id','=','course.id')
|
|
|
+// $Paginator = $orders->query()
|
|
|
+// ->join('orders_product','orders_product.order_id','=','orders.id')
|
|
|
+// ->join('course','orders_product.course_id','=','course.id')
|
|
|
+// ->where($map)
|
|
|
+// ->whereColumn('orders_product.reservation_number','<','orders_product.course_number')
|
|
|
+// ->orderByDesc('orders_product.id')
|
|
|
+// ->paginate($limit, $select);
|
|
|
+ $Paginator = $Model->query()
|
|
|
->where($map)
|
|
|
- ->whereColumn('orders_product.reservation_number','<','orders_product.course_number')
|
|
|
- ->orderByDesc('orders_product.id')
|
|
|
- ->paginate($limit, $select);
|
|
|
+ ->paginate($limit);
|
|
|
foreach ($Paginator->items() as &$orders_product) {
|
|
|
$orders_product['image'] = path_compat($orders_product['image']);
|
|
|
}
|