<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Withdraw_rule;
use Illuminate\Support\Facades\DB;
use Request;

/**
 *
 */
class MoneyController extends Controller
{

    /**
     * @return 账务管理
     */
    function index()
    {
        return view('admin.MoneyManage/Index');
    }

    //用户存取反水列表
    function moneyList()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
        $field = Request::has('field') ? Request::get('field') : 6;
        $order = Request::has('order') ? Request::get('order') : 'desc';

        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
        $order_id = Request::has('order_id') ? Request::get('order_id') : '';
        $trade_type = Request::has('trade_type') ? Request::get('trade_type') : '';
        $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
        $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
        $money_small = Request::has('money_small') ? Request::get('money_small') : '';
        $money_big = Request::has('money_big') ? Request::get('money_big') : '';
        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
        $status = Request::has('status') ? Request::get('status') : '';
        $where = array();
        if (is_numeric($status)) {
            $where[] = array('money_details.status', '=', $status);
        }
        if (!empty($trade_type)) {
            $where[] = array('trade_type', '=', $trade_type);
        }
        if (!empty($star_time)) {
            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
            $where[] = array('money_time', '>=', $star_time);
        }
        if (!empty($end_time)) {
            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
            $where[] = array('money_time', '<=', $end_time);
        }

        if (!empty($money_small)) {
            $where[] = array('money', '>=', $money_small);
        }
        if (!empty($money_big)) {
            $where[] = array('money', '<=', $money_big);
        }

        if (!empty($account_name)) {
            if (empty($sureblur) || $sureblur == '模糊') {
                $where[] = array('account_name', 'like', '%' . $account_name . '%');
            } else {
                $where[] = array('money_details.account_name', '=', $account_name);
            }
        }
        if (!empty($order_id)) {
            $where = array(array('trade_id', '=', $order_id));
        }

        $moneydetails = new \App\Models\Money_details;
        $data = $moneydetails->getPartlist($where, 1, $limit, $field, $order);
        if ($data < 0) {
            return responseToJson($data);
        }

