<?php
$type = array
(
    1 => '普通代理',
    2 => '区域门店代理',
    3 => '特殊代理',
);

$area = array
(
	1 => '城市',
	2 => '区县',
	3 => '街道',
);

$yes = array
(
	1 => '是',
	2 => '否',
);

return array
(
    # 表名
    'name' => 'role',
    # 显示给用户看的名称
    'lang' => '代理商角色',
    # 后台菜单排序
    'order' => 2,
    'config_type' => $type,
    # 数据结构
    'struct' => array
    (
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
            'order'     => 'desc',
        ),
        
        'name'      => array
        (
            'type'      => 'varchar-200',
            'name'      => '名称',
            'default'   => '',
            'desc'      => '名称',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'      => true,
        ),

        'short_name'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '简称',
            'default'   => '',
            'desc'      => '简称',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'      => true,
        ),

        'desc'      => array
        (
            'type'      => 'varchar-500',
            'name'      => '描述',
            'default'   => '',
            'desc'      => '描述',
            'match'     => 'is_string',
            'update'    => 'textarea',
            //'search'    => 'fulltext',
            //'list'      => true,
        ),

        'type'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '代理类型',
            'default'   => '1',
            'desc'      => '代理类型',
            'match'     => 'is_numeric',
            'update'  	=> 'radio',
            'option'    => $type,
            'search'    => 'select',
            'list'      => true,
            'control'	=> 'type',
        ),

        'area'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '区域',
            'default'   => '1',
            'desc'      => '区域',
            'match'     => 'is_numeric',
            'update'  	=> 'radio',
            'option'    => $area,
            'value'     => '1',
            //'show'		=> 'type=2',
        ),

        'price'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '代理价格-以元为单位',
            'default'   => '0',
            'desc'      => '代理价格',
            'match'     => 'option',
            'update'    => 'text',
            //'list'      => true,
            'show'      => 'type=1',
        ),

        'soft'      => array
        (
            'type'      => 'varchar-50',
            'name'      => '软件服务费-如果填写软件服务费,则代理商订单可以进行拆分,如带有%号,就表示是百分比,如10%',
            'default'   => '0',
            'desc'      => '软件服务费',
            'match'     => 'option',
            'update'    => 'text',
        ),

        'option_price'      => array
        (
            'type'      => 'varchar-50',
            'name'      => '赠送期权价值-如果填写赠送期权价值,如带有%号,就表示是百分比,如10%',
            'default'   => '0',
            'desc'      => '软件服务费',
            'match'     => 'option',
            'update'    => 'text',
        ),

        'profit'      => array
        (
            'type'      => 'int-11',
            'name'      => '收益-区域内门店利润百分比,这里直接输入数字即可,如输入10,就是10%',
            'default'   => '0',
            'desc'      => '收益',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'show'		=> 'type=2',
        ),

        'isbuy'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '是否可购买-是否允许购买',
            'default'   => '1',
            'desc'      => '是否可购买',
            'match'     => 'is_numeric',
            'update'      => 'radio',
            'option'    => $yes,
            'list'      => true,
        ),

        'levelup'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '是否可升级-该角色是否可以升级到新角色',
            'default'   => '1',
            'desc'      => '是否可升级',
            'match'     => 'is_numeric',
            'update'  	=> 'radio',
            'option'    => $yes,
            'list'      => true,
            'control'   => 'levelup',
        ),

        'levelup_yue'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '升级补余额-升级到新角色,是否补足余额,如果选否,就直接用新角色全额购买',
            'default'   => '1',
            'desc'      => '升级补余额',
            'match'     => 'is_numeric',
            'update'    => 'radio',
            'option'    => $yes,
            'show'      => 'levelup=1',
        ),

        'max_me_num'      => array
        (
            'type'      => 'int-11',
            'name'      => '赠送名额最大值',
            'default'   => '100',
            'desc'      => '赠送名额最大值',
            'match'     => 'is_numeric',
            'update'    => 'text',
            //'list'      => true,
        ),

        'reorder'       => array
        (
            'type'      => 'int-11',
            'name'      => '排序-数值越大越靠前',
            'default'   => '1',
            'desc'      => '请输入排序',
            'match'     => 'option',
            'update'  => 'text',
            'search'    => 'order',
            '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,
            'list'      => 'date("Y-m-d H:i:s", {cdate})',
        ),
    ),

    'alter' => array
    (
        5 => array
        (
            array('update', 'price', 'price', 'decimal-11,2 0 代理价格'),
        ),
        'version' => 5,
    ),

    'default' => array
	(
		'col' => 'id,name,short_name,`desc`,type,area,isbuy,levelup,levelup_yue,profit,price,state,cdate',
		'value' => array
		(
			'1,"普通用户", "用户", "注册但未注册成功代理商角色的用户", 1, 1, 2, 2, 2, "0", "0", 1,' . DEVER_TIME,
            '2,"城市代理商", "城市", "一个城市代理商,有一二三线城市的区分。获得区域内门店利润1%收益。", 2, 1, 1, 2, 1, "1", "0", 1,' . DEVER_TIME,
            '3,"区县代理商", "区县", "一线城市的区,与二三线城市的县级代理商。获得区域内门店利润3%收益。", 2, 2, 1, 1, 1, "3", "0", 1,' . DEVER_TIME,
			'4,"街道代理商", "街道", "一个街道区域的代理商。获得区域内门店利润5%收益。", 2, 3, 1, 1, 1, "5", "0", 1,' . DEVER_TIME,
			
			'5,"创服代理商", "创服", "在开创本系统时的一个代理商角色,以后此角色不新增,要保留,因为其中还有一些权益未兑换。", 3, 1, 2, 1, 1, "0", "0", 1,' . DEVER_TIME,
			'6,"创客会员", "创客", "有分销能力的会员,但不产生代理商收益。", 1, 1, 1, 2, 2, "0", "5000", 1,' . DEVER_TIME,
			'7,"消客会员", "消客", "能带动产品销售量的会员。", 1, 1, 1, 2, 2, "0", "2000", 1,' . DEVER_TIME,
		),
	),

    'manage' => array
    (
    	//'insert' => false,
        'delete' => false,
        'edit' => false,
        'list_button' => array
        (
        	'fast' => array('编辑', '"role&where_id={id}&oper_save_jump=role&oper_table=role&oper_parent=role&area={area}"'),

        	'list1' => array('直推奖励', '"role_reward&search_option_role_id={id}&oper_table=role"'),

        	//'list2' => array('商品权益', '"role_goods&search_option_role_id={id}&oper_table=role"'),

            'location1' => array('赠送权益', Dever::url('lib/set.home', 'agent')),

            'list2' => array('自动升级', '"role_up&search_option_role_id={id}&oper_table=role"'),

            //'list3' => array('名额权益', '"role_quota&search_option_role_id={id}&oper_table=role"'),
        )
    ),

    'request' => array
    (
        'getInfo' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'type' => array('yes', 'in'),
                'levelup' => 'yes',
                'isbuy' => 'yes',
                'area' => array('yes', 'in'),
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('reorder' => 'desc', 'id' => 'desc'),
            'col' => 'id,short_name as name,area,type,price',
        ),
        'getAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'id' => array('yes','>'),
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('reorder' => 'desc', 'id' => 'asc'),
            'col' => '*',
        ),
    ),
);