rabin 2 yıl önce
ebeveyn
işleme
438065eebb
7 değiştirilmiş dosya ile 159 ekleme ve 33 silme
  1. 19 0
      database/config_type.php
  2. 13 5
      database/info.php
  3. 32 5
      database/info_log.php
  4. 7 10
      database/push.php
  5. 22 12
      lib/Info.php
  6. 1 1
      lib/Manage.php
  7. 65 0
      src/Api.php

+ 19 - 0
database/config_type.php

@@ -19,6 +19,12 @@ $type = array
 	2 => '减少',
 );
 
+$manual = array
+(
+	1 => '手动操作',
+	2 => '不可以手动操作',
+);
+
 $id = Dever::input('where_id');
 
 return array
@@ -95,6 +101,18 @@ return array
             'list'		=> true,
         ),
 
+        'manual'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否允许手动操作',
+            'default'   => '1',
+            'desc'      => '是否允许手动操作',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $manual,
+            'list'		=> true,
+        ),
+
 		'reorder'		=> array
 		(
 			'type' 		=> 'int-11',
@@ -166,6 +184,7 @@ return array
 			'option' => array
 			(
 				'type' => 'yes',
+				'manual' => 'yes',
 				'project_id' => array('yes', 'in'),
 				'state' => 1,
 			),

+ 13 - 5
database/info.php

@@ -23,9 +23,16 @@ $project = function()
 
 $user = '用户ID';
 $search = 'hidden';
-
+$config_key = Dever::input('config_key');
+if ($config_key) {
+	$info = Dever::db('account/config')->find(array('key' => $config_key));
+	if ($info) {
+		Dever::setInput('search_option_config_id', $info['id']);
+	}
+}
+$uid = Dever::input('search_option_uid');
 $config_id = Dever::input('search_option_config_id');
-if ($config_id) {
+if ($config_id && $uid) {
 	$search_config = Dever::load('account/lib/info')->getSearch($config_id);
 	if ($search_config) {
 		$search = $search_config;
@@ -33,7 +40,7 @@ if ($config_id) {
 	}
 }
 
-$account_log = 'info_log&project=account&search_option_uid={uid}&oper_parent=info&oper_project=account';
+$account_log = 'info_log&project=account&search_option_info_id={id}&search_option_uid={uid}&search_option_config_id={config_id}&oper_parent=info&oper_project=account';
 
 $oper_table = Dever::input('oper_table');
 if ($oper_table) {
@@ -46,6 +53,7 @@ return array
 	# 显示给用户看的名称
 	'lang' => '用户账户列表',
 	'order' => 100,
+	'menu' => false,
 	# 数据结构
 	'struct' => array
 	(
@@ -67,7 +75,7 @@ return array
 			'desc' 		=> '用户名称',
 			'match' 	=> 'is_numeric',
             'search'	=> $search,
-            'value'     => Dever::input('search_option_uid'),
+            'value'     => $uid,
             'list_name'	=> '用户名称',
 			'list'		=> 'Dever::load("account/lib/info.getName", {uid}, {config_id})',
 		),
@@ -171,7 +179,7 @@ return array
 		# 列表
 		'list_button' => array
 		(
-			'fast_add' => array('账户操作', 'push&project=account&uid={id}'),
+			'fast_add' => array('账户操作', 'push&project=account&search_option_config_id={config_id}&search_option_uid={uid}'),
 			'list' => array('账户流水', $account_log),
 		),
 	),

+ 32 - 5
database/info_log.php

@@ -32,16 +32,40 @@ $config = function()
 	}
 	return $array;
 };
-
+$button = array();
+$desc = '';
 $user = '用户ID';
 $search = 'hidden';
-
+$config_key = Dever::input('config_key');
+if ($config_key) {
+    $info = Dever::db('account/config')->find(array('key' => $config_key));
+    if ($info) {
+        Dever::setInput('search_option_config_id', $info['id']);
+    }
+}
+$uid = Dever::input('search_option_uid');
 $config_id = Dever::input('search_option_config_id');
-if ($config_id) {
+if ($config_id && $uid) {
 	$search_config = Dever::load('account/lib/info')->getSearch($config_id);
 	if ($search_config) {
 		$search = $search_config;
 		$user = '用户名称';
+
+        $button['账户操作'] = array('fast', false, 'push');
+
+        $account_info = Dever::db('account/info')->find(array('config_id' => $config_id, 'uid' => $uid));
+        if ($account_info) {
+            $username = Dever::load("account/lib/info.getName", $uid, $config_id);
+            $desc = '<blockquote class="layui-elem-quote">';
+            $desc .= $search_config['project_name'] . '.' . $search_config['name'];
+            $desc .= ' -> ';
+            $desc .= '<b>' . $username.'</b>';
+            $desc .= '<br />';
+            $desc .= '可用金额:' . '<b>' . $account_info['cash'] . '</b>';
+            $desc .= ' 总获取金额:' . '<b>' . $account_info['z_cash'] . '</b>';
+            $desc .= ' 总消耗金额:' . '<b>' . $account_info['t_cash'] . '</b>';
+            $desc .= '</blockquote>';
+        }
 	}
 }
 
@@ -58,6 +82,7 @@ return array
     # 显示给用户看的名称
     'lang' => '用户资金流水',
     'menu' => false,
+    'info' => $desc,
     'order' => 99,
     # 数据结构
     'struct' => array
@@ -91,10 +116,10 @@ return array
 			'desc' 		=> '用户名称',
 			'match' 	=> 'is_numeric',
             'search'	=> $search,
-            'value'     => Dever::input('search_option_uid'),
+            'value'     => $uid,
             'list_name'	=> '用户名称',
 			'list'		=> 'Dever::load("account/lib/info.getName", {uid}, {config_id})',
-            'list'      => true,
+            //'list'      => true,
 		),
 
 		'config_id'		=> array
@@ -184,6 +209,7 @@ return array
             'desc'      => '资金说明',
             'match'     => 'is_string',
             'update'    => 'text',
+            'search'    => 'fulltext',
             'list'      => true,
         ),
 
