dever 3 years ago
parent
commit
6bb751f5cc

+ 1 - 1
config/base.php

@@ -70,7 +70,7 @@ $config['base'] = array
 
         'option' => array
         (
-            'title' => '厨人易料期权管理系统',
+            'title' => '厨人易料期权账户验证',
             'link' => 'option/lib/email.act',
             'content' => '<img src="https://7.churenyiliao.com/1/2022/02/28/ca21f07ab6333b74dcb78d09fdcd2d20.png" width="150"/>
 <br /><br />

+ 92 - 83
service/option/database/account.php

@@ -23,12 +23,6 @@ $audit = array
     4 => '审核未通过',
 );
 
-$type = array
-(
-    1 => '子账号',
-    2 => '主账号',
-);
-
 $is_email = array
 (
     1 => '邮箱已验证',
@@ -43,32 +37,44 @@ $is_idcard = array
 
 $col = Dever::input('col');
 
-$search_type = Dever::input('search_option_type');
+$search_audit = Dever::input('search_option_audit');
+
+$button = $list_button = array();
+
+$list_button = array
+(
+    'list' => array('查看详情', '"cash&mid={mid}&page_type=1&search_audit='.$search_audit.'"'),
+);
+
+if (!$search_audit) {
+    $button = array
+    (
+        '创建账户' => array('fast', '', 'member'),
+    );
+    $list_button['list1'] = array('子账户列表', '"member&search_option_aid={id}&search_option_main=2&oper_table=account"');
+} else {
+    $list_button['edit'] = array('审核', 'audit,audit_desc', '{audit} == 2');
+}
 
 return array
 (
     # 表名
     'name' => 'account',
     # 显示给用户看的名称
-    'lang' => '期权账户认证审核',
+    'lang' => '期权登录账户',
     'order' => 100,
     'set' => array
     (
         'status' => $status,
-        'type' => $type,
         'audit' => $audit,
         'is_email' => $is_email,
         'is_idcard' => $is_idcard,
     ),
-    'start' => array
-    (
-        'insert' => 'option/lib/manage.updateAccountAudit',
-    ),
     'end' => array
     (
         'update' => 'option/lib/manage.updateAccount',
     ),
-    'check' => 'mobile',
+    'check' => 'mid',
     # 数据结构
     'struct' => array
     (
@@ -84,61 +90,54 @@ return array
             //'list'        => true,
         ),
 
-        'type'        => array
-        (
-            'type'      => 'tinyint-1',
-            'name'      => '账号类型',
-            'default'   => '1',
-            'desc'      => '账号类型',
-            'match'     => 'is_numeric',
-            'option'    => $type,
-            'search'    => 'hidden',
-            'update'    => 'radio',
-        ),
-
-        'key'      => array
+        'mid'      => array
         (
             'type'      => 'int-11',
-            'name'      => '账户索引-通过账户索引来判断同一个人',
-            'default'   => '',
-            'desc'      => '账户索引',
-            'match'     => 'is_string',
-            'update'    => 'text',
-        ),
-
-        'name'      => array
-        (
-            'type'      => 'varchar-100',
             'name'      => '姓名',
             'default'   => '',
-            'desc'      => '姓名',
-            'match'     => 'is_string',
+            'desc'      => '期权账户',
+            'match'     => 'is_numeric',
             'update'    => 'text',
-            'search'    => 'fulltext',
-            'list'      => 'Dever::load("option/lib/account.getInfo", {id})',
+            'search'    => array
+            (
+                'api' => 'option/member-find',
+                'col' => 'name',
+                'result' => 'id',
+                'search' => 'mid',//本表的字段,默认为当前的字段
+            ),
+            'list_name' => '期权账户',
+            'list'      => 'Dever::load("option/lib/member.getInfo", {mid})',
             'list_order' => 1,
         ),
 
-        'mobile'      => array
+        'option-member-mobile'=> array
         (
-            'type'      => 'bigint-11',
             'name'      => '手机号',
             'default'   => '',
-            'desc'      => '请输入手机号',
-            'match'     => Dever::rule('mobile'),
-            'update'    => 'text',
-            'search'    => 'fulltext',
-            //'list'      => true,
+            'desc'      => '手机号',
+            'match'     => 'option',
+            'search'    => array
+            (
+                'api' => 'option/member-find',
+                'col' => 'mobile',
+                'result' => 'id',
+                'search' => 'mid',
+            ),
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
         ),
 
         'is_email'        => array
         (
             'type'      => 'tinyint-1',
-            'name'      => '邮箱是否验证',
+            'name'      => '邮箱证',
             'default'   => '2',
             'desc'      => '邮箱是否验证',
             'match'     => 'is_numeric',
+            'search'    => 'select',
             'option'    => $is_email,
+            'list'      => 'Dever::load("option/lib/account.getEmail", {id})',
+            'list_order' => 3,
         ),
 
         'email'     => array
@@ -147,6 +146,7 @@ return array
             'name'      => '邮箱',
             'default'   => '',
             'desc'      => '请输入邮箱',
+            'search'    => 'fulltext',
             'match'     => 'option||' . Dever::rule('email'),
             //'update'    => 'text',
         ),
@@ -160,20 +160,26 @@ return array
             'match'     => 'is_numeric',
             'option'    => $is_idcard,
             //'update'    => 'radio',
-            'list'      => $search_type ? false : true,
+            'list'      => !$search_audit ? false : true,
             'list_order' => 3,
         ),
 
