dever 3 年之前
父節點
當前提交
2f3ddf4dc7
共有 2 個文件被更改,包括 16 次插入2 次删除
  1. 14 0
      database/user.php
  2. 2 2
      lib/Core.php

+ 14 - 0
database/user.php

@@ -137,5 +137,19 @@ return array
 			'order' => array('id' => 'desc'),
 			'col' => 'id,uid,config_id,score|config_id',
 		),
+
+		# 更新积分
+		'inc' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'score' => array('yes', '+='),
+			),
+		),
 	)
 );

+ 2 - 2
lib/Core.php

@@ -321,7 +321,7 @@ class Core
 
 		$update = array();
 		$update['where_id'] = $user['id'];
-		$update['score'] = $user['score'] + $num;
+		$update['score'] = $num;
 
 		$insert = $where;
 		$insert['action_log_id'] = $log['id'];
@@ -337,7 +337,7 @@ class Core
 		$insert['id'] = Dever::db($this->user_log)->insert($insert);
 
 		if ($insert['id']) {
-			Dever::db($this->user)->update($update);
+			Dever::db($this->user)->inc($update);
 
 			# 提升等级
 			$level_type = Dever::db('score/level_type')->state();