<?php

$status = array
(
    1 => array('name' => '待入账', 'style' => 'font-weight:bold;color:#436EEE'),
    2 => array('name' => '已入账', 'style' => 'font-weight:bold;color:green'),
    3 => array('name' => '已作废', 'style' => 'font-weight:bold;color:#CD3700'),
);

$manage_status = array
(
    //1 => '待审核',
    2 => '已审核',
    3 => '已作废',
);

$type = array
(
    1 => '充值',
    2 => '充值返还',
    3 => '邀请奖励',
    4 => '商品退款',
    11 => '提现',
    12 => '购买商品',
);
$excel = false;
$mul = false;
$list_button = array();
$list_button['list'] = array('查看详情', '"user_money_sign&project=shop&id={id}&page_type=1&[refer]"');

/*
if (Dever::load('manage/auth')->checkFunc('shop.user_money', 'edit', '审核')) {
    $list_button['fast'] = array('审核', '"cash&where_id={id}&col=audit,audit_desc&oper_save_jump=cash&oper_table=cash&oper_parent=cash"', '{status} == 1');
}
if (Dever::load('manage/auth')->checkFunc('shop.user_money', 'user_money', '批量审核')) {
    $mul = '{status} == 1';
}
*/
$button = array();

return array
(
    # 表名
    'name' => 'use_money',
    # 显示给用户看的名称
    'lang' => '用户资金流水',
    'set' => array
    (
        'status' => $status,
        'type' => $type,
    ),

    'end' => array
    (
        'update' => 'bill/lib/manage.cashAuditUpdate',
        'updatemul' => 'bill/lib/manage.cashAuditUpdate',
    ),
    'order' => 99,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            //'list'        => true,
        ),

        'uid'      => array
        (
            'type'      => 'int-11',
            'name'      => '用户信息',
            'default'   => '-1',
            'desc'      => '用户信息',
            'match'     => 'is_string',
            'update'    => 'text',
            'list'      =>'Dever::load("shop/lib/money.showUser", {uid})',
            'list_order' => 2,
        ),

        'order_num'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '流水号',
            'default'   => '',
            'desc'      => '流水号',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list_name' => '流水号<br />交易时间',
            'list'      =>'"{order_num}<br />".date(\'Y-m-d H:i\', {cdate})',
            'list_order' => 1,
        ),

        'type'      => array
        (
            'type'      => 'int-11',
            'name'      => '交易类型',
            'default'   => '1',
            'desc'      => '交易类型',
            'match'     => 'is_numeric',
            'search'    => 'select',
            'update'    => 'checkbox',
            'option'    => $type,
            'list'      => true,
            'list_order' => 2,
        ),

        'type_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '交易来源id',
            'default'   => '',
            'desc'      => '交易来源id',
            'match'     => 'is_string',
            'update'    => 'text',
        ),

        'cash'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '金额',
            'default'   => '0',
            'desc'      => '金额',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list_name' => '交易金额<br />账户余额',
            'list'      =>'Dever::load("shop/lib/money.getCash", {id})',
            'list_order' => 3,
        ),

        'yue'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '操作后余额',
            'default'   => '0',
            'desc'      => '操作后余额',
            'match'     => 'is_numeric',
            'update'    => 'text',
            // 'list'      => true,
            // 'list_order' => 7,
        ),

        'status'        => array
        (
            'type'      => 'int-11',
            'name'      => '交易状态',
            'default'   => '1',
            'desc'      => '交易状态',
            'match'     => 'is_numeric',
            'update'    => 'hidden',
            'option'    => $status,
            'search'    => 'select',
            'list'      => true,
            'list_name' => '交易状态',
            'list_order' => 4,
        ),

        'audit'        => array
        (
            'type'      => 'int-11',
            'name'      => '审核状态',
            'default'   => '2',
            'desc'      => '审核状态',
            'match'     => 'is_numeric',
            'update'    => 'radio',
            'option'    => $manage_status,
            'mul'       => true,
            'control'   => 'audit',
        ),

        'audit_desc'      => array
        (
            'type'      => 'varchar-600',
            'name'      => '备注',
            'default'   => '',
            'desc'      => '审核说明',
            'match'     => 'is_string',
            'update'    => 'textarea',
            'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
            'list_order'  => 5,
            'show'      => 'audit=3',
        ),

        'desc'      => array
        (
            'type'      => 'varchar-600',
            'name'      => '资金说明',
            'default'   => '',
            'desc'      => '资金说明',
            'match'     => 'is_string',
            'update'    => 'text',
        ),

        'operdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '审核确认时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
            //'list'      => '"{operdate}" > 0 ? date("Y-m-d H:i", {operdate}) : "-"',
            //'list_order'  => 9,
        ),

        '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_name'      => '交易时间<br />审核时间',
            //'list'      => 'Dever::load("bill/lib/cash.order_num#num", {id})',
            //'list_order'  => 20,
        ),
    ),

    'manage' => array
    (
        'insert' => false,
        'delete' => false,
        'edit' => false,
        //'excel' => $excel,
        'button' => $button,
        'mul' => $mul,
        'list_button' => $list_button,
    ),

    'request' => array
    (
        'getData' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'uid' => 'yes',
                'type' => 'yes',
                'state' => 1,
            ),
            'order' => array('id' => 'desc'),
            'page' => array(10, 'list'),
            'type' => 'all',
            'col' => '*',
        ),

        # 获取订单数量
        'getCash' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'type' => array('yes', 'in'),
                'uid' => 'yes',
                'status' => 2,
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(cash) as total',
        ),
        'getwsCash' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'status' => array('yes', 'in'),
                'uid' => array('yes', 'in'),
                'mid' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(cash) as total',
        ),
        'getExcelAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'state' => 1,
            ),
            'type' => 'all',
            'col' => '*',
        ),
    ),
);