@@ -237,6 +263,7 @@ return array
         'insert' => false,
         'delete' => false,
         'edit' => false,
+        'button' => $button,
     ),
 
     'request' => array

+ 7 - 10
database/push.php

@@ -1,13 +1,10 @@
 <?php
-$uid = Dever::input('uid');
-$config = function() {
-    $config = Dever::input('config', 1);
-    return Dever::db('account/config')->getData(array('ids' => $config));
-};
+$config_id = Dever::input('search_option_config_id', 1);
+$uid = Dever::input('search_option_uid');
 
-$type = function() use($config) {
-    $config = $config();
-    return Dever::db('account/config_type')->getData(array('project_id' => '-1,' . $config[0]['project_id']));
+$type = function() use($config_id) {
+    $config = Dever::db('account/config')->find($config_id);
+    return Dever::db('account/config_type')->getData(array('manual' => 1, 'project_id' => '-1,' . $config['project_id']));
 };
 
 return array
@@ -55,8 +52,8 @@ return array
             'default'   => '1',
             'desc'      => '选择账户',
             'match'     => 'is_numeric',
-            'update'    => 'radio',
-            'option'     => $config,
+            'update'    => 'hidden',
+            'value'     => $config_id,
         ),
 
         'type_id'      => array

+ 22 - 12
lib/Info.php

@@ -38,6 +38,8 @@ class Info
                 'col' => $project['source_name'],
                 'result' => 'id',
                 'search' => 'uid',
+                'project_name' => $project['name'],
+                'name' => $info['name'],
             );
         }
         
@@ -45,29 +47,29 @@ class Info
     }
 
     # 入账
