<?php

$config = array
(
    # 表名
    'name' => 'goods_sku',
    # 显示给用户看的名称
    'lang' => '商品价格设置',
    'order' => 200,
    'menu' => false,

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

        'price_id'       => array
        (
            'type'      => 'int-11',
            'name'      => '商品价格模板ID',
            'default'   => '',
            'desc'      => '商品价格模板ID',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
        ),

        'goods_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '商品名称',
            'default'   => '',
            'desc'      => '商品名称',
            'match'     => 'is_numeric',
            'search'    => array
            (
                'api' => 'goods/info-like',
                'col' => 'name',
                'result' => 'id',
            ),
        ),

        'sku_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '规格型号',
            'default'   => '-1',
            'desc'      => '规格型号',
            'match'     => 'is_numeric',
        ),

        'price_sell'     => array
        (
            'type'      => 'varchar-100',
            'name'      => '销售价',
            'default'   => '',
            'desc'      => '销售价',
            'match'     => 'option',
            'update'    => 'text',
        ),

        'price_buy'       => array
        (
            'type'      => 'varchar-100',
            'name'      => '门店采购价',
            'default'   => '',
            'desc'      => '采购价',
            'match'     => 'option',
            'update'    => 'text',
        ),

        'price_num'       => array
        (
            'type'      => 'int-11',
            'name'      => '起购数',
            'default'   => '1',
            'desc'      => '起购数',
            'match'     => 'is_string',
            'update'    => 'text',
        ),

        '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,
        'edit' => false,
        'delete' => false,
        'page_list_table' => 'sku',

        # 自定义快捷新增和编辑
        'button' => array
        (
            //'自定义属性' => array('fast', 1, 'config&where_id=1'),
        ),
    ),

    # request 请求接口定义
    'request' => array
    (
    	'getDataPage' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'price_id' => array('yes-t_1.price_id'),
                'name' => array('yes-t_2.name', 'like'),
                'column' => array('yes-t_2.column_id', 'like'),
                'category' => array('yes-t_2.category', 'like'),
                'top_category_id' => array('yes-t_2.top_category_id'),
                'second_category_id' => array('yes-t_2.second_category_id'),
                'category_id' => array('yes-t_2.category_id'),
                'status' => array('yes-t_2.status', 1),
                'state' => array('yes-t_2.state', 1),
                'state_1' => array('yes-t_1.state', 1),
            ),
            # 联表
            'join' => array
            (
                array
                (
                    'table' => 'goods/info',
                    'type' => 'left join',
                    'on' => array('goods_id','id'),
                    'col' => 'goods_id',
                ),
            ),
            'type' => 'all',
            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
            'page' => array(30, 'list'),
            'col' => '*,t_2.name,t_2.cover,t_2.id as id',
        ),

        'getAllData' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'price_id' => array('yes-t_1.price_id'),
                'name' => array('yes-t_2.name', 'like'),
                'column' => array('yes-t_2.column_id', 'like'),
                'category' => array('yes-t_2.category', 'like'),
                'top_category_id' => array('yes-t_2.top_category_id'),
                'second_category_id' => array('yes-t_2.second_category_id'),
                'category_id' => array('yes-t_2.category_id'),
                'status' => array('yes-t_2.status', 1),
                'state' => array('yes-t_2.state', 1),
                'state_1' => array('yes-t_1.state', 1),
            ),
            # 联表
            'join' => array
            (
                array
                (
                    'table' => 'goods/info',
                    'type' => 'left join',
                    'on' => array('goods_id','id'),
                    'col' => 'goods_id',
                ),
            ),
            'type' => 'all',
            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
            'col' => '*,t_2.name,t_2.cover,t_2.id as id',
        ),

       	# 列表
        'getData' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'price_id' => 'yes',
                'goods_id' => 'yes',
                'sku_id' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('id' => 'desc'),
            'col' => '*|sku_id',
        ),

        # 列表
        'getDataByPrice' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'price_id' => 'yes',
                'goods_id' => 'yes',
                'sku_id' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('id' => 'desc'),
            'col' => '*|price_id',
        ),

        # 获取单条数据
        'getOne' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'price_id' => 'yes',
                'goods_id' => 'yes',
                'sku_id' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'col' => '*',
        ),
    ),
);

return $config;