<?php

$main = array
(
    1 => '主账号',
    2 => '子账号',
);

$status = array
(
    1 => '手动添加',
    2 => '系统导入',
);

$idcard_bind = array
(
    1 => '身份证已绑定',
    2 => '身份证未绑定',
);

$search_auth = Dever::input('search_option_dever_auth', 1);

$list_button = array();

if ($search_auth <= 2) {
    $list_button = array
    (
        //'list' => array('查看详情', '"cash&mid={id}&page_type=1&search_audit=-1"'),
        'fast_add' => array('期权价值交付', 'push_cash&search_option_aid={aid}&search_option_mid={id}&type=1'),
        'fast_add1' => array('期权价值发放', 'push_cash&search_option_aid={aid}&search_option_mid={id}type=2'),
        'list1' => array('交付记录', '"bill_jiaofu&search_option_main=2&search_option_aid={aid}&search_option_mid={id}&top_table=account"'),
        'list2' => array('发放记录', '"bill_fafang&search_option_main=2&search_option_aid={aid}&search_option_mid={id}&top_table=account"'),
        'list3' => array('兑付记录', '"bill_duifu&search_option_main=2&search_option_aid={aid}&search_option_mid={id}&top_table=account"'),
    );
}

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',
        'update_main' => 'option/lib/manage.updateMain',
    ),
    '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',
            'order'     => 'asc',
            'list'      => true,
            'edit'      => true,
        ),

        'key'      => array
        (
            'type'      => 'int-11',
            'name'      => '账户索引-通过账户索引来判断同一个人',
            'default'   => '',
            'desc'      => '账户索引',
            'match'     => 'is_string',
            'update'    => 'text',
            # 绑定js脚本，更新时使用，第一个参数是执行的方式，第二个参数执行的方法，第三个参数是传值。
            'bind'        => array('onblur', 'loading', array('url' => Dever::url("lib/member.search", 'option'))),
            '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,
        ),

        'idcard_bind'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '身份证是否绑定',
            'default'   => '2',
            'desc'      => '身份证是否绑定',
            'match'     => 'is_numeric',
            'option'    => $idcard_bind,
        ),

        'status'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '添加方式',
            'default'   => '1',
            'desc'      => '添加方式',
            'match'     => 'is_numeric',
            'option'    => $status,
            'search'    => 'select',
            // 'list'      => true
        ),

        'dever_auth'      => array
        (
            'name'      => '权限',
            'default'   => '',
            'desc'      => '类型',
            'match'     => 'is_string',
            'search'    => 'hidden',
        ),

        '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' => $list_button,
    ),

    'request' => array
    (
        'getOne' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'main' => 1,
                'key' => 'yes',
                'mobile' => array('yes', 'like'),
                'name' => array('yes', 'like'),
                'idcard' => array('yes', 'like'),
                'state' => 1,
            ),
            'type' => 'all',
            'col' => '*|id',
        ),

        'getList' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'main' => 'yes',
                'key' => 'yes',
                'state' => 1,
            ),
            'order' => array('main' => 'asc','id' => 'desc'),
            'type' => 'all',
            'col' => '*',
        ),

        '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' => '*',
        ),

        'getDataByKeys' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'main' => 1,
                'start' => array('yes-key', '>='),
                'end' => array('yes-key', '<='),
                'state' => 1,
            ),
            'order' => array('main' => 'asc','id' => 'desc'),
            'type' => 'all',
            'col' => '*',
        ),
        #获取所有数据
        'getCount' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'state' => 1,
            ),
            // 'order' => array('id' => 'desc'),
            'type' => 'count',
            'col' => '*',
        ),
    ),
);
