<?php


namespace App\dao\Pay;


use App\Facade\TableName;
use Illuminate\Support\Facades\DB;

class Recharge
{
    // 充值轮询验证
    public function poll()
    {
        $PollSwitch = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
            ->where('StatusName', 'PollSwitch')
            ->value('StatusValue');
        if ($PollSwitch) {
            $names = DB::table(TableName::agent() . 'admin_configs')
                ->where('type', 'pay')
                ->select('id', 'name', 'new_pay_type')
                ->orderBy('pay_error')
                ->orderByDesc('sort')
                ->get()->map(function ($value) {
                    return (array)$value;
                })->toArray();

        } else {
            $names = DB::table('agent.dbo.admin_configs')->where('type', 'pay')->select('id', 'name', 'new_pay_type')->orderByDesc('sort')->get()->map(function ($value) {
                return (array)$value;
            })->toArray();
        }

        return $names;
    }
}
