xialei 1 рік тому
батько
коміт
79c4a1622a

+ 11 - 16
app/common/repositories/store/product/ProductAttrValueRepository.php

@@ -113,32 +113,29 @@ class ProductAttrValueRepository extends BaseRepository
113 113
             $address_id = explode(',',$address_code_list);
114 114
             log::info($address_id);
115 115
             $address_id = end($address_id);
116
-//            $address_id = $address_id[0];
117 116
         }
118 117
         $sku = [[
119 118
             'sku_id'=>$sku_id,
120 119
             'num'=>$num
121 120
         ]];
122 121
         //查询商品是否有货
123
-        $stock = GongApiRequest::stock($sku_id,$address_id,$num);
124
-        if($stock != '有货'){
125
-            Db::name('store_product')->where('product_id',$product_id)->update(['is_show' => 0, 'argument' => '此商品无货']);
126
-            if($delivery){
127
-                return false;
128
-            }else{
129
-                return ['code'=>-1,'message'=>'此商品无货'];
130
-//                throw new AuthException('此商品无货');
131
-            }
132
-        }
122
+        // $stock = GongApiRequest::stock($sku_id,$address_id,$num);
123
+        // if($stock != '有货'){
124
+        //     // Db::name('store_product')->where('product_id',$product_id)->update(['is_show' => 0, 'argument' => '此商品无货']);
125
+        //     if($delivery){
126
+        //         return false;
127
+        //     }else{
128
+        //         return ['code'=>-1,'message'=>'此商品无货'];
129
+        //     }
130
+        // }
133 131
         //查询商品上下架
134 132
         $goods_status = GongApiRequest::goods_status($spu_id);
135
-        if(!isset($goods_status[0]['status']) || $goods_status[0]['status'] != 1){
133
+        if(!isset($goods_status['status']) || $goods_status['status'] != 1){
136 134
             Db::name('store_product')->where('product_id',$product_id)->update(['is_show' => 0, 'argument' => '此商品已下架'.json_encode($goods_status)]);
137 135
             if($delivery){
138 136
                 return false;
139 137
             }else{
140 138
                 return ['code'=>-1,'message'=>'此商品已下架'];
141
-//                throw new AuthException('此商品已下架');
142 139
             }
143 140
         }
144 141
         //查询库存
@@ -149,7 +146,6 @@ class ProductAttrValueRepository extends BaseRepository
149 146
                 return false;
150 147
             }else {
151 148
                 return ['code'=>-1,'message'=>'此商品规格无货'];
152
-//                throw new AuthException('此商品规格无货');
153 149
             }
154 150
         }
155 151
         //查询运费
@@ -158,8 +154,7 @@ class ProductAttrValueRepository extends BaseRepository
158 154
             if($delivery){
159 155
                 return false;
160 156
             }else {
161
-                return ['code'=>-1,'message'=>'此商品下架'];
162
-//                throw new AuthException('此商品下架');
157
+                return ['code'=>-1,'message'=>'此商品不支持该地区'];
163 158
             }
164 159
         }
165 160
         return true;

+ 2 - 2
app/controller/admin/gong/Goods.php

@@ -319,7 +319,7 @@ class Goods extends BaseController
319 319
                     'stock'=>100,
320 320
                     'cost_price'=>$v['cost_price'],
321 321
                     'extension_one'=>5,
322
-                    'gong_sku_id'=>$v['sku_sn'],
322
+                    'gong_sku_id'=>$v['sku_id'],
323 323
                     'gong_mer_profit' => $v['profit'],
324 324
                     'gong_pension' => $v['yanglaojin'],
325 325
                     'gong_market_price' => $v['market_price'],
@@ -356,7 +356,7 @@ class Goods extends BaseController
356 356
                     'stock'=>100,
357 357
                     'cost_price'=>$v['cost_price'],
358 358
                     'extension_one'=>5,
359
-                    'gong_sku_id'=>$v['sku_sn'],
359
+                    'gong_sku_id'=>$v['sku_id'],
360 360
                     'gong_mer_profit' => $v['profit'],
361 361
                     'gong_pension' => $v['yanglaojin'],
362 362
                     'gong_market_price' => $v['market_price'],

+ 4 - 4
app/controller/merchant/gong/Goods.php

@@ -315,11 +315,11 @@ class Goods extends BaseController
315 315
                     'cost'=>$v['cost_price'],
316 316
                     'ot_price'=>$v['retail_price'],
317 317
                     'price'=>$v['market_price'],
318
-                    'unique'=>$ProductRepository->setUnique($id,$v['sku_sn'],0),
318
+                    'unique'=>$ProductRepository->setUnique($id,$v['sku_id'],0),
319 319
                     'stock'=>100,
320 320
                     'cost_price'=>$v['cost_price'],
321 321
                     'extension_one'=>5,
322
-                    'gong_sku_id'=>$v['sku_sn'],
322
+                    'gong_sku_id'=>$v['sku_id'],
323 323
                     'gong_mer_profit' => $v['profit'],
324 324
                     'gong_pension' => $v['yanglaojin'],
325 325
                     'gong_market_price' => $v['market_price'],
@@ -352,11 +352,11 @@ class Goods extends BaseController
352 352
                     'cost'=>$v['cost_price'],
353 353
                     'ot_price'=>$v['retail_price'],
354 354
                     'price'=>$v['market_price'],
355
-                    'unique'=>$ProductRepository->setUnique($id,$v['sku_sn'],0),
355
+                    'unique'=>$ProductRepository->setUnique($id,$v['sku_id'],0),
356 356
                     'stock'=>100,
357 357
                     'cost_price'=>$v['cost_price'],
358 358
                     'extension_one'=>5,
359
-                    'gong_sku_id'=>$v['sku_sn'],
359
+                    'gong_sku_id'=>$v['sku_id'],
360 360
                     'gong_mer_profit' => $v['profit'],
361 361
                     'gong_pension' => $v['yanglaojin'],
362 362
                     'gong_market_price' => $v['market_price'],

+ 6 - 3
app/traits/GongApiRequest.php

@@ -198,19 +198,22 @@ trait GongApiRequest
198 198
     }
199 199
 
200 200
     /**
201
-     * 查询商品上下架(未更改)
201
+     * 查询商品上下架
202 202
      * @param string $spu_id 商品spu_id
203 203
      * @return array|boolean
204 204
      * @author lin
205 205
      * @created 2022年5月19日11:46:54
206 206
      * */
207 207
     public static function goods_status($spu_id){
208
-        $url = '/api/goods/status';
208
+        $url = '/api_v2/Goods/getGoodsDetail';
209 209
         $body = [
210 210
             'access_token' => self::access_token(),
211
-            'spu_id' => $spu_id
211
+            'goods_id' => $spu_id,
212 212
         ];
213 213
         $res = self::curl_post(self::$path.$url,$body);
214
+        if ($res['error_code'] == 2001) {
215
+            return $res;
216
+        }
214 217
         if($res['error_code'] == 0){
215 218
             return $res['result'];
216 219
         }