Browse Source

在线选品下单

xialei 1 year ago
parent
commit
79c4a1622a

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

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

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

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

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

@@ -315,11 +315,11 @@ class Goods extends BaseController
315
                     'cost'=>$v['cost_price'],
315
                     'cost'=>$v['cost_price'],
316
                     'ot_price'=>$v['retail_price'],
316
                     'ot_price'=>$v['retail_price'],
317
                     'price'=>$v['market_price'],
317
                     'price'=>$v['market_price'],
318
-                    'unique'=>$ProductRepository->setUnique($id,$v['sku_sn'],0),
318
+                    'unique'=>$ProductRepository->setUnique($id,$v['sku_id'],0),
319
                     'stock'=>100,
319
                     'stock'=>100,
320
                     'cost_price'=>$v['cost_price'],
320
                     'cost_price'=>$v['cost_price'],
321
                     'extension_one'=>5,
321
                     'extension_one'=>5,
322
-                    'gong_sku_id'=>$v['sku_sn'],
322
+                    'gong_sku_id'=>$v['sku_id'],
323
                     'gong_mer_profit' => $v['profit'],
323
                     'gong_mer_profit' => $v['profit'],
324
                     'gong_pension' => $v['yanglaojin'],
324
                     'gong_pension' => $v['yanglaojin'],
325
                     'gong_market_price' => $v['market_price'],
325
                     'gong_market_price' => $v['market_price'],
@@ -352,11 +352,11 @@ class Goods extends BaseController
352
                     'cost'=>$v['cost_price'],
352
                     'cost'=>$v['cost_price'],
353
                     'ot_price'=>$v['retail_price'],
353
                     'ot_price'=>$v['retail_price'],
354
                     'price'=>$v['market_price'],
354
                     'price'=>$v['market_price'],
355
-                    'unique'=>$ProductRepository->setUnique($id,$v['sku_sn'],0),
355
+                    'unique'=>$ProductRepository->setUnique($id,$v['sku_id'],0),
356
                     'stock'=>100,
356
                     'stock'=>100,
357
                     'cost_price'=>$v['cost_price'],
357
                     'cost_price'=>$v['cost_price'],
358
                     'extension_one'=>5,
358
                     'extension_one'=>5,
359
-                    'gong_sku_id'=>$v['sku_sn'],
359
+                    'gong_sku_id'=>$v['sku_id'],
360
                     'gong_mer_profit' => $v['profit'],
360
                     'gong_mer_profit' => $v['profit'],
361
                     'gong_pension' => $v['yanglaojin'],
361
                     'gong_pension' => $v['yanglaojin'],
362
                     'gong_market_price' => $v['market_price'],
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
      * @param string $spu_id 商品spu_id
202
      * @param string $spu_id 商品spu_id
203
      * @return array|boolean
203
      * @return array|boolean
204
      * @author lin
204
      * @author lin
205
      * @created 2022年5月19日11:46:54
205
      * @created 2022年5月19日11:46:54
206
      * */
206
      * */
207
     public static function goods_status($spu_id){
207
     public static function goods_status($spu_id){
208
-        $url = '/api/goods/status';
208
+        $url = '/api_v2/Goods/getGoodsDetail';
209
         $body = [
209
         $body = [
210
             'access_token' => self::access_token(),
210
             'access_token' => self::access_token(),
211
-            'spu_id' => $spu_id
211
+            'goods_id' => $spu_id,
212
         ];
212
         ];
213
         $res = self::curl_post(self::$path.$url,$body);
213
         $res = self::curl_post(self::$path.$url,$body);
214
+        if ($res['error_code'] == 2001) {
215
+            return $res;
216
+        }
214
         if($res['error_code'] == 0){
217
         if($res['error_code'] == 0){
215
             return $res['result'];
218
             return $res['result'];
216
         }
219
         }