rabin 2 anni fa
parent
commit
beec52168a
4 ha cambiato i file con 96 aggiunte e 2 eliminazioni
  1. 24 1
      database/config.php
  2. 1 1
      database/config_type.php
  3. 56 0
      lib/Info.php
  4. 15 0
      lib/Manage.php

+ 24 - 1
database/config.php

@@ -28,6 +28,12 @@ $is_withdraw = array
 	2 => '不可以提现',
 );
 
+$type = array
+(
+	1 => '主账户',
+	2 => '普通账户',
+);
+
 return array
 (
 	# 表名
@@ -37,7 +43,11 @@ return array
 	# 是否显示在后台菜单
 	'check' => 'key',
 	'order' => 1,
-
+	'end' => array
+	(
+		'insert' => 'account/lib/manage.config',
+		'update' => 'account/lib/manage.config',
+	),
 	# 数据结构
 	'struct' => array
 	(
@@ -75,6 +85,19 @@ return array
 			'list'		=> true,
 		),
 
+		'type'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '是否主账户-只能有一个主账户,主主账户将作为用户主要账户显示在用户信息中',
+			'default' 	=> '2',
+			'desc' 		=> '是否主账户',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $type,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
 		'info'      => array
         (
             'type'      => 'varchar-800',

+ 1 - 1
database/config_type.php

@@ -188,7 +188,7 @@ return array
 				'project_id' => array('yes', 'in'),
 				'state' => 1,
 			),
-			'col' => '*',
+			'col' => '*|id',
 		),
 	)
 );

+ 56 - 0
lib/Info.php

@@ -6,6 +6,62 @@ use Dever;
 
 class Info
 {
+    # 获取账户
+    public function getInfo($uid, $config_id = false)
+    {
+        if (!$config_id) {
+            $config = Dever::db('account/config')->one(array('type' => 1));
+        } else {
+            $config = Dever::db('account/config')->one($config_id);
+        }
+        
+        if ($config) {
+            $where = array();
+            $where['uid'] = $uid;
+            $where['config_id'] = $config['id'];
+            $account = Dever::db('account/info')->one($where);
+            if ($account) {
+                return array('name' => $config['name'], 'cash' => $account['cash'], 'z_cash' => $account['z_cash'], 't_cash' => $account['t_cash']);
+            } else {
+                return array();
+            }
+        }
+
+        return array();
+    }
+
+    # 获取列表
+    public function getList($uid, $config_id = false, $type = false, $type_id = false)
+    {
+        if (!$config_id) {
+            $config = Dever::db('account/config')->one(array('type' => 1));
+        } else {
+            $config = Dever::db('account/config')->one($config_id);
+        }
+        
+        if ($config) {
+            $where = array();
+            $where['uid'] = $uid;
+            $where['config_id'] = $config['id'];
+
+            $result = Dever::db('account/info_log')->getList($where);
+        }
+
+        if ($result) {
+            $type = Dever::db('account/config_type')->getData();
+            foreach ($result as $k => $v) {
+                $result[$k]['cdate'] = date('Y-m-d H:i:s', $v['cdate']);
+                if (isset($type[$v['type_id']])) {
+                    $result[$k]['type_name'] = $type[$v['type_id']]['name'];
+                } else {
+                    $result[$k]['type_name'] = '未知';
+                }
+            }
+        }
+        
+        return $result;
+    }
+
     public function test_api()
     {
         //return $this->up(1, 500, 'tixian', 'role_zijin', 'test');

+ 15 - 0
lib/Manage.php

@@ -32,4 +32,19 @@ class Manage
 
         Dever::load('account/lib/info.up_commit', $uid, $cash, $type['key'], $config['key'], $desc, 'account/push', $id, 2);
     }
+
+    /**
+     * 设置主账户
+     *
+     * @return mixed
+     */
+    public function config($id, $name, $param)
+    {
+        $type = Dever::param('type', $param);
+
+        if ($type == 1) {
+            Dever::db('account/config')->updates(array('type' => 2));
+            Dever::db('account/config')->update(array('where_id' => $id, 'type' => 1));
+        }
+    }
 }