dever 4 years ago
parent
commit
6448700dc3
2 changed files with 25 additions and 4 deletions
  1. 1 1
      database/config.php
  2. 24 3
      lib/Core.php

+ 1 - 1
database/config.php

@@ -97,7 +97,7 @@ return array
 		(
 			'list' => array('规则设置', '"rule&search_option_config_id={id}&oper_parent=config"'),
 
-			'list1' => array('自定义积分列表', '"config_child&search_option_config_id={id}&oper_parent=config"'),
+			'list1' => array('自定义积分列表', '"config_child&search_option_config_id={id}&oper_parent=config"', '{type} == 3'),
 		),
 	),
 

+ 24 - 3
lib/Core.php

@@ -13,6 +13,12 @@ class Core
 	 */
 	public function log($uid, $action_key, $action_name, $callback = '', $score = false, $num = false, $type = false, $type_id = false)
 	{
+		if (strstr($action_key, '.')) {
+			$temp = explode('.', $action_key);
+			$action_key = $temp[0];
+			$type = $temp[1];
+			$type_id = $temp[2];
+		}
 		$action = Dever::db('score/action')->one(array('key' => $action_key));
 
 		if (!$action) {
@@ -71,7 +77,7 @@ class Core
 	# 获取某一个用户的积分
 	public function getUserScore($uid, $config_id = false, $type = false, $type_id = false)
 	{
-		if ($type && $type_id) {
+		if ($config_id && $type && $type_id) {
 			$where['config_id'] = $config_id;
 			$where['type'] = $type;
 			$where['type_id'] = $type_id;
@@ -83,11 +89,26 @@ class Core
 				$where['config_child_id'] = $child['id'];
 				$score = Dever::db('score/user_child')->one($where);
 
-				return array('name' => $child['name'], 'score' => $score['score']);
+				return array('name' => $child['name'], 'score' => $score['score'] ? $score['score'] : 0);
 			}
 		} else {
-			$config = Dever::db('score/config')->one($config_id);
+			if (!$config_id) {
+				$config = Dever::db('score/config')->one(array('type' => 1));
+			} else {
+				$config = Dever::db('score/config')->one($config_id);
+			}
+			
+			if ($config) {
+				$where = array();
+				$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);
+			}
 		}
+
+		return false;
 	}
 
 	# 设置子积分