dever 4 years ago
parent
commit
bead5634f4

+ 20 - 0
database/action_log.php

@@ -87,6 +87,26 @@ return array
 			'list'		=> true,
 		),
 
+		'type' 		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '所属数据源',
+			'default' 	=> '',
+			'desc' 		=> '所属数据源',
+			'match' 	=> 'is_string',
+			//'list'		=> true,
+		),
+		
+		'type_id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '数据源id',
+			'default' 	=> '',
+			'desc' 		=> '数据源id',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+
 		'score_type'		=> array
 		(
 			'type' 		=> 'int-11',

+ 20 - 0
database/action_log_finish.php

@@ -97,6 +97,26 @@ return array
 			'list'		=> true,
 		),
 
+		'type' 		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '所属数据源',
+			'default' 	=> '',
+			'desc' 		=> '所属数据源',
+			'match' 	=> 'is_string',
+			//'list'		=> true,
+		),
+		
+		'type_id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '数据源id',
+			'default' 	=> '',
+			'desc' 		=> '数据源id',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+
 		'score_type'		=> array
 		(
 			'type' 		=> 'int-11',

+ 3 - 0
database/config.php

@@ -4,6 +4,7 @@ $type = array
 (
 	1 => '主积分',
 	2 => '普通积分',
+	3 => '可自定义积分',
 );
 
 return array
@@ -95,6 +96,8 @@ return array
 		'list_button' => array
 		(
 			'list' => array('规则设置', '"rule&search_option_config_id={id}&oper_parent=config"'),
+
+			'list1' => array('自定义积分列表', '"config_child&search_option_config_id={id}&oper_parent=config"'),
 		),
 	),
 

+ 150 - 0
database/config_child.php

@@ -0,0 +1,150 @@
+<?php
+$config = function()
+{
+	$array = array();
+	$info = Dever::db('score/config')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+return array
+(
+	# 表名
+	'name' => 'config_child',
+	# 显示给用户看的名称
+	'lang' => '子积分设置',
+	'order' => 1,
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '积分名称',
+			'default' 	=> '',
+			'desc' 		=> '请输入积分名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'type' 		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '所属数据源',
+			'default' 	=> '',
+			'desc' 		=> '所属数据源',
+			'match' 	=> 'is_string',
+			//'update'	=> 'select',
+			'list'		=> true,
+		),
+		
+		'type_id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '数据源id',
+			'default' 	=> '',
+			'desc' 		=> '数据源id',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'config_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '上级积分名称',
+			'default' 	=> '1',
+			'desc' 		=> '上级积分名称',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $config,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'config_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '上级积分名称',
+			'default' 	=> '1',
+			'desc' 		=> '上级积分名称',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $config,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+		
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+
+	# 索引
+	'index' => array
+	(
+		1 => array
+		(
+			'search' => 'config_id,type,type_id',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+
+	'manage' => array
+	(
+		'insert' => false,
+		'edit' => false,
+		'delete' => false,
+	),
+
+	'request' => array
+	(
+		
+	),
+	
+);

+ 12 - 0
database/user.php

@@ -98,6 +98,18 @@ return array
 		),
 	),
 
