rabin 2 år sedan
förälder
incheckning
42f95e233c
8 ändrade filer med 302 tillägg och 41 borttagningar
  1. 46 2
      database/config.php
  2. 116 0
      database/config_card.php
  3. 1 1
      database/config_project.php
  4. 6 3
      database/config_type.php
  5. 4 4
      database/info.php
  6. 92 15
      database/info_log.php
  7. 35 15
      lib/Info.php
  8. 2 1
      lib/Manage.php

+ 46 - 2
database/config.php

@@ -92,7 +92,7 @@ return array
 			'default' 	=> '2',
 			'desc' 		=> '是否主账户',
 			'match' 	=> 'is_numeric',
-			'update'	=> 'select',
+			'update'	=> 'radio',
 			'option'	=> $type,
 			'search'	=> 'select',
 			'list'		=> true,
@@ -152,6 +152,7 @@ return array
             'update'    => 'radio',
             'option'    => $is_withdraw,
             'control'	=> 'is_withdraw',
+            'tab'		=> 1,
         ),
 
         'withdraw_up'     => array
@@ -163,6 +164,7 @@ return array
             'match'     => 'option',
             'update'    => 'text',
             'show'		=> 'is_withdraw=1',
+            'tab'		=> 1,
         ),
 
         'withdraw_down'     => array
@@ -174,6 +176,7 @@ return array
             'match'     => 'option',
             'update'    => 'text',
             'show'		=> 'is_withdraw=1',
+            'tab'		=> 1,
         ),
 
         'withdraw_fee'     => array
@@ -185,8 +188,47 @@ return array
             'match'     => 'option',
             'update'    => 'text',
             'show'		=> 'is_withdraw=1',
+            'tab'		=> 1,
+        ),
+
+        'withdraw_audit'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '提现审核',
+            'default'   => '1',
+            'desc'      => '提现审核',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => array(1 => '需要审核', 2 => '不需要审核'),
+            'show'		=> 'is_withdraw=1',
+            'tab'		=> 1,
+        ),
+
+        'withdraw_grant'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '发放审核',
+            'default'   => '1',
+            'desc'      => '发放审核',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => array(1 => '需要审核', 2 => '不需要审核'),
+            'show'		=> 'is_withdraw=1',
+            'tab'		=> 1,
         ),
 
+        'withdraw_check'		=> array
+		(
+			'type' 		=> 'varchar-1500',
+			'name' 		=> '提现验证接口-提现时,可以自定义验证接口,仅支持dever::load方法',
+			'default' 	=> '',
+			'desc' 		=> '提现验证接口',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'show'		=> 'is_withdraw=1',
+			'tab'		=> 1,
+		),
+
         'reorder'		=> array
 		(
 			'type' 		=> 'int-11',
@@ -225,6 +267,7 @@ return array
 
 	'manage' => array
 	(
+		'tab' => array('基本配置', '提现配置'),
 		'button' => array
         (
             '项目配置' => array('list', 'config_project&parent=config'),
@@ -232,7 +275,8 @@ return array
         ),
         'list_button' => array
         (
-        	'list' => array('用户账户列表', '"info&search_option_config_id={id}&parent=config"'),
+        	'list' => array('账户列表', '"info&search_option_config_id={id}&parent=config"'),
+        	'list1' => array('充值卡列表', '"config_card&search_option_config_id={id}&parent=config"'),
         )
 	),
 

+ 116 - 0
database/config_card.php

@@ -0,0 +1,116 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'config_card',
+    # 显示给用户看的名称
+    'lang' => '用户充值卡',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'        => true,
+        ),
+
+        'config_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '账户id',
+			'default' 	=> '',
+			'desc' 		=> '账户id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_config_id'),
+		),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '充值卡名称',
+            'default'   => '',
+            'desc'      => '充值卡名称',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'    	=> true,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '充值卡金额',
+            'default'   => '',
+            'desc'      => '充值卡金额',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'    	=> true,
+        ),
+
+        'pay'      => array
+        (
+           	'type'      => 'varchar-100',
+            'name'      => '支付金额',
+            'default'   => '',
+            'desc'      => '支付金额',
+            'match'     => 'is_string',
+            '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_name' => '交易时间',
+            'list'        => 'date("Y-m-d H:i", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'link' => 'parent=config.config_card',
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 1 - 1
database/config_project.php

@@ -117,7 +117,7 @@ return array
 		'col' => 'name,source,source_name,state,cdate',
 		'value' => array
 		(
-			'"默认项目","passport/user","username", 1,' . DEVER_TIME,
+			'"默认项目","user/info","name", 1,' . DEVER_TIME,
 		),
 	),
 

