<?php

$super_vip_flag = array
(
	1 => '超级VIP',
	2 => '普通VIP',
);

$user_active = array
(
	1 => '可用',
	2 => '不可用',
);

$is_super = array
(
	1 => '是',
	2 => '否',
);
return array
(
	# 表名
	'name' => 'user',
	# 显示给用户看的名称
	'lang' => '用户扩展信息',
	# 后台菜单排序
	'order' => 1,
	'menu' => false,
	
	# 数据结构
	'struct' => array
	(
		'id' 		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> 'ID',
			'default' 	=> '',
			'desc' 		=> '',
			'match' 	=> 'is_numeric',
			'search'	=> 'order',
			'list'		=> true,
			'order'		=> 'desc',
		),
		
		'uid'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '用户名',
			'default' 	=> '0',
			'desc' 		=> '请选择用户',
			'match' 	=> 'is_numeric',
			//'update'	=> 'select',
			//'search'	=> 'select',
			'search'    => array
            (
                'api' => 'passport/user-all',
                'col' => 'username',
                'result' => 'id',
            ),
			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
		),

		'invite_uid'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '上级邀请人',
			'default' 	=> '0',
			'desc' 		=> '上级邀请人',
			'match' 	=> 'is_numeric',
			'list'		=> '{invite_uid} > 0 ? Dever::load("passport/user-one#username", {invite_uid}) : "匿名用户"',
		),

		# 旧版本导入的字段
		'user_active'		=> array
		(
			'type' 		=> 'tinyint-1',
			'name' 		=> '用户是否可用',
			'default' 	=> '1',
			'desc' 		=> '用户是否可用',
			'match' 	=> 'is_numeric',
			'option'	=> $user_active,
			//'list'		=> true,
		),

		'is_super'		=> array
		(
			'type' 		=> 'tinyint-1',
			'name' 		=> '超级VIP标识',
			'default' 	=> '2',
			'desc' 		=> '超级VIP标识',
			'match' 	=> 'is_numeric',
			//'option'	=> $is_super,
			//'list'		=> true,
		),

		'super_vip_flag'		=> array
		(
			'type' 		=> 'tinyint-1',
			'name' 		=> '超级VIP标识',
			'default' 	=> '2',
			'desc' 		=> '超级VIP标识',
			'match' 	=> 'is_numeric',
			'option'	=> $super_vip_flag,
			//'list'		=> true,
		),

		# 旧版本导入的字段 可以升级的次数？
		'can_upgrade_order_count'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '可以升级的次数',
			'default' 	=> '0',
			'desc' 		=> '升级次数',
			'match' 	=> 'is_numeric',
		),

		'has_operated_order_count'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '已经升级的次数',
			'default' 	=> '0',
			'desc' 		=> '升级次数',
			'match' 	=> 'is_numeric',
		),

		'remain_order_count'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '升级次数',
			'default' 	=> '0',
			'desc' 		=> '升级次数',
			'match' 	=> 'is_numeric',
		),

		# ？
		'user_bonuse_balance'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '升级次数',
			'default' 	=> '0',
			'desc' 		=> '升级次数',
			'match' 	=> 'is_numeric',
		),

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

	'request' => array
	(
		'getSupper' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
            	'super_vip_flag' => 1,
            	'is_super' => 2,
            	'user_active' => 1,
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('id' => 'desc'),
            'col' => '*',
        ),

        'getSupperVip' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
            	'remain_order_count' => array(0, '>'),
            	'super_vip_flag' => array('yes-t_1.super_vip_flag', 2),
            	'is_super' => array('yes-t_1.is_super', 2),
            	'user_active' => array('yes-t_1.user_active', 1),
            	'total_type' => array('yes-t_2.total_type', 1),
            	'level' => array('yes-t_2.level', '>'),
                'state' => array('yes-t_1.state', 1),
            ),
            # 联表
			'join' => array
			(
				array
				(
					'table' => 'score/level',
					'type' => 'left join',
					'on' => array('level_id','id'),
					'col' => 'level_id',
				),
			),
            'type' => 'all',
            'order' => array('id' => 'desc'),
            'col' => '*',
        ),
	),
);
