<?php

$status = array
(
    -1 => array('name' => '未审核待发放', 'style' => 'font-weight:bold;color:#436EEE'),
    1 => array('name' => '已审核待发放', 'style' => 'font-weight:bold;color:green'),
    //2 => array('name' => '已审核待发放', 'style' => 'font-weight:bold;color:green'),
    2 => array('name' => '已发放', 'style' => 'font-weight:bold;color:#CD3700'),
    3 => array('name' => '已作废','style' => 'font-weight:bold;color:#CD3700'),
);

$cash_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 => '用户钱包提现',
);

$list_button = array();
$list_button['list'] = array('查看详情', '"push_cash&project=bill&id={cash_id}&page_type=1&[refer]"', '{type} == 1');
$list_button['list1'] = array('查看详情', '"record&project=shop&id={cash_id}&page_type=1&[refer]"', '{type} == 2');
$list_button['list2'] = array('查看详情', '"user_money_sign&project=shop&id={cash_id}&page_type=1&[refer]"', '{type} == 3');
if (Dever::load('manage/auth')->checkFunc('bill.tixian', 'edit1', '发放')) {
    $list_button['fast'] = array('发放', '"tixian&where_id={id}&col=audit,audit_desc,pic&oper_save_jump=tixian&oper_table=tixian&oper_parent=tixian"', '{status} == 1 && "{bill-cash-status}" == 2');
}

$mid = Dever::input('search_option_mid');

