zilong há 4 anos atrás
pai
commit
cca7ed3e78
3 ficheiros alterados com 11 adições e 36 exclusões
  1. 7 35
      app/Models/Order.php
  2. 1 1
      app/Models/SchedulePeriod.php
  3. 3 0
      upgrade.md

+ 7 - 35
app/Models/Order.php

xqd xqd xqd xqd
@@ -145,6 +145,7 @@ class Order extends BaseModel
         Order::where('id', $order_id)->update([
             'order_status' => $order_status,
             'payment_status' => 2,
+            'is_source' => 1,
             'payment_time' => time(),
         ]);
         //发送下单消息
@@ -175,18 +176,6 @@ class Order extends BaseModel
             OrderPack::deductPackData($order['pay_order_pack_id'], $order['product_type']);
         }
 
-        //如果是门诊预约,预约时间段的订单数要加1
-        if ($order['product_type'] == 3) {
-            $schedule_date = date('Y-m-d', $orderPatient['appoint_start_time']);
-            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])) {
-            $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');
-        }
-
         //如果是疫苗就减少疫苗库存
         if ($order['product_type'] == 4) {
             $orderVaccine = OrderVaccine::where('order_id', $order_id)->first();
@@ -310,20 +299,14 @@ class Order extends BaseModel
                 }
             }
         }
-        Order::where('id', $order_id)->update($updateOrder);
 
-        //如果是门诊预约且距离预约时间还有1个小时以上,那么预约时间段的订单数减1
-        if ($order['product_type'] == 3 && $can_refund) {
-            $schedule_date = date('Y-m-d', $order['order_patient']['appoint_start_time']);
-            SchedulePeriod::where('docter_id', $order['docter_id'])->where('organization_id', $order['organization_id'])->where('time_period_id', $order['order_patient']['time_period_id'])->where('schedule_date', $schedule_date)->where('order_num', '>', 0)->decrement('order_num');
+        //能退就是取消占用号源
+        if ($can_refund) {
+            $updateOrder['is_source'] = 0;
         }
 
-        //如果是疫苗儿保预约且距离预约时间还有1个小时以上,那么预约时间段的订单数减1
-        if (in_array($order['product_type'], [4,5]) && $can_refund) {
-            $schedule_type_map = [4 => 2, 5 => 3];
-            $schedule_date = date('Y-m-d', $order['order_patient']['appoint_start_time']);
-            SchedulePeriod::where('organization_id', $order['organization_id'])->where('time_period_id', $order['order_patient']['time_period_id'])->where('schedule_date', $schedule_date)->where('schedule_type', $schedule_type_map[$order['product_type']])->where('order_num', '>', 0)->decrement('order_num');
-        }
+        Order::where('id', $order_id)->update($updateOrder);
+
         //如果是疫苗预约那么取消订单就增加疫苗库存
         if ($order['product_type'] == 4) {
             $orderVaccine = OrderVaccine::where('order_id', $order_id)->first();
@@ -446,20 +429,9 @@ class Order extends BaseModel
                 $updateOrder['payment_status'] = 5;
             }
         }
+        $updateOrder['is_source'] = 0;
         Order::where('id', $order_id)->update($updateOrder);
 
-        //如果是门诊预约且距离预约时间还有1个小时以上,那么预约时间段的订单数减1
-        if ($order['product_type'] == 3) {
-            $schedule_date = date('Y-m-d', $order['order_patient']['appoint_start_time']);
-            SchedulePeriod::where('docter_id', $order['docter_id'])->where('organization_id', $order['organization_id'])->where('time_period_id', $order['order_patient']['time_period_id'])->where('schedule_date', $schedule_date)->where('order_num', '>', 0)->decrement('order_num');
-        }
-
-        //如果是疫苗儿保预约且距离预约时间还有1个小时以上,那么预约时间段的订单数减1
-        if (in_array($order['product_type'], [4,5])) {
-            $schedule_type_map = [4 => 2, 5 => 3];
-            $schedule_date = date('Y-m-d', $order['order_patient']['appoint_start_time']);
-            SchedulePeriod::where('organization_id', $order['organization_id'])->where('time_period_id', $order['order_patient']['time_period_id'])->where('schedule_date', $schedule_date)->where('schedule_type', $schedule_type_map[$order['product_type']])->where('order_num', '>', 0)->decrement('order_num');
-        }
         //如果是疫苗预约那么取消订单就增加疫苗库存
         if ($order['product_type'] == 4) {
             $orderVaccine = OrderVaccine::where('order_id', $order_id)->first();

+ 1 - 1
app/Models/SchedulePeriod.php

xqd
@@ -38,7 +38,7 @@ class SchedulePeriod extends BaseModel
 
         $timePeriod = TimePeriod::select(['start_time_period'])->where('id', $this->time_period_id)->first();
         $appoint_start_time = strtotime($this->schedule_date.' '.$timePeriod['start_time_period'].':00');
-        $count = $builder->where('appoint_start_time', $appoint_start_time)->count();
+        $count = $builder->where('is_source', 1)->where('appoint_start_time', $appoint_start_time)->count();
 
         return $count;
     }

+ 3 - 0
upgrade.md

xqd
@@ -37,5 +37,8 @@
       PRIMARY KEY (`id`),
       KEY `user_id` (`user_id`)
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+    
+    ALTER TABLE `bm_orders` 
+    ADD COLUMN `is_source` tinyint(2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否占用号源(0.否 1.是)' AFTER `cancel_time`;
 
 - 线上在社区端后台改消息通知的菜单链接为:/community/noticeManage/noticelist