wesmiler 2 лет назад
Родитель
Сommit
e0c7a0da4a

+ 3 - 2
app/Http/Controllers/Api/v1/GoodsController.php

@@ -62,10 +62,11 @@ class GoodsController extends webApp
     public function freight()
     {
         $addressId = request()->post('address_id', 0);
-        if($addressId<=0){
+        $skuList = request()->post('sku_list', []);
+        if($addressId<=0 || empty($skuList)){
             return showJson(1009, false);
         }
-        $info = GoodsService::make()->getFreight($this->userId, $addressId);
+        $info = GoodsService::make()->getFreight($this->userId, $addressId, $skuList);
         return showJson(1010, true, $info);
     }
 }

+ 3 - 3
app/Services/Api/GoodsService.php

@@ -205,9 +205,9 @@ class GoodsService extends BaseService
 
     }
 
-    public function getFreight($userId, $addressId)
+    public function getFreight($userId, $addressId,$skuList)
     {
-        $cacheKey = "caches:goods:freight:{$userId}_{$addressId}";
+        $cacheKey = "caches:goods:freight:{$userId}_{$addressId}_".md5(json_encode($skuList,256));
         $data =  RedisService::get($cacheKey);
         if($data){
             return $data;
@@ -218,7 +218,7 @@ class GoodsService extends BaseService
             $addressId = isset($address['district_code'])? $address['district_code'] : '';
         }
 
-        $result = SupplyService::make()->getApiData('getFreight',['address_id'=> $addressId]);
+        $result = SupplyService::make()->getApiData('getFreight',['address_id'=> intval($addressId),'sku_list'=> $skuList]);
         var_dump($result);
     }