<?php

$type = Dever::db('setting/role_goods')->config['set']['type'];
$mid = Dever::input('search_option_mid');
$search_api_mid = Dever::input('search_api_mid');
$button = array();
if ($mid) {
    $button = array
    (
        '返回上一页' => array('location', 'l=project/database/list&project=agent&table=member_goods&search_option_mid=' . $mid . '&search_api_mid=' . $search_api_mid),
    );
}

return array
(
    # 表名
    'name' => 'member_goods_log',
    # 显示给用户看的名称
    'lang' => '代理商权益日志',
    'menu' => false,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'update'    => 'hidden',
            //'list'        => true,
        ),

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

        'parent_order_num'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '关联订单',
            'default'   => '',
            'desc'      => '关联订单',
            'match'     => 'is_string',
            'list'		=> true,
            'list_order' => 11,
        ),

        'agent-member-name'=> array
        (
            'name'      => '代理商',
            'default'   => '',
            'desc'      => '代理商',
            'match'     => 'option',
            # 读取另外表的关联方式
            'sync'      => array('mid', 'id'),
            'list'      => $mid ? false : true,
            'list_order' => 3,
        ),

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

        'order_num'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '日志单号',
            'default'   => '',
            'desc'      => '日志单号',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'      => true,
            'list_order'  => 1,
        ),

        'type'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '权益类型',
            'default'   => '1',
            'desc'      => '类型',
            'match'     => 'is_numeric',
            'update'  	=> 'radio',
            'option'    => $type,
            'search'    => 'select',
            'list'      => true,
            'list_order' => 6,
        ),

        'type_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '类型id',
            'default'   => '-1',
            'desc'      => '类型id',
            'match'     => 'is_numeric',
            'list_name' => '权益名称',
            'list'      => 'Dever::load("agent/lib/manage.getGoods#name", "{type}", "{type_id}", "{sku_id}")',
            'list_order' => 7,
        ),

        'sku_id'      => array
        (
            'type'      => 'int-11',
            'name'      => 'sku_id',
            'default'   => '-1',
            'desc'      => 'sku_id',
            'match'     => 'is_numeric',
        ),

        'num'        => array
        (
            'type'      => 'varchar-11',
            'name'      => '数量',
            'default'   => '0',
            'desc'      => '数量',
            'match'     => 'is_string',
            'list'      => true,
            'list_order' => 8,
        ),

        'pnum'      => array
        (
            'type'      => 'varchar-11',
            'name'      => '操作前数量',
            'default'   => '0',
            'desc'      => '操作前数量',
            'match'     => 'option',
            'list_name' => '操作前/后',
            'list'      => '"{pnum}/{fnum}"',
            'list_order' => 9,
        ),

        'fnum'      => array
        (
            'type'      => 'varchar-11',
            'name'      => '操作后数量',
            'default'   => '0',
            'desc'      => '操作后数量',
            'match'     => 'option',
        ),

        'desc'      => array
        (
            'type'      => 'varchar-600',
            'name'      => '备注',
            'default'   => '',
            'desc'      => '备注',
            'match'     => 'is_string',
            'update'    => 'text',
            'list'		=> true,
            'list_order' => 10,
        ),

        '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", {cdate})',
            'list_order' => 2,
        ),
    ),

    'manage' => array
    (
        'edit' => false,
        'insert' => false,
        'delete' => false,
        'button' => $button,
    ),

    'request' => array
    (
        'getData' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'mid' => 'yes',
                'type' => 'yes',
                'state' => 1,
            ),
            'order' => array('type' => 'asc', 'id' => 'desc'),
            'type' => 'all',
            'col' => '*, total_num-sell_num as num',
        ),
    ),
);
