<?php
$config = array
(
    # 表名
    'name' => 'goods_log',
    # 显示给用户看的名称
    'lang' => '商品库存日志',
    'order' => 200,
    'menu' => false,

    # 数据结构 不同的字段放这里
    'struct' => array
    (
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            //'list'        => true,
        ),

        'sid'      => array
        (
            'type'      => 'int-11',
            'name'      => 'sid',
            'default'   => '',
            'desc'      => 'sid',
            'search'    => 'hidden',
            'match'     => 'is_numeric',
        ),

        'store_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '仓库名称',
            'default'   => '',
            'desc'      => '仓库名称',
            'match'     => 'is_numeric',
            'list'      => 'Dever::load("store/info-find#name", {store_id})',
            'search'    => array
            (
                'api' => 'store/info-like',
                'col' => 'name',
                'result' => 'id',
            ),
            'search'    => 'hidden',
            'list_order' => 1,
        ),

        'goods-info-code'=> array
        (
            'name'      => '商品编码',
            'default'   => '',
            'desc'      => '商品编码',
            'match'     => 'option',
            # 读取另外表的关联方式
            'sync'      => array('sku_id', 'id', 'goods_id', 'info_id', 'key'),
            'list'      => true,
            'list_order' => 2,
        ),

        'goods_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '商品名称',
            'default'   => '',
            'desc'      => '商品名称',
            'match'     => 'is_numeric',
            'search'    => array
            (
                'api' => 'goods/info-like',
                'col' => 'name',
                'result' => 'id',
            ),
            'list'      => 'Dever::load("goods/info-find#name", {goods_id})',
            'list_order' => 3,
        ),

        'sku_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '规格型号',
            'default'   => '-1',
            'desc'      => '规格型号',
            'match'     => 'is_numeric',
            'search'    => 'hidden',
            'list'      => 'Dever::load("shop/lib/manage.getSku", {goods_id}, {sku_id})',
            'list_order' => 4,
        ),

        'cur_num'        => array
        (
            'type'      => 'float-11,2',
            'name'      => '当前库存',
            'default'   => '0',
            'desc'      => '新增库存',
            'match'     => 'is_numeric',
            'list_name' => '当前库存',
            'list'      => true,
            'list_order' => 5,
        ),

        'sell_num'      => array
        (
            'type'      => 'float-11,2',
            'name'      => '占用库存',
            'default'   => '0',
            'desc'      => '占用库存',
            'match'     => 'option',
            'list'      => true,
            'list_order' => 6,
        ),

        'online_num'  => array
        (
            'type'      => 'float-11,2',
            'name'      => '在途库存',
            'default'   => '0',
            'desc'      => '在途库存',
            'match'     => 'option',
            //'search'    => 'order',
            'list'      => true,
            'list_order' => 7,
        ),

        'total_num'        => array
        (
            'type'      => 'float-11,2',
            'name'      => '总库存',
            'default'   => '0',
            'desc'      => '总库存',
            'match'     => 'is_numeric',
            'list'      => true,
            'list_order' => 8,
        ),

        'num'        => array
        (
            'type'      => 'float-11,2',
            'name'      => '调整数量',
            'default'   => '0',
            'desc'      => '调整数量',
            'match'     => 'is_numeric',
            'list'      => true,
            'list_order' => 9,
        ),

        'after_cur_num'        => array
        (
            'type'      => 'float-11,2',
            'name'      => '调整后库存',
            'default'   => '0',
            'desc'      => '调整后库存',
            'match'     => 'is_numeric',
            'list'      => true,
            'list_order' => 10,
        ),

        'after_total_num'        => array
        (
            'type'      => 'float-11,2',
            'name'      => '调整后总库存',
            'default'   => '0',
            'desc'      => '调整后总库存',
            'match'     => 'is_numeric',
            'list'      => true,
            'list_order' => 11,
        ),

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

    'alter' => array
    (
        2 => array
        (
            array('update', 'cur_num', 'cur_num', 'float-11,2 0 当前库存'),
            array('update', 'sell_num', 'sell_num', 'float-11,2 0 占用库存'),
            array('update', 'online_num', 'online_num', 'float-11,2 0 在途库存'),
            array('update', 'total_num', 'total_num', 'float-11,2 0 总库存'),
            array('update', 'num', 'num', 'float-11,2 0 调整后数量'),
            array('update', 'after_cur_num', 'after_cur_num', 'float-11,2 0 调整后库存'),
            array('update', 'after_total_num', 'after_total_num', 'float-11,2 0 调整后总库存'),
        ),
        'version' => 2,
    ),

    'manage' => array
    (
        'insert' => false,
        'edit' => false,
        'delete' => false,
        'num' => false,
        'excel' => true,
    ),

    # request 请求接口定义
    'request' => array
    (
        'getDataByDate' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'store_id' => 'yes',
                'status' => 'yes',
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'sku_id' => array('yes', 'in'),
                'goods_id' => array('yes', 'in'),
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('store_id' => 'desc', 'goods_id' => 'desc', 'id' => 'desc'),
            'col' => '*',
        ),
    ),
);

return $config;