<?php
$status = array
(
    1 => '未核实',
    2 => '已核实',
    3 => '驳回',
);

$manage_audit = array
(
    //1 => '未核实',
    2 => '已核实',
    3 => '驳回',
);

$type = array
(
    1 => '个人',
    2 => '公司',
);

$col = Dever::input('col');

return array
(
    # 表名
    'name' => 'user_bind',
    # 显示给用户看的名称
    'lang' => '零售绑定认证',
    'end' => array
    (
        'update' => 'agent/lib/manage.updateUserBind',
    ),
    'status' => $status,
    'order' => 1,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            //'list'        => true,
        ),

        'uid'       => array
        (
            'type'      => 'int-11',
            'name'      => '绑定用户',
            'default'   => '',
            'desc'      => '绑定用户',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list_name' => '昵称',
            'list'      => '{uid} > 0 ? Dever::load("passport/user-find#username", {uid}) : "匿名用户"',
            'list_order' => 1,
        ),

        'mid'      => array
        (
            'type'      => 'int-11',
            'name'      => '代理商姓名/手机号',
            'default'   => '-1',
            'desc'      => '代理商',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => array
            (
                'api' => 'agent/member-getSearch',
                'col' => 'col',
                'result' => 'id',
                'search' => 'mid',
            ),
            'list_name' => '代理商信息',
            'list'      => 'Dever::load("agent/lib/member.getOne", {mid}, "agent/member", true)',
            'list_order' => 3,
        ),

        'name'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '绑定姓名',
            'default'   => '',
            'desc'      => '姓名',
            'match'     => 'is_string',
            'update'    => 'text',
            //'search'    => 'fulltext',
            //'list'      => true,
            'list_order' => 4,
        ),

        'mobile'      => array
        (
            'type'      => 'bigint-11',
            'name'      => '手机号',
            'default'   => '',
            'desc'      => '请输入手机号',
            'match'     => Dever::rule('mobile'),
            'update'    => 'text',
            //'search'    => 'fulltext',
            'list'      => true,
            'list_order' => 2,
        ),

        'type'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '类型',
            'default'   => '1',
            'desc'      => '类型',
            'match'     => 'is_numeric',
            'option'    => $type,
            'update'    => 'radio',
            'control'   => 'type',
        ),

        'idcard'      => array
        (
            'type'      => 'varchar-32',
            'name'      => '身份证号码',
            'default'   => '',
            'desc'      => '身份证号码',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'		=> true,
            'list_order' => 5,
        ),

        'idcard_front'     => array
        (
            'type'      => 'varchar-150',
            'name'      => '身份证正面',
            'default'   => '',
            'desc'      => '身份证正面',
            'match'     => 'option',
            'update'    => 'image',
            'key'       => '8',
            'place'     => '660*660',
        ),

        'idcard_back'     => array
        (
            'type'      => 'varchar-150',
            'name'      => '身份证背面',
            'default'   => '',
            'desc'      => '身份证背面',
            'match'     => 'option',
            'update'    => 'image',
            'key'       => '8',
            'place'     => '660*660',
        ),

        'company_name'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '公司名称',
            'default'   => '',
            'desc'      => '公司名称',
            'match'     => 'is_string',
            'update'    => 'text',
            //'search'    => 'fulltext',
            //'list'      => true,
            'show'      => 'type=2',
        ),

        'company_pic'      => array
        (
            'type'      => 'varchar-150',
            'name'      => '营业执照',
            'default'   => '',
            'desc'      => '营业执照',
            'match'     => 'option',
            'update'    => 'image',
            'key'       => '8',
            'place'     => '660*660',
            'show'      => 'type=2',
        ),

        'company_number'      => array
        (
            'type'      => 'varchar-80',
            'name'      => '营业执照号码',
            'default'   => '',
            'desc'      => '营业执照号码',
            'match'     => 'is_string',
            'update'    => 'text',
            'show'      => 'type=2',
        ),

        'status'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '状态',
            'default'   => '1',
            'desc'      => '状态',
            'match'     => 'is_numeric',
            'option'    => $status,
            'search'    => 'select',
            'list'      => true,
        ),

        'audit'        => array
        (
            'type'      => 'int-11',
            'name'      => '审核状态',
            'default'   => '2',
            'desc'      => '审核状态',
            'match'     => 'is_numeric',
            'update'    => $col ? 'radio' : false,
            'option'    => $manage_audit,
            'mul'       => true,
            'control'   => 'audit',
        ),

        'audit_desc'      => array
        (
            'type'      => 'varchar-600',
            'name'      => '备注',
            'default'   => '',
            'desc'      => '审核说明',
            'match'     => 'is_string',
            'update'    => $col ? 'textarea' : false,
            // 'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
            // 'list_order'  => 9,
            'show'      => 'audit=3',
        ),

        'audit_date'     => array
        (
            'type'      => 'int-11',
            'name'      => '审核时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '审核时间',
        ),

        'admin'     => array
        (
            'type'      => 'int-11',
            'name'      => '操作人',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '操作人',
            //'list'      => '"{admin}" > 0 ? Dever::load("manage/admin-find#username", {admin}) : "-"',
        ),

        '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", {cdate})',
            'list_order' => 3,
        ),
    ),

    'manage' => array
    (
        'insert' => false,
        'delete' => false,
        'edit' => false,
        'page_list' => 'user_bind',

        'list_button' => array
        (
        	'list' => array('查看详情', '"user_bind&id={id}&page_type=1"'),

            //'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin,tk_status', '{status} == 6'),
            'edit' => array('审核', 'audit,audit_desc', '{status} == 1'),
            //'delete' => array('删除关联', '', '{status} == 2'),
        ),
    ),

    'request' => array
    (
        'getInfo' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'status' => 2,
                'state' => 1,
            ),
            'order' => array('id' => 'desc'),
            'type' => 'one',
            'col' => '*',
        ),

        'getData' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'idcard' => 'yes',
                'id' => array('yes', '!='),
                'status' => 2,
                'state' => 1,
            ),
            'order' => array('id' => 'desc'),
            'type' => 'all',
            'page' => array(20, 'list'),
            'col' => '*',
        ),
    ),
);