-    public function up_commit($uid, $cash, $type, $config, $desc = '', $source = '', $source_id = '', $method = 1)
+    public function up_commit($uid, $cash, $type, $config, $desc = '', $source = '', $source_id = '', $method = 1, $state = true)
     {
         if ($cash == 0) {
-            Dever::alert('金额不能为0');
+            return $this->alert('金额不能为0', $state);
         }
         
         $config = Dever::db('account/config')->find(array('key' => $config));
         if (!$config) {
-            Dever::alert('账户信息不存在');
+            return $this->alert('账户信息不存在', $state);
         }
 
         $project = Dever::db('account/config_project')->find($config['project_id']);
         $user = Dever::db($project['source'])->find($uid);
         if (!$user) {
-            Dever::alert('用户信息不存在');
+            return $this->alert('用户信息不存在', $state);
         }
 
         $type = Dever::db('account/config_type')->find(array('key' => $type));
         if (!$type) {
-            Dever::alert('交易类型不存在');
+            return $this->alert('交易类型不存在', $state);
         }
         if ($type['project_id'] != -1 && $type['project_id'] != $config['project_id']) {
-            Dever::alert('交易类型不正确');
+            return $this->alert('交易类型不正确', $state);
         }
 
         $data['uid'] = $uid;
@@ -78,23 +80,23 @@ class Info
         if (!$info) {
             $info['id'] = Dever::db('account/info')->insert($data);
             if (!$info['id']) {
-                Dever::alert('用户信息不存在');
+                return $this->alert('用户信息不存在', $state);
             }
             $info['cash'] = 0;
         }
 
         if ($type['key'] == 'tixian') {
             if ($config['is_withdraw'] == 2) {
-                Dever::alert('当前账户不能提现');
+                return $this->alert('当前账户不能提现', $state);
             }
             if ($config['withdraw_down'] > 0 && $cash < $config['withdraw_down']) {
-                Dever::alert('提现金额不能少于' . $config['withdraw_down']);
+                return $this->alert('提现金额不能少于' . $config['withdraw_down'], $state);
             }
             if ($config['withdraw_up'] > 0 && $cash > $config['withdraw_up']) {
-                Dever::alert('提现金额不能大于' . $config['withdraw_up']);
+                return $this->alert('提现金额不能大于' . $config['withdraw_up'], $state);
             }
             if ($cash > $info['cash']) {
-                Dever::alert('提现金额不能大于账户余额');
+                return $this->alert('提现金额不能大于账户余额', $state);
             }
         }
 
@@ -103,7 +105,7 @@ class Info
             $cash = -1*$cash;
             $func = 'dec';
         }
-
+        $data['info_id'] = $info['id'];
         $data['cash'] = $cash;
         $data['type_id'] = $type['id'];
 
@@ -147,4 +149,12 @@ class Info
         }
         return $yue;
     }
+
+    private function alert($msg, $state = true)
+    {
+        if ($state) {
+            return Dever::alert($msg);
+        }
+        return -1;
+    }
 }

+ 1 - 1
lib/Manage.php

@@ -30,6 +30,6 @@ class Manage
     		Dever::alert('交易类型不存在');
     	}
 
-        Dever::load('account/lib/info')->up_commit($uid, $cash, $type['key'], $config['key'], $desc, 'account/push', $id, 2);
+        Dever::load('account/lib/info.up_commit', $uid, $cash, $type['key'], $config['key'], $desc, 'account/push', $id, 2);
     }
 }

+ 65 - 0
src/Api.php

@@ -17,7 +17,49 @@ class Api
         return $data;
     }
 
+    public function getOne($uid, $account)
+    {
+        if (!$account) {
+            return array();
+        }
+        $config = Dever::db('account/config')->one($account);
+
+        $result = array();
+
+        if ($config) {
+            $info = Dever::db('account/info')->find(array('uid' => $uid, 'config_id' => $config['id']));
+            if ($info) {
+                $info['name'] = $config['name'];
+                $result = $info;
+            }
+        }
+        
+        return $result;
+    }
+
     public function getInfo($uid, $account)
+    {
+        if (!$account) {
+            return array();
+        }
+        $config = Dever::db('account/config')->getData(array('ids' => $account));
+
+        $result = array();
+
+        if ($config) {
+            foreach ($config as $k => $v) {
+                $info = Dever::db('account/info')->find(array('uid' => $uid, 'config_id' => $v['id']));
+                if ($info) {
+                    $info['name'] = $v['name'];
+                    $result[$k] = $info;
+                }
+            }
+        }
+        
+        return $result;
+    }
+
+    public function getTableInfo($uid, $account)
     {
     	if (!$account) {
     		return '无账户信息';
@@ -52,4 +94,27 @@ class Api
             return '无账户信息';
         }
     }
+
+    # 获取日志
+    public function getLogBySource($source, $source_id)
+    {
+        $where['source'] = $source;
+        $where['source_id'] = $source_id;
+        $data = Dever::db('account/info_log')->select($where, function(&$info) {
+            $info['username'] = '无';
+            $config = Dever::db('account/config')->find($info['config_id']);
+            $project = Dever::db('account/config_project')->find($config['project_id']);
+            $source = Dever::db($project['source'])->find($info['uid']);
+            if ($source) {
+                $info['username'] = $source[$project['source_name']];
+            }
+            
+            $info['configname'] = $config['name'];
+            $info['typename'] = Dever::load("account/config_type-one#name", $info['type_id']);
+            $info['cdate'] = date('Y-m-d H:i', $info['cdate']);
+            return $info;
+        });
+
+        return $data;
+    }
 }