        $data['data'] = arrayToNumber($data['data'], ['money']);
        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
    }

    //用户账务日志
    function fundLog()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
        $field = Request::has('field') ? Request::get('field') : 6;
        $order = Request::has('order') ? Request::get('order') : 'desc';

        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
        $loss_name = Request::has('loss_name') ? Request::get('loss_name') : '';
        $agent_name = Request::has('agent_name') ? Request::get('agent_name') : '';
        $startime = Request::get('startime') ? Request::get('startime') . ' 00:00:00' : '';
        $endtime = Request::get('endtime') ? Request::get('endtime') . ' 23:59:59' : '';

        if (empty($account_name) && !empty($agent_name)) {
            $db = new \App\Models\NagentChild;
            $account_name = $db->getChildStr($agent_name);
        }
        /*$whereIn = array();
        $whereNotin = array();
        $where = array();
        if (!empty($account_name)) {
            $whereIn[] = array('account_name', explode(',', $account_name));
        }
        if (!empty($loss_name)) {
            $whereNotin[] = array('account_name', explode(',', $loss_name));
        }
        if (!empty($startime)) {
            $startime = date('Y-m-d H:i:s', strtotime($startime));
            $where[] = array('money_time', '>=', $startime);
        }
        if (!empty($endtime)) {
            $endtime = date('Y-m-d H:i:s', strtotime($endtime));
            $where[] = array('money_time', '<=', $endtime);
        }*/
        $where = '';
        if (!empty($account_name)) {
            $account_name = explode(',', $account_name);
            $account_name = implode("','", $account_name);
            $where .= " where account_name in ('" . $account_name . "') ";
        }
        if (!empty($loss_name)) {
            $loss_name = explode(',', $loss_name);
            $loss_name = implode("','", $loss_name);
            $where .= empty($where) ? ' where ' : ' and ';
            $where .= "account_name not in ('" . $loss_name . "')";
        }
        if (!empty($startime)) {
            $startime = date('Y-m-d H:i:s', strtotime($startime));
            $where .= empty($where) ? ' where ' : ' and ';
            $where .= "money_time>='" . $startime . "'";
        }
        if (!empty($endtime)) {
            $endtime = date('Y-m-d H:i:s', strtotime($endtime));
            $where .= empty($where) ? ' where ' : ' and ';
            $where .= "money_time<='" . $endtime . "'";
        }

        $moneydetails = new \App\Models\Money_details();
        $data = $moneydetails->getFundlog($where, 1, $limit, $field, $order, $page);
        if ($data < 0) {
            return responseToJson($data);
        }

        $data['data'] = arrayToNumber($data['data'], ['sendmoney', 'savemoney', 'getmoney', 'winmoney', 'adminadd', 'adminpull', 'recharge_send', 'back_return']);
        /*$uwhere = array();
        $uwhere = $where;
        $countmoney = $moneydetails->getPatlog($where, 4);
        foreach ($data['data'] as $k => $v) {
            $data['data'][$k]['sendmoney'] = 0;
            $data['data'][$k]['savemoney'] = 0;
            $data['data'][$k]['getmoney'] = 0;
            $data['data'][$k]['winmoney'] = 0;
            $data['data'][$k]['adminadd'] = 0;
            $data['data'][$k]['adminpull'] = 0;
            $data['data'][$k]['recharge_send'] = 0;
            $data['data'][$k]['back_return'] = 0;
            $data['data'][$k]['countmoney'] = $countmoney;
            if (is_array($countmoney) && count($countmoney) > 0) {
                foreach ($countmoney as $sk => $sv) {
                    if ($v['account_name'] == $sv['account_name']) {
                        $data['data'][$k]['sendmoney'] = ($sv['trade_type'] == 14) ? ($data['data'][$k]['sendmoney'] + $sv['summoney']) : $data['data'][$k]['sendmoney'];
                        $data['data'][$k]['savemoney'] = ($sv['trade_type'] == 6 || $sv['trade_type'] == 11 || $sv['trade_type'] == 14) ? ($data['data'][$k]['savemoney'] + $sv['summoney']) : $data['data'][$k]['savemoney'];
                        $data['data'][$k]['getmoney'] = ($sv['trade_type'] == 5 || $sv['trade_type'] == 9) ? ($data['data'][$k]['getmoney'] + $sv['summoney']) : $data['data'][$k]['getmoney'];
                        $data['data'][$k]['adminadd'] = ($sv['trade_type'] == 12 && $sv['money_type'] == 1) ? ($data['data'][$k]['adminadd'] + $sv['summoney']) : $data['data'][$k]['adminadd'];
                        $data['data'][$k]['adminpull'] = ($sv['trade_type'] == 12 && $sv['money_type'] == 2) ? ($data['data'][$k]['adminpull'] + $sv['summoney']) : $data['data'][$k]['adminpull'];
                        $data['data'][$k]['recharge_send'] = ($sv['trade_type'] == 13) ? ($data['data'][$k]['recharge_send'] + $sv['summoney']) : $data['data'][$k]['recharge_send'];
                        $data['data'][$k]['back_return'] = ($sv['trade_type'] == 7 || $sv['trade_type'] == 8) ? ($data['data'][$k]['back_return'] + $sv['summoney']) : $data['data'][$k]['back_return'];
                    }
                }
            }
            $data['data'][$k]['winmoney'] = $data['data'][$k]['sendmoney'] + $data['data'][$k]['savemoney'] - $data['data'][$k]['getmoney'];
        }
        $data['data'] = arrayToNumber($data['data'], ['sendmoney', 'savemoney', 'getmoney', 'winmoney', 'adminadd', 'adminpull', 'recharge_send', 'back_return']);*/
        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
    }

    //用户资金流水列表
    function moneyWaterList()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
        $field = Request::has('field') ? Request::get('field') : 6;
        $order = Request::has('order') ? Request::get('order') : 'desc';

        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
        $order_id = Request::has('order_id') ? Request::get('order_id') : '';
        $trade_type = Request::has('trade_type') ? Request::get('trade_type') : '';
        $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
        $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
        $money_small = Request::has('money_small') ? Request::get('money_small') : '';
        $money_big = Request::has('money_big') ? Request::get('money_big') : '';
        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
        $status = Request::has('status') ? Request::get('status') : '';
        $isuser = Request::has('isuser') ? Request::get('isuser') : 2;
        if ($isuser == 1) {
            $star_time = '';
            $end_time = '';
        }
        $where = array();
        if (!empty($account_name)) {
            if (empty($sureblur) || $sureblur == '模糊') {
                $where[] = array('money_details.account_name', 'like', '%' . $account_name . '%');
            } else {
                $where[] = array('money_details.account_name', '=', $account_name);
            }
        }
        if (!empty($trade_type)) {
            $where[] = array('trade_type', '=', $trade_type);
        }
        if (!empty($status)) {
            $where[] = array('money_details.status', '=', $status);
        }
        if (!empty($star_time)) {
            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
            $where[] = array('money_time', '>=', $star_time);
        }
        if (!empty($end_time)) {
            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
            $where[] = array('money_time', '<=', $end_time);
        }
        if (!empty($money_small)) {
            $where[] = array('money', '>=', $money_small);
        }
        if (!empty($money_big)) {
            $where[] = array('money', '<=', $money_big);
        }
        if (!empty($order_id)) {
            $where = array(array('trade_id', '=', $order_id));
        }

        if (count($where) == 0) {
            return \App\Lib\DataTable\DataTable::init()->toJson(array(), 0, 0, $where);
        }
        $moneydetails = new \App\Models\Money_details();
        $data = $moneydetails->getMoneylist($where, 1, $limit, $field, $order);
        if ($data < 0) {
            return responseToJson($data);
        }
        $usercash = array();
        $data['data'] = arrayToNumber($data['data'], ['money']);
        foreach ($data['data'] as $k => $v) {
            /*if(isset($usercash[$v['account_name']])){
                if($v['money_type'] == 1){
                    $ccash = $usercash[$v['account_name']] + $v['money'];
                }else{
                    $ccash = $usercash[$v['account_name']] - $v['money'];
                }
                //$usercash[$v['account_name']] = $ccash;
                if($v['money_cash'] != $ccash){
                    $data['data'][$k]['money_cash'] = $ccash;
                }
            }else{
                $usercash[$v['account_name']] = $v['money_cash'];
            }*/

            if ($v['trade_type'] == 9 && strpos($v['trade_desc'], '撤销') !== false) {
                if (strpos($v['trade_desc'], '重新开奖') !== false) {
                    $data['data'][$k]['isdel'] = 2;
                } else {
                    $data['data'][$k]['isdel'] = 1;
                }
            } else {
                $data['data'][$k]['isdel'] = 2;
            }
            $data['data'][$k]['money_time'] = date('Y-m-d H:i:s', strtotime($v['money_time']));
        }

        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
    }

    //交易订单详情
    function moneyDetails()
    {
        $tradeid = Request::has('tradeid') ? Request::get('tradeid') : '';
        if (empty($tradeid)) {
            return responseToJson(-3021000202); //未提交对应订单号
        }
        $moneydetails = new \App\Models\Money_details();
        $data = $moneydetails->getOrderDetails($tradeid, 3, 'account_bank', 'account_identity', 'account_identity');

        return responseToJson($data);
    }

    //充值记录
    function recharge()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
        $field = Request::has('field') ? Request::get('field') : 6;
        $order = Request::has('order') ? Request::get('order') : 'desc';

        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
        $order_id = Request::has('order_id') ? Request::get('order_id') : '';
        $recharge_type = Request::has('recharge_type') ? Request::get('recharge_type') : '';
        $status = Request::has('status') ? Request::get('status') : '';
        $apply_startime = Request::get('apply_startime') ? Request::get('apply_startime') . ' 00:00:00' : '';
        $apply_endtime = Request::get('apply_endtime') ? Request::get('apply_endtime') . ' 23:59:59' : '';
        $haddle_startime = Request::get('haddle_startime') ? Request::get('haddle_startime') . ' 00:00:00' : '';
        $haddle_endtime = Request::get('haddle_endtime') ? Request::get('haddle_endtime') . ' 23:59:59' : '';
        $money_small = Request::has('money_small') ? Request::get('money_small') : '';
        $money_big = Request::has('money_big') ? Request::get('money_big') : '';
        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
        if($status==-1)$status='';
        $where = array();
        $whereIn = array();
        $sql = '';
        if (!empty($recharge_type) && empty($status)) {
            $where[] = array('recharge_type', '=', $recharge_type);
        }
        if (!empty($recharge_type)) {
            $where[] = array('recharge_type', '=', $recharge_type);
        }
        if ($status || $status === '0') $where[] = array('status', '=', $status);
        if (!empty($apply_startime)) {
            $apply_startime = date('Y-m-d H:i:s', strtotime($apply_startime));
            $where[] = array('apply_time', '>=', $apply_startime);
        }
        if (!empty($apply_endtime)) {
            $apply_endtime = date('Y-m-d H:i:s', strtotime($apply_endtime));
            $where[] = array('apply_time', '<=', $apply_endtime);
        }
        if (!empty($haddle_startime)) {
            $haddle_startime = date('Y-m-d H:i:s', strtotime($haddle_startime));
            $where[] = array('complete_time', '>=', $haddle_startime);
        }
        if (!empty($haddle_endtime)) {
            $haddle_endtime = date('Y-m-d H:i:s', strtotime($haddle_endtime));
            $where[] = array('complete_time', '<=', $haddle_endtime);
        }
        if (!empty($money_small)) {
            $where[] = array('money', '>=', $money_small);
        }
        if (!empty($money_big)) {
            $where[] = array('money', '<=', $money_big);
        }

        if (!empty($account_name)) {
            if (empty($sureblur) || $sureblur == '模糊') {
                $where[] = array('account_name', 'like', '%' . $account_name . '%');
            } else {
                $where[] = array('account_name', '=', $account_name);
            }
        }

        if (!empty($order_id)) {
            $where = array(array('order_id', '=', $order_id));
        }
        $moneydetails = new \App\Models\Money_recharge();

        if ($status || (int)$status < -1) {
            $sql = "status={$status}";
        }
        $data = $moneydetails->getRechargelist($where, 1, $limit, $field, $order, '', '', '', $whereIn, $sql);
        if ($data < 0) {
            return $data;
        }
        $data['data'] = arrayToNumber($data['data'], ['money', 'money_cash']);
        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
    }

    //待审核充值记录量获取
    function getRechargeNum()
    {
        $recharge = new \App\Models\Money_recharge();
        $status = Request::has('status') ? Request::get('status') : 1;
        $data = $recharge->getCount($status);
        return responseToJson(1, '', $data);
    }

    //充值订单详情
    function rechargeDetails()
    {
        $orderid = Request::has('orderid') ? Request::get('orderid') : '';
        if (empty($orderid)) {
            return responseToJson(-3020000202); //未提交对应订单号
        }
        $rechargedetails = new \App\Models\Money_recharge();
        $data = $rechargedetails->getOrderDetails($orderid, 3, 'account_bank', 'account_identity', 'account_identity');

        return responseToJson($data);
    }

    //提现记录
    function withdraw()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
        $field = Request::has('field') ? Request::get('field') : 'id';
        $order = Request::has('order') ? Request::get('order') : 'desc';
        $grade = Request::has('grade') ? Request::get('grade') : '-1';
        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
        $order_id = Request::has('order_id') ? Request::get('order_id') : '';
        $bank_user = Request::has('bank_user') ? Request::get('bank_user') : '';
        $money_small = Request::has('money_small') ? Request::get('money_small') : '';
        $money_big = Request::has('money_big') ? Request::get('money_big') : '';
        $apply_startime = Request::get('apply_startime') ? Request::get('apply_startime') . ' 00:00:00' : '';
        $apply_endtime = Request::get('apply_endtime') ? Request::get('apply_endtime') . ' 23:59:59' : '';
        $haddle_startime = Request::get('haddle_startime') ? Request::get('haddle_startime') . ' 00:00:00' : '';
        $haddle_endtime = Request::get('haddle_endtime') ? Request::get('haddle_endtime') . ' 23:59:59' : '';
        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'on';
        $status = Request::has('status') ? Request::get('status') : '';

        $where = array();

        if ($grade < 0) {
            // $where .= ' AND grade=';
            $grade = '';
        } else {
            $grade = ($grade == 10) ? '' : $grade;
            $where[] = array('grade', '=', $grade);
        }
        if (!empty($bank_user)) {
            $where[] = array('bank_user', 'like', '%' . $bank_user . '%');
        }
        if (!empty($money_small)) {
            $where[] = array('money', '>=', $money_small);
        }
        if (!empty($money_big)) {
            $where[] = array('money', '<=', $money_big);
        }
        if (!empty($apply_startime)) {
            $apply_startime = date('Y-m-d H:i:s', strtotime($apply_startime));
            $where[] = array('apply_time', '>=', $apply_startime);
        }
        if (!empty($apply_endtime)) {
            $apply_endtime = date('Y-m-d H:i:s', strtotime($apply_endtime));
            $where[] = array('apply_time', '<=', $apply_endtime);
        }
        if (!empty($haddle_startime)) {
            $haddle_startime = date('Y-m-d H:i:s', strtotime($haddle_startime));
            $where[] = array('pass_time', '>=', $haddle_startime);
        }
        if (!empty($haddle_endtime)) {
            $haddle_endtime = date('Y-m-d H:i:s', strtotime($haddle_endtime));
            $where[] = array('pass_time', '<=', $haddle_endtime);
        }
        if (!empty($status) && $status != 4) {
            if ($status == 3) {
                $where[] = array('status', '=', '0');
            } else {
                $where[] = array('status', '=', $status);
            }
        }
        if (!empty($account_name)) {
            if (empty($sureblur) || $sureblur == 'off') {
                $where = array(array('account_name', 'like', '%' . $account_name . '%'));
            } else {
                $where = array(array('account_name', '=', $account_name));
            }
        }

        if (!empty($order_id)) {
            $where = array(array('order_id', '=', $order_id));
        }
        $takedetails = new \App\Models\Money_take();
        $jointable = '';
        if (is_numeric($grade)) {
            $jointable = 'account_detailed';
        }
        $data = $takedetails->getTakelist($where, 1, $limit, $field, $order, $jointable, $grade);

        if ($data < 0) {
            return responseToJson($data);
        }
        $take_status = trans('status.money_take.status');
        $has_root = 0;
        if (\App\Models\Role::hasRoot('/enable/show/bankcard') < 0) {
            $has_root = 1;
        }

        foreach ($data['data'] as $k => $v) {
            $data['data'][$k]['apply_time'] = $v['order_id'] . '<br>' . $v['apply_time'];
            $data['data'][$k]['status'] = ($v['status'] == 0) ? $take_status[3] : $take_status[$v['status']];
            // $data['data'][$k]['bank_info_no'] = $v['bank_info'] . '<br>' . bankHide($v['bank_no']);
            $has_root == 1 ? $data['data'][$k]['bank_no'] = bankHide($v['bank_no']) : null;

            $data['data'][$k]['bank_user_address'] = $v['bank_user'] . '<br>' . $v['bank_address'];
            // $data['data'][$k]['pass_time'] = '<p style="color:red;">'.$data['data'][$k]['status'] . '<br>' . $v['pass_time'];
        }
        $data['data'] = arrayToNumber($data['data'], ['money']);
        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
    }

    //待审核提现记录量获取
    function getTakeNum()
    {
        $take = new \App\Models\Money_take();
        $status = Request::has('status') ? Request::get('status') : 3;
        $data = $take->getCountnum($status);
        return responseToJson(1, '', $data);
    }

    //提现订单详情
    function withdrawDetails()
    {
        $orderid = Request::has('orderid') ? Request::get('orderid') : '';
        if (empty($orderid)) {
            return responseToJson(-3020100202); //未提交对应订单号
        }
        $takedetails = new \App\Models\Money_take();
        $data = $takedetails->getOrderDetails($orderid, 3, '', '', '', 2);

        if ($data < 0) {
            return responseToJson($data);
        }
        $data['trade_type'] = 5;

        return responseToJson($data);
    }

    //回水记录
    function returnList()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
        $field = Request::has('field') ? Request::get('field') : 6;
        $order = Request::has('order') ? Request::get('order') : 'desc';

        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
        $order_id = Request::has('order_id') ? Request::get('order_id') : '';
        $haddle_startime = Request::get('haddle_startime') ? Request::get('haddle_startime') . ' 00:00:00' : '';
        $haddle_endtime = Request::get('haddle_endtime') ? Request::get('haddle_endtime') . ' 23:59:59' : '';
        $money_small = Request::has('money_small') ? Request::get('money_small') : '';
        $money_big = Request::has('money_big') ? Request::get('money_big') : '';
        $lossmoney_small = Request::has('lossmoney_small') ? Request::get('lossmoney_small') : '';
        $lossmoney_big = Request::has('lossmoney_big') ? Request::get('lossmoney_big') : '';
        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';

        $where = array();
        if (!empty($account_name)) {
            if (empty($sureblur) || $sureblur == '模糊') {
                $where[] = array('account_name', 'like', '%' . $account_name . '%');
            } else {
                $where[] = array('account_name', '=', $account_name);
            }
        }
        if (!empty($haddle_startime)) {
            $haddle_startime = date('Y-m-d H:i:s', strtotime($haddle_startime));
            $where[] = array('processing_time', '>=', $haddle_startime);
        }
        if (!empty($haddle_endtime)) {
            $haddle_endtime = date('Y-m-d H:i:s', strtotime($haddle_endtime));
            $where[] = array('processing_time', '<=', $haddle_endtime);
        }
        if (!empty($money_small)) {
            $where[] = array('money', '>=', $money_small);
        }
        if (!empty($money_big)) {
            $where[] = array('money', '<=', $money_big);
        }
        if (!empty($lossmoney_small)) {
            $where[] = array('total_money', '>=', $lossmoney_small);
        }
        if (!empty($lossmoney_big)) {
            $where[] = array('total_money', '<=', $lossmoney_big);
        }

        if (!empty($order_id)) {
            $where = array(array('order_id', '=', $order_id));
        }
        $moneydetails = new \App\Models\Money_return();
        $data = $moneydetails->getReturnlist($where, 1, $limit, $field, $order);

        if ($data < 0) {
            return responseToJson($data);
        }

        foreach ($data['data'] as $k => $v) {
            $data['data'][$k]['orderid_time'] = $v['order_id'] . '<br>' . $v['processing_time'];
        }
        $data['data'] = arrayToNumber($data['data'], array('return_money', 'total_money'));
        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
    }

    //回水订单详情
    function returnDetails()
    {
        $orderid = Request::has('orderid') ? Request::get('orderid') : '';
        if (empty($orderid)) {
            return responseToJson(-3020200202); //未提交对应订单号
        }
        $returndetails = new \App\Models\Money_return();
        $data = $returndetails->getOrderDetails($orderid, 3, 'account_bank', 'account_identity', 'account_identity');
        if ($data < 0) {
            return responseToJson($data);
        }
        $data['trade_type'] = 8;

        return responseToJson($data);
    }

    //加款扣款
    function moneyChange()
    {
        $changeType = Request::has('changetype') ? Request::get('changetype') : '';
        $account_identity = Request::has('account_identity') ? Request::get('account_identity') : '';
        $money = Request::has('money') ? Request::get('money') : '';
        $bili = Request::has('bili') ? Request::get('bili') : 0;
        $reson = Request::has('reson') ? Request::get('reson') : 0;
        $orderid = Request::has('orderid') ? Request::get('orderid') : '';
        $status = Request::has('status') ? Request::get('status') : 1; //1：成功 2：失败
        if (empty($changeType)) {
            return responseToJson(-3020300302); //未提交加款扣款类型 1：加款，2：扣款
        }
        if (empty($money)) {
            return responseToJson(-3020300402); //操作金额不能为空
        }
        if (empty($account_identity)) {
            return responseToJson(-3020300502); //未提交用户ID
        }
        if ($bili > 0) {
            $money = $money * $bili;
        }
        //第三方充值
        if (empty($orderid)) {
            $res = $status; //加款扣款
            if ($res == 1) {
                return responseToJson($res);
            }
            return responseToJson(-3020300602); //加款扣款失败
        }
        //活动加款扣款
        $res = $status; //加款扣款
        if ($res == 1) {
            return responseToJson($res);
        }
        return responseToJson(-3020300702); //加款扣款失败
    }

    //加款扣款用户信息获取
    function getUser()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
        $field = Request::has('field') ? Request::get('field') : 'id';
        $order = Request::has('order') ? Request::get('order') : 'desc';
        $account = Request::has('account_name') ? Request::get('account_name') : '';
        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
        if (empty($account)) {
            $data = array(
                array(
                    'account_name' => '',
                    'account_identity' => '',
                    'cash' => '',
                ),
            );
            return \App\Lib\DataTable\DataTable::init()->toJson($data, 1);
        }
        $account = strtolower($account);
        $where = array();
        if (!empty($account)) {
//			if (empty($sureblur) || $sureblur == '模糊') {
//				$where[] = array('account', 'like', '%' . $account . '%');
//			} else {
            $where[] = array('account', '=', $account);
//			}
        }

        $userdetails = new \App\Models\Account();
        $data = $userdetails->getUserDetails($where, 3, 'account_detailed', 'identity', 'account_identity', $page, $limit, $field, $order);

        if ($data < 0) {
            return responseToJson($data); //没有用户数据
        }

        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
    }

    //回水管理
    function returnInfo()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
