rabin 3 rokov pred
commit
34b2175cd1
11 zmenil súbory, kde vykonal 1480 pridanie a 0 odobranie
  1. 240 0
      database/config.php
  2. 128 0
      database/config_project.php
  3. 175 0
      database/config_type.php
  4. 204 0
      database/info.php
  5. 244 0
      database/info_log.php
  6. 107 0
      database/money.php
  7. 132 0
      database/push.php
  8. 10 0
      index.php
  9. 150 0
      lib/Info.php
  10. 35 0
      lib/Manage.php
  11. 55 0
      src/Api.php

+ 240 - 0
database/config.php

@@ -0,0 +1,240 @@
+<?php
+
+$project = function()
+{
+	$array = array();
+	$data = Dever::load('account/config_project-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$money = function()
+{
+	$array = array();
+	$data = Dever::load('account/money-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$is_withdraw = array
+(
+	1 => '可以提现',
+	2 => '不可以提现',
+);
+
+return array
+(
+	# 表名
+	'name' => 'config',
+	# 显示给用户看的名称
+	'lang' => '账户名称设置',
+	# 是否显示在后台菜单
+	'check' => 'key',
+	'order' => 1,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '账户名称',
+			'default' 	=> '',
+			'desc' 		=> '请输入账户名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-50',
+			'name' 		=> '账户唯一标识',
+			'default' 	=> '',
+			'desc' 		=> '账户唯一标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'info'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '账户名称介绍',
+            'default'   => '',
+            'desc'      => '账户名称介绍',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'project_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属项目',
+            'default'   => '1',
+            'desc'      => '所属项目',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $project,
+            'list'		=> true,
+        ),
+
+        'money_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '关联法定货币',
+			'default' 	=> '1',
+			'desc' 		=> '关联法定货币',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $money,
+			'list'		=> true,
+		),
+
+        'balance_alert'     => array
+        (
+            'type'      => 'varchar-11',
+            'name'      => '消耗下限-输入100,就是当余额小于等于100时,无法继续消耗,以元为单位,一般为限制授信账户',
+            'default'   => '0',
+            'desc'      => '消耗下限',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'is_withdraw'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否可提现',
+            'default'   => '1',
+            'desc'      => '是否可提现',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $is_withdraw,
+            'control'	=> 'is_withdraw',
+        ),
+
+        'withdraw_up'     => array
+        (
+            'type'      => 'varchar-11',
+            'name'      => '提现上限-每次提现的上限,0不限制,以元为单位',
+            'default'   => '0',
+            'desc'      => '提现上限',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'		=> 'is_withdraw=1',
+        ),
+
+        'withdraw_down'     => array
+        (
+            'type'      => 'varchar-11',
+            'name'      => '提现下限-每次提现的下限,0不限制,输入100,就是余额至少有100才能提现,以元为单位',
+            'default'   => '0',
+            'desc'      => '提现下限',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'		=> 'is_withdraw=1',
+        ),
+
+        'withdraw_fee'     => array
+        (
+            'type'      => 'varchar-11',
+            'name'      => '提现手续费-输入10%就是百分之10%',
+            'default'   => '10%',
+            'desc'      => '提现手续费',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'		=> 'is_withdraw=1',
+        ),
+
+        '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,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'button' => array
+        (
+            '项目配置' => array('list', 'config_project&oper_parent=config'),
+            '交易类型配置' => array('list', 'config_type&oper_parent=config'),
+        ),
+        'list_button' => array
+        (
+        	'list' => array('用户账户列表', '"info&search_option_config_id={id}"'),
+        )
+	),
+
+	/*
+	'default' => array
+	(
+		'col' => 'name,project_id,state,cdate',
+		'value' => array
+		(
+			'"默认账户", 1, 1,' . DEVER_TIME,
+		),
+	),
+	*/
+
+	'request' => array
+	(
+		'getData' => array
+		(
+			'type' => 'all',
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'state' => 1,
+			),
+			'col' => '*',
+		),
+	)
+);

+ 128 - 0
database/config_project.php

