<?php
$role = array
(
    1 => '代理商角色',
);

$cate = function() 
{
    $where['project_id'] = 1;
    return Dever::db('category/info')->getTop($where);
};

return array
(
    # 表名
    'name' => 'discount',
    # 显示给用户看的名称
    'lang' => '角色折扣管理',
    'order' => 90,

    # 数据结构
    'struct' => array
    (
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'list'      => true,
        ),

        'role'        => array
        (
            'type'      => 'int-11',
            'name'      => '折扣角色',
            'default'   => '1',
            'desc'      => '折扣角色',
            'match'     => 'is_numeric',
            'update'    => 'select',
            'option'    => $role,
            'search'    => 'radio',
            'list'      => true,
        ),
        
        'name'      => array
        (
            'type'      => 'varchar-80',
            'name'      => '折扣标题',
            'default'   => '',
            'desc'      => '标题',
            'match'     => 'is_string',
            'update'    => 'text',
            'list'      => true,
            'search'    => 'fulltext',
        ),

        'num'        => array
        (
            'type'      => 'int-11',
            'name'      => '折扣数值-直接填写折扣的数值,如填写9,就是9折,如一个角色填写了多个折扣,支付时自动使用最低折扣结算',
            'default'   => '9',
            'desc'      => '折扣数值',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
        ),

        'category'      => array
        (
            'type'      => 'varchar-500',
            'name'      => '可用商品分类-不选择则所有商品可用',
            'default'   => '',
            'desc'      => '可用商品分类',
            'match'     => 'option',
            //'search'    => 'linkage',
            'update'    => 'checkbox',
            'option'    => $cate,
            //'option'    => Dever::url('api.get', 'category'),
            //'list'        => 'Dever::load("category/api.string", "{category}")',
        ),

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

    # 默认值
    'default' => array
    (
        'col' => 'name,role,num,state,cdate',
        'value' => array
        (
            '"代理优惠",1,9,1,' . time(),
        ),
    ),
    
    # 管理功能
    'manage' => array
    (
        //'insert' => false,
        //'edit' => false,
        //'delete' => false,
        # 列表
        'list_button' => array
        (
            //'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=1'))),
            'location' => array('商品设置', Dever::url('lib/goods_set.home', 'act')),
        ),
    ),

    # request 请求接口定义
    'request' => array
    (
        
    ),
);