//		$field = Request::has('field') ? Request::get('field') : '';
//		$order = Request::has('order') ? Request::get('order') : 'desc';

        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
//		$account_name = 'gust17687';
        $gametype = Request::has('gametype') ? Request::get('gametype') : '';
        $lossmoney_small = Request::has('lossmoney_small') ? Request::get('lossmoney_small') : '';
        $lossmoney_big = Request::has('lossmoney_big') ? Request::get('lossmoney_big') : '';
        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
        $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
        $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
        $total_money = Request::has('total_money') ? Request::get('total_money') : '';

        $where = array();
        $user_where = array();
        $wheregame = array();
        $orwhere = array();
        $having = '';
        if (!empty($total_money)) {
            $having = 'sum("get_money")<=' . (-$total_money);
        }
        if (!empty($account_name)) {
            if (empty($sureblur) || $sureblur == '模糊') {
                $where[] = array('account_name', 'like', '%' . $account_name . '%');
            } else {
                $where[] = array('account_name', '=', $account_name);
            }
            $user_where = array('account' => $account_name, 'status' => 4);
        }
        if (!empty($gametype) || $gametype != 0) {
            $where[] = array('game_name', '=', $gametype);
        } else {
//			$wheregame[] = array('game_name', '=', 'xy28');
//			$orwhere[] = array('game_name', '=', 'jnd28');
            $wheregame = array('xy28', 'jnd28');
        }
        if (!empty($lossmoney_small)) {
            $where[] = array('total_money', '>=', $lossmoney_small);
        }
        if (!empty($lossmoney_big)) {
            $where[] = array('total_money', '<=', $lossmoney_big);
        }
        if (!empty($star_time)) {
            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
            $where[] = array('money_time', '>=', $star_time);
        }
        if (!empty($end_time)) {
            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
            $where[] = array('money_time', '<=', $end_time);
        }

