Browse Source

修改京东脚本改为分批次入库

hefei 1 year ago
parent
commit
b86b524ded
1 changed files with 4 additions and 19 deletions
  1. 4 19
      app/controller/api/store/product/Jt.php

+ 4 - 19
app/controller/api/store/product/Jt.php

@@ -153,13 +153,7 @@ class Jt extends BaseController
153 153
           'sortName' => 'brokerage',
154 154
           'sort' => 'desc',
155 155
         ];
156
-      
157
-        // 尝试从缓存获取数据
158
-        $cachedData = cache('jd_goods_list');
159
-        if ($cachedData) {
160
-          return $cachedData;
161
-        }
162
-      
156
+
163 157
         $response = self::curlPost($url, $params);
164 158
       
165 159
         if (isset($response['result']['total_count'])) {
@@ -169,8 +163,7 @@ class Jt extends BaseController
169 163
           // 处理错误或返回合适信息
170 164
           return 'Error: 无法获取总数量';
171 165
         }
172
-      
173
-        $allGoods = [];
166
+
174 167
         for ($i = 1; $i <= $totalPages; $i++) {
175 168
           $params['pageIndex'] = $i;
176 169
           $response = self::curlPost($url, $params);
@@ -178,17 +171,9 @@ class Jt extends BaseController
178 171
           if (!isset($response['result']['data']) || count($response['result']['data']) < 1) {
179 172
             break;
180 173
           }
181
-      
182
-          $allGoods = array_merge($allGoods, $response['result']['data']);
174
+            $this->formatGoodsList($response['result']['data']);
183 175
         }
184
-      
185
-        // 格式化并处理商品列表
186
-        $formattedGoods = $this->formatGoodsList($allGoods);
187
-      
188
-        // 缓存数据 (根据需求调整过期时间)
189
-        cache('jd_goods_list', $formattedGoods, 3600);
190
-      
191
-        return $formattedGoods;
176
+        return '执行结束';
192 177
       }
193 178
 
194 179