Jelajahi Sumber

fix: bug修复

zhengzhibin 1 tahun lalu
induk
melakukan
c880469c15
2 mengubah file dengan 15 tambahan dan 6 penghapusan
  1. 14 5
      app/api/controller/Appointment.php
  2. 1 1
      app/common/model/Appointment.php

+ 14 - 5
app/api/controller/Appointment.php

@@ -7,6 +7,7 @@ use app\common\model\Address;
 use app\common\model\Appointment as appointmentModel;
 use app\common\model\AppointmentApplication;
 use app\common\model\AppointmentTicket;
+use think\Exception;
 use time\DateHelper;
 
 class Appointment extends Base
@@ -51,8 +52,12 @@ class Appointment extends Base
         $address_id = $this->request->param('address_id');
         $daytime = $this->request->param('daytime', date('Y-m-d'));
 
-        //生成工作日号源
-        \app\common\model\Appointment::createWeekTicketAll($daytime);
+        try {
+            //生成工作日号源
+            \app\common\model\Appointment::createWeekTicketAll($daytime);
+        } catch (Exception $e) {
+            $this->json_error($e->getMessage());
+        }
 
         $ticketModel = new AppointmentTicket();
         $tickets = $ticketModel->where('address_id', $address_id)->where('appointment_daytime', strtotime($daytime))->select();
@@ -98,7 +103,7 @@ class Appointment extends Base
             //标记预约状态
             if (in_array($period, $ticketPeriods)) {
 //                $arr[] = ['period' => $period, 'status' => 1];
-                continue;//排除
+                continue;//排除已被预约的
             } else {
                 $arr[] = ['period' => $period, 'status' => 0];
             }
@@ -122,8 +127,12 @@ class Appointment extends Base
 
         $daytime = $this->request->param('daytime', date('Y-m-d'));
 
-        //生成工作日号源
-        \app\common\model\Appointment::createWeekTicketAll($daytime);
+        try {
+            //生成工作日号源
+            \app\common\model\Appointment::createWeekTicketAll($daytime);
+        } catch (Exception $e) {
+            $this->json_error($e->getMessage());
+        }
 
         $addressIds = $ticketModel->where('appointment_daytime', strtotime($daytime))->distinct(true)->column('address_id');
 

+ 1 - 1
app/common/model/Appointment.php

@@ -70,7 +70,7 @@ class Appointment extends Model
                     (new AppointmentTicket())->allowField(true)->save([
                         'appointment_id' => $appoint->id,
                         'appointment_daytime' => $daytimestamp,
-                        'address_id' => $appoint->address_id,
+                        'address_id' => $appoint->specialist->address_id,
                         'provider_id' => $appoint->provider_id,
                         'status' => AppointmentTicket::STATUS_OPEN
                     ]);