-        'idcard'      => array
+        'option-member-idcard'=> array
         (
-            'type'      => 'varchar-32',
             'name'      => '身份证号码',
             'default'   => '',
             'desc'      => '身份证号码',
-            'match'     => Dever::rule('idcard'),
-            'match'     => 'is_string',
-            'update'    => 'text',
-            'list'      => $search_type ? 'Dever::load("option/lib/account.getCash#daijiaofu", {id})' : false,
+            'match'     => 'option',
+            'search'    => array
+            (
+                'api' => 'option/member-find',
+                'col' => 'idcard',
+                'result' => 'id',
+                'search' => 'mid',
+            ),
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+            'list'      => !$search_audit ? 'Dever::load("option/lib/account.getCash#daijiaofu", {id})' : false,
             'list_name' => '待交付',
             'list_order' => 4,
         ),
@@ -188,7 +194,7 @@ return array
             'update'    => $col ? 'image' : false,
             'key'       => '8',
             //'place'     => '660*660',
-            'list'      => $search_type ? 'Dever::load("option/lib/account.getCash#qiquan", {id})' : false,
+            'list'      => !$search_audit ? 'Dever::load("option/lib/account.getCash#qiquan", {id})' : false,
             'list_name' => '期权',
             'list_order' => 5,
         ),
@@ -203,26 +209,15 @@ return array
             'update'    => $col ? 'image' : false,
             'key'       => '8',
             //'place'     => '660*660',
-            'list'      => $search_type ? 'Dever::load("option/lib/account.getCash#yuanshiqiquan", {id})' : false,
+            'list'      => !$search_audit ? 'Dever::load("option/lib/account.getCash#yuanshiqiquan", {id})' : false,
             'list_name' => '原始期权',
             'list_order' => 6,
         ),
 
-        'sign'     => array
-        (
-            'type'      => 'varchar-150',
-            'name'      => '合同签字',
-            'default'   => '',
-            'desc'      => '合同签字',
-            'match'     => 'option',
-            'update'    => $col ? 'image' : false,
-            'key'       => '7',
-        ),
-
         'audit'        => array
         (
             'type'      => 'tinyint-1',
-            'name'      => $search_type ? '账户认证' : '审核状况',
+            'name'      => !$search_audit ? '账户认证' : '审核状况',
             'default'   => $col ? '3' : '1',
             'desc'      => '审核状况',
             'match'     => 'is_numeric',
@@ -230,7 +225,7 @@ return array
             'search'    => 'select',
             'update'    => $col ? 'radio' : false,
             'list'      => 'Dever::load("option/lib/account.getAudit", {id})',
-            'list_order' => $search_type ? 3 : 5,
+            'list_order' => !$search_audit ? 3 : 5,
             'value'     => $col ? '3' : '1',
             'control'   => 'audit',
         ),
@@ -263,7 +258,7 @@ return array
             'match'     => 'is_numeric',
             'option'    => $status,
             //'search'    => 'select',
-            'list'      => $search_type ? true : false,
+            'list'      => !$search_audit ? true : false,
             'list_order' => 100,
         ),
 
@@ -285,28 +280,42 @@ return array
             # 只有insert时才生效
             'insert'    => true,
             'search'    => 'date',
