<?php
$status = array
(
    4 => array('name' => '提现完成', 'style' => 'font-weight:bold;color:green'),
    5 => array('name' => '提现失败', 'style' => 'font-weight:bold;color:#CD3700'),
);

$merchant_id = Dever::input('search_option_merchant_id');
$button = array();
$info = '';
$tixian = Dever::input('tixian', 1);
if ($merchant_id) {
    # 申请提现和查看提现日志
    $account = Dever::db('pay/yspay_merchant')->find($merchant_id);
    if ($account) {
        $info = $account['name'] . '，当前余额：' . round($account['yue']/100, 2) . '元，总提现金额：' . round($account['tx_cash']/100, 2) . '元';
    }
    
    if ($tixian == 1) {
        $button['手动申请提现'] = array('fast', 1,'yspay_tixian_apply&search_option_merchant_id=' . $merchant_id);
        $button['提现申请记录'] = array('location', 'l=project/database/list&project=pay&table=yspay_tixian_log&search_option_state=1&search_option_merchant_id='.$merchant_id.'&oper_table=yspay_tixian&top_table=yspay_merchant');
    }
}

return array
(
    # 表名
    'name' => 'yspay_tixian',
    # 显示给用户看的名称
    'lang' => '银联提现列表',
    'order' => -200,
    'info' => $info,
    'menu' => false,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'update'    => 'hidden',
            //'list'        => true,
        ),

        'account_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '账户id',
            'default'   => '',
            'desc'      => '账户id',
            'match'     => 'option',
            'search'    => 'hidden',
            'update'    => 'hidden',
            'value'     => Dever::input('search_option_account_id'),
        ),

        'merchant_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '商户id',
            'default'   => '',
            'desc'      => '商户id',
            'match'     => 'option',
            'search'    => 'hidden',
            'update'    => 'hidden',
            'value'     => Dever::input('search_option_merchant_id'),
            'list_name' => '商户名称',
            'list'      => 'Dever::load("pay/yspay_merchant-one#name", "{merchant_id}")',
        ),

        'mid'      => array
        (
            'type'      => 'varchar-50',
            'name'      => '分账商户号',
            'default'   => '',
            'desc'      => '分账商户号',
            'match'     => 'option',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'		=> true,
        ),

        'order_num'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '订单号',
            'default'   => '',
            'desc'      => '订单号',
            'match'     => 'is_string',
            'update'    => 'text',
            'list'		=> true,
        ),

        'type'      => array
        (
            'type'      => 'varchar-10',
            'name'      => '类型',
            'default'   => '',
            'desc'      => '类型',
            'match'     => 'is_numeric',
            'update'    => 'text',
        ),

        'cash'      => array
        (
            'type'      => 'int-11',
            'name'      => '提现金额',
            'default'   => '0',
            'desc'      => '提现金额',
            'match'     => 'option',
            'update'    => 'text',
            'list'      => 'round({cash}/100, 2)',
        ),

        'cardNo'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '到账银行卡号',
            'default'   => '',
            'desc'      => '到账银行卡号',
            'match'     => 'is_string',
            'update'    => 'text',
            //'list'		=> true,
        ),

        'tdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '提现到账时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
            'search'    => 'date',
            'list'      => '"{tdate}" ? date("Y-m-d H:i", \'{tdate}\') : "-"',
            'order'		=> 'desc',
        ),

        'status'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '提现状态',
            'default'   => '1',
            'desc'      => '提现状态',
            'match'     => 'is_numeric',
            'option'    => $status,
            'search'    => 'select',
            'list'      => true,
        ),

        '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:s", {cdate})',
        ),
    ),

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

    'request' => array
    (
        'getTotal' => array
        (
            'option' => array
            (
                'merchant_id' => 'yes',
                'status' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(cash) as cash',
        ),
    ),
);