+	# 索引
+	'index' => array
+	(
+		1 => array
+		(
+			'search' => 'uid,config_id',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+
 	'manage' => array
 	(
 		'delete' => false,

+ 151 - 0
database/user_child.php

@@ -0,0 +1,151 @@
+<?php
+$config = function()
+{
+	$array = array();
+	$info = Dever::db('score/config')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'user_child',
+	# 显示给用户看的名称
+	'lang' => '用户子积分列表',
+	'order' => 100,
+	'menu' => 'passport',
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			//'search'	=> 'select',
+			'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
+		),
+
+		'config_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '积分名称',
+			'default' 	=> '1',
+			'desc' 		=> '积分名称',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $config,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'config_child_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '子积分名称',
+			'default' 	=> '',
+			'desc' 		=> '子积分名称',
+			'match' 	=> 'is_numeric',
+			'list'		=> 'Dever::load("score/config_child#name", {config_child_id})',
+		),
+
+		'score'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '可用数量',
+			'default' 	=> '0',
+			'desc' 		=> '可用数量',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'no_score'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '冻结数量',
+			'default' 	=> '0',
+			'desc' 		=> '冻结数量',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+
+	# 索引
+	'index' => array
+	(
+		1 => array
+		(
+			'search' => 'uid,config_id,config_child_id',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+
+	'manage' => array
+	(
+		'delete' => false,
+		'edit' => false,
+		'insert' => false,
+
+		# 列表
+		'list_button' => array
+		(
+			'list' => array('积分日志', '"user_child_log&&project=score&search_option_uid={uid}&oper_parent=user&oper_project=score&top_project=passport&top_parent=user"'),
+		),
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		'getScoreByConfig' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+			),
+			'type' => 'all',
+			'order' => array('id' => 'desc'),
+			'col' => 'id,uid,config_child_id,score|config_child_id',
+		),
+	)
+);

+ 259 - 0
database/user_child_log.php

@@ -0,0 +1,259 @@
+<?php
+
+$config = function()
+{
+	$array = array();
+	$info = Dever::db('score/config')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$action = function()
+{
+	$array = array();
+	$info = Dever::db('score/action')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+$status = array
+(
+    1 => '收入',
+    2 => '支出',
+);
+
+
+return array
+(
+	# 表名
+	'name' => 'user_child_log',
+	# 显示给用户看的名称
+	'lang' => '用户积分日志',
+	'order' => 10,
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+		),
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			//'search'	=> 'select',
+			'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
+		),
+
+		'rebate_uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '下级用户',
+			'default' 	=> '0',
+			'desc' 		=> '下级用户',
+			'match' 	=> 'is_numeric',
+			'list'		=> '{rebate_uid} > 0 ? Dever::load("passport/user-one#username", {rebate_uid}) : "无"',
+		),
+
+		'config_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '积分名称',
+			'default' 	=> '1',
+			'desc' 		=> '积分名称',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $config,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'config_child_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '子积分名称',
+			'default' 	=> '',
+			'desc' 		=> '子积分名称',
+			'match' 	=> 'is_numeric',
+			'list'		=> 'Dever::load("score/config_child#name", {config_child_id})',
+		),
+		
+		'action_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属行为',
+			'default' 	=> '1',
+			'desc' 		=> '所属行为',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $action,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'action_log_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属行为日志',
+			'default' 	=> '1',
+			'desc' 		=> '所属行为日志',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '收入支出状态',
+            'default'   => '1',
+            'desc'      => '收入支出状态',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $status,
+            //'search'  => 'select',
+            'list'      => true,
+            //'edit'        => true,
+        ),
+
+		'num'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '增加积分数-如果为负数,则是减少积分',
+			'default' 	=> '',
+			'desc' 		=> '增加积分数',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+		),
+
+		'total'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '总积分数',
+			'default' 	=> '',
+			'desc' 		=> '总积分数',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+		),
+
+		'desc'     => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '描述',
+            'default'   => '',
+            'desc'      => '描述',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'list'      => 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	# 索引
+	'index' => array
+	(
+		1 => array
+		(
+			'search' => 'uid,config_id,config_child_id,action_id,action_log_id',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+
+	'manage' => array
+	(
+		'delete' => false,
+		'edit' => false,
+		'insert' => false,
+
+		# 列表
+		'list_button' => array
+		(
+			//'list' => array('行为日志', '"action_log&search_option_action_id={action_id}&search_option_uid={uid}&oper_parent=user_log"'),
+		),
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		'getNew' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'config_child_id' => 'yes',
+				'config_id' => 'yes',
+				'action_id' => 'yes',
+				'uid' => 'yes',
+				'status' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'one',
+			'order' => array('cdate' => 'desc'),
+			'col' => '*',
+		),
+
+		'getNewTotal' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'config_child_id' => 'yes',
+				'config_id' => 'yes',
+				'action_id' => 'yes',
+				'uid' => 'yes',
+				'status' => 'yes',
+				'state' => 1,
+				'start' => array('yes-cdate', '>='),
+				'end' => array('yes-cdate', '<='),
+			),
+			'type' => 'count',
+			'order' => array('cdate' => 'desc'),
+			'col' => 'count(1) as total',
+		),
+	)
+);

+ 12 - 0
database/user_log.php

@@ -182,6 +182,18 @@ return array
 		),
 	),
 
