<?php
$status = array
(
    1 => '待支付',
    2 => '待发货',
    3 => '待收货',
    4 => '已完成',
    5 => '已取消',
);

return array
(
    # 表名
    'name' => 'order',
    # 显示给用户看的名称
    'lang' => '礼品卡订单',
    'status' => $status,
    
    # 后台菜单排序
    'order' => 100,
    # 数据结构
    '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'    => 'text',
            //'search'  => 'select',
            'search'    => array
            (
                'api' => 'passport/user-one',
                'col' => 'username',
                'result' => 'id',
            ),
            'list'      => 'Dever::load("card/lib/manage.user", {id})',
        ),

        'mobile'        => array
        (
            'type'      => 'varchar-300',
            'name'      => '下单手机号',
            'default'   => '',
            'desc'      => '手机号',
            'match'     => 'option',
            'search'    => 'fulltext',
        ),

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

        'address_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '送货地址',
            'default'   => '',
            'desc'      => '送货地址',
            'match'     => 'is_numeric',
            //'list'      => 'Dever::load("passport/address-find#address", {address_id})';
        ),

        'order_num'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '订单号',
            'default'   => '',
            'desc'      => '订单号',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'      => true,
        ),

        'oprice'      => array
        (
            'type'      => 'varchar-50',
            'name'      => '原价',
            'default'   => '0',
            'desc'      => '原价',
            'match'     => 'option',
            'update'    => 'text',
            //'list'        => true,
        ),

        'price'      => array
        (
            'type'      => 'varchar-50',
            'name'      => '支付金额',
            'default'   => '0',
            'desc'      => '支付金额',
            'match'     => 'option',
            'update'    => 'text',
            'list'        => true,
        ),

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

        'status'      => array
        (
            'type'      => 'int-11',
            'name'      => '状态',
            'default'   => '1',
            'desc'      => '状态',
            'match'     => 'is_numeric',
            'option'    => $status,
            'search'    => 'select',
            'update'    => 'select',
            'list'      => true,
            'mul'       => array(4 => '批量完成'),
        ),

        'fdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '完成时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
        ),

        'operdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '操作时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
        ),

        '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' => '{status} == 3',

        'list_button' => array
        (
            'list' => array('查看详情', '"order_card&project=card&order_id={id}&page_type=1"'),

            'new' => array('手动查单', 'https://www.kuaidi100.com/?from=openv'),

            'fast1' => array('发货', '"order_ps&where_id={id}&search_option_order_id={id}&oper_save_jump=order&oper_table=order&oper_parent=order"', '{status} == 2'),

            'oper1'  => array('确认收货', '"card/lib/manage.send?order_id={id}"', '{status} == 3'),

            

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

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

    'request' => array
    (
        'getAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'uid' => 'yes',
                'name' => array('yes', 'like'),
                'order_num' => array('yes', 'like'),
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'status' => array('yes', 'in'),
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('cdate' => 'desc'),
            'page' => array(20, 'list'),
            'col' => '*',
        ),

        'getData' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'uid' => 'yes',
                'name' => array('yes', 'like'),
                'order_num' => array('yes', 'like'),
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'status' => array('yes', 'in'),
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('cdate' => 'desc'),
            'col' => '*',
        ),
    ),
);
