<?php

$type = Dever::db('option/cash')->config['config_type'];

$status = array
(
    1 => '已生效',
    2 => '未生效',
);

$audit = array
(
    1 => '正常',
    2 => '作废',
);

$audit_manage = array
(
    //1 => '正常',
    2 => '作废',
);

$aid = Dever::input('search_option_aid');
$mid = Dever::input('search_option_mid');
$oper_table = Dever::input('oper_table');
$button = array();
if (!$oper_table && $aid) {
    $option_aid = $aid;
    $search_auth = Dever::input('search_auth');
    if ($search_auth) {
        $option_aid .= '&search_auth=' . $search_auth;
    }
    $button = array
    (
        // '返回上一页' => array('location', 'l=project/database/list&project=option&table=cash&page_type=1&aid=' . $option_aid),
    );
}


return array
(
    # 表名
    'name' => 'bill_duifu',
    # 显示给用户看的名称
    'lang' => '期权兑付记录',
    'order' => 88,
    'end' => array
    (
        'update' => 'option/lib/manage.setDuifu',
    ),
    'config_audit' => $audit,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            //'list'        => true,
        ),

        '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',
            'option'    => $type,
            'update'    => 'radio',
            'list'      => true,
            'list_order'  => 7,
        ),

        'aid'      => array
        (
            'type'      => 'int-11',
            'name'      => '主账号手机号',
            'default'   => '-1',
            'desc'      => '期权登录账户',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => $aid ? 'hidden' : array
            (
                'api' => 'option/member-getMain',
                'col' => 'mobile',
                'result' => 'aid',
                'search' => 'aid',//本表的字段,默认为当前的字段
            ),
            'list_name' => '主账户',
            'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
            'list_order' => 3,
        ),

        'mid'      => array
        (
            'type'      => 'int-11',
            'name'      => '子账号手机号',
            'default'   => '-1',
            'desc'      => '期权账户',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => $mid ? 'hidden' : array
            (
                'api' => 'option/member-getChild',
                'col' => 'mobile',
                'result' => 'id',
                'search' => 'mid',//本表的字段,默认为当前的字段
            ),
            'list_name' => '子账户',
            'list'      => 'Dever::load("option/lib/member.getInfo", {mid})',
            'list_order' => 3,
        ),

        'cash'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '兑付价值',
            'default'   => '0',
            'desc'      => '兑付价值',
            'match'     => 'is_numeric',
            //'update'    => 'text',
            'list'      => '"-{cash}"',
            'list_order' => 5,
        ),

        'yue'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '兑付后价值',
            'default'   => '0',
            'desc'      => '兑付后价值',
            'match'     => 'is_numeric',
            //'update'    => 'text',
            //'list'      => true,
            //'list_order' => 6,
        ),

        'status'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '是否生效',
            'default'   => '2',
            'desc'      => '是否生效',
            'match'     => 'is_numeric',
            'option'    => $status,
            'update'    => 'radio',
            'search'    => 'hidden',
            //'list'      => true,
            //'list_order' => 4,
        ),

        'audit'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '审核',
            'default'   => '1',
            'desc'      => '审核',
            'match'     => 'is_numeric',
            'option'    => $audit_manage,
            'update'    => 'radio',
            'control'   => 'audit',
        ),

        'audit_desc'        => array
        (
            'type'      => 'varchar-500',
            'name'      => '备注',
            'default'   => '',
            'desc'      => '备注',
            'match'     => 'option',
            'update'    => 'textarea',
            'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
            'list_order'  => 9,
        ),

        'audit_date'     => array
        (
            'type'      => 'int-11',
            'name'      => '审核时间',
            'match'     => 'is_numeric',
            'desc'      => '审核时间',
            'default'   => '',
        ),

        'audit_admin'     => array
        (
            'type'      => 'int-11',
            'name'      => '操作人',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '操作人',
            'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#username", {audit_admin}) : "-"',
            'list_order'  => 8,
        ),

        'desc'        => array
        (
            'type'      => 'varchar-500',
            'name'      => '备注说明',
            'default'   => '',
            'desc'      => '备注说明',
            'match'     => 'option',
            'update'    => 'textarea',
            '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'      => '',
            'default'   => '',
            # 只有insert时才生效
            'insert'    => true,
            'list'      => 'date("Y-m-d H:i:s", {cdate})',
            'list_order' => 2,
        ),
    ),

    'alter' => array
    (
        5 => array
        (
            array('update', 'cash', 'cash', 'decimal-11,2 0 兑付价值'),
            array('update', 'yue', 'yue', 'decimal-11,2 0 兑付后价值'),
        ),
        'version' => 5,
    ),

    'manage' => array
    (
        'insert' => false,
        'delete' => false,
        'edit' => false,
        'button' => $button,
        'list_button' => array
        (
            //'list' => array('查看详情', '"member_area&mid={id}&page_type=1"'),

            'edit' => array('作废', 'audit,audit_desc', '{audit} == 1'),
            //'delete' => array('删除', '', '{status} == 1'),
        ),
    ),

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