dever 3 years ago
parent
commit
34b1e226b9
1 changed files with 12 additions and 5 deletions
  1. 12 5
      lib/Core.php

+ 12 - 5
lib/Core.php

@@ -77,6 +77,7 @@ class Core
 	# 获取某一个用户的积分
 	public function getUserScore($uid, $config_id = false, $type = false, $type_id = false)
 	{
+		$score = array();
 		if ($config_id && $type && $type_id) {
 			$where['config_id'] = $config_id;
 			$where['type'] = $type;
@@ -88,8 +89,11 @@ class Core
 				$where['uid'] = $uid;
 				$where['config_child_id'] = $child['id'];
 				$score = Dever::db('score/user_child')->one($where);
-
-				return array('name' => $child['name'], 'score' => $score['score'] ? $score['score'] : 0);
+				if ($score) {
+					return array('name' => $child['name'], 'score' => $score['score'] ? $score['score'] : 0);
+				} else {
+					return array();
+				}
 			}
 		}
 
@@ -104,11 +108,14 @@ class Core
 			$where['uid'] = $uid;
 			$where['config_id'] = $config['id'];
 			$score = Dever::db('score/user')->one($where);
-
-			return array('name' => $config['name'], 'score' => $score['score'] ? $score['score'] : 0);
+			if ($score) {
+				return array('name' => $config['name'], 'score' => $score['score'] ? $score['score'] : 0);
+			} else {
+				return array();
+			}
 		}
 
-		return false;
+		return array();
 	}
 
 	# 获取用户积分日志列表