zilong 4 vuotta sitten
vanhempi
commit
7e76ae075c

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

xqd
@@ -301,7 +301,7 @@ class OrderController extends AuthController
             $orderPatient = OrderPatient::create($addPatient);
             //保存订单疫苗信息
             if ($req['product_type'] == 4) {
-                $addVaccine = Vaccine::select(['id as vaccine_id', 'type as vaccine_type', 'price as vaccine_price', 'name as vaccine_name', 'remark as vaccine_remark', 'supplier as vaccine_supplier'])->where('id', $req['vaccine_id'])->first()->getOriginal();
+                $addVaccine = Vaccine::join('organization_vaccines', 'organization_vaccines.vaccine_id', '=', 'vaccines.id')->select(['vaccines.id as vaccine_id', 'organization_vaccines.type as vaccine_type', 'organization_vaccines.price as vaccine_price', 'vaccines.name as vaccine_name', 'organization_vaccines.remark as vaccine_remark', 'organization_vaccines.supplier as vaccine_supplier'])->where('organization_vaccines.org_id', $req['organization_id'])->where('organization_vaccines.vaccine_id', $req['vaccine_id'])->first()->getOriginal();
                 $addVaccine['order_id'] = $order['id'];
                 $addVaccine['order_patient_id'] = $orderPatient['id'];
                 OrderVaccine::create($addVaccine);

+ 4 - 7
app/Http/Controllers/Api/V1/VaccineController.php

xqd
@@ -22,22 +22,19 @@ class VaccineController extends AuthController
             'sort_type' => 'in:0,1,2',
         ]);
 
-        $builder = Vaccine::join('organization_vaccines', 'organization_vaccines.vaccine_id', '=', 'vaccines.id')->select(['vaccines.id', 'vaccines.type', 'vaccines.price', 'vaccines.name', 'vaccines.remark', 'vaccines.supplier', 'organization_vaccines.stock'])->where('organization_vaccines.stock', '>', 0);
+        $builder = Vaccine::join('organization_vaccines', 'organization_vaccines.vaccine_id', '=', 'vaccines.id')->select(['vaccines.id', 'organization_vaccines.id as organization_vaccine_id', 'organization_vaccines.type', 'organization_vaccines.price', 'vaccines.name', 'organization_vaccines.remark', 'organization_vaccines.supplier', 'organization_vaccines.stock'])->where('organization_vaccines.stock', '>', 0)->where('organization_vaccines.org_id', $req['organization_id']);
         if (!empty($req['type'])) {
-            $builder->where('vacciness.type', $req['type']);
+            $builder->where('organization_vaccines.type', $req['type']);
         }
         if (!empty($req['name'])) {
             $builder->where('vacciness.name', 'like', '%'.$req['name'].'%');
         }
-        if (!empty($req['organization_id'])) {
-            $builder->where('organization_vaccines.org_id', $req['organization_id']);
-        }
         if (!empty($req['sort_type'])) {
             if ($req['sort_type'] == 1) {
-                $builder->orderBy('vaccines.price', 'asc');
+                $builder->orderBy('organization_vaccines.price', 'asc');
             }
             elseif ($req['sort_type'] == 2) {
-                $builder->orderBy('vaccines.price', 'desc');
+                $builder->orderBy('organization_vaccines.price', 'desc');
             }
         }