$mul = false;
if (Dever::load('manage/auth')->checkFunc('bill.tixian', 'fafangedit', '批量发放')) {
    $mul = '{status} == 1';
}
return array
(
    # 表名
    'name' => 'tixian',
    # 显示给用户看的名称
    'lang' => '提现管理',
    'auto' => 100000,
    'set' => array
    (
    	'status' => $status,
    ),
    'end' => array
    (
        'update' => 'bill/lib/manage.tixianAuditUpdate',
        'updatemul' => 'bill/lib/manage.tixianAuditUpdate',
    ),
    'order' => 80,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            //'list'        => true,
        ),

        'type'      => array
        (
            'type'      => 'int-11',
            'name'      => '提现类型',
            'default'   => '1',
            'desc'      => '提现类型',
            'match'     => 'is_numeric',
            'search'    => 'select',
            'option'    => $type,
        ),

        'mid'      => array
        (
            'type'      => 'int-11',
            'name'      => '代理商姓名/手机号',
            'default'   => '-1',
            'desc'      => '代理商',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => array
            (
                'api' => 'agent/member-getSearch',
                'col' => 'col',
                'result' => 'id',
                'search' => 'mid',
            ),
            'list_name' => '提现用户信息',
            'list'      => 'Dever::load("bill/lib/tixian.getInfo", {type}, {mid})',
            'list_order' => 3,
        ),

        'agent-member-name'=> array
        (
            'name'      => '姓名',
            'default'   => '',
            'desc'      => '姓名',
            'match'     => 'option',
            # 读取另外表的关联方式
            'sync'      => array('mid', 'id'),
        ),

        'agent-member-role'=> array
        (
            'name'      => '代理角色',
            'default'   => '',
            'desc'      => '代理角色',
            'match'     => 'option',
            # 读取另外表的关联方式
            'sync'      => array('mid', 'id'),
            // 'list'      => 'Dever::load("setting/role-find#name", "{agent-member-role}")',
            // 'list_order' => 5,
        ),

        'order_num'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '流水号',
            'default'   => '',
            'desc'      => '流水号',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'      => true,
            'list_name' => '流水号<br />交易时间<br />发放时间',
            'list'      => 'Dever::load("bill/lib/tixian.order_num#name",{id})',
            'list_order'  => 1,
        ),

        'ycash'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '提现金额',
            'default'   => '0',
            'desc'      => '金额',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
            'list_name' => '提现金额<br />实际提现金额<br />提现后余额',
            'list'      => 'Dever::load("bill/lib/tixian.order_num#money",{id})',
            'list_order' => 6,
        ),

        'cash'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '实际提现金额',
            'default'   => '0',
            'desc'      => '提现金额',
            'match'     => 'is_numeric',
            'update'    => 'text',
            // 'list'      => true,
            // 'list_order' => 7,
        ),

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

        'cash_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '资金表id',
            'default'   => '',
            'desc'      => '资金表id',
            'match'     => 'is_string',
            'update'    => 'text',
        ),

        'bill-cash-status'=> array
        (
            'name'      => '交易状态',
            'default'   => '',
            'desc'      => '交易状态',
            'match'     => 'option',
            # 读取另外表的关联方式
            'sync'      => array('cash_id', 'id'),
            // 'search'    => 'select',
            //'list'      => true,
            'option'	=> $cash_status,
            //'list_name' => '交易状态<br />发放状态',
            //'list'      => 'Dever::load("bill/lib/tixian.order_num#status",{id})',
            //'list_order' => 9,
        ),

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

        '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'  => 12,
            'show'      => 'audit=3',
        ),

        'pic'		=> array
		(
			'type' 		=> 'text-255',
			'name' 		=> '凭证',
			'default' 	=> '',
			'desc' 		=> '请选择凭证',
			'match' 	=> 'option',
			'update'	=> 'images',
			'key' 		=> '1',
			'place'		=> '150',
            'show'      => 'audit=2',
		),
        'sign'     => array
        (
            'type'      => 'varchar-150',
            'name'      => '手写签名',
            'default'   => '',
            'desc'      => '手写签名',
            'match'     => 'option',
            'update'    => 'image',
            'key'       => '7',
            'list'      => '"<img src=\'{sign}\' width=\'150\'>"',
        ),
        'operdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '发放时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
            // 'list'      => '"{operdate}" > 0 ? date("Y-m-d H:i", {operdate}) : "-"',
            // 'list_order'  => 11,
        ),
        '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,
        ),
        '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", {cdate})',
            // 'list_order'  => 2,
        ),
    ),

    'manage' => array
    (
        'insert' => false,
        'delete' => false,
        'edit' => false,
        'mul' => $mul,
        'list_button' => $list_button,
        'excel' => array
        (
            array('数据导出','提现数据导出', 'bill/lib/manage.tixian_out'),
        ),
    ),

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

        'getNew' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'mid' => 'yes',
                'state' => 1,
            ),
            'order' => array('id' => 'desc'),
            'type' => 'one',
            'col' => '*',
        ),
        'gettxCash' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'status' => array('yes', 'in'),
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(cash) as total',
        ),
        // 'getdfCash' => array
        // (
        //     # 匹配的正则或函数 选填项
        //     'option' => array
        //     (
        //         'start' => array('yes-cdate', '>='),
        //         'end' => array('yes-cdate', '<='),
        //         'status' => array('yes', 'in'),
        //         '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'),
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(cash) as total',
        ),
        'upStatus' => array
        (
            'type' => 'update',
            'where' => array
            (
                'id' => 'yes',
            ),
            'set' => array
            (
                'status' =>'yes',
                'bill-cash-status'=>'yes',
            ),
        ),
        'getExcelAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'status' => array('yes', 'in'),
                'state' => 1,
            ),
            'type' => 'All',
            'order' => array('cdate' => 'desc'),
            'col' => '*',
        ),

        'getdfCash' => array
         (
             'option' => array
             (
                'start' => array('yes-t_2.operdate', '>='),
                'end' => array('yes-t_2.operdate', '<='),
                'status' => array('yes-t_1.status', 'in'),
               'state' => 'yes-t_1.state',
             ),
             'join' => array
            (
             array
             (
              'table' => 'bill/cash',
              'type' => 'left join',
              'on' => array('cash_id','id'),
              'col' => 't_2.id as cid',
             ),
            ),
                 'type' => 'one',
                 // 'limit' => '0,5',
                 // 'order' => array('t_2.sdate' => 'desc','id' => 'desc'),
           // 'col' => 'id,t_1.name,t_1.content,t_2.name as company_name',
                 'col' => 'id,sum(t_1.cash) as total',
      ),
    ),
);