//        $user= new \App\Model\Account;
//        $users=$user->Accounta($user_where);
        $moneyreturn = new \App\Models\MoneyBuy();
//		if ($users > 0){
//            return responseToJson(-3020400202);
//        }
        $data = $moneyreturn->getMoneyReturn($where, 1, $limit, $wheregame, $orwhere, $having);

        if ($data < 0) {
            return responseToJson($data);
        }

//		$game = trans('money');
//        var_dump($data['data']);

//		$gamearr = $game['gametype'];
        foreach ($data['data'] as $k => $v) {
//			$data['data'][$k]['game_name'] = $gamearr[$v['game_name']];
            if ($v['total_money'] < 0) {
                $data['data'][$k]['total_money'] = floatval(abs($v['total_money']));
            } else {
                unset($data['data'][$k]);
            }

            // $data['data'][$k]['total_money'] = floatval($v['total_money']);
        }
//        var_dump($data['data'])

        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
    }

    //回水
    function returnAct()
    {
        $status = Request::has('status') ? Request::get('status') : 1; //1：成功 2：失败
        $systemUser = Request::has('systemuser') ? Request::get('systemuser') : ''; //管理员名
        $data = Request::has('data') ? Request::get('data') : '';
        //$data = '{"data":[{"account_name":"147ceshi","account_identity":"3df48c6c-f805-ed8b-1d2f-e4e95f09242f","total_money":200,"status":2,"game_name":"\u5e78\u8fd028","ratio":0.1},{"account_name":"123daili","account_identity":"f243a05d-f0b4-6eee-e8ad-53472612230e","total_money":0,"status":1,"game_name":"\u5e78\u8fd028","ratio":0.1}]}';
        if (empty($data)) {
            return Rens(-3020400202); //未提交回水信息
        }
        if (empty($systemUser)) {
            return Rens(-3020400302); //未提交操作管理员信息
        }
        $data = json_decode($data);
        $data = $data->data;
        $addData = array();
        foreach ($data as $k => $v) {
            $addData[] = array(
                'info_identity' => '',
                'order_id' => '',
                'account_name' => $v->account_name,
                'account_identity' => $v->account_identity,
                'money' => $v->total_money * $v->ratio,
                'total_money' => $v->total_money,
                'sysetem_user' => $systemUser,
                'processing_time' => date('Y-m-d H:i:s', time()),
                'ratio' => $v->ratio,
                'reason' => '',
            );
        }

        foreach ($addData as $v) {
            if (!empty($v)) {
                $res = $status;
            }
        }
        if ($res == 1) {
            return Rens($res);
        }
        return Rens(-3020400402); //回水操作失败

    }

    //提现账单详情
    function stateDetails()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
        $field = Request::has('field') ? Request::get('field') : 6;
        $order = Request::has('order') ? Request::get('order') : 'desc';

        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
        $account_identity = Request::has('account_identity') ? Request::get('account_identity') : '';
        $status = Request::has('status') ? Request::get('status') : '';
        if (empty($account_name) && empty($account_identity)) {
            return responseToJson(-3020200102); //未提交对应用户信息
        }
        if (empty($status)) {
            return responseToJson(-3020200202); //未提交对应信息状态
        }
        $where = array();
        if (!empty($account_name)) {
            $where[] = array('account_name', '=', $account_name);
        } else {
            $where[] = array('account_identity', '=', $account_identity);
        }
        if ($status == 3) {
            $where[] = array('money_take.status', '=', '0');
        } else {
            $where[] = array('money_take.status', '=', $status);
        }

        $takedetails = new \App\Models\Money_take();
        $data = $takedetails->getTotalDetails($where, 1, $limit, $page, $field, $order);

        if ($data < 0) {
            return responseToJson($data);
        }

        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
    }

    //充值账单详情
    function rechargesDetails()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
        $field = Request::has('field') ? Request::get('field') : 6;
        $order = Request::has('order') ? Request::get('order') : 'desc';

        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
        $account_identity = Request::has('account_identity') ? Request::get('account_identity') : '';
        $status = Request::has('status') ? Request::get('status') : '';
        if (empty($account_name) && empty($account_identity)) {
            return responseToJson(-3020200102); //未提交对应用户信息
        }
        if (empty($status)) {
            return responseToJson(-3020200202); //未提交对应信息状态
        }
        $where = array();
        if (!empty($account_name)) {
            $where[] = array('money_recharge.account_name', '=', $account_name);
        } else {
            $where[] = array('money_recharge.account_identity', '=', $account_identity);
        }

        $where[] = array('money_recharge.status', '=', $status);

        $takedetails = new \App\Models\Money_recharge();
        $data = $takedetails->getTotalDetails($where, 1, $limit, $page, $field, $order);

        if ($data < 0) {
            return responseToJson($data);
        }

        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
    }

    //用户回水详情列表
    function userreturnList()
    {
        $page = Request::has('page') ? Request::get('page') : 1;
        $limit = Request::has('limit') ? Request::get('limit') : 10;
        $field = Request::has('field') ? Request::get('field') : 13;
        $order = Request::has('order') ? Request::get('order') : 'desc';

        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
        $game_name = Request::has('game_name') ? Request::get('game_name') : '';
        if (empty($account_name) && empty($account_identity)) {
            return responseToJson(-3020300102); //未提交对应用户信息
        }
        $game_name = ($game_name == '幸运28') ? 'xy28' : ($game_name == '加拿大28' ? 'jnd28' : '');
        if (empty($game_name)) {
            return responseToJson(-3020300202); //未提交对应游戏信息
        }
        $where = array();
        $where[] = array('account_name', '=', $account_name);
        $where[] = array('game_name', '=', $game_name);

        $moneybuy = new \App\Models\MoneyBuy();
        $data = $moneybuy->getUserReturndetail($where, 1, $limit, $field, $order);

        if ($data < 0) {
            return responseToJson($data);
        }
        foreach ($data['data'] as $k => $v) {
            $data['data'][$k]['money_time'] = $v['order_id'] . '<br>' . $v['money_time'];
        }

        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
    }

    //统计

    /**
     * 充值金额统计
     * 'money description'
     * @return 'type' 'description'
     */
    function rechargeMoneyCount()
    {
        $where = Request::has('where') ? Request::get('where') : '';
        $db = new \App\Models\Money_recharge;

        $data = $db->rechargeMoneyCount($where);
        return responseToJson($data);
    }

    /**
     * 提款金额统计
     * 'money description'
     * @return 'type' 'description'
     */
    function takeMoneyCount()
    {
        $where = Request::has('where') ? Request::get('where') : '';
        $db = new \App\Models\Money_take;

        $data = $db->takeMoneyCount($where);
        return responseToJson($data);
    }

    /**
     * 汇款金额统计
     * 'money description'
     * @return 'type' 'description'
     */
    function sendMoneyCount()
    {
        $where = Request::has('where') ? Request::get('where') : '';
        $db = new \App\Models\Money_recharge;

        $data = $db->sendMoneyCount($where);
        return responseToJson($data);
    }

    /**
     * 回水金额统计
     * 'money description'
     * @return 'type' 'description'
     */
    function returnMoneyCount()
    {
        $where = Request::has('where') ? Request::get('where') : '';
        $db = new \App\Models\Money_return;

        $data = $db->returnMoneyCount($where);
        return responseToJson($data);
    }

    //获取交易表名后缀
    private function getTradetable($num)
    {
        $type = array(
            '1' => 'buy',
            '2' => 'buy',
            '3' => 'buy',
            '4' => 'prize',
            '5' => 'take',
            '6' => 'recharge',
            '7' => 'back',
            '8' => 'return',
            '11' => 'recharge',
            '12' => 'recharge',
            '13' => 'recharge',
            '14' => 'recharge',
        );
        return $type[$num];
    }

    //汇款
    function Rimit($order_id, $rale)
    {
        DB::beginTransaction();
        $db = new \App\Models\Money_recharge;
        $accountDB = new \App\Models\Account_detailed(); //用户详情
        $info = $db->getRimitDetails($order_id);
        if ($info < 0) {
            return $info;
        }
        $limitroot = new \App\Models\System_user();
        $limitmoney = $limitroot->checkActMoney($info['money']);
        if ($limitmoney < 0) {
            return $limitmoney;
        }
        //更新统计数据
        $data = $info;
        $info['complete_time'] = date('Y-m-d H:i:s');
        $data['pass_time'] = $info['complete_time'];
        $res = \App\Models\Money_count::AddCountinfo($data, 'save');
        if ($res < 0) {
            DB::rollback();//事务回滚
            return responseToJson($res);
        }
        //更新数据状态
        $res = $db->updateStatus($order_id, 1);
        if ($res < 0) {
            DB::rollBack();
            return $res;
        }
        $acount = new \App\Models\Account_detailed;
        $acount_info = $acount->getInfoBy($info['account_identity']);
        $prize_moeny = 0;
        //添加汇款详情
        unset($info['apply_time']);
        unset($info['complete_time']);
        unset($info['status']);
        unset($info['recharge_type']);
        unset($info['recharge_type']);
        unset($info['id']);
        unset($info['info_identity']);
        unset($info['money_cash']);
        unset($info['order_id']);
        unset($info['remark']);
        $rate = $info['rate'] ?? 1;
        if (isset($info['rate']))
            unset($info['rate']);

        //获取充值备注信息
        $remarkinfo = \App\Models\Recharge_Remark::where('order_id', $order_id)->first();
        if (!$remarkinfo) {
            return -30010102;
        }
        $remarkinfo = $remarkinfo->toArray();
        //添加汇款详情
        $info["sysetem_user"] = session('adminInfo.admin_name');
        $res = $this->addLog($info, 14, $acount_info['cash'], $rate, $order_id);
        if ($res < 0) {
            DB::rollBack();
            return $res;
        }
        //更新余额
        $rimt_res = $accountDB->addMoney($acount_info['account_identity'], $info['money']);
        if ($rimt_res < 0) {
            DB::rollBack();
            return $rimt_res;
        }

        //含赠送金额时插入赠送新数据
        if (!empty($rale)) {
            $order_id2 = OrderID();
            $prize_moeny = $info['money'] * $rale; //奖励金额
            $money_cash = $prize_moeny + $acount_info['cash'] + $info['money'];
            $data = array(
                'money' => $prize_moeny,
                "account_name" => $info['account_name'],
                "account_identity" => $info['account_identity'],
                "sysetem_user" => session('adminInfo.admin_name'),
                "reason" => '汇款赠送1',
                "money_cash" => $money_cash,
            );
            $re_data = $data;
            $data['order_id'] = $order_id2;
            $data['apply_time'] = date('Y-m-d H:i:s');
            $data['complete_time'] = date('Y-m-d H:i:s');
            $data['status'] = 1;
            $data['recharge_type'] = '汇款赠送';

            //添加充值赠送备注信息
            $remarkdata = array(
                'order_id' => $order_id2,
                'name' => $remarkinfo['name'],
                'recharge_time' => $remarkinfo['recharge_time'],
                'money' => $prize_moeny,
            );
            $rminfo = \App\Models\Recharge_Remark::insert($remarkdata);
            if (!$rminfo) {
                DB::rollBack();
                return -30010202;
            }

            $order_id2 = $db->addMoney($data);
            if ($order_id2 < 0) {
                DB::rollBack();
                return $order_id2;
            }
            //添加充值详情
            $res2 = $this->addLog($re_data, 13, ($acount_info['cash'] + $info['money']));
            if ($res2 < 0) {
                DB::rollBack();
                return $res2;
            }
            $rimt_res = $accountDB->addMoney($data['account_identity'], $data['money']);
            if ($rimt_res < 0) {
                DB::rollBack();
                return $rimt_res;
            }
        }

        $uinfo = $accountDB->getInfoBy($acount_info['account_identity']);
        $data = array('money_cash' => $uinfo['cash'] - $prize_moeny);
        $res5 = $db->updateInfo($data, 'order_id', $order_id);
        if ($res5 < 0) {
            DB::rollBack();
            return $res5;
        }
        DB::commit();
        return 1;
    }

    //详情记录
    function addLog($data, $type, $cash, int $rate = 1, $order_id = '')
    {
        $data['money_cash'] = $data['money'] + $cash;
        $data['trade_id'] = !empty($order_id) ? $order_id : OrderID();
        $data['trade_type'] = $type;
        $data['money_time'] = date('Y-m-d H:i:s');
        $data['money_type'] = 1;
        $admin_name = session('adminInfo.admin_name');

        $detailsinfo = \App\Models\Money_details::where('trade_id', $order_id)->where('trade_id', '<>', '')->first();
        if ($detailsinfo) {
            return -3020035022;
        }
        if ($type == 13) {
            $data['trade_desc'] = sprintf(trans('trade.admin_prize_money'), $admin_name, $data['account_name'], $data['money'], $data['trade_id'], $rate);
            $data['reason'] = '汇款赠送';
        } else if ($type == 14) {
            $data['trade_desc'] = sprintf(trans('trade.admin_rimit_money'), $admin_name, $data['account_name'], $data['money'], $data['trade_id'], $rate);
            $data['reason'] = '汇款';
        }
        $db_money = new \App\Models\Money_details;
        $res = $db_money->insertData($data);
        return $res;
    }


    //获取提现，汇款，充值待处理内容
    function getNum()
    {
        $model = new \App\Models\Money_recharge();
        $data['rimit'] = $model::where('status', 0)->where('recharge_type', '汇款')->count();
        $data['take'] = \App\Models\Money_take::where('status', 0)->count();
        $data['vip'] = \App\Models\Uservip::where('status', 1)->count();
        // $data['back'] = \App\Model\Oggame_transfer_record::where('type', 3)->count();
        // $data['lotteryMoney'] = \App\Model\LotteryMoneyLog::where('status', 0)->count();//待审核彩金条数
        // $msg_db = new \App\Model\MessageRead;
        // $data['msg'] = $msg_db->countNoReade (session ('adminInfo.admin_id'));
        // $data['agent'] = \App\Model\Agent_detailed::where ('status', 0)->count ('id');
        return responseToJson($data);
    }


    /**
     *检查用户提现规则
     * @param $idd
     * @param null $money
     * @return int
     */
    public function checkWithdrawRule()
    {
        $idd = Request::has('idd') ? Request::get('idd') : '';
        if (!$idd)
            return responseToJson(-1, '非法操作,用户账户不能为空', '');
        $ret = Withdraw_rule::check($idd);
        return responseToJson($ret ? 1 : -1, $ret ? 'success' : '无结果', $ret);
    }

    /**
     * 更新用户提现规则
     * @param $idd
     * @param $data
     * @return array
     */
    public function changeWithDrawRule()
    {

        $idd = Request::has('idd') ? Request::get('idd') : '';
        $start_time = Request::has('start_time') ? Request::post('start_time') : '';
        $end_time = Request::has('end_time') ? Request::post('end_time') : '';
        $bettingMoney = Request::has('bettingMoney') ? Request::post('bettingMoney') : 0;
        $rate = Request::has('rate') ? Request::post('rate') : 1;
        $needBettingMoney = Request::has('needBettingMoney') ? Request::post('needBettingMoney') : 0;
        if (!$idd)
            return responseToJson(-1, '非法操作,用户账户不能为空', '');
        $ret = Withdraw_rule::updateRule($idd, $bettingMoney, $rate);
        return responseToJson($ret ? 1 : -1, $ret ? '修改规则成功' : '修改规则失败', '');
    }

    /**
     *添加用户提现规则
     * @return array|int
     */
    public function addRule()
    {
        $idd = Request::has('idd') ? Request::get('idd') : '';
        $startTime = Request::has('startTime') ? Request::post('startTime') : '';
        $endTime = Request::has('endTime') ? Request::post('endTime') : '';
        $bettingMoney = Request::has('bettingMoney') ? Request::post('bettingMoney') : 0;
        $needBettingMoney = Request::has('needBettingMoney') ? Request::post('needBettingMoney') : 0;
        if (!$idd)
            return responseToJson(-1, '非法操作,用户账户不能为空', '');
        if (!$startTime)
            $startTime = time();
        if (!$endTime)
            $endTime = time();
        if (!$bettingMoney || !$needBettingMoney) {
            //return responseToJson (-1, '金额不能为空或0', '');
        }
        if ($bettingMoney) $data['bettingMoney'] = $bettingMoney;
        if ($needBettingMoney) $data['needBettingMoney'] = $needBettingMoney;
        //$ret = Withdraw_rule::setRule ($idd, $startTime, $endTime, $bettingMoney, $needBettingMoney);
        $ret = Withdraw_rule::setRule($idd, time(), time(), 1000, 1200);
        return responseToJson($ret ? 1 : -1, $ret ? '添加规则成功' : '添加规则失败', $ret);
    }

    /**
     * 删除用户提现规则
     * @return mixed
     */
    public function rmWithdrawRule()
    {
        $idd = Request::has('idd') ? Request::post('idd') : '';
        if (!$idd)
            return responseToJson('', '非法操作', '');
        $ret = Withdraw_rule::rmRule($idd);
        return responseToJson($ret ? 1 : -1, $ret ? '删除规则成功' : '删除规则失败', '');
    }

    public function getWithdrawList()
    {
        $data = Withdraw_rule::get();
        //return responseToJson (1,'',$data);
        return ['code' => 0, 'count' => count($data), 'data' => $data, 'msg' => 'success'];
    }

    /**
     * 用户提现规则表页面
     */
    public function withdrawRules(Request $req)
    {
        $request['title'] = isset($req->title) ? trim($req->title) : '提现规则表';
        $request['type'] = isset($req->type) ? trim($req->type) : null;
        $dt = \App\Lib\DataTable\DataTable::init();
        $dt->setDataSource('/admin/money/getWithdrawList');
        $dt->setLang('withdrawRule');
        $dt->addColsFields('account_identity', ['templet' => '#account_identity']);
        $dt->addColsFields('bettingMoney');
        $dt->addColsFields('needBettingMoney');
        $dt->addColsFields('start_time');
        $dt->addColsFields('end_time');
        //$dt->enableCheckBox ();
        $arr[] = 'editRule';
        $dt->setToolBar($arr, array('width' => 140));
        return view('admin.withdraw/rules', $dt->render($request));
    }

    /**
     * 修改用户提现规则页面
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function editRule()
    {
        $id = Request::has('id') ? Request::get('id') : '';
        if ($id) {
            $data = Withdraw_rule::getRule($id);

            return view('admin.withdraw.editRule', ['data' => $data]);
        }

        die('error');
    }

}


function test()
{
    $db = new \App\Models\Money_recharge;
    $data = $db->text();
    print_r($data);
}

