<?php

$status = array
(
	1 => '未确认',
    2 => '待入账',
	3 => '已入账',
	4 => '申请提现',
    5 => '已提现',
    6 => '提现失败',
);

return array
(
    # 表名
    'name' => 'yspay_cash',
    # 显示给用户看的名称
    'lang' => '银联资金记录表',
    'menu' => false,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'update'    => 'hidden',
            //'list'        => true,
        ),

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

        'order_num'      => array
        (
            'type'      => 'varchar-800',
            'name'      => '流水号',
            'default'   => '',
            'desc'      => '流水号',
            'match'     => 'is_string',
            'update'    => 'text',
            'list'		=> true,
        ),

        'source_order_num'      => array
        (
            'type'      => 'varchar-800',
            'name'      => '关联订单号',
            'default'   => '',
            'desc'      => '关联订单号',
            'match'     => 'is_string',
            'update'    => 'text',
            'list'		=> true,
        ),

        'ycash'      => array
        (
            'type'      => 'int-11',
            'name'      => '交易金额',
            'default'   => '0',
            'desc'      => '交易金额',
            'match'     => 'option',
            'list'      => 'Dever::number({ycash}/100, 2)',
        ),

        'cash'      => array
        (
            'type'      => 'int-11',
            'name'      => '实际金额',
            'default'   => '0',
            'desc'      => '实际金额',
            'match'     => 'option',
            'list'      => 'Dever::number({cash}/100, 2)',
        ),

        'hf_cash'      => array
        (
            'type'      => 'int-11',
            'name'      => '商户划付金额',
            'default'   => '0',
            'desc'      => '划付金额',
            'match'     => 'option',
            //'update'    => 'text',
            'list'		=> 'Dever::number({hf_cash}/100, 2)',
        ),

        'fz_cash'      => array
        (
            'type'      => 'int-11',
            'name'      => '平台分账金额',
            'default'   => '0',
            'desc'      => '分账金额',
            'match'     => 'option',
            //'update'    => 'text',
            'list'		=> 'Dever::number({fz_cash}/100, 2)',
        ),

        'rdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '入账时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
            'search'    => 'date',
            'list'      => '"{rdate}" ? date("Y-m-d H:i", \'{rdate}\') : "-"',
            'list_order' => 100,
        ),

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

        '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' => array
        (
            '资金划付' => array('oper', 'pay/yspay/cash.huafu_commit'),
        ),
    ),

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