<?php
$status = Dever::config('base')->status;

$type = array
(
    1 => '满减券',
    //2 => '通用券',
);

$method = array
(
    1 => '通用券',
    2 => '同城券',
    3 => '门店券',
);

return array
(
    # 表名
    'name' => 'coupon',
    # 显示给用户看的名称
    'lang' => '优惠券配置',
    'method' => $method,
    # 后台菜单排序
    'order' => 100,
    # 数据结构
    'struct' => array
    (
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
            'order'     => 'desc',
        ),
        
        'name'      => array
        (
            'type'      => 'varchar-80',
            'name'      => '优惠券名称',
            'default'   => '',
            'desc'      => '请输入优惠券名称',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'      => true,
        ),

        'type'        => array
        (
            'type'      => 'int-11',
            'name'      => '优惠券类型',
            'default'   => '1',
            'desc'      => '优惠券类型',
            'match'     => 'is_numeric',
            'update'    => 'radio',
            'option'    => $type,
            'search'    => 'select',
            'list'      => true,
            'control'   => 'type',
        ),

        'method'        => array
        (
            'type'      => 'int-11',
            'name'      => '优惠券属性',
            'default'   => '1',
            'desc'      => '优惠券属性',
            'match'     => 'is_numeric',
            'search'    => 'select',
            'update'    => 'radio',
            'option'    => $method,
            'list'      => true,
        ),

        'total_cash'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '满减金额-如满100减50,这里填写100',
            'default'   => '',
            'desc'      => '请输入满减金额',
            'match'     => 'is_string',
            'update'    => 'text',
            //'search'    => 'fulltext',
            //'list'      => true,
            'show'      => 'type=1',
        ),

        'cash'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '抵扣金额',
            'default'   => '',
            'desc'      => '请输入抵扣金额',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            //'list'      => true,
        ),

        'status'        => array
        (
            'type'      => 'int-11',
            'name'      => '状态',
            'default'   => '1',
            'desc'      => '状态',
            'match'     => 'is_numeric',
            //'update'  => 'select',
            'option'    => $status,
            'search'    => 'select',
            'list'      => true,
            'edit'      => true,
        ),

        'content'       => array
        (
            'type'      => 'text-800',
            'name'      => '使用规则',
            'default'   => '',
            'desc'      => '使用规则',
            'match'     => 'is_string',
            'update'    => 'editor',
            'key'       => '1',
        ),

        '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,
            'list'      => 'date("Y-m-d H:i:s", {cdate})',
        ),
    ),

    'manage' => array
    (
        
    ),

    'request' => array
    (
        'getAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'method' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('cash' => 'desc', 'id' => 'asc'),
            'col' => '*,id as value',
        ),
    ),
);