<?php
return array
(
    # 表名
    'name' => 'sell_stat',
    # 显示给用户看的名称
    'lang' => '业绩统计',
    'order' => 79,
    'menu' => 'agent',
    # 数据结构
    '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'      => '',
            'search'    => 'month',
            'list'      => 'date("Y-m", {month})',
        ),

        'mid'      => array
        (
            'type'      => 'int-11',
            'name'      => '手机号',
            'default'   => '-1',
            'desc'      => '代理商',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => array
            (
                'api' => 'agent/member-find',
                'col' => 'mobile',
                'result' => 'id',
                'search' => 'mid',
            ),
            // 'list_name' => '手机号',
            // 'list'      => 'Dever::load("agent/member-find#mobile", {mid})',
            // 'list_order' => 4,
        ),

        'agent-member-name'=> array
        (
            'name'      => '姓名',
            'default'   => '',
            'desc'      => '姓名',
            'match'     => 'option',
            # 读取另外表的关联方式
            'sync'      => array('mid', 'id'),
            'list'      => true,
            // 'search'    => 'fulltext',
            'search'    => array
            (
                'api' => 'agent/member-find',
                'col' => 'name',
                'result' => 'id',
                'search' => 'mid',
            ),
            'list_name' => '代理商',
            'list'      => 'Dever::load("agent/lib/member.daili", {mid})',
            'list_order' => 3,
        ),
        'agent-member-mobile'=> array
        (
            'name'      => '上级代理商信息',
            'default'   => '',
            'desc'      => '姓名',
            'match'     => 'option',
            # 读取另外表的关联方式
            'sync'      => array('mid', 'id'),
            // 'list'      => true,
            // 'search'    => 'fulltext',
            'search'    => array
            (
                'api' => 'agent/member-find',
                'col' => 'name',
                'result' => 'id',
                'search' => 'mid',
            ),
            'list_name' => '上级代理商',
            'list'      => 'Dever::load("agent/lib/member.sdaili", {mid})',
            'list_order' => 4,
        ),
        'agent-member-role'=> array
        (
            'name'      => '代理角色',
            'default'   => '',
            'desc'      => '代理角色',
            'match'     => 'option',
            # 读取另外表的关联方式
            'sync'      => array('mid', 'id'),
            // 'list'      => 'Dever::load("setting/role-find#name", "{agent-member-role}")',
            // 'list_order' => 5,
        ),

        'num'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '团队业绩',
            'default'   => '0',
            'desc'      => '团队业绩',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
        ),

        'new_num'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '本⽉新增团队业绩',
            'default'   => '0',
            'desc'      => '本⽉新增团队业绩',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
            //'list'      => 'Dever::load("bill/lib/manage.getSellNewNum", "{num}", "{month}", "{mid}")',
        ),
        'zt_num'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '直推业绩',
            'default'   => '0',
            'desc'      => '直推业绩',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
        ),

        'new_ztnum'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '本⽉新增直推业绩',
            'default'   => '0',
            'desc'      => '本⽉新增直推业绩',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
            //'list'      => 'Dever::load("bill/lib/manage.getSellNewNum", "{num}", "{month}", "{mid}")',
        ),
        '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,
    ),

    '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,
        ),
    ),
);
