瀏覽代碼

提取pid更新

zhaozhen 1 年之前
父節點
當前提交
b8259ee674
共有 1 個文件被更改,包括 33 次插入1 次删除
  1. 33 1
      app/Console/Commands/Test.php

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

14
 use App\Models\MassMsg;
14
 use App\Models\MassMsg;
15
 use App\Models\MassMsgSendDetail;
15
 use App\Models\MassMsgSendDetail;
16
 use App\Models\MassPopularizData;
16
 use App\Models\MassPopularizData;
17
+use App\Models\MomentTask;
17
 use App\Models\MpPlayletTrendData;
18
 use App\Models\MpPlayletTrendData;
18
 use App\Models\OfficialWebUserActionSetId;
19
 use App\Models\OfficialWebUserActionSetId;
19
 use App\Models\PlatformOrderConf;
20
 use App\Models\PlatformOrderConf;
675
 
676
 
676
     public function repairData()
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
         foreach ($listGenerator as $list) {
687
         foreach ($listGenerator as $list) {
680
             foreach ($list as $item) {
688
             foreach ($list as $item) {
681
                 $dataJson = $item->attachments;
689
                 $dataJson = $item->attachments;
720
             $idMin = $list->max('id');
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
 }