<?php


namespace App\Services;

use Illuminate\Support\Facades\DB;


class GameRoomInfo
{
//    const OpenKindItem = [917,2012,3010,4000,4010,4020];


    // 群控总库存
    public static function RoomStock($where = [], $except = [])
    {

        $buildSql = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo');
        !empty($except) && $buildSql->whereNotIn('ServerID', $except);

        !empty($where) && $buildSql->whereIn('GameID', $where);
        $RoomStock = $buildSql->pluck('RoomStock');

        $groupControlTotalStock = 0;
        foreach ($RoomStock as $key => $val) {
            $explode = explode(':', explode(';', $val)[0])[1] ?? 0;
            $groupControlTotalStock += $explode;
        }

        return $groupControlTotalStock;
    }
}
