<?php
$status = Dever::config('base')->status;

$method = array
(
    1 => '自提',
    2 => '配送',
    3 => '自提+配送',
);

$type = array
(
    1 => '永久有效',
    2 => '固定天数',
);

$card_type = array
(
    1 => '全数字',
    2 => '全小写',
    3 => '全大写',
    4 => '大小写组合',
    5 => '数字+大小写组合',
);

return array
(
    # 表名
    'name' => 'card',
    # 显示给用户看的名称
    'lang' => '商品卡配置',
    # 后台菜单排序
    'order' => 99,
    'menu' => false,
    # 数据结构
    'struct' => array
    (
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
            'order'     => 'desc',
        ),
        
        'name'      => array
        (
            'type'      => 'varchar-80',
            'name'      => '礼品卡名称',
            'default'   => '',
            'desc'      => '请输入礼品卡名称',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'      => true,
        ),

        'type'        => array
        (
            'type'      => 'int-11',
            'name'      => '礼品卡类型-永久有效的时间为10年,即3650天',
            'default'   => '1',
            'desc'      => '礼品卡类型',
            'match'     => 'is_numeric',
            'update'    => 'radio',
            'option'    => $type,
            'control'   => 'type',
        ),

        'day'        => array
        (
            'type'      => 'int-11',
            'name'      => '有效天数',
            'default'   => '7',
            'desc'      => '有效天数',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'show'      => 'type=2',
        ),

        'card_type'        => array
        (
            'type'      => 'int-11',
            'name'      => '卡号生成规则',
            'default'   => '3',
            'desc'      => '卡号生成规则',
            'match'     => 'is_numeric',
            'update'    => 'select',
            'option'    => $card_type,
        ),

        'card_prefix'        => array
        (
            'type'      => 'varchar-80',
            'name'      => '卡号前缀-前缀不占用卡号长度的位数,如卡号长度填写14,卡号前缀为Q,则生成卡号前缀+14位随机数',
            'default'   => '',
            'desc'      => '卡号前缀',
            'match'     => 'option',
            'update'    => 'text',
        ),

        'card_len'        => array
        (
            'type'      => 'int-11',
            'name'      => '卡号长度',
            'default'   => '14',
            'desc'      => '卡号长度',
            'match'     => 'is_numeric',
            'update'    => 'text',
        ),

        'pwd_type'        => array
        (
            'type'      => 'int-11',
            'name'      => '密码生成规则',
            'default'   => '3',
            'desc'      => '密码生成规则',
            'match'     => 'is_numeric',
            'update'    => 'select',
            'option'    => $card_type,
        ),

        'pwd_prefix'        => array
        (
            'type'      => 'varchar-80',
            'name'      => '密码前缀',
            'default'   => '',
            'desc'      => '密码前缀',
            'match'     => 'option',
            'update'    => 'text',
        ),

        'pwd_len'        => array
        (
            'type'      => 'int-11',
            'name'      => '密码长度',
            'default'   => '8',
            'desc'      => '密码长度',
            'match'     => 'is_numeric',
            'update'    => 'text',
        ),

        'method'        => array
        (
            'type'      => 'int-11',
            'name'      => '领取方式',
            'default'   => '3',
            'desc'      => '领取方式',
            'match'     => 'is_numeric',
            //'update'    => 'radio',
            'option'    => $method,
            //'control'   => 'method',
        ),

        'goods'       => array
        (
            'type'      => 'text-1000',
            'name'      => '商品配置-如果该商品有多种价格,礼品卡只能兑换最低价格的商品',
            'default'   => '',
            'desc'      => '商品配置',
            'match'     => 'is_string',
            'update'    => array
            (
                array
                (
                    'col'       => 'goods_id',
                    'name'      => '选择商品',
                    'default'   => '',
                    'desc'      => '选择商品',
                    'match'     => 'option',
                    'update'    => 'select',
                    'update_search' => 'goods/lib/manage.search',
                ),

                array
                (
                    'col'       => 'num',
                    'name'      => '数量',
                    'default'   => '1',
                    'desc'      => '数量',
                    'match'     => 'is_string',
                    'update'    => 'text',
                ),
            ),
        ),

        'status'        => array
        (
            'type'      => 'int-11',
            'name'      => '状态',
            'default'   => '1',
            'desc'      => '状态',
            'match'     => 'is_numeric',
            //'update'  => 'select',
            'option'    => $status,
            'search'    => 'select',
            'list'      => true,
            '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})',
        ),
    ),

    'manage' => array
    (

        'list_button' => array
        (
            'fast' => array('生成卡密', '"add_card&where_id=1&search_option_card_id={id}"', '{status} == 1'),

            'list1' => array('卡密列表', '"card_code&search_option_card_id={id}&oper_table=card"'),
        ),
    ),

    'request' => array
    (
        
    ),
);