<?php

if (Dever::load('manage/auth')->checkFunc('bill.member_stat', 'edit1', '导出数据')) {
    $excel = true;
}else{
    $excel = false;
}
$config = array
(
    # 表名
    'name' => 'member_stat',
    # 显示给用户看的名称
    'lang' => '代理商统计',
    'order' => -10,

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

        'day'     => array
        (
            'type'      => 'int-11',
            'name'      => '日期',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
            'search'    => 'day',
            'search_button' => array
            (
                'sum' => 'num,city_num,county_num,town_num,ck_num,xk_num,cf_num,cv_num',
                'option' => array(
                    'day' => '按天',
                    'week' => '按周',
                    'month' => '按月',
                ),
                'group' => '',
            ),
            'order'     => 'desc',
            'list'      => 'Dever::showDay("{day}")',
        ),

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

        'city_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '城市代理商',
            'default'   => '0',
            'desc'      => '城市代理商',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
        ),

        'county_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '区县代理商',
            'default'   => '0',
            'desc'      => '区县代理商',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
        ),

        'town_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '街道代理商',
            '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,
        ),

        'xk_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '消客',
            'default'   => '0',
            'desc'      => '消客',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
        ),

        'cf_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '创服',
            'default'   => '0',
            'desc'      => '创服',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
        ),

        'cv_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '创V',
            'default'   => '0',
            'desc'      => '创V',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
        ),

        '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,
        'num' => false,
        'excel' => $excel,
    ),

    # request 请求接口定义
    'request' => array
    (
        'list' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start_day' => array('yes-day', '>='),
                'end_day' => array('yes-day', '<='),
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('time' => 'desc', 'cdate' => 'desc'),
            'page' => array(20, 'list'),
            'group' => 'day',//num,city_num,county_num,town_num,ck_num,xk_num
            'col' => '*,min(day) as time, sum(num) as num, sum(city_num) as city_num, sum(county_num) as county_num, sum(town_num) as town_num, sum(ck_num) as ck_num, sum(xk_num) as xk_num,sum(cf_num) as cf_num,sum(cv_num) as cv_num',
        ),

        'all' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start_day' => array('yes-day', '>='),
                'end_day' => array('yes-day', '<='),
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('time' => 'desc', 'cdate' => 'desc'),
            'group' => 'day',//num,city_num,county_num,town_num,ck_num,xk_num
            'col' => '*,min(day) as time, sum(num) as num, sum(city_num) as city_num, sum(county_num) as county_num, sum(town_num) as town_num, sum(ck_num) as ck_num, sum(xk_num) as xk_num',
        ),
    ),
);

return $config;