+ 6 - 3
database/config_type.php

@@ -168,11 +168,14 @@ return array
 
 	'default' => array
 	(
-		'col' => 'name,`key`,project_id,type,state,cdate',
+		'col' => 'name,`key`,project_id,type,manual,state,cdate',
 		'value' => array
 		(
-			'"充值", "chongzhi", -1, 1, 1,' . DEVER_TIME,
-			'"提现", "tixian",-1, 2, 1,' . DEVER_TIME,
+			'"充值", "chongzhi", -1, 1, 1, 1,' . DEVER_TIME,
+			'"提现", "tixian",-1, 2, 1, 1,' . DEVER_TIME,
+			'"采购", "caigou",-1, 2, 2, 1,' . DEVER_TIME,
+			'"购买", "goumai",-1, 2, 2, 1,' . DEVER_TIME,
+			'"销售", "xiaoshou",-1, 1, 2, 1,' . DEVER_TIME,
 		),
 	),
 

+ 4 - 4
database/info.php

@@ -121,9 +121,9 @@ return array
 		'z_cash'		=> array
 		(
 			'type'      => 'decimal-11,2',
-			'name' 		=> '总获取金额',
+			'name' 		=> '总增加金额',
 			'default' 	=> '0',
-			'desc' 		=> '总获取金额',
+			'desc' 		=> '总增加金额',
 			'match' 	=> 'option',
 			'update'	=> 'text',
 			'list'		=> true,
@@ -132,9 +132,9 @@ return array
 		't_cash'		=> array
 		(
 			'type'      => 'decimal-11,2',
-			'name' 		=> '总消耗金额',
+			'name' 		=> '总减少金额',
 			'default' 	=> '0',
-			'desc' 		=> '总消耗金额',
+			'desc' 		=> '总减少金额',
 			'match' 	=> 'option',
 			'update'	=> 'text',
 			'list'		=> true,

+ 92 - 15
database/info_log.php

@@ -62,8 +62,8 @@ if ($config_id && $uid) {
             $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 .= ' 总增加金额:' . '<b>' . $account_info['z_cash'] . '</b>';
+            $desc .= ' 总减少金额:' . '<b>' . $account_info['t_cash'] . '</b>';
             $desc .= '</blockquote>';
         }
 	}
@@ -75,6 +75,24 @@ $method = array
     2 => '手动',
 );
 
+$status = array
+(
+    1 => '待审核',
+    2 => '已审核',
+    3 => '已发放',
+    4 => '已作废',
+);
+
+$audit_status = array
+(
+    //1 => '待审核',
+    2 => '已审核',
+    //3 => '已发放',
+    4 => '已作废',
+);
+
+$col = Dever::input('col');
+
 return array
 (
     # 表名
@@ -178,7 +196,7 @@ return array
             'update'    => 'text',
         ),
 
-        'cash'      => array
+        'ycash'      => array
         (
             'type'      => 'decimal-11,2',
             'name'      => '金额',
@@ -186,7 +204,17 @@ return array
             'desc'      => '金额',
             'match'     => 'is_numeric',
             'update'    => 'text',
-            'list_name' => '金额',
+            'list'      => true,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '实际金额',
+            'default'   => '0',
+            'desc'      => '实际金额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
             'list'      => true,
         ),
 
@@ -213,17 +241,6 @@ return array
             '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',
