rabin 5 years ago
parent
commit
34bd716015
5 changed files with 20 additions and 128 deletions
  1. 14 0
      config/base.php
  2. 1 0
      database/action.php
  3. 1 1
      database/user.php
  4. 0 127
      database/user_score.php
  5. 4 0
      lib/Core.php

+ 14 - 0
config/base.php

@@ -0,0 +1,14 @@
+<?php
+
+# 一些基本配置
+$config['base'] = array
+(
+	# 积分配置
+	'score' => array
+	(
+		# 实时增加积分开启,关闭则需要把lib/core.cron放到计划任务中
+		'sync' => true,
+	),
+);
+
+return $config;

+ 1 - 0
database/action.php

@@ -66,6 +66,7 @@ return array
 
 	'manage' => array
 	(
+		'insert' => false,
 		'delete' => false,
 		'edit' => false,
 		# 列表

+ 1 - 1
database/user.php

@@ -28,7 +28,7 @@ return array
 			'default' 	=> '',
 			'desc' 		=> '',
 			'match' 	=> 'is_numeric',
-			'list'		=> true,
+			//'list'		=> true,
 		),
 
 		'uid'		=> array

+ 0 - 127
database/user_score.php

@@ -1,127 +0,0 @@
-<?php
-$config = function()
-{
-	$array = array();
-	$info = Dever::db('score/config')->state();
-	if($info)
-	{
-		$array += $info;
-	}
-	return $array;
-};
-
-return array
-(
-	# 表名
-	'name' => 'user_score',
-	# 显示给用户看的名称
-	'lang' => '用户积分列表',
-	'order' => 100,
-	'menu' => 'passport',
-	# 数据结构
-	'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}) : "匿名用户"',
-		),
-
-		'config_id'		=> array
-		(
-			'type' 		=> 'int-11',
-			'name' 		=> '积分名称',
-			'default' 	=> '1',
-			'desc' 		=> '积分名称',
-			'match' 	=> 'is_numeric',
-			'update'	=> 'select',
-			'option'	=> $config,
-			'search'	=> 'select',
-			'list'		=> true,
-		),
-
-		'score'		=> array
-		(
-			'type' 		=> 'varchar-80',
-			'name' 		=> '可用数量',
-			'default' 	=> '0',
-			'desc' 		=> '可用数量',
-			'match' 	=> 'option',
-			'update'	=> 'textarea',
-			'search'	=> 'order',
-			'list'		=> true,
-		),
-
-		'no_score'		=> array
-		(
-			'type' 		=> 'varchar-80',
-			'name' 		=> '冻结数量',
-			'default' 	=> '0',
-			'desc' 		=> '冻结数量',
-			'match' 	=> 'option',
-			'update'	=> 'textarea',
-			'search'	=> 'order',
-			'list'		=> true,
-		),
-
-		'cdate'		=> array
-		(
-			'type' 		=> 'int-11',
-			'name' 		=> '录入时间',
-			'match' 	=> array('is_numeric', time()),
-			'desc' 		=> '',
-			# 只有insert时才生效
-			'insert'	=> true,
-		),
-	),
-
-	'manage' => array
-	(
-		'delete' => false,
-		'edit' => false,
-		'insert' => false,
-
-		# 列表
-		'list_button' => array
-		(
-			'list' => array('积分日志', '"user_log&search_option_uid={uid}&oper_parent=user"'),
-		),
-	),
-
-	# request 请求接口定义
-	'request' => array
-	(
-		'getScoreByConfig' => array
-		(
-			# 匹配的正则或函数 选填项
-			'option' => array
-			(
-				'uid' => 'yes',
-			),
-			'type' => 'all',
-			'order' => array('id' => 'desc'),
-			'col' => 'uid,config_id,score|config_id',
-		),
-	)
-);

+ 4 - 0
lib/Core.php

@@ -34,6 +34,10 @@ class Core
 			$insert['cron_type'] = 1;
 			$log_id = Dever::db('score/action_log')->insert($insert);
 
+			$sync = Dever::config('base', 'score')->sync;
+			if ($sync) {
+				Dever::daemon('lib/core.oper?log_id='.$log_id, 'score');
+			}
 			//Dever::daemon('lib/core.oper?log_id='.$log_id, 'score');
 			//Dever::load('score/lib/core.oper?log_id='.$log_id);
 		}