<?php
$status = array
(
    1 => '已生成',
    2 => '未兑换',
    3 => '已使用',
    4 => '已完成',
    5 => '已过期',
);

return array
(
    # 表名
    'name' => 'card_code',
    # 显示给用户看的名称
    'lang' => '商品卡卡密',
    'status' => $status,
    # 后台菜单排序
    'order' => 99,
    'menu'  => false,
    # 数据结构
    'struct' => array
    (
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
            'order'     => 'desc',
        ),
        
        'card_id'        => array
        (
            'type'      => 'int-11',
            'name'      => '礼品卡',
            'default'   => '',
            'desc'      => '礼品卡',
            'match'     => 'is_numeric',
            'update'    => 'hidden',
            'value'     => Dever::input('search_option_card_id'),
            'list'      => 'Dever::load("goods/card-find#name", "{card_id}")',
        ),

        'card'      => array
        (
            'type'      => 'varchar-32',
            'name'      => '卡号',
            'default'   => '',
            'desc'      => '卡号',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'        => true,
        ),

        'pwd'      => array
        (
            'type'      => 'varchar-32',
            'name'      => '密码',
            'default'   => '',
            'desc'      => '密码',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'        => true,
        ),

        'status'      => array
        (
            'type'      => 'int-11',
            'name'      => '使用状态',
            'default'   => '1',
            'desc'      => '使用状态',
            'match'     => 'is_numeric',
            'option'    => $status,
            'search'    => 'select',
            'update'    => 'select',
            'list'      => true,
            //'mul'       => array(1 => '恢复使用', 4 => '已作废'),
        ),

        'uid'       => array
        (
            'type'      => 'int-11',
            'name'      => '用户信息',
            'default'   => '0',
            'desc'      => '用户信息',
            'match'     => 'is_numeric',
            'list_name' => '兑换信息',
            //'list'      => 'Dever::load("goods/lib/manage.showUserInfo", "{id}")',
        ),

        'shop_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '兑换门店',
            'default'   => '',
            'desc'      => '兑换门店',
            'match'     => 'is_numeric',
        ),

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

        'ddate'     => array
        (
            'type'      => 'int-11',
            'name'      => '兑换时间',
            'match'     => 'option',
            'default'   => '',
            'desc'      => '',
            //'search'  => 'date',
        ),

        'edate'     => array
        (
            'type'      => 'int-11',
            'name'      => '失效时间',
            'match'     => 'is_numeric',
            'default'   => '',
            'desc'      => '',
            'list'      => 'date("Y-m-d H:i:s", {edate})',
        ),

        '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
    (
        'excel' => true,
        'delete' => false,
        'edit' => false,
        'insert' => false,
       // 'mul' => '{type} == 1 || {type} == 4',

        'list_button' => array
        (
            //'oper' => array('作废', 'goods/lib/manage.drop?id={id}', '{type} == 1'),

            //'oper2' => array('恢复使用', 'goods/lib/manage.recovery?id={id}', '{type} == 4'),
        ),
    ),

    # 索引
    'index' => array
    (
        # 索引名 => 索引id
        1 => array
        (
            'card' => 'card,pwd'
        ),
        'version' => 1,
    ),

    'request' => array
    (
        
    ),
);