-            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'list'      => 'date("Y-m-d H:i", {cdate})',
             'list_order' => 2,
         ),
     ),
 
     'manage' => array
     (
-        //'insert' => false,
+        'insert' => false,
         'delete' => false,
-        //'edit' => false,
-        'list_button' => array
-        (
-            'list' => array('查看详情', '"cash&aid={id}&page_type=1&search_type='.$search_type.'"'),
-
-            'edit' => array('审核', 'audit,audit_desc', '{audit} == 2'),
-            //'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin,tk_status', '{status} == 6'),
-            //'delete' => array('删除', '', '{status} == 1'),
-        ),
+        'edit' => false,
+        'button' => $button,
+        'list_button' => $list_button,
     ),
 
     'request' => array
     (
+        'list' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                //'mid' => 'yes',
+                'is_email' => 'yes',
+                'is_idcard' => 'yes',
+                'email' => array('yes', 'like'),
+                'audit' => array('yes', 'in'),
+                'start_cdate' => array('yes-cdate', '>='),
+                'end_cdate' => array('yes-cdate', '<='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'page' => array(20, 'list'),
+            'col' => '*',
+        ),
+
         'getInfo' => array
         (
             # 匹配的正则或函数 选填项

+ 30 - 8
service/option/database/bill_duifu.php

@@ -21,12 +21,13 @@ $audit_manage = array
 );
 
 $aid = Dever::input('search_option_aid');
+$mid = Dever::input('search_option_mid');
 $button = array();
 if ($aid) {
     $option_aid = $aid;
-    $search_type = Dever::input('search_type');
-    if ($search_type) {
-        $option_aid .= '&search_type=' . $search_type;
+    $search_audit = Dever::input('search_audit');
+    if ($search_audit) {
+        $option_aid .= '&search_audit=' . $search_audit;
     }
     $button = array
     (
@@ -91,22 +92,43 @@ return array
         'aid'      => array
         (
             'type'      => 'int-11',
-            'name'      => '手机号',
+            'name'      => '主账号手机号',
             'default'   => '-1',
-            'desc'      => '代理商',
+            'desc'      => '期权登录账户',
             'match'     => 'is_string',
             'update'    => 'text',
-            'search'    => array
+            'search'    => $aid ? 'hidden' : array
             (
-                'api' => 'option/account-find',
+                'api' => 'option/member-getMain',
                 'col' => 'mobile',
                 'result' => 'id',
+                'search' => 'aid',//本表的字段,默认为当前的字段
             ),
-            'list_name' => '期权账户',
+            'list_name' => '账户',
             'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
             'list_order' => 3,
         ),
 
+        'mid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '子账号手机号',
+            'default'   => '-1',
+            'desc'      => '期权账户',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => $mid ? 'hidden' : array
+            (
+                'api' => 'option/member-getChild',
+                'col' => 'mobile',
+                'result' => 'id',
+                'search' => 'aid',//本表的字段,默认为当前的字段
+            ),
+            'list_name' => '子账户',
+            'list'      => 'Dever::load("option/lib/member.getInfo", {mid})',
+            'list_order' => 4,
+        ),
+
         'cash'      => array
         (
             'type'      => 'float-11,2',

+ 30 - 8
service/option/database/bill_fafang.php

@@ -21,12 +21,13 @@ $audit_manage = array
 );
 
 $aid = Dever::input('search_option_aid');
+$mid = Dever::input('search_option_mid');
 $button = array();
 if ($aid) {
     $option_aid = $aid;
-    $search_type = Dever::input('search_type');
-    if ($search_type) {
-        $option_aid .= '&search_type=' . $search_type;
+    $search_audit = Dever::input('search_audit');
+    if ($search_audit) {
+        $option_aid .= '&search_audit=' . $search_audit;
     }
     $button = array
     (
@@ -91,22 +92,43 @@ return array
         'aid'      => array
         (
             'type'      => 'int-11',
-            'name'      => '手机号',
+            'name'      => '主账号手机号',
             'default'   => '-1',
-            'desc'      => '代理商',
+            'desc'      => '期权登录账户',
             'match'     => 'is_string',
             'update'    => 'text',
-            'search'    => array
+            'search'    => $aid ? 'hidden' : array
             (
-                'api' => 'option/account-find',
+                'api' => 'option/member-getMain',
                 'col' => 'mobile',
                 'result' => 'id',
+                'search' => 'aid',//本表的字段,默认为当前的字段
             ),
-            'list_name' => '期权账户',
+            'list_name' => '账户',
             'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
             'list_order' => 3,
         ),
 
+        'mid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '子账号手机号',
+            'default'   => '-1',
+            'desc'      => '期权账户',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => $mid ? 'hidden' : array
+            (
+                'api' => 'option/member-getChild',
+                'col' => 'mobile',
+                'result' => 'id',
+                'search' => 'aid',//本表的字段,默认为当前的字段
+            ),
+            'list_name' => '子账户',
+            'list'      => 'Dever::load("option/lib/member.getInfo", {mid})',
+            'list_order' => 4,
+        ),
+
         'cash'      => array
         (
             'type'      => 'float-11,2',

+ 31 - 9
service/option/database/bill_jiaofu.php

@@ -23,12 +23,13 @@ $audit_manage = array
 $col = Dever::input('col');
 
 $aid = Dever::input('search_option_aid');
+$mid = Dever::input('search_option_mid');
 $button = array();
 if ($aid) {
     $option_aid = $aid;
-    $search_type = Dever::input('search_type');
-    if ($search_type) {
-        $option_aid .= '&search_type=' . $search_type;
+    $search_audit = Dever::input('search_audit');
+    if ($search_audit) {
+        $option_aid .= '&search_audit=' . $search_audit;
     }
     $button = array
     (
@@ -93,20 +94,41 @@ return array
         'aid'      => array
         (
             'type'      => 'int-11',
-            'name'      => '手机号',
+            'name'      => '主账号手机号',
             'default'   => '-1',
-            'desc'      => '代理商',
+            'desc'      => '期权登录账户',
             'match'     => 'is_string',
             'update'    => 'text',
-            'search'    => array
+            'search'    => $aid ? 'hidden' : array
             (
-                'api' => 'option/account-find',
+                'api' => 'option/member-getMain',
                 'col' => 'mobile',
                 'result' => 'id',
+                'search' => 'aid',//本表的字段,默认为当前的字段
             ),
-            'list_name' => '期权账户',
+            'list_name' => '账户',
             'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
-            'list_order' => 2,
+            'list_order' => 3,
+        ),
+
+        'mid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '子账号手机号',
+            'default'   => '-1',
+            'desc'      => '期权账户',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => $mid ? 'hidden' : array
+            (
+                'api' => 'option/member-getChild',
+                'col' => 'mobile',
+                'result' => 'id',
+                'search' => 'aid',//本表的字段,默认为当前的字段
+            ),
+            'list_name' => '子账户',
+            'list'      => 'Dever::load("option/lib/member.getInfo", {mid})',
+            'list_order' => 4,
         ),
 
         'cash'      => array

+ 6 - 5
service/option/database/cash.php

@@ -44,20 +44,21 @@ return array
         'aid'      => array
         (
             'type'      => 'int-11',
-            'name'      => '手机号',
+            'name'      => '主账号手机号',
             'default'   => '-1',
-            'desc'      => '代理商',
+            'desc'      => '期权登录账户',
             'match'     => 'is_string',
             'update'    => 'text',
             'search'    => array
             (
-                'api' => 'option/account-find',
+                'api' => 'option/member-getMain',
                 'col' => 'mobile',
                 'result' => 'id',
+                'search' => 'aid',//本表的字段,默认为当前的字段
             ),
-            'list_name' => '姓名',
+            'list_name' => '主账户',
             'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
-            'list_order' => 4,
+            'list_order' => 3,
         ),
 
         'daijiaofu_date'     => array

+ 219 - 0
service/option/database/member.php

@@ -0,0 +1,219 @@
+<?php
+
+$main = array
+(
+    1 => '主账号',
+    2 => '子账号',
+);
+
+$status = array
+(
+    1 => '手动添加',
+    2 => '系统导入',
+);
+
+
+
+return array
+(
+    # 表名
+    'name' => 'member',
+    # 显示给用户看的名称
+    'lang' => '期权账户列表',
+    'order' => 100,
+    'menu' => false,
+    'check' => 'key,mobile',
+    'start' => array
+    (
+        'insert' => 'option/lib/manage.checkMember',
+        //'update' => 'option/lib/manage.checkMember',
+    ),
+    'end' => array
+    (
+        'insert' => 'option/lib/manage.updateMember',
+        'update' => 'option/lib/manage.updateMember',
+    ),
+    'set' => array
+    (
+        'main' => $main,
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'main'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '账号类型',
+            'default'   => '1',
+            'desc'      => '账号类型',
+            'match'     => 'is_numeric',
+            'option'    => $main,
+            //'search'    => 'hidden',
+            'update'    => 'radio',
+            //'list'      => true,
+        ),
+
+        'key'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '账户索引-通过账户索引来判断同一个人',
+            'default'   => '',
+            'desc'      => '账户索引',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'aid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '期权登录账户',
+            'default'   => '-1',
+            'desc'      => '期权登录账户',
+            'match'     => 'is_string',
+            'update'    => 'hidden',
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '姓名',
+            'default'   => '',
+            'desc'      => '姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => 'Dever::load("option/lib/member.getInfo", {id})',
+            'list'      => true,
+        ),
+
+        'mobile'      => array
+        (
+            'type'      => 'bigint-11',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '请输入手机号',
+            'match'     => Dever::rule('mobile'),
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'idcard'      => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => '身份证号码',
+            'default'   => '',
+            'desc'      => '身份证号码',
+            'match'     => Dever::rule('idcard'),
+            'match'     => 'is_string',
+            'search'    => 'fulltext',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '添加方式',
+            'default'   => '1',
+            'desc'      => '添加方式',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            '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,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+        'list_button' => array
+        (
+            'list1' => array('交付记录', '"bill_jiaofu&search_option_main=2&search_option_mid={id}&oper_table=member&top_table=account"'),
+            'list2' => array('发放记录', '"bill_fafang&search_option_main=2&search_option_mid={id}&oper_table=member&top_table=account"'),
+            'list3' => array('兑付记录', '"bill_duifu&search_option_main=2&search_option_mid={id}&oper_table=member&top_table=account"'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'main' => 'yes',
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'type' => 'all',
+            'col' => '*',
+        ),
+
+        # 获取主账号
+        'getMain' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'mobile' => 'yes',
+                'key' => 'yes',
+                'main' => 1,
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*',
+        ),
+
+        # 获取子账号
+        'getChild' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'mobile' => 'yes',
+                'key' => 'yes',
+                'main' => 2,
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*',
+        ),
+    ),
+);

+ 14 - 2
service/option/database/push_cash.php

@@ -1,6 +1,7 @@
 <?php
 
 $aid = Dever::input('search_option_aid');
+$mid = Dever::input('search_option_mid');
 
 $type = array
 (
@@ -46,14 +47,25 @@ return array
         'aid'      => array
         (
             'type'      => 'int-11',
-            'name'      => '期权账户',
+            'name'      => '期权登录账户',
             'default'   => '-1',
-            'desc'      => '代理商',
+            'desc'      => '期权登录账户',
             'match'     => 'is_string',
             'update'    => 'hidden',
             'value'     => $aid,
         ),
 
+        'mid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '期权账户',
+            'default'   => '-1',
+            'desc'      => '期权账户',
+            'match'     => 'is_string',
+            'update'    => 'hidden',
+            'value'     => $mid,
+        ),
+
         'type'        => array
         (
             'type'      => 'tinyint-1',

+ 134 - 106
service/option/lib/Account.php

@@ -6,19 +6,35 @@ use Dever;
 
 class Account
 {
-    public function getInfo($id, $table = 'option/account')
+    public function getInfo($id)
     {
         if ($id < 0) {
             return '无';
         }
-        $account = Dever::db($table)->find($id);
+        $account = Dever::db('option/account')->find($id);
         if ($account) {
-            $string = $account['name'] . '<br />' . $account['mobile'] . '<br />' . $account['idcard'] . '<br />' . $account['email'];
+            return Dever::load('option/lib/member')->getInfo($account['mid']);
+        } else {
+            return '';
+        }
+    }
+
+    public function getEmail($id)
+    {
+        if ($id < 0) {
+            return '无';
+        }
+        $account = Dever::db('option/account')->find($id);
+        if ($account) {
+            $string = $account['email'];
+            if ($string) {
+                $string .= '<br />';
+            }
 
             if ($account['is_email'] == 1) {
-                $string .= '<br /><font style="color:blue">邮箱已验证</font>';
+                $string .= '<font style="color:blue">已验证</font>';
             } else {
-                $string .= '<br /><font style="color:red">邮箱未验证</font>';
+                $string .= '<font style="color:red">未验证</font>';
             }
             return $string;
             
@@ -90,57 +106,55 @@ class Account
      */
     public function show()
     {
-        $aid = Dever::input('aid');
-        $account = Dever::db('option/account')->one($aid);
+        $mid = Dever::input('mid');
 
-        $config = Dever::db('option/account')->config['set'];
+        $member = Dever::db('option/member')->one($mid);
 
-        $result['账户信息'] = $this->getShowInfo($account, $config);
+        $aid = $member['aid'];
 
-        $button = array();
+        $account = Dever::db('option/account')->one($member['aid']);
 
-        $button[0]['btn'][] = array
-        (
-            'type' => 'edit',
-            'link' => Dever::url('project/database/update?project=option&table=account&where_id='.$account['id'].'&status=1&col=name,idcard,idcard_front,idcard_back', 'manage'),
-            'name' => '修改认证资料',
-        );
-        $url = '';
-        if ($account['audit'] == 2) {
-            $button[0]['btn'][] = array
-            (
-                'type' => 'edit',
-                'link' => Dever::url('project/database/update?project=option&table=account&where_id='.$account['id'].'&status=1&col=audit,audit_desc', 'manage'),
-                'name' => '审核',
-            );
-        }
+        $config = Dever::db('option/account')->config['set'];
+        $member_config = Dever::db('option/member')->config['set'];
 
-        if ($account['status'] == 3) {
-            $button[0]['btn'][] = array
-            (
-                'type' => 'action',
-                'link' => Dever::url('lib/account.setStatus?id=' . $account['id'] . '&value=2', 'option'),
-                'name' => '恢复账号',
-            );
-        } elseif ($account['status'] == 2) {
-            $button[0]['btn'][] = array
-            (
-                'type' => 'action',
-                'link' => Dever::url('lib/account.setStatus?id=' . $account['id'] . '&value=3', 'option'),
-                'name' => '禁用账号',
-            );
+        $result['账户信息'] = $this->getMemberInfo($member, $member_config);
+
+        $search_audit = Dever::input('search_audit');
+        $option_aid = $aid;
+        if ($search_audit) {
+            $option_aid .= '&search_audit=' . $search_audit;
         }
 
-        $aid = $account['id'];
-        if ($account['type'] == 1) {
-            # 给主账户发期权
-            $parent = Dever::db('option/account')->find(array('type' => 2, 'key' => $account['key']));
-            if ($parent) {
-                $aid = $parent['id'];
-            } else {
-                $aid = false;
-            }
+        $idcard_front = $idcard_back = '';
+        if ($account['idcard_front']) {
+            $idcard_front = '<a href="'.$account['idcard_front'].'" target="_blank"><img src="'.$account['idcard_front'].'" width="150" /></a>';
+        }
+        
+        if ($account['idcard_back']) {
+            $idcard_back = '&nbsp;&nbsp;<a href="'.$account['idcard_back'].'" target="_blank"><img src="'.$account['idcard_back'].'" width="150" /></a>';
         }
+        if ($account['email']) {
+            $account['email'] .= '('.$config['is_email'][$account['is_email']].')';
+        }
+
+        $table = array();
+        $table['head'] = array('账户状态', '审核状态', '邮箱认证', '身份证正面', '身份证反面');
+        $table['body'] = array();
+
+        $table['body'][] = array
+        (
+            $config['status'][$account['status']],
+            $config['audit'][$account['audit']],
+            $account['email'],
+            $idcard_front,
+            $idcard_back,
+        );
+
+        $result['审核信息'] = array
+        (
+            'type' => 'table',
+            'content' => $table,
+        );
 
         # 获取账户资金
         $cash_type = Dever::db('option/cash')->config['config_type'];
@@ -173,52 +187,79 @@ class Account
             );
         }
 
-        if ($aid) {
-            $search_type = Dever::input('search_type');
-            $option_aid = $aid;
-            if ($search_type) {
-                $option_aid .= '&search_type=' . $search_type;
-            }
+        $button = array();
+
+        $button[0]['btn'][] = array
+        (
+            'type' => 'edit',
+            'link' => Dever::url('project/database/update?project=option&table=member&where_id='.$account['mid'].'&status=1&col=name,idcard', 'manage'),
+            'name' => '修改资料',
+        );
+
+        $url = '';
+        if ($account['audit'] == 2) {
             $button[0]['btn'][] = array
             (
                 'type' => 'edit',
-                'link' => Dever::url('project/database/update?project=option&table=push_cash&search_option_aid='.$option_aid, 'manage'),
-                'name' => '期权价值交付与发放',
+                'link' => Dever::url('project/database/update?project=option&table=account&where_id='.$account['id'].'&status=1&col=audit,audit_desc', 'manage'),
+                'name' => '审核',
             );
+        }
 
-            $button[1]['btn'][] = array
+        if ($account['status'] == 3) {
+            $button[0]['btn'][] = array
             (
-                'type' => 'link',
-                'link' => Dever::url('project/database/list?project=option&table=bill_jiaofu&search_option_aid='.$option_aid.'', 'manage'),
-                'name' => '期权交付记录',
+                'type' => 'action',
+                'link' => Dever::url('lib/account.setStatus?id=' . $account['id'] . '&value=2', 'option'),
+                'name' => '恢复账号',
             );
-
-            $button[1]['btn'][] = array
+        } elseif ($account['status'] == 2) {
+            $button[0]['btn'][] = array
             (
-                'type' => 'link',
-                'link' => Dever::url('project/database/list?project=option&table=bill_fafang&search_option_aid='.$option_aid.'', 'manage'),
-                'name' => '期权发放记录',
+                'type' => 'action',
+                'link' => Dever::url('lib/account.setStatus?id=' . $account['id'] . '&value=3', 'option'),
+                'name' => '禁用账号',
             );
+        }
 
-            $button[1]['btn'][] = array
-            (
-                'type' => 'link',
-                'link' => Dever::url('project/database/list?project=option&table=bill_duifu&search_option_aid='.$option_aid.'', 'manage'),
-                'name' => '期权兑付记录',
-            ); 
+        $button[0]['btn'][] = array
+        (
+            'type' => 'link',
+            'link' => Dever::url('project/database/list?project=option&table=agreement&search_option_aid='.$option_aid.'', 'manage'),
+            'name' => '期权合同',
+        ); 
+        
+        $button[0]['btn'][] = array
+        (
+            'type' => 'edit',
+            'link' => Dever::url('project/database/update?project=option&table=push_cash&search_option_mid='.$mid.'search_option_aid='.$option_aid, 'manage'),
+            'name' => '期权价值交付与发放',
+        );
 
-            $button[1]['btn'][] = array
-            (
-                'type' => 'link',
-                'link' => Dever::url('project/database/list?project=option&table=agreement&search_option_aid='.$option_aid.'', 'manage'),
-                'name' => '期权合同',
-            ); 
-        }
+        $button[1]['btn'][] = array
+        (
+            'type' => 'link',
+            'link' => Dever::url('project/database/list?project=option&table=bill_jiaofu&search_option_mid='.$mid.'&search_option_aid='.$option_aid.'', 'manage'),
+            'name' => '期权交付记录',
+        );
 
+        $button[1]['btn'][] = array
+        (
+            'type' => 'link',
+            'link' => Dever::url('project/database/list?project=option&table=bill_fafang&search_option_mid='.$mid.'&search_option_aid='.$option_aid.'', 'manage'),
+            'name' => '期权发放记录',
+        );
+
+        $button[1]['btn'][] = array
+        (
+            'type' => 'link',
+            'link' => Dever::url('project/database/list?project=option&table=bill_duifu&search_option_mid='.$mid.'&search_option_aid='.$option_aid.'', 'manage'),
+            'name' => '期权兑付记录',
+        ); 
         
         $url = Dever::url('project/database/list?project=option&table=account', 'manage');
-        if ($search_type) {
-            $url .= '&search_option_type=' . $search_type;
+        if ($search_audit) {
+            $url .= '&search_option_audit=' . $search_audit;
         }
         $head_btn[] = array
         (
@@ -237,23 +278,10 @@ class Account
         return $html;
     }
 
-    private function getShowInfo($account, $config)
+    private function getMemberInfo($member, $member_config)
     {
         $result = array();
 
-        $idcard_pic = '';
-        if ($account['idcard_front']) {
-            $idcard_pic = '<a href="'.$account['idcard_front'].'" target="_blank"><img src="'.$account['idcard_front'].'" width="150" /></a>';
-        }
-        
-        if ($account['idcard_back']) {
-            $idcard_pic .= '&nbsp;&nbsp;<a href="'.$account['idcard_back'].'" target="_blank"><img src="'.$account['idcard_back'].'" width="150" /></a>';
-        }
-
-        if ($account['email']) {
-            $account['email'] .= '('.$config['is_email'][$account['is_email']].')';
-        }
-
         $result = array
         (
             'type' => 'info',
@@ -261,26 +289,20 @@ class Account
             (
                 array
                 (
-                    array('姓名', $account['name']),
-                    array('手机号', $account['mobile']),
-                    array('邮箱', $account['email']),
+                    array('账户类型', $member_config['main'][$member['main']]),
+                    array('账户索引', $member['key']),
+                    
                 ),
 
                 array
                 (
-                    array('账户类型', $config['type'][$account['type']]),
-                    array('审核状态', $config['audit'][$account['audit']]),
-                    array('账户状态', $config['status'][$account['status']]),
+                    array('姓名', $member['name']),
+                    array('手机号', $member['mobile']),
+                    array('身份证号', $member['idcard']),
                 ),
             ),
         );
 
-        $result['content'][] = array
-        (
-            array('身份证号', $account['idcard']),
-            array('身份证照片', $idcard_pic),
-        );
-
         return $result;
     }
 
@@ -337,6 +359,12 @@ class Account
             }
         }
         $daijiaofu .= '<br/ >' . number_format($total, 2, '.', '');
+        if (!$qiquan) {
+            $qiquan = '无';
+        }
+        if (!$yuanshiqiquan) {
+            $yuanshiqiquan = '无';
+        }
         return array('daijiaofu' => $daijiaofu, 'qiquan' => $qiquan, 'yuanshiqiquan' => $yuanshiqiquan);
     }
 }

+ 7 - 5
service/option/lib/Agreement.php

@@ -132,6 +132,7 @@ class Agreement
     # 新建合同
     public function up($account, $date, $total, $status = 1)
     {
+        $member = Dever::db('option/member')->find($account['mid']);
         $agreement = Dever::db('setting/agreement')->find(array('type' => 6));
         if (!$agreement) {
             Dever::alert('协议模板不存在');
@@ -146,10 +147,10 @@ class Agreement
 
         $where['order_num'] = $this->getOrderId();
         $where['agreement_name'] = $this->name($agreement, $account);
-        $where['sign'] = $account['sign'];
-        $where['name'] = $account['name'];
-        $where['mobile'] = $account['mobile'];
-        $where['idcard'] = $account['idcard'];
+        $where['sign'] = '';
+        $where['name'] = $member['name'];
+        $where['mobile'] = $member['mobile'];
+        $where['idcard'] = $member['idcard'];
         $where['idcard_front'] = $account['idcard_front'];
         $where['idcard_back'] = $account['idcard_back'];
         $where['address'] = '';
@@ -215,7 +216,8 @@ class Agreement
                     unset($info['edate']);
                     unset($info['qdate']);
                     unset($info['sign']);
-                    $member = Dever::db('option/account')->find($info['aid']);
+                    $account = Dever::db('option/account')->find($info['aid']);
+                    $member = Dever::db('option/member')->find($account['mid']);
 
                     $info['name'] = $member['name'];
                     $info['idcard'] = $member['idcard'];

+ 2 - 1
service/option/lib/Cash.php

@@ -42,7 +42,7 @@ class Cash
         return $this->delete(array('to_uid' => $uid, 'level' => 1), array('uid' => $parent));
     }
 
-    public function up($aid, $type, $cash, $desc, $alert = true)
+    public function up($aid, $mid, $type, $cash, $desc, $alert = true)
     {
         if ($cash == 0) {
             return;
@@ -53,6 +53,7 @@ class Cash
             $where = array();
             $where['clear'] = true;
             $where['aid'] = $aid;
+            $where['mid'] = $mid;
             $where['type'] = $cash_type;
             $info = false;
             if (!$info) {

+ 1 - 0
service/option/lib/Core.php

@@ -19,6 +19,7 @@ class Core
         $this->checkLogin();
         if ($this->uid) {
             $this->user = Dever::db('option/account')->find($this->uid);
+            $this->user += Dever::db('option/member')->find($this->user['mid']);
             //$this->user['idcard'] = '';
         }
 

+ 44 - 18
service/option/lib/Import.php

@@ -11,29 +11,52 @@ class Import
     # 导入账户
     public function get_api()
     {
+        Dever::config('base')->hook = true;
         $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 1, 5, 'excel');
 
         if ($data) {
+            $member = array();
             foreach ($data as $k => $v) {
                 $state = preg_match(Dever::rule('mobile'), $v['C']);
                 if ($state) {
+                    $key = $v['A'];
                     $where['key'] = $v['A'];
                     $where['mobile'] = $v['C'];
-
-                    $info = Dever::db('option/account')->find($where);
+                    $where['clear'] = true;
+                    $info = Dever::db('option/member')->find($where);
                     $update = $where;
                     $update['idcard'] = $v['D'];
                     $update['name'] = $v['B'];
-                    $update['type'] = $v['E'] ? 2 : 1;
+                    $update['main'] = $v['E'] == 1 ? 1 : 2;
                     if (!$info) {
-                        $update['audit'] = 1;
-                        Dever::db('option/account')->insert($update);
+                        $update['status'] = 2;
+                        $id = Dever::db('option/member')->insert($update);
                     } else {
                         $update['where_id'] = $info['id'];
-                        Dever::db('option/account')->update($update);
+                        $id = Dever::db('option/member')->update($update);
                     }
+                    if ($id && $update['main'] == 1) {
+                        if (!isset($member[$key])) {
+                            $member[$key] = array();
+                        }
+                        $account = Dever::db('option/member')->find(array('mid' => $id));
+                        if (!$account) {
+                            $member[$key] = Dever::db('option/account')->insert(array('mid' => $id, 'audit' => 1));
+                        } else {
+                            $member[$key] = $account['id'];
+                        }
+                    }
+                }
+            }
+
+            if ($member) {
+                foreach ($member as $k => $v) {
+                    $where = array();
+                    $where['option_key'] = $k;
+                    $where['set_aid'] = $v;
+                    Dever::db('option/member')->updates($where);
                 }
             }
         }
@@ -43,6 +66,8 @@ class Import
     # 导入交付记录
     public function get_jiaofu_api()
     {
+        Dever::config('base')->hook = true;
+
         $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 2, 5, 'excel');
@@ -58,13 +83,13 @@ class Import
                     } else {
                         $type = 4;
                     }
-                    $info = Dever::db('option/account')->find($where);
-                    if ($info && $info['status'] < 3) {
-                        $info = Dever::db('option/account')->find(array('key' => $info['key'], 'type' => 2));
-                        if ($info && $info['status'] < 3) {
-                            Dever::load('option/lib/cash')->up($info['id'], $type, $v['C'], $v['E'], false);
+                    $info = Dever::db('option/member')->find($where);
+                    if ($info) {
+                        $account = Dever::db('option/account')->find($info['aid']);
+                        if ($account && $account['status'] < 3) {
+                            Dever::load('option/lib/cash')->up($info['id'], $account['id'], $type, $v['C'], $v['E'], false);
                         }
-                    }   
+                    }
                 }
             }
         }
@@ -74,6 +99,7 @@ class Import
     # 导入发放记录
     public function get_fafang_api()
     {
+        Dever::config('base')->hook = true;
         $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 3, 5, 'excel');
@@ -89,13 +115,13 @@ class Import
                     } else {
                         $type = 5;
                     }
-                    $info = Dever::db('option/account')->find($where);
-                    if ($info && $info['status'] < 3) {
-                        $info = Dever::db('option/account')->find(array('key' => $info['key'], 'type' => 2));
-                        if ($info && $info['status'] < 3) {
-                            Dever::load('option/lib/cash')->up($info['id'], $type, $v['C'], $v['E'], false);
+                    $info = Dever::db('option/member')->find($where);
+                    if ($info) {
+                        $account = Dever::db('option/account')->find($info['aid']);
+                        if ($account && $account['status'] < 3) {
+                            Dever::load('option/lib/cash')->up($info['id'], $account['id'], $type, $v['C'], $v['E'], false);
                         }
-                    }   
+                    }
                 }
             }
         }

+ 52 - 10
service/option/lib/Manage.php

@@ -6,6 +6,35 @@ use Dever;
 
 class Manage
 {
+    public function updateMember($id, $name, $data)
+    {
+        Dever::config('base')->hook = true;
+        $where['id'] = $id;
+        $where['clear'] = true;
+        $info = Dever::db('option/member')->find($where);
+        if ($info) {
+            if ($info['main'] == 1) {
+                $update['mid'] = $id;
+                $account = Dever::db('option/account')->one($update);
+                if (!$account) {
+                    $update['audit'] = 1;
+                    $aid = Dever::db('option/account')->insert($update);
+                } else {
+                    $aid = $account['id'];
+                }
+                Dever::db('option/member')->update(array('where_id' => $info['id'], 'aid' => $aid));
+            }
+
+            $main = Dever::db('option/member')->getMain(array('key' => $info['key']));
+            if ($main && $main['aid']) {
+                $where = array();
+                $where['option_key'] = $info['key'];
+                $where['set_aid'] = $main['aid'];
+                Dever::db('option/member')->updates($where);
+            }
+        }
+    }
+
     public function updateAccount($id, $name, $data)
     {
         Dever::config('base')->hook = true;
@@ -123,16 +152,14 @@ class Manage
     {
         Dever::config('base')->hook = true;
         $aid = Dever::param('aid', $data);
+        $mid = Dever::param('mid', $data);
         $type = Dever::param('type', $data);
         $cash = Dever::param('cash', $data);
         $desc = Dever::param('desc', $data);
         if ($aid && $type && $cash && $desc) {
             $account = Dever::db('option/account')->find($aid);
             if ($account && $account['status'] <= 2) {
-                Dever::load('option/lib/cash')->up($aid, $type, $cash, $desc);
-                $where['where_id'] = $aid;
-                $where['cash'] = $cash;
-                Dever::db('agent/member')->upCash($where);
+                Dever::load('option/lib/cash')->up($aid, $mid, $type, $cash, $desc);
             } else {
                 Dever::db('option/push_cash')->update(array('where_id' => $id, 'status' => 2));
                 Dever::alert('期权账户已停用或者未审核,操作失败');
@@ -140,12 +167,6 @@ class Manage
         }
     }
 
-    public function updateAccountAudit($id, $name, $data)
-    {
-        $data['add_audit'] = 1;
-        return $data;
-    }
-
     public function getDate($id)
     {
         $info = Dever::db('option/agreement')->find($id);
@@ -184,4 +205,25 @@ class Manage
 
         return 'reload';
     }
+
+    public function checkMember($id, $name, $data)
+    {
+        $main = Dever::param('main', $data);
+        $key = Dever::param('key', $data);
+        if (!$key) {
+            Dever::alert('请传入账户索引');
+        }
+
+        if ($main == 2) {
+            $main = Dever::db('option/member')->getMain(array('key' => $key));
+            if (!$main) {
+                Dever::alert('请先创建主账号');
+            }
+        } elseif ($main == 1) {
+            $main = Dever::db('option/member')->getMain(array('key' => $key));
+            if ($main) {
+                Dever::alert('已存在主账号');
+            }
+        }
+    }
 }

+ 23 - 0
service/option/lib/Member.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace Option\Lib;
+
+use Dever;
+
+class Member
+{
+    public function getInfo($id)
+    {
+        if ($id < 0) {
+            return '无';
+        }
+        $account = Dever::db('option/member')->find($id);
+        if ($account) {
+            $string = $account['name'] . '<br />' . $account['mobile'] . '<br />' . $account['idcard'] . '<br />' . $account['key'];
+            return $string;
+            
+        } else {
+            return '';
+        }
+    }
+}

+ 16 - 18
service/option/src/Auth.php

@@ -29,18 +29,23 @@ class Auth
     private function checkLogin($state = 1)
     {
         $mobile = Dever::load('option/lib/account')->checkMobile(Dever::input('mobile'));
-        $user = Dever::db('option/account')->find(array('mobile' => $mobile));
+        $user = Dever::db('option/member')->find(array('mobile' => $mobile));
         if (!$user) {
             Dever::alert('手机号不正确');
         }
 
         if ($user) {
+            $data = array();
+            $account = Dever::db('option/account')->find($user['aid']);
+            if (!$account) {
+                Dever::alert('手机号不正确');
+            }
 
-            if ($user['status'] > 2) {
+            if ($account['status'] > 2) {
                 Dever::alert('该账号已停用');
             }
 
-            if ($user['type'] == 1) {
+            if ($user['main'] == 2) {
                 Dever::alert('该账号已建立期权账户');
             }
 
@@ -53,12 +58,6 @@ class Auth
                     $msg .= '::' . $code;
                 }
                 $data['msg'] = $msg;
-                if ($user['status'] == 1) {
-                    $data['status'] = 1;
-                } else {
-                    $data['status'] = 2;
-                }
-                return $data;
             } else {
                 if ($user['status'] == 1) {
                     $idcard = Dever::input('idcard');
@@ -68,16 +67,15 @@ class Auth
                 }
 
                 Dever::load('option/lib/account')->checkMcode($mobile);
-                $data = Dever::load('passport/reg')->getSign($user['id']);
-
-                if ($user['status'] == 1) {
-                    $data['status'] = 1;
-                } else {
-                    $data['status'] = 2;
-                }
-
-                return $data;
+                $data = Dever::load('passport/reg')->getSign($account['id']);
             }
+            if ($account['status'] == 1) {
+                $data['status'] = 1;
+            } else {
+                $data['status'] = 2;
+            }
+
+            return $data;
         } else {
             Dever::alert('该用户还未存在期权数据');
         }

+ 0 - 7
service/option/src/My.php

@@ -7,13 +7,6 @@ use Option\Lib\Core;
 
 class My extends Core
 {
-    public function test()
-    {
-        $email = '2934170@qq.com';
-        $code = Dever::load('passport/reg')->code(false, false);
-        $email = base64_encode($email);
-        Dever::daemon('lib/email.renzheng?aid='.$this->uid.'&email=' . $email . '&code=' . $code . '&username=' . $this->user['name'], 'option');
-    }
     /**
      * 获取基本信息
      *