<?php
$shop = function()
{
    $array = array();
    $data = Dever::db('shop/info-state');
    if($data)
    {
        $array += $data;
    }
    return $array;
};
return array
(
    # 表名
    'name' => 'area_entry',
    # 显示给用户看的名称
    'lang' => '区域分润录入',
    'order' => 79,
    'menu' => 'agent',
    'end' => array
    (
        'insert' => 'mail/lib/manage.updateArea_entry', 
    ),
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            //'list'        => true,
        ),

        'month'     => array
        (
            'type'      => 'int-11',
            'name'      => '月份',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
            'update'    => 'month',
            'search'    => 'day',
            'list'      => 'date("Y-m", {month})',
        ),

     //    'area'       => array
	    // (
	    //     'type'      => 'varchar-500',
	    //     'name'      => '区域',
	    //     'default'   => '',
	    //     'desc'      => '区域',
	    //     'match'     => 'option',
	    //     'update'    => 'linkage',
	    //     'list'      => 'Dever::load("area/api.string", "{area}")',
     //        'option'    => Dever::url('api.get?level_total=4', 'area'),
	    // ),

        'shop_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '店铺名称/店铺编号',
            'default'   => '',
            'desc'      => '店铺名称',
            'match'     => 'is_numeric',
            'option'    => $shop,
            'search'    => array
            (
                'api' => 'shop/info-like',
                'col' => '*',
                'result' => 'id',
            ) ,
            'list_name' => '门店信息',
            'list'      => 'Dever::load("mail/lib/manage.entry_member", {id})',
            'list_order' => 2,
        ),

        'sid'      => array
        (
            'type'      => 'varchar-30',
            'name'      => '店铺编号-一般为5位数字,不能重复',
            'default'   => '',
            'desc'      => '店铺编号',
            'match'     => 'is_string',
            'update'    => 'text',
            # 绑定js脚本,更新时使用,第一个参数是执行的方式,第二个参数执行的方法,第三个参数是传值。
            'bind'        => array('onblur', 'loading', array('url' => Dever::url("shop/lib/record.search"))),
        ),

        'num'      => array
        (
            'type'      => 'decimal-11',
            'name'      => '店铺数量',
            'default'   => '0',
            'desc'      => '店铺数量',
            'match'     => 'is_numeric',
            // 'update'    => 'text',
            // 'list'      => true,
        ),

        'cprice'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '毛利',
            'default'   => '0',
            'desc'      => '采购金额',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
            'list_order' => 4,
        ),

        'price'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '分润金额',
            'default'   => '0',
            'desc'      => '分润金额',
            'match'     => 'is_numeric',
            // 'update'    => 'text',
            // 'list'      => true,
            'list_order' => 5,
        ),

        'state'     => array
        (
            'type'      => 'tinyint-1',
            'name'      => '状态',
            'default'   => '1',
            'desc'      => '请选择状态',
            'match'     => 'is_numeric',
        ),
        
        'cdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '统计时间',
            'match'     => array('is_numeric', time()),
            'desc'      => '',
        ),
    ),

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

    'request' => array
    (
        'getNewAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-month','>='),
                'end' => array('yes-month','<='),
                // 'area' => array('yes','like'),
                'state' => 1,
            ),
            
            'type' => 'all',
            'col' => '*',
        ),
        'getAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-month','>='),
                'end' => array('yes-month','<='),
                // 'area' => array('yes','like'),
                'state' => 1,
            ),
            
            'type' => 'all',
            'col' => 'id,area',
        ),
        'getNum' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-month','>='),
                'end' => array('yes-month','<='),
                'area' => array('yes','like'),
                'state' => 1,
            ),
            
            'type' => 'one',
            'col' => 'sum(num) as num',
        ),
        'getPrice' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-month','>='),
                'end' => array('yes-month','<='),
                'area' => array('yes','like'),
                'state' => 1,
            ),
            
            'type' => 'one',
            'col' => 'sum(cprice) as cprice',
        ),
    ),
);