Explorar el Código

Merge branch 'master' of ssh://git.9026.com:2212/swdz-WangHaijun/BaoMa into develop

Mike hace 4 años
padre
commit
e6b35708fe
Se han modificado 2 ficheros con 4 adiciones y 5 borrados
  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
@@ -169,7 +169,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');
         }
 
         //给用户发送微信消息
@@ -304,7 +304,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;
@@ -377,7 +377,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, '该疫苗库存不足');
             }