@@ -0,0 +1,128 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'config_project',
+	# 显示给用户看的名称
+	'lang' => '项目配置',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '项目名称',
+			'default' 	=> '',
+			'desc' 		=> '项目名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'source'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '账户信息来源-一般为用户信息表,直接填写项目/表名即可,如passport/user',
+            'default'   => '',
+            'desc'      => '账户信息来源',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'source_name'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '账户名称字段-账户名称字段,一般为name',
+            'default'   => '',
+            'desc'      => '账户名称字段',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'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,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'insert' => false,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,source,source_name,state,cdate',
+		'value' => array
+		(
+			'"默认项目","passport/user","username", 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 175 - 0
database/config_type.php

@@ -0,0 +1,175 @@
+<?php
+$project = function()
+{
+	$array = array
+	(
+		-1 => '全部项目',
+	);
+	$data = Dever::load('account/config_project-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$type = array
+(
+	1 => '增加',
+	2 => '减少',
+);
+
+$id = Dever::input('where_id');
+
+return array
+(
+	# 表名
+	'name' => 'config_type',
+	# 显示给用户看的名称
+	'lang' => '交易类型',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'check' => 'key',
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '交易类型名称',
+			'default' 	=> '',
+			'desc' 		=> '交易类型名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-50',
+			'name' 		=> '唯一标识-入账和出账通过该标识定义,充值和提现不能修改',
+			'default' 	=> '',
+			'desc' 		=> '唯一标识',
+			'match' 	=> 'is_string',
+			'update'	=> ($id && $id < 3) ? false : 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'project_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属项目',
+            'default'   => '-1',
+            'desc'      => '所属项目',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $project,
+            'list'		=> true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '交易模式',
+            'default'   => '1',
+            'desc'      => '交易模式',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'		=> true,
+        ),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'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,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'insert' => false,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,`key`,project_id,type,state,cdate',
+		'value' => array
+		(
+			'"充值", "chongzhi", -1, 1, 1,' . DEVER_TIME,
+			'"提现", "tixian",-1, 2, 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		'getData' => array
+		(
+			'type' => 'all',
+			'option' => array
+			(
+				'type' => 'yes',
+				'project_id' => array('yes', 'in'),
+				'state' => 1,
+			),
+			'col' => '*',
+		),
+	)
+);

+ 204 - 0
database/info.php

@@ -0,0 +1,204 @@
+<?php
+$config = function()
+{
+	$array = array();
+	$info = Dever::db('account/config')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$project = function()
+{
+	$array = array();
+	$data = Dever::load('account/config_project-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$user = '用户ID';
+$search = 'fulltext';
+
+$config_id = Dever::input('search_option_config_id');
+if ($config_id) {
+	$search_config = Dever::load('account/lib/info')->getSearch($config_id);
+	if ($search_config) {
+		$search = $search_config;
+		$user = '用户名称';
+	}
+}
+
+return array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'lang' => '用户账户列表',
+	'order' => 100,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> $user,
+			'default' 	=> '0',
+			'desc' 		=> '用户名称',
+			'match' 	=> 'is_numeric',
+            'search'	=> $search,
+            'list_name'	=> '用户名称',
+			'list'		=> 'Dever::load("account/lib/info.getName", {uid}, {config_id})',
+		),
+
+		'config_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '账户名称',
+			'default' 	=> '1',
+			'desc' 		=> '账户名称',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $config,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'project_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属项目',
+            'default'   => '1',
+            'desc'      => '所属项目',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $project,
+            'list'		=> true,
+        ),
+
+		'cash'		=> array
+		(
+			'type'      => 'decimal-11,2',
+			'name' 		=> '可用金额',
+			'default' 	=> '0',
+			'desc' 		=> '可用金额',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'z_cash'		=> array
+		(
+			'type'      => 'decimal-11,2',
+			'name' 		=> '总获取金额',
+			'default' 	=> '0',
+			'desc' 		=> '总获取金额',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		't_cash'		=> array
+		(
+			'type'      => 'decimal-11,2',
+			'name' 		=> '总消耗金额',
+			'default' 	=> '0',
+			'desc' 		=> '总消耗金额',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'list'		=> 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' => 'uid,config_id,project_id',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+
+	'manage' => array
+	(
+		'delete' => false,
+		'edit' => false,
+		'insert' => false,
+
+		# 列表
+		'list_button' => array
+		(
+			'list' => array('账户流水', '"info_log&&project=account&search_option_uid={uid}&oper_parent=info&oper_project=account"'),
+		),
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		# 更新
+		'inc' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'cash' => array('yes', '+='),
+				'col' => array('yes-z_cash', '+='),
+			),
+		),
+
+		# 更新
+		'dec' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'cash' => array('yes', '+='),
+				'col' => array('yes-t_cash', '+='),
+			),
+		),
+	)
+);

+ 244 - 0
database/info_log.php

@@ -0,0 +1,244 @@
+<?php
+
+$project = function()
+{
+	$array = array();
+	$data = Dever::load('account/config_project-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$type = function()
+{
+	$array = array();
+	$data = Dever::load('account/config_type-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$config = function()
+{
+	$array = array();
+	$data = Dever::load('account/config-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$user = '用户ID';
+$search = 'fulltext';
+
+$config_id = Dever::input('search_option_config_id');
+if ($config_id) {
+	$search_config = Dever::load('account/lib/info')->getSearch($config_id);
+	if ($search_config) {
+		$search = $search_config;
+		$user = '用户名称';
+	}
+}
+
+$method = array
+(
+    1 => '自动',
+    2 => '手动',
+);
+
+return array
+(
+    # 表名
+    'name' => 'info_log',
+    # 显示给用户看的名称
+    'lang' => '用户资金流水',
+    'menu' => false,
+    'order' => 99,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'info_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '账户id',
+			'default' 	=> '',
+			'desc' 		=> '账户id',
+			'match' 	=> 'is_numeric',
+		),
+
+        'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> $user,
+			'default' 	=> '0',
+			'desc' 		=> '用户名称',
+			'match' 	=> 'is_numeric',
+            'search'	=> $search,
+            'list_name'	=> '用户名称',
+			'list'		=> 'Dever::load("account/lib/info.getName", {uid}, {config_id})',
+		),
+
+		'config_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '账户名称',
+			'default' 	=> '1',
+			'desc' 		=> '账户名称',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $config,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'project_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属项目',
+            'default'   => '1',
+            'desc'      => '所属项目',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $project,
+            'list'		=> true,
+        ),
+
+        'type_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '交易类型',
+            'default'   => '1',
+            'desc'      => '交易类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'		=> true,
+        ),
+
+        'source'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '来源表名',
+            'default'   => '',
+            'desc'      => '来源表名',
+            'match'     => 'is_numeric',
+        ),
+
+        'source_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '来源表id',
+            'default'   => '',
+            'desc'      => '来源表id',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '金额',
+            'default'   => '0',
+            'desc'      => '金额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list_name' => '金额',
+            'list'      => true,
+        ),
+
+        'yue'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '操作后余额',
+            'default'   => '0',
+            'desc'      => '操作后余额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-600',
+            'name'      => '资金说明',
+            'default'   => '',
+            'desc'      => '资金说明',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'admin_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '操作人',
+            'default'   => '',
+            'desc'      => '操作人',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => '"{admin_id}" > 0 ? Dever::load("manage/admin-find#username", {admin_id}) : "-"',
+        ),
+
+        'method'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '方式',
+            'default'   => '1',
+            'desc'      => '方式',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $method,
+        ),
+
+        '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,
+            'search'    => 'date',
+            'list_name' => '交易时间',
+            'list'        => 'date("Y-m-d H:i", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 107 - 0
database/money.php

