浏览代码

提取pid更新

zhaozhen 2 年之前
父节点
当前提交
b8259ee674
共有 1 个文件被更改,包括 33 次插入1 次删除
  1. 33 1
      app/Console/Commands/Test.php

+ 33 - 1
app/Console/Commands/Test.php

@@ -14,6 +14,7 @@ use App\Models\Es\MassMsgSendDetailEs;
14 14
 use App\Models\MassMsg;
15 15
 use App\Models\MassMsgSendDetail;
16 16
 use App\Models\MassPopularizData;
17
+use App\Models\MomentTask;
17 18
 use App\Models\MpPlayletTrendData;
18 19
 use App\Models\OfficialWebUserActionSetId;
19 20
 use App\Models\PlatformOrderConf;
@@ -675,7 +676,14 @@ class Test extends Command
675 676
 
676 677
     public function repairData()
677 678
     {
678
-        $listGenerator = $this->massGenerator();
679
+        $masslistGenerator = $this->massGenerator();
680
+        $this->repairData2($masslistGenerator);
681
+        $momelistGenerator = $this->momentGenerator();
682
+        $this->repairData2($momelistGenerator);
683
+    }
684
+
685
+    public function repairData2($listGenerator)
686
+    {
679 687
         foreach ($listGenerator as $list) {
680 688
             foreach ($list as $item) {
681 689
                 $dataJson = $item->attachments;
@@ -720,4 +728,28 @@ class Test extends Command
720 728
             $idMin = $list->max('id');
721 729
         }
722 730
     }
731
+
732
+    public function momentGenerator()
733
+    {
734
+        $limit = 500;
735
+        $idMin = 0;
736
+        $idMax = MomentTask::query()->where('is_draw', 1)->max('id');
737
+
738
+        while ($idMin < $idMax) {
739
+            $list = MomentTask::query()
740
+                ->where('is_draw', 1)
741
+                ->where('id', '>', $idMin)
742
+                ->where('id', '<=', $idMax)
743
+                ->orderBy('id', 'ASC')
744
+                ->limit($limit)
745
+                ->get();
746
+            $count = $list->count();
747
+            if ($count == 0) break;
748
+
749
+            yield $list;
750
+
751
+            if ($count < $limit) break;
752
+            $idMin = $list->max('id');
753
+        }
754
+    }
723 755
 }