Ver código fonte

优化收益

程旭源 8 meses atrás
pai
commit
084d15c7ee
1 arquivos alterados com 12 adições e 1 exclusões
  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);