post('kind_id'); $game_level = $request->post('game_level'); $toArr = explode('-', $game_level); $GameID = $toArr[0] ?? ''; $SortID = $toArr[1] ?? ''; $gameType = $request->gameType ?: ''; $room_list = []; if (!empty($kind_id)) { $where[] = ['ki.KindID', '=', $kind_id]; $room_list = DB::connection('write')->table('QPPlatformDB.dbo.RoomConfig') ->where('GameID', $GameID) ->select('GameID', 'RoomName', 'SortID') ->get(); } $where = []; !empty($GameID) && $where[] = ['rc.GameID', $GameID]; !empty($SortID) && $where[] = ['rc.SortID', $SortID]; if (!empty($gameType)) { $gameType = explode(',', $gameType); $where[] = [function ($query) use ($gameType) { $query->whereIn('rc.GameID', $gameType); }]; } $game_name = DB::connection('read')->table('QPPlatformDB.dbo.GameKindItem') ->whereIn('GameID', config('games.openKGame')) ->pluck('KindName as GameName', 'GameID');//单选框数据 $KindName = DB::connection('read')->table('QPPlatformDB.dbo.GameKindItem')->pluck('KindName', 'GameID')->toArray(); $GameRoomInfo = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo')->select('ServerID', 'GameID', 'SortID')->get(); $list = DB::connection('write')->table('QPPlatformDB.dbo.RoomConfig as rc') ->whereIn('rc.GameID', config('games.openKGame')) ->leftJoin('QPPlatformDB.dbo.RoomStockDay as rsd', function ($join) use ($date) { $join->on('rc.GameID', 'rsd.GameID')->on('rc.SortID', 'rsd.SortID')->where('DateID', $date); })->leftjoin('QPPlatformDB.dbo.RoomStockStatic as rs', function ($join) { $join->on('rc.GameID', 'rs.GameID')->on('rc.SortID', 'rs.SortID'); }) ->where($where) ->select('rc.GameID', 'rc.SortID') ->selectRaw('IsNull(Revenue,0) Revenue,IsNull(RevenueD,0) RevenueD,IsNull(Stock,0) Stock,IsNull(TurnOver,0) TurnOver,IsNull(Winlost,0) Winlost,RoomName') ->orderBy('rc.GameID') ->paginate(10); foreach ($list as &$value) { $value->WinRate = $value->LostRate = $value->ServerID = ''; foreach ($GameRoomInfo as $val) { if (($value->GameID == $val->GameID) && ($value->SortID == $val->SortID)) { $value->ServerID = $val->ServerID; continue; } } $value->KindName = $KindName[$value->GameID] ?? ''; $value->ShaLv = (int)$value->TurnOver > 0 ? round(($value->Winlost / $value->TurnOver) * 100, 2) : 0; $value->Stock /= NumConfig::NUM_VALUE; $value->Revenue /= NumConfig::NUM_VALUE; $value->RevenueD /= NumConfig::NUM_VALUE; $value->TurnOver /= NumConfig::NUM_VALUE; $value->Winlost /= NumConfig::NUM_VALUE; // 当前系统输赢概率 $ShaLv = $value->ShaLv * NumConfig::NUM_VALUE; $first = DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig') ->where('GameID', $value->GameID) ->where('SortID', $value->SortID) ->whereRaw("$ShaLv between KillRateMin and KillRateMax") ->first(); if ($first) { $value->WinRate = round($first->WinRate / NumConfig::NUM_VALUE, 2) . '%'; $value->LostRate = round($first->LostRate / NumConfig::NUM_VALUE, 2) . '%'; } switch ($value->SortID) { default: $value->SortIDTxt = $value->SortID; break; } } unset($value); if (!empty($gameType)) { $gameType = implode(',', $gameType); } return view('admin.GroupControlRecord.control', [ 'list' => $list, 'kind_id' => $kind_id, 'game_level' => $game_level, 'game_name' => $game_name, 'room_list' => $room_list, 'gameType' => $gameType, 'SortID' => $SortID ]); } // 查看群控配置 public function show_control_config(Request $request, $GameID) { $SortID = $request->SortID ?: ''; $date = date('Ymd'); $info = DB::connection('write')->table('QPPlatformDB.dbo.RoomConfig as rc') ->leftJoin('QPPlatformDB.dbo.RoomStockDay as rsd', function ($join) use ($date) { $join->on('rc.GameID', 'rsd.GameID')->on('rc.SortID', 'rsd.SortID')->where('DateID', $date); }) ->where('rc.GameID', $GameID) ->where('rc.SortID', $SortID) ->select('rc.GameID', 'rc.SortID') ->selectRaw('IsNull(rsd.Winlost,0) Winlost,IsNull(rsd.TurnOver,0) TurnOver') ->first(); // 展示配置 $where[] = ['GameID', $GameID]; $where[] = ['SortID', $SortID]; $showConfig = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as rc') ->where($where) ->select('CellScore', 'MinEnterScore', 'MaxEnterScore', 'ServerName', 'CellScore') ->first(); if ($showConfig) { $showConfig->CellScore = $showConfig->CellScore / NumConfig::NUM_VALUE; $showConfig->MinEnterScore = number_float($showConfig->MinEnterScore / NumConfig::NUM_VALUE); $showConfig->MaxEnterScore = number_float($showConfig->MaxEnterScore / NumConfig::NUM_VALUE); } $list = DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig')->where($where)->get(); if ($list->isNotEmpty()) { foreach ($list as &$val) { $val->KillRateMin = round($val->KillRateMin / NumConfig::NUM_VALUE, 2) . '%'; $val->KillRateMax = round($val->KillRateMax / NumConfig::NUM_VALUE, 2) . '%'; $val->WinRate = round($val->WinRate / NumConfig::NUM_VALUE, 2) . '%'; $val->LostRate = round($val->LostRate / NumConfig::NUM_VALUE, 2) . '%'; } unset($val); } if (!empty($info)) { $info->Winlost /= NumConfig::NUM_VALUE; $info->TurnOver /= NumConfig::NUM_VALUE; $info->ShaLv = $info->TurnOver > 0 ? round(($info->Winlost / $info->TurnOver) * NumConfig::NUM_VALUE, 2) : 0; } $data = compact('GameID', 'SortID', 'list', 'info', 'showConfig'); return view('admin.GroupControlRecord.show_control_config', $data); } public function control_del($ID) { if (empty($ID)) return apiReturnFail('缺少参数'); DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig') ->where('ID', $ID) ->delete(); return apiReturnSuc(); } // 添加配置 public function control_add(Request $request, $GameID) { $SortID = $request->SortID; $where[] = ['GameID', $GameID]; $where[] = ['SortID', $SortID]; if ($request->isMethod('post')) { $post = $request->all(); $post['GameID'] = $GameID; $post['Status'] = 1; $KillRateMin = $post['KillRateMin']; $KillRateMax = $post['KillRateMax']; $first = DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig') ->where($where) ->whereRaw("($KillRateMin between KillRateMin and KillRateMax or $KillRateMax between KillRateMin and KillRateMax)") ->first(); if ($first) { return apiReturnFail('档位已存在'); } $count = DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig')->where($where)->count(); if ($count >= 10) { return apiReturnFail('档位达到创建数量限制'); } DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig')->insert($post); return apiReturnSuc(); } else { $data = compact('GameID', 'SortID'); return view('admin.GroupControlRecord.control_add', $data); } } // 修改配置 public function control_update(Request $request, $GameID) { $SortID = $request->SortID; $id = $request->ID ?: ''; $where[] = ['GameID', $GameID]; $where[] = ['SortID', $SortID]; if ($request->isMethod('post')) { $post = $request->all(); $post['GameID'] = $GameID; $KillRateMin = $post['KillRateMin']; $KillRateMax = $post['KillRateMax']; $first = DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig') ->where('ID', '<>', $id) ->where($where) ->whereRaw("($KillRateMin between KillRateMin and KillRateMax or $KillRateMax between KillRateMin and KillRateMax)") ->first(); if ($first) { return apiReturnFail('档位已存在'); } $count = DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig')->where($where)->count(); if ($count >= 10) { return apiReturnFail('档位达到创建数量限制'); } unset($post['ID']); DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig')->where('ID', $id)->update($post); return apiReturnSuc(); } else { $info = DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig')->where('ID', $id)->first(); $data = compact('GameID', 'SortID', 'info'); return view('admin.GroupControlRecord.control_update', $data); } } // 修改状态 public function control_updateStatus(Request $request, $id) { $status = $request->status ?: 1; $date = date('Ymd'); DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig')->where('ID', $id)->update(['Status' => $status]); return apiReturnSuc(); } // 刷新数据 public function sync_res(Request $request, $GameID) { $SortID = $request->SortID ?: ''; $where[] = ['rsd.GameID', $GameID]; $where[] = ['rsd.SortID', $SortID]; $date = date('Ymd'); $GameRoomInfo = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo') ->where('GameID', $GameID) ->where('SortID', $SortID) ->select('ServerID') ->first(); $info = DB::connection('write')->table('QPPlatformDB.dbo.RoomStockDay as rsd') ->leftjoin('QPPlatformDB.dbo.RoomStockStatic as rs', function ($join) { $join->on('rsd.GameID', 'rs.GameID')->on('rsd.SortID', 'rs.SortID'); }) ->where('DateID', $date) ->where($where) ->select('rsd.GameID', 'rsd.SortID', 'rs.Revenue', 'rs.RevenueD', 'rs.Stock', 'TurnOver', 'Winlost') ->first(); if (empty($info)) { return apiReturnFail('刷新失败'); } $info->ServerID = $GameRoomInfo->ServerID ?? ''; $info->WinRate = $info->LostRate = ''; $info->ShaLv = (int)$info->TurnOver > 0 ? round(($info->Winlost / $info->TurnOver) * 100, 2) : 0; $info->Stock /= NumConfig::NUM_VALUE; $info->Revenue /= NumConfig::NUM_VALUE; $info->RevenueD /= NumConfig::NUM_VALUE; $info->TurnOver /= NumConfig::NUM_VALUE; $info->Winlost /= NumConfig::NUM_VALUE; // 当前系统输赢概率 $ShaLv = $info->ShaLv * NumConfig::NUM_VALUE; $first = DB::connection('write')->table('QPPlatformDB.dbo.RoomStockConfig') ->where('GameID', $info->GameID) ->where('SortID', $info->SortID) ->whereRaw("$ShaLv between KillRateMin and KillRateMax") ->first(); if ($first) { $info->WinRate = round($first->WinRate / NumConfig::NUM_VALUE, 2) . '%'; $info->LostRate = round($first->LostRate / NumConfig::NUM_VALUE, 2) . '%'; } return apiReturnSuc($info); } // 下拉框搜索 public function roomList(Request $request) { $GameID = (int)$request->post('GameID'); $sql = $room_list = DB::connection('write')->table('QPPlatformDB.dbo.RoomConfig') ->where('GameID', $GameID) ->select('GameID', 'RoomName', 'SortID'); $list = $sql->get(); return apiReturnSuc($list); } // 群控房间列表 public function room(Request $request) { $kind_id = $request->post('kind_id'); $game_level = $request->post('game_level'); $toArr = explode('-', $game_level); $GameID = $toArr[0] ?? ''; $SortID = $toArr[1] ?? ''; $gameType = $request->gameType ?: ''; $room_list = []; $game_name = DB::connection('read')->table('QPPlatformDB.dbo.GameKindItem') ->whereIn('GameID', config('games.openKGame')) ->pluck('KindName as GameName', 'GameID');//单选框数据 $KindName = DB::connection('read')->table('QPPlatformDB.dbo.GameKindItem')->pluck('KindName', 'GameID')->toArray(); if (!empty($kind_id)) { $where[] = ['ki.KindID', '=', $kind_id]; $room_list = DB::connection('write')->table('QPPlatformDB.dbo.RoomConfig') ->where('GameID', $GameID) ->select('GameID', 'RoomName', 'SortID') ->get(); } $where = []; !empty($GameID) && $where[] = ['rsd.GameID', $GameID]; !empty($SortID) && $where[] = ['rsd.SortID', $SortID]; // 游戏类型搜索 if (!empty($gameType)) { $gameType = explode(',', $gameType); $where[] = [function ($query) use ($gameType) { $query->whereIn('rc.GameID', $gameType); }]; } $list = DB::connection('write')->table('QPPlatformDB.dbo.RoomConfig as rc') ->whereIn('rc.GameID', config('games.openKGame')) ->leftjoin('QPPlatformDB.dbo.RoomStockDay as rsd', function ($join) { $join->on('rc.GameID', 'rsd.GameID')->on('rc.SortID', 'rsd.SortID')->where('DateID', date('Ymd')); }) ->where($where) ->select('rc.*') ->orderBy('rc.GameID') ->paginate(10); if (!empty($gameType)) { $gameType = implode(',', $gameType); } $data = compact('list', 'kind_id', 'room_list', 'KindName', 'game_name', 'gameType'); return view('admin.GroupControlRecord.room', $data); } // 添加群控房间配置 public function room_add(Request $request) { if ($request->isMethod('post')) { $post = $request->post(); $first = DB::connection('write')->table('QPPlatformDB.dbo.RoomConfig') ->where('GameID', $post['GameID']) ->where('SortID', $post['SortID']) ->first(); if ($first) { return apiReturnFail('房间配置已存在'); } DB::connection('write')->table('QPPlatformDB.dbo.RoomConfig')->insert($post); return apiReturnSuc(); } else { $gameKind = DB::connection('read')->table('QPPlatformDB.dbo.GameKindItem')->select('KindName', 'KindID')->get(); $sortID = [1, 2, 3, 4, 5, 6, 7]; $data = compact('sortID', 'gameKind'); return view('admin.GroupControlRecord.room_add', $data); } } public function room_update(Request $request, $id) { if ($request->isMethod('post')) { $post = $request->post(); DB::connection('write')->table('QPPlatformDB.dbo.RoomConfig') ->where('ID', $id) ->update($post); return apiReturnSuc(); } else { $info = DB::connection('write')->table('QPPlatformDB.dbo.RoomConfig')->where('ID', $id)->first(); return view('admin.GroupControlRecord.room_update', compact('info')); } } public function record(Request $request) { $server_id = $request->server_id ?: ''; $time = Helper::return_time($request); list($start_time, $end_time) = [$time['start_time'], $time['end_time']]; $where = []; !empty($server_id) && $where[] = ['server_id', '=', $server_id]; !empty($start_time) && $where[] = ['created_at', '>=', $start_time]; !empty($end_time) && $where[] = ['created_at', '<=', $end_time]; $list = GroupControlRecord::where($where)->orderBy('created_at', 'desc')->paginate(10); $server_ids = []; $admin_ids = []; foreach ($list as &$val) { $server_ids[] = $val->server_id; $admin_ids[] = $val->admin_id; } // 查询房间 $server_names = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo') ->whereIn('ServerID', $server_ids) ->pluck('ServerName', 'ServerID')->toArray(); // 查询管理员 $admin_names = DB::connection('read')->table('agent.dbo.admin_users') ->whereIn('id', $admin_ids) ->pluck('account', 'id')->toArray(); foreach ($list as &$val) { $val->ServerName = isset($server_names[$val->server_id]) ? $server_names[$val->server_id] : ''; $val->account = isset($admin_names[$val->admin_id]) ? $admin_names[$val->admin_id] : ''; } $room_list = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo') ->select('ServerID', 'ServerName') ->get(); return view('admin.GroupControlRecord.index', [ 'list' => $list, 'server_id' => $server_id, 'start_time' => $start_time, 'end_time' => $end_time, 'room_list' => $room_list ]); } public function show_config($id) { $filed = ['gi.GameID', 'gi.ServerName', 'gi.ServerID as gi_ServerID', 'RoomStock', 'ki.KindName', 'ki.KindID', 'si.*']; $config = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi') ->leftJoin('QPPlatformDB.dbo.GameKindItem as ki', 'ki.GameID', '=', 'gi.GameID') ->leftJoin('QPTreasureDB.dbo.StockConfigInfo as si', 'gi.ServerID', 'si.ServerID') ->where('gi.ServerID', $id) ->select($filed) ->first(); $config->BaseScore = $config->BaseScore / 100; return view('admin.GroupControlRecord.show_config', ['config' => $config]); } // 刮刮乐配置 public function award_allocation(Request $request) { if ($request->isMethod('post')) { } $list = DB::connection('write')->table('QPPlatformDB.dbo.ScratchCard') ->get(); foreach ($list as &$value) { $value->RewardScore = $value->RewardScore / NumConfig::NUM_VALUE; } return view('admin.GroupControlRecord.award_allocation', compact('list')); } // 刮刮乐配置修改 public function award_allocation_update(Request $request, $id) { if ($request->isMethod('post')) { $post = $request->post(); $CardLevel = $post['CardLevel']; $RewardRate = $post['RewardRate']; $RewardScore = $post['RewardScore']; $ImageID = $post['ImageID']; $RewardType = $post['RewardType']; $count = count($CardLevel); if ($count != count(array_unique($CardLevel))) { return apiReturnFail('等级重复'); } $data = []; for ($i = 0; $i < $count; $i++) { $data[$i]['CardLevel'] = $CardLevel[$i]; $data[$i]['RewardRate'] = $RewardRate[$i] ?? 0; $data[$i]['RewardScore'] = isset($RewardScore[$i]) ? $RewardScore[$i] * NumConfig::NUM_VALUE : 0; $data[$i]['CardID'] = $CardLevel[$i]; $data[$i]['RewardType'] = $RewardType[$i] ?? 0; $data[$i]['ImageID'] = $ImageID[$i] ?? 0; $data[$i]['RewardRound'] = 0; } DB::connection('write')->table('QPPlatformDB.dbo.ScratchCard') ->delete(); DB::connection('write')->table('QPPlatformDB.dbo.ScratchCard') ->insert($data); return apiReturnSuc(); } } // 幸运宝石 public function gemstone(Request $request) { $list = DB::connection('write')->table('QPPlatformDB.dbo.LuckyGemstone') ->get(); foreach ($list as &$value) { $value->RewardMul = $value->RewardMul / 10; } $LuckyGemstoneMul = DB::connection('write')->table('QPPlatformDB.dbo.LuckyGemstoneMul')->first(); // 倍数 /10 $LuckyGemstoneMul->CrownMul = $LuckyGemstoneMul->CrownMul / 10; $arr = explode(',', $LuckyGemstoneMul->DiamondTeamMul); $newArr = []; foreach ($arr as &$value) { $newArr[] = $value / 10; } $LuckyGemstoneMul->DiamondTeamMul = implode(',', $newArr); return view('admin.GroupControlRecord.gemstone', compact('list', 'LuckyGemstoneMul')); } // 幸运宝石修改 public function gemstone_update(Request $request) { if ($request->isMethod('post')) { $post = $request->post(); // +----------------------------------------------------------------------------------- $GemstoneLevel = $post['GemstoneLevel']; $RewardRate = $post['RewardRate']; $RewardMul = $post['RewardMul']; $count = count($GemstoneLevel); if ($count != count(array_unique($GemstoneLevel))) { return apiReturnFail('等级重复'); } $data = []; for ($i = 0; $i < $count; $i++) { $data[$i]['GemstoneLevel'] = $GemstoneLevel[$i]; $data[$i]['RewardRate'] = $RewardRate[$i] ?? 0; $data[$i]['RewardMul'] = isset($RewardMul[$i]) ? $RewardMul[$i] * 10 : 0; $data[$i]['GemstoneID'] = $GemstoneLevel[$i]; $data[$i]['RewardRound'] = 0; $data[$i]['RewardType'] = 0; } DB::connection('write')->table('QPPlatformDB.dbo.LuckyGemstone') ->delete(); DB::connection('write')->table('QPPlatformDB.dbo.LuckyGemstone') ->insert($data); // 服务器通知 // 向服务端发送通知 $url = config('transfer.stock')['url'] . 'loadLuckGemstone'; $data = [ ]; (new HttpCurl())->service($url, $data); return apiReturnSuc(); } } public function LuckyGemstoneMul() { $LuckyGemstoneMul = DB::connection('write')->table('QPPlatformDB.dbo.LuckyGemstoneMul')->first(); // 倍数 /10 $LuckyGemstoneMul->CrownMul = $LuckyGemstoneMul->CrownMul / 10; $arr = explode(',', $LuckyGemstoneMul->DiamondTeamMul); $newArr = []; foreach ($arr as &$value) { $newArr[] = $value / 10; } $LuckyGemstoneMul->DiamondTeamMul = $newArr; return view('admin.GroupControlRecord.LuckyGemstoneMul', compact('LuckyGemstoneMul')); } public function LuckyGemstoneMul_update(Request $request) { $post = $request->post(); // 钻石组倍数 $DiamondTeamMul = $post['DiamondTeamMul']; // 皇冠倍数 $CrownMul = $post['CrownMul'] * 10; if (count($DiamondTeamMul) != 15) { return apiReturnFail('钻石组组合倍数信息错误'); } // 检查第一个倍数 $RewardMul = DB::connection('write')->table('QPPlatformDB.dbo.LuckyGemstone')->pluck('RewardMul')->toArray(); $newArr = []; $num = 0; foreach ($DiamondTeamMul as &$value) { $mul = $value * 10; if (!in_array($mul, $RewardMul)) { return apiReturnFail('钻石组倍数不在范围内'); } $newArr[] = $mul; $num += $mul; } unset($value); if (!in_array($num, $RewardMul)) { return apiReturnFail('钻石组倍数和不在范围内'); } if (!in_array($CrownMul, $RewardMul)) { return apiReturnFail('皇冠倍数不在范围内'); } $LuckyGemstoneMul['DiamondTeamMul'] = implode(',', $newArr); $LuckyGemstoneMul['CrownMul'] = $post['CrownMul'] * 10; DB::connection('write')->table('QPPlatformDB.dbo.LuckyGemstoneMul')->delete(); DB::connection('write')->table('QPPlatformDB.dbo.LuckyGemstoneMul')->insert($LuckyGemstoneMul); return apiReturnSuc(); } }