@@ -235,6 +252,61 @@ return array
             'option'    => $method,
         ),
 
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '2',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'list'      => true,
+        ),
+
+        'audit_admin'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核人',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '审核人',
+            'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#username", {audit_admin}) : "-"',
+        ),
+
+        'audit_status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '审核状态',
+            'default'   => '2',
+            'desc'      => '审核状态',
+            'match'     => 'is_numeric',
+            'option'    => $audit_status,
+            'update'    => $col ? 'radio' : false,
+            'control'   => 'audit_status',
+        ),
+
+        'audit_desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '审核备注',
+            'default'   => '',
+            'desc'      => '审核备注',
+            'match'     => 'is_string',
+            'update'    => $col ? 'textarea' : false,
+            'show'      => 'audit_status=4',
+            'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
+        ),
+
+        'audit_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核时间',
+            'match'     => 'is_numeric',
+            'desc'      => '审核时间',
+            'default'   => '',
+            'list'      => '{audit_date} ? date("Y-m-d H:i:s", {audit_date}) : "-"',
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -264,6 +336,11 @@ return array
         'delete' => false,
         'edit' => false,
         'button' => $button,
+        # 列表
+        'list_button' => array
+        (
+            'edit' => array('审核', 'audit_status,audit_desc', '{status} == 1'),
+        ),
     ),
 
     'request' => array

+ 35 - 15
lib/Info.php

@@ -50,7 +50,7 @@ class Info
         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']);
+                $result[$k]['cdate'] = date('Y-m-d H:i', $v['cdate']);
                 if (isset($type[$v['type_id']])) {
                     $result[$k]['type_name'] = $type[$v['type_id']]['name'];
                 } else {
@@ -127,7 +127,7 @@ class Info
         if ($type['project_id'] != -1 && $type['project_id'] != $config['project_id']) {
             return $this->alert('交易类型不正确', $state);
         }
-
+        $data['status'] = 2;
         $data['uid'] = $uid;
         $data['config_id'] = $config['id'];
         $data['project_id'] = $config['project_id'];
@@ -141,6 +141,18 @@ class Info
             $info['cash'] = 0;
         }
 
+        $func = 'inc';
+        if ($type['type'] == 2) {
+            if ($info['cash'] < $cash) {
+                return $this->alert('账户余额不足', $state);
+            }
+            $cash = -1*$cash;
+            $func = 'dec';
+        }
+        $data['info_id'] = $info['id'];
+        $data['ycash'] = $cash;
+        $data['cash'] = $cash;
+
         if ($type['key'] == 'tixian') {
             if ($config['is_withdraw'] == 2) {
                 return $this->alert('当前账户不能提现', $state);
@@ -154,18 +166,22 @@ class Info
             if ($cash > $info['cash']) {
                 return $this->alert('提现金额不能大于账户余额', $state);
             }
-        }
-
-        $func = 'inc';
-        if ($type['type'] == 2) {
-            if ($info['cash'] < $cash) {
-                return $this->alert('账户余额不足', $state);
+            if ($config['withdraw_check']) {
+                $msg = Dever::load($config['withdraw_check'], $uid, $cash);
+                if ($msg != 'ok') {
+                    return $this->alert($msg, $state);
+                }
+            }
+            if ($config['withdraw_audit'] == 1) {
+                $data['status'] = 1;
+            }
+            if ($config['withdraw_fee']) {
+                $fee = Dever::per($cash, $config['withdraw_fee']);
+                $data['cash'] -= $fee;
             }
-            $cash = -1*$cash;
-            $func = 'dec';
         }
-        $data['info_id'] = $info['id'];
-        $data['cash'] = $cash;
+
+
         $data['type_id'] = $type['id'];
 
         if ($source) {
@@ -191,12 +207,16 @@ class Info
 
         $yue = $data['yue'];
         $data['method'] = $method;
-        $admin = Dever::load('manage/auth.data');
-        if ($admin) {
-            $data['admin_id'] = $admin['id'];
+        if ($data['status'] == 2) {
+            $admin = Dever::load('manage/auth.data');
+            if ($admin) {
+                $data['audit_admin'] = $admin['id'];
+            }
+            $data['audit_date'] = time();
         }
         
         $data['clear'] = true;
+
         $id = Dever::db('account/info_log')->insert($data);
         if ($id) {
             $update = array();

+ 2 - 1
lib/Manage.php

@@ -40,10 +40,11 @@ class Manage
      */
     public function config($id, $name, $param)
     {
+        Dever::config('base')->hook = true;
         $type = Dever::param('type', $param);
 
         if ($type == 1) {
-            Dever::db('account/config')->updates(array('type' => 2));
+            Dever::db('account/config')->updates(array('option_type' => 1, 'set_type' => 2));
             Dever::db('account/config')->update(array('where_id' => $id, 'type' => 1));
         }
     }