zilong il y a 4 ans
Parent
commit
3cde3b8e44
2 fichiers modifiés avec 4 ajouts et 5 suppressions
  1. 1 2
      app/Http/Controllers/Api/V1/OrderController.php
  2. 3 3
      app/Models/Order.php

+ 1 - 2
app/Http/Controllers/Api/V1/OrderController.php

xqd xqd
@@ -16,7 +16,6 @@ use App\Models\OrderNurse;
 use App\Models\OrderPack;
 use App\Models\OrderPatient;
 use App\Models\OrderVaccine;
-use App\Models\OrganizationVaccine;
 use App\Models\Patient;
 use App\Models\Payment;
 use App\Models\SchedulePeriod;
@@ -177,7 +176,7 @@ class OrderController extends AuthController
 
         //疫苗预约检查库存是否足够
         if ($req['product_type'] == 4) {
-            $stock = OrganizationVaccine::where('org_id', $req['organization_id'])->where('vaccine_id', $req['vaccine_id'])->value('stock');
+            $stock = Vaccine::where('id', $req['vaccine_id'])->value('stock');
             if ($stock <= 0) {
                 return out(null, 10009, '该疫苗库存不足');
             }

+ 3 - 3
app/Models/Order.php

xqd xqd xqd
@@ -168,7 +168,7 @@ class Order extends BaseModel
         //如果是疫苗就减少疫苗库存
         if ($order['product_type'] == 4) {
             $orderVaccine = OrderVaccine::where('order_id', $order_id)->first();
-            OrganizationVaccine::where('org_id', $order['organization_id'])->where('vaccine_id', $orderVaccine['vaccine_id'])->decrement('stock');
+            Vaccine::where('id', $orderVaccine['vaccine_id'])->decrement('stock');
         }
 
         //给用户发送微信消息
@@ -303,7 +303,7 @@ class Order extends BaseModel
         //如果是疫苗预约那么取消订单就增加疫苗库存
         if ($order['product_type'] == 4) {
             $orderVaccine = OrderVaccine::where('order_id', $order_id)->first();
-            OrganizationVaccine::where('org_id', $order['organization_id'])->where('vaccine_id', $orderVaccine['vaccine_id'])->increment('stock');
+            Vaccine::where('id', $orderVaccine['vaccine_id'])->increment('stock');
         }
 
         return true;
@@ -376,7 +376,7 @@ class Order extends BaseModel
 
         //疫苗预约检查库存是否足够
         if ($product_type == 4) {
-            $stock = OrganizationVaccine::where('org_id', $order['organization_id'])->where('vaccine_id', $order['order_vaccine']['vaccine_id'])->value('stock');
+            $stock = Vaccine::where('id', $order['order_vaccine']['vaccine_id'])->value('stock');
             if ($stock <= 0) {
                 exit_out(null, 10009, '该疫苗库存不足');
             }