dyjh 6 gadi atpakaļ
vecāks
revīzija
3af2219805
1 mainītis faili ar 15 papildinājumiem un 1 dzēšanām
  1. 15 1
      app/Http/Controllers/Api/V1/AlbumController.php

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

xqd xqd
@@ -520,7 +520,7 @@ class AlbumController extends Controller
             AlbumWatchRecord::create($add_record);
         }
         $goods = AlbumProductModel::where([['id',$goods_id],['store_id',$store_id]])->first();
-        if(!empty($goods) && $userAuth->up_agent_id != 1){
+        if(!empty($goods) && $userAuth->is_dealer != 1){
             $price = DB::table('album_product_price')->where([['agent_id',$userAuth->up_agent_id],['store_id',$store_id],['product_id',$goods['id']]])->first();
             if(!empty($price)){
                 $goods->price = $price->price;
@@ -541,6 +541,20 @@ class AlbumController extends Controller
                 $goods->is_favorite = 0;
                 $goods->favorite_id = '';
             }
+        }elseif(!empty($goods) && $userAuth->is_dealer == 1){
+            $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
+            $agent_id = $user_agent['id'];
+            $price = DB::table('album_product_price')->where([['agent_id',$agent_id],['store_id',$store_id],['product_id',$goods['id']]])->first();
+            if(!empty($price)){
+                $goods->price = $price->price;
+                $goods->mobile = $price->mobile;
+                $address = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
+                $goods->address = $address;
+            }else{
+                $goods->price = '';
+                $goods->mobile = '';
+                $goods->address = '';
+            }
         }
 
         return $this->api($goods);