dyjh 6 éve
szülő
commit
8f146b165c
1 módosított fájl, 15 hozzáadás és 5 törlés
  1. 15 5
      app/Http/Controllers/Api/V1/AlbumController.php

+ 15 - 5
app/Http/Controllers/Api/V1/AlbumController.php

xqd
@@ -427,16 +427,26 @@ class AlbumController extends Controller
         $goods = $goods->select('id','cover_pic','name','style','hot_cake','news')->orderByDesc('sort')->get();
 
         foreach($goods as $key =>$val){
-            if(isset($data['agent_id'])){
-               // dd(111);
-                $check = AlbumProductPriceModel::where([['agent_id',$userAuth->up_agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
+            if($userAuth->is_dealer != 1){
+                if($userAuth->up_agent_id==0){
+                    $goods[$key]['price'] = '';
+                }else{
+                    $check = AlbumProductPriceModel::where([['agent_id',$userAuth->up_agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
+                    if($check){
+                        $goods[$key]['price'] = $check->price;
+                    }else{
+                        $goods[$key]['price'] = '';
+                    }
+                }
+            }elseif($userAuth->is_dealer == 1){
+                $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
+                $agent_id = $user_agent['id'];
+                $check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
                 if($check){
                     $goods[$key]['price'] = $check->price;
                 }else{
                     $goods[$key]['price'] = '';
                 }
-            }else{
-                $goods[$key]['price'] = '';
             }
         }
         $data =AlbumManufacturerModel::where('store_id',$store_id)->first();