<?php
$button = array();
$excel = false;
if (Dever::load('manage/auth')->checkFunc('bill.shop_stat', 'editSout', '导出数据')) {
    $excel[] = array('数据导出','归店数据统计','bill/lib/manage.out_shop_stat');
}
$shop = function()
{
    $array = array();
    $data = Dever::db('shop/info-state');
    if($data)
    {
        $array += $data;
    }
    return $array;
};
$list_button = array();
$list_button['list1'] = array('归店明细', 'member_shop_log&project=agent&menu=agent&search_option_state=1&menu_id=306&search_option_new_shop_id={shop_id}&search_option_dever_auth=2');
$list_button['list2'] = array('直推明细', 'order&project=agent&menu=agent&search_option_state=1&menu_id=306&search_in_parent_mid={mids}');
$config = array
(
    # 表名
    'name' => 'shop_stat',
    # 显示给用户看的名称
    'lang' => '归店统计',
    'order' => -10,

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

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

        'mids'      => array
        (
            'type'      => 'text-255',
            'name'      => '代理商id',
            'default'   => '',
            'desc'      => '代理商id',
            'match'     => 'is_numeric',
            // 'option'    => $shop,
            // 'list'      => true,
            //'list_order' => 6,
        ),

        'shop_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '店铺名称/店铺编号',
            'default'   => '',
            'desc'      => '店铺名称',
            'match'     => 'is_numeric',
            'option'    => $shop,
            'search'    => array
            (
                'api' => 'shop/info-getSearch',
                'col' => 'col',
                'result' => 'id',
            ) ,
            'list_name' => '门店名称<br/>门店编号<br/>所属代理商',
            'list'      => 'Dever::load("bill/lib/manage.shop_stat", {id})',
            'list_order' => 2,
        ),

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

        'num'        => array
        (
            'type'      => 'int-11',
            'name'      => '代理商总数量',
            'default'   => '0',
            'desc'      => '代理商总数量',
            'match'     => 'is_numeric',
            'search'    => 'order',
            // 'list'      => true,
        ),

        'dl_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '代理商<br/>数量-除掉创v的数量',
            'default'   => '0',
            'desc'      => '代理商数量',
            'match'     => 'is_numeric',
            // 'search'    => 'order',
            'list'      => true,
        ),

        'ck_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '创客数',
            'default'   => '0',
            'desc'      => '创客数',
            'match'     => 'is_numeric',
            // 'search'    => 'order',
            'list'      => true,
            'list_order' => 5,
        ),

        'v_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '创V数',
            'default'   => '0',
            'desc'      => '创V总数量',
            'match'     => 'is_numeric',
            // 'search'    => 'order',
            'list'      => true,
            'list_order' => 6,
        ),

        'out_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '名额外创V',
            'default'   => '0',
            'desc'      => '创V名额外数量',
            'match'     => 'is_numeric',
            // 'search'    => 'order',
            'list'      => true,
            'list_order' => 7,
        ),

        'money'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '代理商的总业绩',
            'default'   => '0',
            'desc'      => '代理商的总业绩',
            'match'     => 'is_numeric',
            'update'    => 'text',
            // 'list'      => true,
        ),

        'dl_money'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '归店业绩<br/>(除创V)',
            'default'   => '0',
            'desc'      => '代理商业绩',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
            'list_order' => 4,
        ),

        'v_money'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '创V总业绩',
            'default'   => '0',
            'desc'      => '创V总业绩',
            'match'     => 'is_numeric',
            'update'    => 'text',
            // 'list'      => true,
        ),

        'out_money'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '名额外创V<br/>业绩',
            'default'   => '0',
            'desc'      => '创V名额外业绩',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
            'list_order' => 8,
        ),

        '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,
        'excel' => $excel,
        'button' => $button,
        'list_button' => $list_button,
            // (

            //     'new' => array('查看明细', '"lib/manage.guidian?id={id}"', 'bill'),
            // ),
        
    ),

    # request 请求接口定义
    'request' => array
    (
        'getState' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-month', '>='),
                'end' => array('yes-month', '<='),
                'shop_id' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'col' => '*',
        ),
    ),
);

return $config;