zilong 4 years ago
parent
commit
bc15d2f8c9
1 changed files with 8 additions and 1 deletions
  1. 8 1
      app/Models/Order.php

+ 8 - 1
app/Models/Order.php

xqd
@@ -129,7 +129,14 @@ class Order extends BaseModel
         if ($order['product_type'] == 3) {
             $orderPatient = OrderPatient::select(['time_period_id', 'appoint_start_time'])->where('order_id', $order_id)->first();
             $schedule_date = date('Y-m-d', $orderPatient['appoint_start_time']);
-            SchedulePeriod::where('docter_id', $order['docter_id'])->where('organization_id', $order['organization_id'])->where('time_period_id', $orderPatient['time_period_id'])->where('schedule_date', $schedule_date)->increment('order_num');
+            SchedulePeriod::where('docter_id', $order['docter_id'])->where('organization_id', $order['organization_id'])->where('schedule_type', 1)->where('time_period_id', $orderPatient['time_period_id'])->where('schedule_date', $schedule_date)->increment('order_num');
+        }
+        //如果是儿保和疫苗预约,预约时间段的订单数要加1
+        if (in_array($order['product_type'], [4,5])) {
+            $orderPatient = OrderPatient::select(['time_period_id', 'appoint_start_time'])->where('order_id', $order_id)->first();
+            $schedule_date = date('Y-m-d', $orderPatient['appoint_start_time']);
+            $schedule_type = $order['product_type'] == 4 ? 2 : 3;
+            SchedulePeriod::where('organization_id', $order['organization_id'])->where('schedule_type', $schedule_type)->where('time_period_id', $orderPatient['time_period_id'])->where('schedule_date', $schedule_date)->increment('order_num');
         }
 
         //如果是疫苗就减少疫苗库存