+	# 索引
+	'index' => array
+	(
+		1 => array
+		(
+			'search' => 'uid,config_id,action_id,action_log_id',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+
 	'manage' => array
 	(
 		'delete' => false,

+ 118 - 28
lib/Core.php

@@ -11,7 +11,7 @@ class Core
 	 *
 	 * @return mixed
 	 */
-	public function log($uid, $action_key, $action_name, $callback = '', $score = false, $num = false)
+	public function log($uid, $action_key, $action_name, $callback = '', $score = false, $num = false, $type = false, $type_id = false)
 	{
 		$action = Dever::db('score/action')->one(array('key' => $action_key));
 
@@ -40,12 +40,18 @@ class Core
 			if ($parent_uid > 0) {
 				$insert['parent_uid'] = $parent_uid;
 			}
+			if ($type) {
+	            $insert['type'] = $type;
+	        }
+	        if ($type_id) {
+	            $insert['type_id'] = $type_id;
+	        }
 			$insert['cron_type'] = 1;
 			$log_id = Dever::db('score/action_log')->insert($insert);
 
 			Dever::load('score/lib/core.oper?log_id='.$log_id);
 			return;
-			$sync = Dever::config('base', 'score')->sync;
+			$sync = Dever::config('base', 'project')->score['sync'];
 			if ($sync) {
 				Dever::daemon('lib/core.oper?log_id='.$log_id, 'score');
 			}
@@ -62,6 +68,61 @@ class Core
 		return $data;
 	}
 
+	# 获取某一个用户的积分
+	public function getUserScore($uid, $config_id = false, $type = false, $type_id = false)
+	{
+		if ($type && $type_id) {
+			$where['config_id'] = $config_id;
+			$where['type'] = $type;
+			$where['type_id'] = $type_id;
+			$where['state'] = 1;
+			$child = Dever::db('score/config_child')->one($where);
+			if ($child) {
+				$where = array();
+				$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']);
+			}
+		} else {
+			$config = Dever::db('score/config')->one($config_id);
+		}
+	}
+
+	# 设置子积分
+	public function setScoreChild($config_type, $config_id, $type, $type_id, $name)
+	{
+		$where['config_id'] = $config_id;
+		$where['type'] = $type;
+		$where['type_id'] = $type_id;
+		$info = Dever::db('score/config_child')->one($where);
+
+		if ($info && $config_type == 1) {
+			$update['where_id'] = $info['id'];
+			$update['state'] = 2;
+			Dever::db('score/config_child')->update($update);
+		} elseif ($config_type == 2) {
+			if (!$name) {
+				$config = Dever::db('score/config')->one($config_id);
+				$name = $config['name'];
+			}
+			if ($info) {
+				$update['where_id'] = $info['id'];
+				$update['name'] = $name;
+				$update['state'] = 1;
+				Dever::db('score/config_child')->update($update);
+			} else {
+				$insert = $where;
+				$insert['name'] = $name;
+				Dever::db('score/config_child')->insert($insert);
+			}
+		}
+		
+
+		return true;
+	}
+
 	public function oper_api()
 	{
 
@@ -99,9 +160,23 @@ class Core
 		}
 
 		$uid = $log['uid'];
-
 		$num = $info['num'];
 
+		$this->user = 'score/user';
+		$this->user_log = 'score/user_log';
+		$info['config_child_id'] = false;
+
+		# 验证是否有子积分设置
+		if ($log['type'] && $log['type_id']) {
+			$child = Dever::db('score/config_child')->one(array(
+				'config_id' => $info['config_id'], 'type' => $log['type'], 'type_id' => $log['type_id'], 'state' => 1));
+			if ($child) {
+				$this->user = 'score/user_child';
+				$this->user_log = 'score/user_child_log';
+				$info['config_child_id'] = $child['id'];
+			}
+		}
+
 		if ($info['upper'] == 2 && $info['upper_limit'] >= 1) {
 			$upper = $this->upper($uid, $info, $log);
 			if (!$upper) {
@@ -113,21 +188,17 @@ class Core
 		# 完成
 		$this->finish($log, 2, $num);
 
-		$user_log_id = $this->add($uid, $num, $info['config_id'], $info['action_id'], $log['id']);
+		$user_log_id = $this->add($uid, $num, $info, $log);
+
+		if (!$user_log_id) {
+			return;
+		}
 
 		# 增加返利
 		if ($info['rebate_type'] > 1) {
 			$this->rebate($uid, $num, $info, $log);
 		}
 
-		# 提升等级
-		$level_type = Dever::db('score/level_type')->state();
-		if ($level_type) {
-			foreach ($level_type as $k => $v) {
-				$this->setLevel($uid, $v);
-			}
-		}
-
 		if ($log['callback']) {
 			if (strstr($log['callback'], '?')) {
 				Dever::load($log['callback'] . '&user_log_id=' . $user_log_id);
@@ -138,13 +209,19 @@ class Core
 	}
 
 	# 增加积分
-	private function add($uid, $num, $config_id, $action_id, $log_id, $rebate_uid = false)
+	private function add($uid, $num, $info, $log, $rebate_uid = false)
 	{
-		$user = Dever::db('score/user')->one(array('uid' => $uid, 'config_id' => $config_id));
+		$where = array();
+		$where['uid'] = $uid;
+		$where['config_id'] = $info['config_id'];
+		if ($info['config_child_id']) {
+			$where['config_child_id'] = $info['config_child_id'];
+		}
+		$user = Dever::db($this->user)->one($where);
 
 		if (!$user) {
 			$user = array();
-			$user['id'] = Dever::db('score/user')->insert(array('uid' => $uid, 'config_id' => $config_id, 'score' => 0, 'no_score' => 0));
+			$user['id'] = Dever::db($this->user)->insert($where);
 			$user['score'] = 0;
 		}
 
@@ -152,20 +229,30 @@ class Core
 		$update['where_id'] = $user['id'];
 		$update['score'] = $user['score'] + $num;
 
-		$insert['uid'] = $uid;
-		$insert['config_id'] = $config_id;
-		$insert['action_log_id'] = $log_id;
-		$insert['action_id'] = $action_id;
+		$insert = $where;
+		$insert['action_log_id'] = $log['id'];
+		$insert['action_id'] = $info['action_id'];
 		if ($rebate_uid) {
 			$insert['rebate_uid'] = $rebate_uid;
 		}
+		
 		$insert['status'] = 1;
 		$insert['num'] = $num;
 		$insert['total'] = $update['score'];
 		$insert['cdate'] = time();
-		$user_log_id = Dever::db('score/user_log')->insert($insert);
+		$user_log_id = Dever::db($this->user_log)->insert($insert);
+
+		if ($user_log_id) {
+			Dever::db($this->user)->update($update);
 
-		Dever::db('score/user')->update($update);
+			# 提升等级
+			$level_type = Dever::db('score/level_type')->state();
+			if ($level_type) {
+				foreach ($level_type as $k => $v) {
+					$this->setLevel($uid, $v);
+				}
+			}
+		}
 
 		return $user_log_id;
 	}
@@ -197,7 +284,7 @@ class Core
 				}
 				
 				if ($parent_uid > 0) {
-					$this->add($parent_uid, $value, $info['config_id'], $info['action_id'], $log['id'], $uid);
+					$this->add($parent_uid, $value, $info, $log, $uid);
 				}
 			} elseif ($invite) {
 				# 上级的上级
@@ -210,7 +297,7 @@ class Core
 				}
 				$other_parent_uid = Dever::load('invite/api')->getParent($rebate_uid, $level);
 				if ($other_parent_uid > 0) {
-					$this->add($other_parent_uid, $value, $info['config_id'], $info['action_id'], $log['id'], $rebate_uid);
+					$this->add($other_parent_uid, $value, $info, $log, $rebate_uid);
 				}
 			}
 		}
@@ -239,7 +326,7 @@ class Core
 	}
 
 	# 设置上限限制
-	private function upper($uid, $info)
+	private function upper($uid, $info, $log)
 	{
 		# 有上限限制
 		$limit = $info['upper_limit'];
@@ -248,11 +335,14 @@ class Core
 		$time = time();
 
 		$where = array();
+		if ($info['config_child_id']) {
+			$where['config_child_id'] = $info['config_child_id'];
+		}
 		$where['config_id'] = $info['config_id'];
 		$where['action_id'] = $info['action_id'];
 		$where['uid'] = $uid;
 		$where['status'] = 1;
-		$user_log = Dever::db('score/user_log')->getNew($where);
+		$user_log = Dever::db($this->user_log)->getNew($where);
 		if ($user_log) {
 			if ($info['upper_type'] == 1) {
 				# 按天
@@ -268,7 +358,7 @@ class Core
 				return true;
 			}
 
-			$user_log_num = Dever::db('score/user_log')->getNewTotal($where);
+			$user_log_num = Dever::db($this->user_log)->getNewTotal($where);
 			if ($user_log_num >= $info['upper_limit']) {
 				return false;
 			}
@@ -360,7 +450,7 @@ class Core
 			
 			$rule = Dever::array_decode($config['score']);
 			if ($rule) {
-				$user_score = Dever::db('score/user')->getScoreByConfig($where);
+				$user_score = Dever::db($this->user)->getScoreByConfig($where);
 				if ($user_score) {
 					foreach ($rule as $k => $v) {
 						$score = $v['config'];
@@ -372,7 +462,7 @@ class Core
 							if ($level_type['score'] == 2 && $level_type['type'] == 1) {
 								$user_score_update['where_id'] = $user_score[$score]['id'];
 								$user_score_update['score'] = $user_score[$score]['score'] - $num;
-								Dever::db('score/user')->update($user_score_update);
+								Dever::db($this->user)->update($user_score_update);
 							}
 						} else {
 							$yes = false;