dever 7 年之前
父节点
当前提交
c5ae4b906f
共有 1 个文件被更改,包括 15 次插入10 次删除
  1. 15 10
      task/lib/Cron.php

+ 15 - 10
task/lib/Cron.php

@@ -56,17 +56,19 @@ class Cron
         
     	if ($data) {
     		foreach ($data as $k => $v) {
-    			$update['where_id'] = $v['id'];
-    			$update['score_status'] = 2;
-    			Dever::db('task/user_report')->update($update);
+                $state = $this->updateUserScore($v['uid'], $v['score']);
 
-    			$this->updateUserScore($v['uid'], $v['score']);
+                if ($state) {
+                    $update['where_id'] = $v['id'];
+                    $update['score_status'] = 2;
+                    Dever::db('task/user_report')->update($update);
 
-    			$this->updateScoreLog($v['uid'], $v['score'], 4, 2, $v['task_id'], $v['id']);
+                    $this->updateScoreLog($v['uid'], $v['score'], 4, 2, $v['task_id'], $v['id']);
 
-                $this->updateMsg($v['uid'], $v['score'], 4, $v['task_id']);
+                    $this->updateMsg($v['uid'], $v['score'], 4, $v['task_id']);
 
-				$this->group($v['uid'], $v['group_score'], $v['task_id'], $v['id'], 1);
+                    $this->group($v['uid'], $v['group_score'], $v['task_id'], $v['id'], 1);
+                }
     		}
     	}
 
@@ -169,9 +171,12 @@ class Cron
      */
     private function updateUserScore($uid, $score)
     {
-    	$update['where_uid'] = $uid;
-		$update['set_score'] = $score;
-		Dever::db('task/user_score')->updateScore($update);
+        if ($score > 0) {
+            $update['where_uid'] = $uid;
+            $update['score'] = $score;
+            return Dever::db('task/user_score')->updateScore($update);
+        }
+        return false;
     }
 
     /**