@@ -0,0 +1,107 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'money',
+	# 显示给用户看的名称
+	'lang' => '法定货币设置',
+	# 是否显示在后台菜单
+	'order' => -1,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '货币名称',
+			'default' 	=> '',
+			'desc' 		=> '货币名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'code'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '货币代码-如中文就是CNY',
+			'default' 	=> '',
+			'desc' 		=> '货币代码',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'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,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		
+	),
+
+	'default' => array
+	(
+		'col' => 'name,code,state,cdate',
+		'value' => array
+		(
+			'"人民币","CNY", 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 132 - 0
database/push.php

@@ -0,0 +1,132 @@
+<?php
+$uid = Dever::input('uid');
+$config = function() {
+    $config = Dever::input('config', 1);
+    return Dever::db('account/config')->getData(array('ids' => $config));
+};
+
+$type = function() use($config) {
+    $config = $config();
+    return Dever::db('account/config_type')->getData(array('project_id' => '-1,' . $config[0]['project_id']));
+};
+
+return array
+(
+    # 表名
+    'name' => 'push',
+    # 显示给用户看的名称
+    'lang' => '发放资金',
+    'order' => 99,
+    'menu' => false,
+    'end' => array
+    (
+        'insert' => 'account/lib/manage.push',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户ID',
+            'default'   => '0',
+            'desc'      => '用户名称',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => $uid,
+        ),
+
+        'config_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '选择账户',
+            'default'   => '1',
+            'desc'      => '选择账户',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'     => $config,
+        ),
+
+        'type_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '交易类型',
+            'default'   => '1',
+            'desc'      => '交易类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '发放金额-金额单位为元',
+            'default'   => '',
+            'desc'      => '发放金额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-600',
+            '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,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i", {cdate})',
+            'list_order'  => 2,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+
+        'list_button' => array
+        (
+            
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 10 - 0
index.php

@@ -0,0 +1,10 @@
+<?php
+
+define('DEVER_APP_NAME', 'account');
+define('DEVER_APP_LANG', '账户系统');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 2);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-flag');
+define('DEVER_GROUP_ORDER', -7);
+define('DEVER_GROUP_NAME', '平台系统管理');
+include(DEVER_APP_PATH . '../boot.php');

+ 150 - 0
lib/Info.php

@@ -0,0 +1,150 @@
+<?php
+
+namespace Account\Lib;
+
+use Dever;
+
+class Info
+{
+    public function test_api()
+    {
+        //return $this->up(1, 500, 'tixian', 'role_zijin', 'test');
+        return $this->up_commit(1, 1, 'chongzhi', 'role_zijin', 'test');
+    }
+
+    public function getName($uid, $config_id)
+    {
+        $name = $uid;
+        $info = Dever::db('account/config')->find($config_id);
+        if ($info) {
+        	$project = Dever::db('account/config_project')->find($info['project_id']);
+            $source = Dever::db($project['source'])->find($uid);
+            if ($source) {
+                return $source[$project['source_name']];
+            }
+        }
+        return $name;
+    }
+
+    public function getSearch($config_id)
+    {
+        $result = '';
+        $info = Dever::db('account/config')->find($config_id);
+        if ($info) {
+            $project = Dever::db('account/config_project')->find($info['project_id']);
+            $result = array
+            (
+                'api' => $project['source'] . '-all',
+                'col' => $project['source_name'],
+                'result' => 'id',
+                'search' => 'uid',
+            );
+        }
+        
+        return $result;
+    }
+
+    # 入账
+    public function up_commit($uid, $cash, $type, $config, $desc = '', $source = '', $source_id = '', $method = 1)
+    {
+        if ($cash == 0) {
+            Dever::alert('金额不能为0');
+        }
+        
+        $config = Dever::db('account/config')->find(array('key' => $config));
+        if (!$config) {
+            Dever::alert('账户信息不存在');
+        }
+
+        $project = Dever::db('account/config_project')->find($config['project_id']);
+        $user = Dever::db($project['source'])->find($uid);
+        if (!$user) {
+            Dever::alert('用户信息不存在');
+        }
+
+        $type = Dever::db('account/config_type')->find(array('key' => $type));
+        if (!$type) {
+            Dever::alert('交易类型不存在');
+        }
+        if ($type['project_id'] != -1 && $type['project_id'] != $config['project_id']) {
+            Dever::alert('交易类型不正确');
+        }
+
+        $data['uid'] = $uid;
+        $data['config_id'] = $config['id'];
+        $data['project_id'] = $config['project_id'];
+        $data['clear'] = true;
+        $info = Dever::db('account/info')->find($data);
+        if (!$info) {
+            $info['id'] = Dever::db('account/info')->insert($data);
+            if (!$info['id']) {
+                Dever::alert('用户信息不存在');
+            }
+            $info['cash'] = 0;
+        }
+
+        if ($type['key'] == 'tixian') {
+            if ($config['is_withdraw'] == 2) {
+                Dever::alert('当前账户不能提现');
+            }
+            if ($config['withdraw_down'] > 0 && $cash < $config['withdraw_down']) {
+                Dever::alert('提现金额不能少于' . $config['withdraw_down']);
+            }
+            if ($config['withdraw_up'] > 0 && $cash > $config['withdraw_up']) {
+                Dever::alert('提现金额不能大于' . $config['withdraw_up']);
+            }
+            if ($cash > $info['cash']) {
+                Dever::alert('提现金额不能大于账户余额');
+            }
+        }
+
+        $func = 'inc';
+        if ($type['type'] == 2) {
+            $cash = -1*$cash;
+            $func = 'dec';
+        }
+
+        $data['cash'] = $cash;
+        $data['type_id'] = $type['id'];
+
+        if ($source) {
+            $data['source'] = $source;
+        }
+
+        if ($source_id) {
+            $data['source_id'] = $source_id;
+        }
+
+        if ($desc) {
+            $data['desc'] = $desc;
+        }
+
+        if ($info) {
+            $data['yue'] = $info['cash'] + $data['cash'];
+        } else {
+            $data['yue'] = 0;
+        }
+
+        if ($data['yue'] < 0) {
+            $data['yue'] = 0;
+        }
+        $yue = $data['yue'];
+        $data['method'] = $method;
+        $admin = Dever::load('manage/auth.data');
+        if ($admin) {
+            $data['admin_id'] = $admin['id'];
+        }
+        
+        $data['clear'] = true;
+        $id = Dever::db('account/info_log')->insert($data);
+        if ($id) {
+            $update = array();
+            $update['where_id'] = $info['id'];
+            $update['set_cash'] = $data['cash'];
+            $update['set_col'] = $data['cash'];
+            $update['clear'] = true;
+            Dever::db('account/info')->$func($update);
+        }
+        return $yue;
+    }
+}

+ 35 - 0
lib/Manage.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace Account\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function push($id, $name, $data)
+    {
+    	Dever::config('base')->hook = true;
+        $uid = Dever::param('uid', $data);
+        $cash = Dever::param('cash', $data);
+        $desc = Dever::param('desc', $data);
+        $config_id = Dever::param('config_id', $data);
+        $type_id = Dever::param('type_id', $data);
+        $config = $type = array();
+        if ($config_id) {
+        	$config = Dever::db('account/config')->find($config_id);
+        }
+        if ($type_id) {
+        	$type = Dever::db('account/config_type')->find($type_id);
+        }
+
+        if (!$config) {
+    		Dever::alert('账户信息不存在');
+    	}
+
+    	if (!$type) {
+    		Dever::alert('交易类型不存在');
+    	}
+
+        Dever::load('account/lib/info')->up_commit($uid, $cash, $type['key'], $config['key'], $desc, 'account/push', $id, 2);
+    }
+}

+ 55 - 0
src/Api.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace Account\Src;
+
+use Dever;
+
+class Api
+{
+    public function getConfig($table)
+    {
+    	$data = array();
+        $project = Dever::db('account/config_project')->find(array('source' => $table));
+        if ($project) {
+        	$data = Dever::db('account/config')->select(array('project_id' => $project['id']));
+        }
+
+        return $data;
+    }
+
+    public function getInfo($uid, $account)
+    {
+    	if (!$account) {
+    		return '无账户信息';
+    	}
+    	$config = Dever::db('account/config')->getData(array('ids' => $account));
+
+    	$table = array();
+        $table['head'] = array('账户名称', '余额', '总获取金额', '总消耗金额');
+        $table['body'] = array();
+
+        if ($config) {
+        	foreach ($config as $k => $v) {
+        		$info = Dever::db('account/info')->find(array('uid' => $uid, 'config_id' => $v['id']));
+        		if ($info) {
+        			$table['body'][$k] = array
+                    (
+                        $v['name'], $info['cash'], $info['z_cash'], $info['t_cash']
+                    );
+        		}
+        	}
+        }
+        
+        $body[''] = array
+        (
+            'type' => 'table',
+            'content' => $table,
+        );
+
+        if ($table['body']) {
+            return Dever::show('', $body);
+        } else {
+            return '无账户信息';
+        }
+    }
+}