haozi 5 лет назад
Родитель
Сommit
be58d76cb9
2 измененных файлов с 8 добавлено и 15 удалено
  1. 6 13
      app/Services/CommodityService.php
  2. 2 2
      package-lock.json

+ 6 - 13
app/Services/CommodityService.php

@@ -355,11 +355,13 @@ Class CommodityService
     public function pushCommodityToCache()
     {
         $amount = 1000;
-        $sum = Commodity::query()->count('id');
+        $commodity = Commodity::query()->orderByDesc('id')->first();
+        $sum=$commodity->id;
         $number = ceil($sum / $amount);
         for ($i = 0; $i < $number; $i++) {
+            if ($i<41) continue;
             $commodities = $this->getPiece(($i * $amount), $amount);
-            if (!$commodities) continue;
+            if (count($commodities)<1) continue;
             $this->pushToCache($commodities);
         }
     }
@@ -368,7 +370,7 @@ Class CommodityService
     {
         $commodities = Commodity::query()->with(['owner', 'barcodes'])
             ->where('id', '>=', $start)
-            ->where('id', '<', $amount)
+            ->where('id', '<', ($start+$amount))
             ->get();
         return $commodities;
     }
@@ -381,15 +383,6 @@ Class CommodityService
             Cache::remember($commodity_key, config('cache.expirations.forever'), function () use ($commodity) {
                 return $commodity;
             });
-
-//            if (count($commodity->barcodes) >= 1) {
-//                foreach ($commodity->barcodes as $barcode) {
-//                    $barcode_key = "barcode_{$barcode['code']}";
-//                    Cache::remember($barcode_key, config('cache.expirations.forever'),function()use($commodity) {
-//                        return $commodity;
-//                    });
-//                }
-//            }
         }
     }
 
@@ -407,7 +400,7 @@ Class CommodityService
         $last_records = $basSkus->where('addtime', $last_time);
         if (!$basSkus) return;
         $addBasSkus = $this->getLastRecordsByRedis($create_set, $create_key, $basSkus);
-        if (count($addBasSkus) > 0) $addBasSkus=$this->filterByCommodityCache($addBasSkus);
+        //if (count($addBasSkus) > 0) $addBasSkus=$this->filterByCommodityCache($addBasSkus);
         if (count($addBasSkus) > 0) {
             $this->syncCreateCommodity($addBasSkus);
             $this->deleteCacheKey($create_set, $create_keys);

+ 2 - 2
package-lock.json

@@ -6254,7 +6254,7 @@
         },
         "minimist": {
             "version": "1.2.0",
-            "resolved": "https://registry.npm.taobao.org/minimist/download/minimist-1.2.0.tgz",
+            "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
             "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
             "dev": true
         },
@@ -8840,7 +8840,7 @@
         },
         "socket.io-client": {
             "version": "2.3.0",
-            "resolved": "https://registry.npm.taobao.org/socket.io-client/download/socket.io-client-2.3.0.tgz",
+            "resolved": "https://registry.npm.taobao.org/socket.io-client/download/socket.io-client-2.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsocket.io-client%2Fdownload%2Fsocket.io-client-2.3.0.tgz",
             "integrity": "sha1-FNW6LgC5vNFFrkQ6uWs/hsvMG7Q=",
             "requires": {
                 "backo2": "1.0.2",