<?php

$role = function()
{
    $array = array();
    $data = Dever::load('setting/role-state');
    if($data)
    {
        $array += $data;
    }
    return $array;
};
$excel = false;
if (Dever::load('manage/auth')->checkFunc('menu_240.menu_271', 'area_excel1', '已售区域列表导出')) {
    $excel = array
    (
        array('已售区域列表导出', '已售区域列表导出', 'agent/lib/manage.out_arealog'),
    );
}
$type = array
(
    1 => '购买',
    2 => '赠送',
    3 => '后台修改',
    4 => '系统导入',
    5 => '系统同步',
);

return array
(
    # 表名
    'name' => 'member_area',
    # 显示给用户看的名称
    'lang' => '已售区域列表',
    'order' => 8,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            //'list'        => true,
        ),

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

        'order_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '订单表id',
            'default'   => '',
            'desc'      => '订单表id',
            'match'     => 'is_numeric',
        ),

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

        'price'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '实付金额',
            'default'   => '0',
            'desc'      => '金额',
            'match'     => 'option',
            'update'    => 'text',
            'list'      => true,
        ),

        'role'      => array
        (
            'type'      => 'int-11',
            'name'      => '代理角色',
            'default'   => '',
            'desc'      => '代理角色',
            'match'     => 'is_numeric',
            'search'    => 'select',
            'update'    => 'checkbox',
            'option'    => $role,
            // 'list'      => true,
        ),

        'area'       => array
        (
            'type'      => 'varchar-500',
            'name'      => '区域',
            'default'   => '',
            'desc'      => '区域',
            'match'     => 'option',
            'search'    => 'linkage',
            'update'    => 'linkage',
            'option'    => Dever::url('api.get?level_total=4', 'area'),
            'list'      => 'Dever::load("area/api.string", "{area}", ",", true, "不限", 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})',
        ),
    ),

    'alter' => array
    (
        5 => array
        (
            array('update', 'price', 'price', 'decimal-11,2 0 实付金额'),
        ),
        'version' => 5,
    ),

    'manage' => array
    (
        'insert' => false,
        'delete' => false,
        'edit' => false,
        'page_list' => 'member_area',
        'excel' => $excel,
    ),

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

        'getOne' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'order_id' => 'yes',
                'role' => 'yes',
                'mid' => 'yes',
                'type' => 'yes',
                'area' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'order' => array('id' => 'desc'),
            'col' => '*',
        ),
    ),
);