diff --git a/Application/Admin/Controller/AutoPackController.class.php b/Application/Admin/Controller/AutoPackController.class.php index a3ab3f691..0989fff49 100644 --- a/Application/Admin/Controller/AutoPackController.class.php +++ b/Application/Admin/Controller/AutoPackController.class.php @@ -20,6 +20,7 @@ use BaiduBce\Auth\SignOptions; use BaiduBce\Log\LogFactory; use Think\Think; use Base\Service\GameSourceService; +use Base\Tool\Printer; /** * 后台首页控制器 @@ -309,23 +310,35 @@ class AutoPackController extends Think ->limit(200) ->select(); + if (count($applys) == 0) { + Printer::export('无等待队列', true); + } + + $applyIds = array_column($applys, 'id'); $gameIds = array_unique(array_column($applys, 'game_id')); - $games = M('game', 'tab_')->field(['id', 'game_appid'])->where(['id' => ['in', $gameIds]])->find(); + $games = M('game', 'tab_')->field(['id', 'game_appid'])->where(['id' => ['in', $gameIds]])->select(); $games = index_by_column('id', $games); $launchCountList = $launchModel->field(['apply_id', 'count(*) count'])->where(['apply_id' => ['in', $applyIds]])->group('apply_id')->select(); $launchCountList = index_by_column('apply_id', $launchCountList); - $gameSources = M('game_source', 'tab_')->field(['id', 'file_name', 'source_version', 'file_type', 'bao_name'])->where(['id' => ['game_id', $gameIds]])->find(); + $gameSources = M('game_source', 'tab_')->field(['id', 'file_name', 'source_version', 'file_type', 'bao_name', 'game_id'])->where(['game_id' => ['in', $gameIds]])->select(); $gameSources = index_by_column('game_id', $gameSources); - $gameSourceService = new GameSourceService(); + if (!empty($applys)) { foreach ($applys as $apply) { $gameSource = $gameSources[$apply['game_id']] ?? null; - $game = $games[$apply['game_id']]['game_appid']; + $game = $games[$apply['game_id']]; $launchCount = $launchCountList[$apply['id']] ?? 0; - $gameSourceService->channelPack($gameSource, $game, $apply, $launchCount); + $result = $gameSourceService->channelPack($gameSource, $game, $apply, $launchCount); + $message = '游戏['. $apply['game_id'] . '],渠道['. $apply['promote_id'] . ']打包,'; + if ($result['status']) { + $message = 'SUCCESS ----- ' . $message . $result['message']; + } else { + $message = 'ERROR ----- ' . $message . $result['message']; + } + Printer::export($message); } } } diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php new file mode 100644 index 000000000..cd6fd82a8 --- /dev/null +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -0,0 +1,27 @@ +select(['game_id', 'server_id', 'role_id'])->group('game_id, server_id, role_id')->having('count(*)>1')->select(); + + } + + public function modifyRecharge() + { + + } +} diff --git a/Application/Base/Service/ApplyService.class.php b/Application/Base/Service/ApplyService.class.php index 8d92b3e6d..f1e75a38b 100644 --- a/Application/Base/Service/ApplyService.class.php +++ b/Application/Base/Service/ApplyService.class.php @@ -33,8 +33,7 @@ class ApplyService { $data['enable_status'] = 1; $data['dispose_id'] = 0; $data['dispose_time'] = time(); - $data['plist_url'] = $plist_url; - $res = M('Apply', 'tab_')->save($data); - return $res; + $data['plist_url'] = $plistUrl; + return M('Apply', 'tab_')->save($data); } } \ No newline at end of file diff --git a/Application/Base/Service/GameSourceService.class.php b/Application/Base/Service/GameSourceService.class.php index faf0cb15d..054f3c9aa 100644 --- a/Application/Base/Service/GameSourceService.class.php +++ b/Application/Base/Service/GameSourceService.class.php @@ -101,7 +101,7 @@ class GameSourceService { } else { return [ 'status' => false, - 'message' => '打包失败,上传OSS失败!', + 'message' => '打包失败,上传OSS失败!' . $result['message'], ]; } @@ -123,7 +123,7 @@ class GameSourceService { } else { return [ 'status' => false, - 'message' => '打包失败,生成plist文件失败!', + 'message' => '打包失败,生成plist文件失败!' . $result['message'], ]; } @@ -134,7 +134,7 @@ class GameSourceService { } else { return [ 'status' => false, - 'message' => '打包失败,生成原包plist文件失败!', + 'message' => '打包失败,生成原包plist文件失败!' . $result['message'], ]; } } @@ -170,15 +170,16 @@ class GameSourceService { $savePath = ''; $fileName = 'game_package' . $apply['game_id'] . '-' . $apply['promote_id']; if ($apply['sdk_version'] == 1) { - $savePath = 'Uploads/GamePack/' . $fileName . '.apk'; + $fileName .= '.apk'; + $savePath = 'Uploads/GamePack/' . $fileName; } else { - $savePath = 'Uploads/IosGamePack/' . $fileName . '.ipa'; + $fileName .= '.ipa'; + $savePath = 'Uploads/IosGamePack/' . $fileName; } - $channelConfigFile = $this->getChannelConfigFile($gameSource); $relativePath = './' . $savePath; $localPath = ROOTTT . $savePath; copy($gameSourceUrl, $localPath); - + $packData = [ 'game_id' => $apply['game_id'], 'game_name' => $apply['game_name'], @@ -187,6 +188,8 @@ class GameSourceService { 'promote_account' => $apply['promote_account'], 'source_version' => $gameSource['source_version'], ]; + + $channelConfigFile = $this->getChannelConfigFile($gameSource); $status = $this->packChannelInfo($localPath, $channelConfigFile, $packData); if (!$status) { return [ @@ -194,14 +197,15 @@ class GameSourceService { 'message' => '打包失败,加入渠道信息失败!', ]; } - $result = $this->uploadPackage($localPath, $savePath, true); + $distFilePath = 'GamePack/' . $fileName; + $result = $this->uploadPackage($localPath, $distFilePath, false); if ($result['status']) { $packageUrl = $result['data']['url']; $packageUrl = $packageUrl == '@' ? $relativePath : $packageUrl; } else { return [ 'status' => false, - 'message' => '打包失败,上传OSS失败!', + 'message' => '打包失败,上传OSS失败!' . $result['message'], ]; } $plistInfo = ['game_id' => $apply['game_id'], 'promote_id' => $apply['promote_id']]; @@ -222,10 +226,11 @@ class GameSourceService { } else { return [ 'status' => false, - 'message' => '打包失败,生成plist文件失败!', + 'message' => '打包失败,生成plist文件失败!' . $result['message'], ]; } } + $applyService = new ApplyService(); $applyService->updateAfterPack($apply, $packageUrl, $plistUrl); return [ 'status' => true, diff --git a/Application/Base/Tool/Base62.class.php b/Application/Base/Tool/Base62.class.php new file mode 100644 index 000000000..b0cc27bf5 --- /dev/null +++ b/Application/Base/Tool/Base62.class.php @@ -0,0 +1,109 @@ + 5) { + $char = $encodes[$val >> ($pos -= 6)]; + $result[] = ( + $char == 'i' ? "ia" : + $char == '+' ? "ib" : + $char == '/' ? "ic" : $char + ); + $val &= ((1 << $pos) - 1); + } + } + if ($pos > 0) { + $char = $encodes[$val << (6 - $pos)]; + $result[] = ( + $char == 'i' ? "ia" : + $char == '+' ? "ib" : + $char == '/' ? "ic" : $char + ); + } + return implode('', $result); + } + + public static function decode($string, $decodes) + { + $decodes = self::getIndexChars(self::ENCODES); + $chars = self::getCharArray($string); + $pos = 0; + $val = 0; + $bytes = []; + for ($i = 0; $i < count($chars); $i++) { + $char = $chars[$i]; + if ($char == 'i') { + $char = $chars[++$i]; + $char = + $char == 'a' ? 'i' : + $char == 'b' ? '+' : + $char == 'c' ? '/' : $chars[--$i]; + } + $val = ($val << 6) | $decodes[$char]; + $pos += 6; + while ($pos > 7) { + $bytes[] = $val >> ($pos -= 8); + $val &= ((1 << $pos) - 1); + } + } + return self::bytesToString($bytes); + } + + private static function bytesToString($bytes) { + $string = ''; + foreach($bytes as $byte) { + $string .= chr($byte); + } + return $string; + } + + private static function stringToBytes($string) { + $length = strlen($string); + $bytes = array(); + for($i = 0; $i < $length; $i++) { + if(ord($string[$i]) >= 128){ + $byte = ord($string[$i]) - 256; + }else{ + $byte = ord($string[$i]); + } + $bytes[] = $byte ; + } + return $bytes; + } +} \ No newline at end of file diff --git a/Application/Base/Tool/Printer.class.php b/Application/Base/Tool/Printer.class.php new file mode 100644 index 000000000..b47935f43 --- /dev/null +++ b/Application/Base/Tool/Printer.class.php @@ -0,0 +1,13 @@ +