<?php

if (Dever::load('manage/auth')->checkFunc('bill.order_stat', 'edit1', '导出数据')) {
    $excel = true;
}else{
    $excel = false;
}
$config = array
(
    # 表名
    'name' => 'order_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,yes_num,cash,daili_num,agent_cash,no_num,no_cash',
                '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,
        ),

        'yes_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '确认订单数',
            'default'   => '0',
            'desc'      => '确认订单数',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
        ),

        'cash'        => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '确认订单额度',
            'default'   => '0',
            'desc'      => '确认订单额度',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
            // 'round({cash}, 2)',
        ),

        'agent_cash'        => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '确认代理费',
            'default'   => '0',
            'desc'      => '确认代理费',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
            // 'round({cash}, 2)',
        ),

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

         'no_num'        => array
        (
            'type'      => 'int-11',
            'name'      => '未确认订单数',
            'default'   => '0',
            'desc'      => '未确认订单数',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
        ),

        'no_cash'        => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '未确认订单额度',
            'default'   => '0',
            'desc'      => '未确认订单额度',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
            // 'round({cash}, 2)',
        ),
        '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,
    ),

    # 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,yes_num,cash,daili_num
            'col' => '*,min(day) as time, sum(yes_num) as yes_num, sum(num) as num, sum(cash) as cash, sum(daili_num) as daili_num, sum(agent_cash) as agent_cash, sum(no_cash) as no_cash, sum(no_num) as no_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,yes_num,cash,daili_num
            'col' => '*,min(day) as time, sum(yes_num) as yes_num, sum(num) as num, sum(cash) as cash, sum(daili_num) as daili_num, sum(agent_cash) as agent_cash, sum(no_cash) as no_cash, sum(no_num) as no_num',
        ),
    ),
);

return $config;