<?php

$status = array
(
    1 => '正常',
    2 => '申请退款中',
    3 => '已取消',
);

return array
(
    # 表名
    'name' => 'order_card',
    # 显示给用户看的名称
    'lang' => '礼品卡子订单',
    'menu' => false,
    'status' => $status,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'update'    => 'hidden',
            //'list'        => true,
        ),

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

        'uid'       => array
        (
            'type'      => 'int-11',
            'name'      => '购买人名称',
            'default'   => '0',
            'desc'      => '请选择用户',
            'match'     => 'is_numeric',
            'update'    => 'text',
            //'search'  => 'select',
            'search'    => array
            (
                'api' => 'passport/user-one',
                'col' => 'username',
                'result' => 'id',
            ),
            'list'      => 'Dever::load("shop/lib/manage.user", {id})',
        ),

        'card_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '礼品卡名称',
            'default'   => '',
            'desc'      => '礼品卡名称',
            'match'     => 'is_numeric',
            'list'      => 'Dever::load("card/info-find#name", {card_id})',
        ),

        'city'      => array
        (
            'type'      => 'int-11',
            'name'      => '城市',
            'default'   => '',
            'desc'      => '城市',
            'match'     => 'option',
            //'update'  => 'text',
        ),

        'price'      => array
        (
            'type'      => 'varchar-50',
            'name'      => '单价',
            'default'   => '',
            'desc'      => '单价',
            'match'     => 'option',
            'update'    => 'text',
            'list'        => true,
        ),

        'num'        => array
        (
            'type'      => 'int-11',
            'name'      => '购买数量',
            'default'   => '',
            'desc'      => '购买数量',
            'match'     => 'is_numeric',
            'search'    => 'select',
            'list'        => true,
        ),

        'cards'      => array
        (
            'type'      => 'varchar-2000',
            'name'      => '卡号',
            'default'   => '',
            'desc'      => '卡号',
            'match'     => 'option',
            'list'      => true,
        ),

        '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,
            'search'    => 'date',
            'list'      => 'date("Y-m-d H:i:s", {cdate})',
        ),
    ),

    'manage' => array
    (
        'insert' => false,
        'delete' => false,
        'page_list' => 'order_card',
    ),

    'request' => array
    (
        # 获取单条数据
        'getIds' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'uid' => 'yes',
                'card_id' => 'yes',
                'order_id' => 'yes',
                'status' => 1,
                'state' => 1,
            ),
            'type' => 'all',
            'col' => '*|id',
        ),

        # 获取多条数据
        'getDataByIds' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'ids' => array('yes-id', 'in'),
                'uid' => 'yes',
                'card_id' => 'yes',
                'order_id' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'col' => '*',
        ),

        # 获取多条数据
        'getTotal' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'uid' => 'yes',
                'order_id' => 'yes',
                'status' => array('yes', 'in'),
                'state' => 1,
            ),
            'type' => 'count',
            'col' => '*',
        ),
    ),
);