<?php


namespace App\Http\Controllers\Admin;


use App\Http\helper\Helper;
use App\Http\helper\NumConfig;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class ExtensionController
{
    // -----------------------------------------------------------------------邀请注册------------------------------------------------------------------------------
    // 推广奖金审核
    public function verify(Request $request)
    {

        $NickName = $request->NickName ?: '';
        $GameID = $request->GameID ?: '';
        $mobile = $request->mobile ?: '';
        $SpreaderID = $request->SpreaderID ?: '';
        $start_time = $request->start_time ?: '';
        $end_time = $request->end_time ?: '';
        $Type = $request->Type ?: '';
        $Sort = $request->Sort ?: '';
        $FinalScoreSort = $request->FinalScoreSort ?: '';


        if (!empty($SpreaderID)) {
            $getSpreaderID = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo ')
                    ->where('GameID', $SpreaderID)
                    ->select('UserID')
                    ->first()->UserID ?? '';
        }

        $where = [];

        !empty($NickName) && $where[] = ['ai.NickName', 'like', $NickName . '%'];
        !empty($GameID) && $where[] = ['ai.GameID', $GameID];
        !empty($getSpreaderID) && $where[] = ['ai.SpreaderID', $getSpreaderID];
        !empty($start_time) && $where[] = ['ai.RegisterDate', '>=', $start_time];
        !empty($end_time) && $where[] = ['ai.RegisterDate', '<=', $end_time];


        if (!empty($mobile)) {
            $PhoneNum = DB::connection('read')->table('QPAccountsDB.dbo.AccountPhone')
                ->where('PhoneNum', $mobile)
                ->pluck('UserID')->toArray();
            if (!empty($PhoneNum)) {
                $where[] = [function ($where) use ($PhoneNum) {
                    $where->whereIn('vy.UserID', $PhoneNum);
                }];
            }
        }

        if (!empty($Type)) {
            $TypeData = explode(',', trim($Type, ','));
            if (!empty($TypeData)) {
                $where[] = [function ($where) use ($TypeData) {
                    $where->whereIn('vy.Type', $TypeData);
                }];
            }

        }

        // 审核可见金额
        $visibleAmount = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'VerifyScore')
            ->first();

        $UpperLimit = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'UpperLimit')
            ->first();

        // 自动审核开关
        $AutoVerify = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'AutoVerify')
            ->value('StatusValue');

        $where[] = ['TotalScore', '>=', $visibleAmount->StatusValue];
        $where[] = ['Status', 0];

        $field = ['vy.Remarks', 'vy.ReceivedScore', 'vy.OverLook', 'vy.id', 'ua.UserID', 'Higher1ID', 'Higher2ID', 'downCount1', 'downCount2', 'ai.GameID', 'ai.RegisterDate', 'FinalScore', 'TotalScore', 'vy.Type', 'ai.SpreaderID'];


        $SQL = DB::connection('write')->table('agent.dbo.extension_verify as vy')
            ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'vy.UserID', 'ai.UserID')
            ->join('QPAccountsDB.dbo.UserAgent as ua', 'vy.UserID', 'ua.UserID')
            ->where($where)
            ->select($field)
            ->orderBy('OverLook', 'asc');

        // 历史通过审核金排序
        if (!empty($FinalScoreSort)) {
            $SQL = $SQL->orderBy("FinalScore", $FinalScoreSort);
        }

        // 待审金额排序
        if (!empty($Sort)) {
            $SQL = $SQL->orderBy("TotalScore", $Sort);
        }

        // 待审金额 默认排序 倒叙
        if (empty($Sort) && empty($FinalScoreSort)) {
            $SQL = $SQL->orderBy("TotalScore", 'desc');
        }

        $list = $SQL->paginate(10);


        $UserIDs = [];
        $SpreaderIDs = [];
        foreach ($list as $v) {
            $UserIDs[] = $v->UserID;
            $SpreaderIDs[] = $v->SpreaderID;
        }

        // 获取上级ID 'ai1.GameID as SpreaderID'
        $getSpreaderID = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
            ->whereIn('UserID', $SpreaderIDs)
            ->select('GameID', 'UserID')
            ->pluck('GameID', 'UserID')->toArray();

        // 获取来源人数
        $user_profit_log = DB::connection('write')->table('agent.dbo.extension_user_profit_log')
            ->where('OrderID', 0)
            ->whereIn('UserID', $UserIDs)
            ->selectRaw('IsNull(sum(NoteCount),0) NoteCount,UserID,Type')
            ->where('Status', 1)
            ->groupBy('UserID', 'Type')
            ->get();
        foreach ($user_profit_log as &$value) {
            $InvitationUserIDs = DB::connection('write')->table('agent.dbo.extension_user_profit_log')
                ->where('UserID', $value->UserID)
                ->where('Status', 1)
                ->where('OrderID', 0)
                ->where('Type', $value->Type)
                ->select('InvitationUserIDs')
                ->pluck('InvitationUserIDs')->toArray();
            $value->InvitationUserIDs = implode(',', $InvitationUserIDs);
        }
        unset($value);

        $rewards = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew')
            ->where('ScoreType', 36)
            ->whereIn('UserID', $UserIDs)
            ->selectRaw('sum(Score) Score,UserID')
            ->groupBy('UserID')
            ->pluck('Score', 'UserID')->toArray();
        $service = new Extension();
        foreach ($list as &$value) {

            $value->count = $value->rechargeCount = $value->RechargeSum = 0;
            $value->TotalScore = number_float($value->TotalScore / NumConfig::NUM_VALUE);
            $value->ReceivedScore = number_float($value->ReceivedScore / NumConfig::NUM_VALUE);
            $value->SpreaderID = isset($getSpreaderID[$value->SpreaderID]) ? $getSpreaderID[$value->SpreaderID] : '';

            // 来源人数,充值金额，充值人数
            $service->sourcePlayer($user_profit_log, $value);

            $reward = isset($rewards[$value->UserID]) ? $rewards[$value->UserID] : 0;

            $TotalReward1 = DB::connection('read')->table('QPAccountsDB.dbo.UserAgent')
                    ->where('Higher1ID', $value->UserID)
                    ->selectRaw('IsNull(sum(TotalReward1),0)  TotalReward')
                    ->first()->TotalReward ?? 0;
            $TotalReward2 = DB::connection('read')->table('QPAccountsDB.dbo.UserAgent')
                    ->Where('Higher2ID', $value->UserID)
                    ->selectRaw('IsNull(sum(TotalReward2),0) TotalReward')
                    ->first()->TotalReward ?? 0;
            $value->Total = number_float(($reward + $TotalReward1 + $TotalReward2 + $value->FinalScore) / NumConfig::NUM_VALUE);

            $value->FinalScore = number_float($value->FinalScore / NumConfig::NUM_VALUE);
        }
        unset($value);


        $visibleAmount->StatusValue /= NumConfig::NUM_VALUE;
        $UpperLimit->StatusValue /= NumConfig::NUM_VALUE;
        $start_time = Helper::timeChange($start_time);
        $end_time = Helper::timeChange($end_time);
        $data = compact('list', 'GameID', 'SpreaderID', 'start_time', 'end_time', 'mobile', 'NickName', 'Type', 'visibleAmount', 'Sort', 'UpperLimit', 'FinalScoreSort', 'AutoVerify');
        return view('admin.extension.verify', $data);
    }

    // 推广奖金审核 -- 修改状态
    public function verify_update(Request $request, $id)
    {
        $field = $request->field;
        $value = $request->value;
        $UserID = $request->UserID;
        $TotalScore = $request->TotalScore;


        $data[$field] = $value;

        if ($field == 'Status') {

            $first = DB::connection('write')->table('agent.dbo.extension_verify')
                ->where('id', $id)
                ->first();

            // 添加记录
            DB::connection('write')->table('agent.dbo.extension_verify_log')
                ->insert([
                    'UserID' => $UserID,
                    'AgreeScore' => $TotalScore * NumConfig::NUM_VALUE,
                    'CreateTime' => date('Y-m-d H:i:s'),
                    'Remarks' => $first->Remarks,
                    'Type' => $first->Type,
                ]);

            $data['Remarks'] = '';
        }

        DB::connection('write')->table('agent.dbo.extension_verify')
            ->where('id', $id)
            ->update($data);
        return apiReturnSuc();
    }

    // 注册奖金配置
    public function register_config()
    {
        $list = DB::connection('write')->table('agent.dbo.extension_config')
            ->where('type', 1)
            ->paginate(10);

        foreach ($list as &$value) {

            foreach ($value as $key => &$val) {
                if ($key != 'id' && $key != 'name' && $key != 'level_quota_number' && $key != 'two_level_quota_number') {
                    $val /= NumConfig::NUM_VALUE;
                }
            }

        }
        return view('admin.extension.register_config', compact('list'));
    }

    // 注册奖金配置 -- 添加
    public function register_config_add(Request $request)
    {
        if ($request->isMethod('post')) {
            $post = $request->post();
            foreach ($post as $key => &$value) {

                if ($key != 'name' && $key != 'level_quota_number' && $key != 'two_level_quota_number') {
                    $value *= NumConfig::NUM_VALUE;
                }
            }
            DB::connection('write')->table('agent.dbo.extension_config')->insert($post);
            return apiReturnSuc();
        }

        return view('admin.extension.register_config_add');
    }

    // 注册奖金配置 -- 修改
    public function register_config_update(Request $request, $id)
    {
        if ($request->isMethod('post')) {
            $post = $request->post();
            foreach ($post as $key => &$value) {

                if ($key != 'name' && $key != 'level_quota_number' && $key != 'two_level_quota_number') {
                    $value *= NumConfig::NUM_VALUE;
                }
            }

            DB::connection('write')->table('agent.dbo.extension_config')
                ->where('id', $id)
                ->update($post);
            return apiReturnSuc();
        }


        $info = DB::connection('write')->table('agent.dbo.extension_config')
            ->where('id', $id)
            ->first();

        foreach ($info as $key => &$value) {
            if ($key != 'id' && $key != 'name' && $key != 'level_quota_number' && $key != 'two_level_quota_number') {
                $value /= NumConfig::NUM_VALUE;
            }
        }
        return view('admin.extension.register_config_update', compact('info'));
    }

    // 裂变可领额度上限配置
    public function upperLimit(Request $request)
    {
        if ($request->isMethod('post')) {
            $post = $request->post();
            $post['StatusValue'] *= NumConfig::NUM_VALUE;

            DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
                ->where('StatusName', 'UpperLimit')
                ->update($post);

            return apiReturnSuc();
        }


        $info = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'UpperLimit')
            ->first();

        $info->StatusValue /= NumConfig::NUM_VALUE;
        return view('admin.extension.upper_limit', compact('info'));
    }

    // 审核可见分数修改
    public function verifyScore(Request $request)
    {
        if ($request->isMethod('post')) {
            $post = $request->post();
            $post['StatusValue'] *= NumConfig::NUM_VALUE;

            DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
                ->where('StatusName', 'VerifyScore')
                ->update($post);

            return apiReturnSuc();
        }


        $info = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'VerifyScore')
            ->first();

        $info->StatusValue /= NumConfig::NUM_VALUE;
        return view('admin.extension.verify_score', compact('info'));
    }

    // 待审核页面的备注
    public function verifyRemarks(Request $request, $UserID)
    {
        $post = $request->post();
        DB::connection('write')->table('agent.dbo.extension_verify')
            ->where('UserID', $UserID)
            ->update($post);

        return apiReturnSuc();
    }

    // 奖励来源
    public function userSource(Request $request)
    {
        $UserID = $request->UserID ?: '';
        $Type = $request->Type ?: '';
        $GameID = $request->GameID ?: '';
        $OrderID = $request->OrderID ?: 0;

        if (!empty($OrderID) || $OrderID === 0) {

            $list = DB::connection('write')->table('agent.dbo.extension_user_profit_log')
                ->where('OrderID', $OrderID)
                ->where('UserID', $UserID)
                ->where('Type', $Type)
                ->where('Status', 1)
                ->paginate(10);
        } else {

            $list = DB::connection('write')->table('agent.dbo.extension_user_profit_log')
                ->where('UserID', $UserID)
                ->where('Type', $Type)
                ->where('OrderID', 0)
                ->where('Status', 1)
                ->paginate(10);
        }

        foreach ($list as &$value) {
            $value->toGold /= NumConfig::NUM_VALUE;

        }

        unset($value);


        return view('admin.extension.user_source', compact('list', 'UserID', 'Type', 'GameID'));
    }

    // 审核通过列表
    public function verifyFinal(Request $request)
    {
        $NickName = $request->NickName ?: '';
        $GameID = $request->GameID ?: '';
        $mobile = $request->mobile ?: '';
        $SpreaderID = $request->SpreaderID ?: '';
        $start_time = $request->start_time ?: '';
        $end_time = $request->end_time ?: '';
        $Type = $request->Type ?: '';
        $Sort = $request->Sort ?: '';
        $CreateTimeStart = $request->CreateTimeStart ?: '';
        $CreateTimeEnd = $request->CreateTimeEnd ?: '';


        if (!empty($SpreaderID)) {
            $getSpreaderID = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo ')
                    ->where('GameID', $SpreaderID)
                    ->select('UserID')
                    ->first()->UserID ?? '';
        }

        $where = [];

        !empty($NickName) && $where[] = ['ai.NickName', 'like', $NickName . '%'];
        !empty($GameID) && $where[] = ['ai.GameID', $GameID];
        !empty($getSpreaderID) && $where[] = ['ai.SpreaderID', $getSpreaderID];
        !empty($start_time) && $where[] = ['ai.RegisterDate', '>=', $start_time];
        !empty($end_time) && $where[] = ['ai.RegisterDate', '<=', $end_time];
        !empty($CreateTimeStart) && $where[] = ['log.CreateTime', '>=', $CreateTimeStart];
        !empty($CreateTimeEnd) && $where[] = ['log.CreateTime', '<=', $CreateTimeEnd];
        !empty($Type) && $where[] = ['vy.Type', $Type];

        if (!empty($mobile)) {
            $PhoneNum = DB::connection('read')->table('QPAccountsDB.dbo.AccountPhone')
                ->where('PhoneNum', $mobile)
                ->pluck('UserID')->toArray();
            if (!empty($PhoneNum)) {
                $where[] = [function ($where) use ($PhoneNum) {
                    $where->whereIn('vy.UserID', $PhoneNum);
                }];
            }
        }


        // 审核可见金额
        $visibleAmount = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'VerifyScore')
            ->first();

        $UpperLimit = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'UpperLimit')
            ->first();


        $field = ['log.id', 'log.OrderID', 'log.CreateTime', 'log.UpdateTime', 'log.Remarks', 'AgreeScore', 'log.FinalScore as logFinalScore', 'vy.ReceivedScore', 'vy.OverLook', 'ua.UserID', 'Higher1ID', 'Higher2ID', 'downCount1', 'downCount2', 'ai.GameID', 'ai.RegisterDate', 'vy.FinalScore', 'TotalScore', 'log.Type', 'ai.SpreaderID'];

        $SQL = DB::connection('write')->table('agent.dbo.extension_verify_log as log')
            ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'log.UserID', 'ai.UserID')
            ->leftjoin('agent.dbo.extension_verify as vy', function ($join) {
                $join->on('log.UserID', 'vy.UserID')->on('log.Type', 'vy.Type');
            })
            ->join('QPAccountsDB.dbo.UserAgent as ua', 'log.UserID', 'ua.UserID')
            ->where($where)
            ->select($field)
            ->orderBy('CreateTime', 'desc');

        if (!empty($Sort)) {
            $list = $SQL->orderBy("TotalScore", $Sort)->paginate(10);
        } else {
            $list = $SQL->orderBy('TotalScore', 'desc')->paginate(10);
        }


        $OrderIDs = [];
        $SpreaderIDs = [];
        $UserIDs = [];

        foreach ($list as $v) {
            $OrderIDs[] = $v->OrderID;
            $SpreaderIDs[] = $v->SpreaderID;
            $UserIDs[] = $v->UserID;
        }


        // 获取上级ID 'ai1.GameID as SpreaderID'
        $getSpreaderID = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
            ->whereIn('UserID', $SpreaderIDs)
            ->select('GameID', 'UserID')
            ->pluck('GameID', 'UserID')->toArray();

        $user_profit_log = DB::connection('write')->table('agent.dbo.extension_user_profit_log')
            ->whereIn('OrderID', $OrderIDs)
            ->whereIn('UserID', $UserIDs)
            ->selectRaw('IsNull(sum(NoteCount),0) NoteCount,OrderID,UserID,Type')
            ->groupBy('OrderID', 'UserID', 'Type')
            ->get();

        $user_profit_log1 = DB::connection('write')->table('agent.dbo.extension_user_profit_log')
            ->whereIn('OrderID', $OrderIDs)
            ->whereIn('UserID', $UserIDs)
            ->selectRaw('count(distinct(InvitationUserIDs)) NoteCount,OrderID')
            ->groupBy('OrderID')
            ->pluck('NoteCount', 'OrderID')->toArray();


        foreach ($list as &$value) {
            $value->count = 0;
            $value->TotalScore = number_float($value->TotalScore / NumConfig::NUM_VALUE);
            $value->ReceivedScore = number_float($value->ReceivedScore / NumConfig::NUM_VALUE);
            $value->logFinalScore = !empty($value->logFinalScore) ? number_float($value->logFinalScore / NumConfig::NUM_VALUE) : '';
            $value->AgreeScore = number_float($value->AgreeScore / NumConfig::NUM_VALUE);

            // 来源人数
            if ($value->Type == 1) {
                foreach ($user_profit_log as $val) {
                    if ($val->UserID == $value->UserID && $val->Type == $value->Type) {
                        $value->count = $val->NoteCount;
                    }
                }
            } else {
                $value->count = isset($user_profit_log1[$value->OrderID]) ? $user_profit_log1[$value->OrderID] : 0;
            }

            $value->SpreaderID = isset($getSpreaderID[$value->SpreaderID]) ? $getSpreaderID[$value->SpreaderID] : '';


            $reward = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew')
                    ->where('ScoreType', 36)
                    ->where('UserID', $value->UserID)
                    ->selectRaw('sum(Score) Score')
                    ->first()->Score ?? 0;

            $TotalReward1 = DB::connection('read')->table('QPAccountsDB.dbo.UserAgent')
                    ->where('Higher1ID', $value->UserID)
                    ->selectRaw('IsNull(sum(TotalReward1),0)  TotalReward')
                    ->first()->TotalReward ?? 0;
            $TotalReward2 = DB::connection('read')->table('QPAccountsDB.dbo.UserAgent')
                    ->Where('Higher2ID', $value->UserID)
                    ->selectRaw('IsNull(sum(TotalReward2),0) TotalReward')
                    ->first()->TotalReward ?? 0;
            $value->Total = number_float(($reward + $TotalReward1 + $TotalReward2 + $value->FinalScore) / NumConfig::NUM_VALUE);

            $value->FinalScore = number_float($value->FinalScore / NumConfig::NUM_VALUE);
        }


        $visibleAmount->StatusValue /= NumConfig::NUM_VALUE;
        $UpperLimit->StatusValue /= NumConfig::NUM_VALUE;

        $start_time = Helper::timeChange($start_time);
        $end_time = Helper::timeChange($end_time);
        $CreateTimeStart = Helper::timeChange($CreateTimeStart);
        $CreateTimeEnd = Helper::timeChange($CreateTimeEnd);
        $data = compact('list', 'GameID', 'SpreaderID', 'start_time', 'end_time', 'mobile', 'NickName', 'Type', 'visibleAmount', 'Sort', 'UpperLimit', 'CreateTimeStart', 'CreateTimeEnd');
        return view('admin.extension.verify_final', $data);
    }

    // 审核通过列表页面的备注
    public function verifyFinalRemarks(Request $request, $ID)
    {

        $post = $request->post();
        DB::connection('write')->table('agent.dbo.extension_verify_log')
            ->where('id', $ID)
            ->update($post);

        return apiReturnSuc();
    }

    // -----------------------------------------------------------------------游戏对局------------------------------------------------------------------------------
    // 游戏对局 ---- 配置
    public function gameCountConfig(Request $request)
    {
        $list = DB::connection('write')->table('agent.dbo.extension_config')
            ->where('type', 2)
            ->paginate(10);

        foreach ($list as &$value) {

            foreach ($value as $key => &$val) {
                if ($key != 'id' && $key != 'name' && $key != 'level_quota_number' && $key != 'two_level_quota_number') {
                    $val /= NumConfig::NUM_VALUE;
                }
            }

        }
        return view('admin.extension.gamecount_config', compact('list'));
    }


    // 注册奖金配置 -- 添加
    public function gameCountConfig_add(Request $request)
    {
        if ($request->isMethod('post')) {
            $post = $request->post();
            foreach ($post as $key => &$value) {

                if ($key != 'name' && $key != 'level_quota_number' && $key != 'two_level_quota_number') {
                    $value *= NumConfig::NUM_VALUE;
                }
            }
            $post['type'] = 2;
            DB::connection('write')->table('agent.dbo.extension_config')->insert($post);
            return apiReturnSuc();
        }

        return view('admin.extension.gamecount_config_add');
    }

    // 注册奖金配置 -- 修改
    public function gameCountConfig_update(Request $request, $id)
    {
        if ($request->isMethod('post')) {
            $post = $request->post();
            foreach ($post as $key => &$value) {

                if ($key != 'name' && $key != 'level_quota_number' && $key != 'two_level_quota_number') {
                    $value *= NumConfig::NUM_VALUE;
                }
            }

            DB::connection('write')->table('agent.dbo.extension_config')
                ->where('id', $id)
                ->update($post);
            return apiReturnSuc();
        }


        $info = DB::connection('write')->table('agent.dbo.extension_config')
            ->where('id', $id)
            ->first();

        foreach ($info as $key => &$value) {
            if ($key != 'id' && $key != 'name' && $key != 'level_quota_number' && $key != 'two_level_quota_number') {
                $value /= NumConfig::NUM_VALUE;
            }
        }
        return view('admin.extension.gamecount_config_update', compact('info'));
    }

    // 裂变可领额度上限配置
    public function gameCountLimit(Request $request)
    {
        if ($request->isMethod('post')) {
            $post = $request->post();
            $post['StatusValue'] *= NumConfig::NUM_VALUE;

            DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
                ->where('StatusName', 'GameCountLimit')
                ->update($post);

            return apiReturnSuc();
        }


        $info = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'GameCountLimit')
            ->first();

        $info->StatusValue /= NumConfig::NUM_VALUE;
        return view('admin.extension.gamecount_limit', compact('info'));
    }

    // 自动审核开关
    public function autoVerify(Request $request)
    {
        $StatusValue = $request->StatusValue;

        DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'AutoVerify')
            ->update(['StatusValue' => $StatusValue]);
        return apiReturnSuc();
    }

    public function recharge_rate(Request $request)
    {
        if ($request->isMethod('post')) {
            $post = $request->post();

            if (is_array($post)) {
                foreach ($post as $key => $value) {

                    DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
                        ->where('StatusName', $key)
                        ->update(['StatusValue' => $value * NumConfig::NUM_VALUE]);
                }
            }
            return apiReturnSuc();
        }

        $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'AgentRebateRatio1')
            ->orWhere('StatusName', 'AgentRebateRatio2')
            ->get();
        return view('admin.extension.recharge_rate',compact('list'));
    }
}
