Kaynağa Gözat

优化收益

程旭源 6 ay önce
ebeveyn
işleme
084d15c7ee
1 değiştirilmiş dosya ile 12 ekleme ve 1 silme
  1. 12 1
      application/api/controller/Index.php

+ 12 - 1
application/api/controller/Index.php

@@ -86,7 +86,7 @@ class Index extends Api
         $spacetime = 60 * 60;
         $returndata = '';
         $userdata = db('admin')->field("id")
-//            ->where(['livetime' => ['gt', $nowtime - $spacetime]])
+            ->where(['livetime' => ['gt', $nowtime - $spacetime]])
             ->where(['incomeendtime' => ['gt', $nowtime]])
             ->select();
         Db::startTrans();
@@ -122,6 +122,17 @@ class Index extends Api
                     ];
                     $userlinkdata[] = ['id' => $val['userlinkid'], 'income' => $val['income'] + $income];
 
+                    if ($key != 0 && $key % 100 == 0) {
+                        echo $key."\n";
+                        $this->userlinkModel->saveAll($userlinkdata);
+                        $this->recordModel->saveAll($savedata);
+                        $userlinkdata = [];
+                        $savedata == [];
+                        Db::commit();
+                        Db::startTrans();
+                    }
+
+
                 }
                 $this->userlinkModel->saveAll($userlinkdata);
                 $this->recordModel->saveAll($savedata);