gorden 7 months ago
parent
commit
e3eb058972
1 changed files with 21 additions and 1 deletions
  1. 21 1
      app/admin/service/order/AppointmentService.php

+ 21 - 1
app/admin/service/order/AppointmentService.php

@@ -32,6 +32,8 @@ class AppointmentService
         $id = $request->get('id', '');
         $mobile = $request->get('mobile', '');
         $status = $request->get('status', '');
+        $premisesName = $request->get('premises', '');
+        $appointmentMode = $request->get('appointment_mode', '');
 
         $rows = Db::table('appointment')
             ->leftJoin('member', 'member.member_id', '=', 'appointment.join_appointment_member_id')
@@ -45,9 +47,20 @@ class AppointmentService
             ->when($id != '', function ($query) use ($id) {
                 $query->where('appointment.appointment_id', 'like', '%' . $id . '%');
             })->when($mobile != '', function ($query) use ($mobile) {
-                $query->where('member.member_mobile', 'like', '%' . $mobile . '%');
+                $query->where(function($query2) use ($mobile) {
+                    $query2->where('member.member_mobile', 'like', '%' . $mobile . '%')
+                    ->orWhere('member_cert.member_cert_name', 'like', '%' . $mobile . '%');
+                });
             })->when($status != '', function ($query) use ($status) {
                 $query->where('appointment.appointment_status', $status);
+            })->when($premisesName != '',function($query) use ($premisesName){
+                $query->whereJsonContains('appointment_apply_json->premises',$premisesName);
+            })->when($appointmentMode != '',function($query) use ($appointmentMode){
+                if($appointmentMode == 'ONLINE'){
+                    $query->whereIn('appointment_mode',['ONLINE','ORDER']);
+                }else{
+                    $query->where('appointment_mode',$appointmentMode);
+                }
             });
 
         $total = $rows->count('member.member_id');
@@ -652,10 +665,15 @@ class AppointmentService
         $date = $request->get('date', '');
 //        $memberId = $request->get('member_id', '');
         $appointmentId = $request->get('appointment_id', '');
+        $premisesName = $request->get('premisses','');
         if (!$goodsId || !$date) {
             return json_fail("查询时间段失败!");
         }
 
+        if (!$premisesName){
+            return json_fail("请先选择预约场所");
+        }
+
         $goods = Goods::where('goods_id', $goodsId)->first();
         if (!$goods) {
             return json_fail('数据不存在');
@@ -664,6 +682,7 @@ class AppointmentService
         // 当前服务已预约出去的
         $appointments = Appointment::where('join_appointment_goods_id', $goodsId)
             ->where('appointment_datetime', $date)
+            ->whereJsonContains('appointment_apply_json->premises',$premisesName)
             ->when($appointmentId != '', function ($query) use ($appointmentId) {
                 $query->where('appointment_id', '<>', $appointmentId);
             })
@@ -686,6 +705,7 @@ class AppointmentService
                         if ($time['duration'] == $applyJsonTimes) {
                             $times[$key]['person'] -= $applyJson['person'];
                             if ($times[$key]['person'] < 1) {
+                                $times[$key]['person'] = 0;
                                 $times[$key]['disabled'] = true;
                             }
                         }