<?php
return array
(
    # 表名
    'name' => 'area_stat',
    # 显示给用户看的名称
    'lang' => '区域分润管理统计',
    'order' => 79,
    'menu' => 'agent',
    // 'end' => array
    // (
    //     'insert' => 'mail/lib/manage.updateArea_stat', 
    // ),
    # 数据结构
    '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',
            'search'    => 'linkage',
	        'list'      => 'Dever::load("area/api.string", "{area}")',
            'option'    => Dever::url('api.get?level_total=4', 'area'),
	    ),

        'mid'      => array
        (
            'type'      => 'int-11',
            'name'      => '收益代理商姓名/电话',
            'default'   => '-1',
            'desc'      => '代理商',
            'match'     => 'is_string',
            // 'update'    => 'text',
            'search'    => array
            (
                'api' => 'agent/member-getSearch',
                'col' => 'col',
                'result' => 'id',
                'search' => 'mid',
            ),
            'list_name' => '收益代理商',
            'list'      => 'Dever::load("mail/lib/manage.area_member", {id})',
            'list_order' => 15,
        ),

        'mobile'      => array
        (
            'type'      => 'bigint-11',
            'name'      => '代理商手机号',
            'default'   => '',
            'desc'      => '请输入手机号',
            'match'     => Dever::rule('mobile'),
            'update'    => 'text',
            # 绑定js脚本,更新时使用,第一个参数是执行的方式,第二个参数执行的方法,第三个参数是传值。
            'bind'        => array('onblur', 'loading', array('url' => Dever::url("lib/soft_cash.search", 'agent'))),
            //'search'    => 'fulltext',
            //'list'      => true,
        ),

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

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

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

        't_price'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '体验店采购金额',
            'default'   => '0',
            'desc'      => '体验店采购金额',
            'match'     => 'is_numeric',
            // 'update'    => 'text',
            'list'      => true,
        ),
        't_fprice'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '体验店分润金额',
            'default'   => '0',
            'desc'      => '体验店分润金额',
            'match'     => 'is_numeric',
            // 'update'    => 'text',
            // 'list'      => true,
        ),

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

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

        'l_price'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '零售店采购金额',
            'default'   => '0',
            'desc'      => '零售店采购金额',
            'match'     => 'is_numeric',
            // 'update'    => 'text',
            'list'      => true,
        ),

        'l_fprice'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '零售店分润金额',
            'default'   => '0',
            'desc'      => '零售店分润金额',
            'match'     => 'is_numeric',
            // 'update'    => 'text',
            // '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'      => '',
        ),
    ),

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

    'request' => array
    (
        'getData' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'mid' => 'yes',
                'state' => 1,
            ),
            'order' => array('id' => 'desc'),
            'page' => array(10, 'list'),
            'type' => 'all',
            'col' => '*',
        ),

        'prev' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'month' => array('yes-month', '<'),
                'mid' => 'yes',
                'state' => 1,
            ),
            'order' => array('time' => 'desc', 'id' => 'desc'),
            'type' => 'one',
            'col' => '*,min(month) as time, sum(num) as num',
            # 允许自定义以上配置
            'config' => true,
        ),
        'getMoney' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'mid' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(price) as  price',
        ),
        'getTy' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'mid' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'group' => 'mid',
            'col' => 'sum(t_fprice) as t_fprice,sum(l_fprice) as l_fprice',
        ),
        'getTiyan' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'mid' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('month'=>'desc'),
            'page' => array(20, 'list'),
            'col' => 't_fprice,l_fprice,month',
        ),
    ),
);