diff --git a/Application/Base/Service/ApplyService.class.php b/Application/Base/Service/ApplyService.class.php index eda474d25..851dcec70 100644 --- a/Application/Base/Service/ApplyService.class.php +++ b/Application/Base/Service/ApplyService.class.php @@ -77,19 +77,23 @@ class ApplyService { return M('Apply', 'tab_')->save($data); } - public function getDownloadUrl($apply) + public function getDownloadUrl($apply, $code = null) { $host = $this->getDownloadDomain(); $host = $host ? $host : Request::getHost(); - $code = $this->encodeApplyCode($apply, self::ENCRYPT_TYPE_DOWNLOAD); + if (!$code) { + $code = $this->encodeApplyCode($apply, self::ENCRYPT_TYPE_DOWNLOAD); + } return $host . '/index.php?s=/Home/Package/download/code/' . $code; } - public function getLandingPageUrl($apply) + public function getLandingPageUrl($apply, $code = null) { $host = $this->getDownloadDomain(); $host = $host ? $host : Request::getHost(); - $code = $this->encodeApplyCode($apply, self::ENCRYPT_TYPE_LANDING_PAGE); + if (!$code) { + $code = $this->encodeApplyCode($apply, self::ENCRYPT_TYPE_DOWNLOAD); + } return $host . '/index.php?s=/Home/Home/landingPage/code/' . $code; } @@ -171,12 +175,12 @@ class ApplyService { 'message' => '参数异常', ]; } - if ($data['type'] != $type) { + /* if ($data['type'] != $type) { return [ 'status' => false, 'message' => '参数异常', ]; - } + } */ if ($data['expires_in'] > 0 && time() > (strtotime($data['created_at']) + $data['expires_in'])) { return [ 'status' => false, diff --git a/Application/Home/Controller/HomeController.class.php b/Application/Home/Controller/HomeController.class.php index 15ccb99a2..d003d02fe 100644 --- a/Application/Home/Controller/HomeController.class.php +++ b/Application/Home/Controller/HomeController.class.php @@ -312,7 +312,7 @@ class HomeController extends Controller if (!$isNewIos && $isIOS13) { $downloadUrl = 'itms-services://?action=download-manifest&url=' . Request::getHost() . ltrim($gameSource['org_plist_url'], '.'); } else { - $downloadUrl = $applyService->getDownloadUrl($apply); + $downloadUrl = $applyService->getDownloadUrl($apply, $code); if ($force) { $downloadUrl .= '/force/' . $force; } diff --git a/Application/Home/Controller/PackageController.class.php b/Application/Home/Controller/PackageController.class.php index 54941fa11..f24766b9a 100644 --- a/Application/Home/Controller/PackageController.class.php +++ b/Application/Home/Controller/PackageController.class.php @@ -69,36 +69,40 @@ class PackageController extends Controller $this->error('链接已失效'); } + $sdkVersion = 0; + if (Request::isMobile() || Request::isTablet() || $force == 'ios' || $force == 'android') { + if (Request::isAndroid() || $force == 'android') { + $sdkVersion = 1; + } elseif (Request::isIOS() || Request::isIPadOS() || $force == 'ios') { + $sdkVersion = 2; + } + } + + $gameColumns = ['id', 'game_name', 'sdk_version', 'apply_auth', 'relation_game_id']; + $game = M('game','tab_')->field($gameColumns)->where(['id' => $gameId])->find(); + if ($sdkVersion > 0 && $game && $game['sdk_version'] != $sdkVersion) { + $game = M('game','tab_')->field($gameColumns)->where(['sdk_version' => $sdkVersion, 'relation_game_id' => $game['relation_game_id']])->find(); + } + + if (!$game) { + $this->error('游戏不存在'); + } + $map = []; $map['status'] = 1; $map['enable_status'] = 1; - $map['game_id'] = $gameId; + $map['game_id'] = $game['id']; $map['promote_id'] = $promoteId; - $columns = ['game_id', 'promote_id', 'promote_account', 'pack_url', 'plist_url', 'status', 'enable_status']; - $apply = M('apply','tab_')->field($columns)->where($map)->find(); + $apply = M('apply','tab_')->where($map)->find(); if (!$apply) { $this->redirect("package/downloadError", ['message' => '该链接已经停止使用']); } - $game = M('game','tab_')->field(['id', 'game_name', 'sdk_version', 'apply_auth'])->where(['id' => $apply['game_id']])->find(); - - if (Request::isMobile() || Request::isTablet() || $force == 'ios' || $force == 'android') { - if (!(Request::isAndroid() || $force == 'android') && $game['sdk_version'] == 1) { - $this->redirect("package/downloadError", ['message' => '请使用安卓浏览器下载']); - } - if (!(Request::isIOS() || Request::isIPadOS() || $force == 'ios') && $game['sdk_version'] == 2) { - $this->redirect("package/downloadError", ['message' => '请使用ios浏览器下载']); - } - } - $packageUrl = $game['sdk_version'] == 1 ? $apply['pack_url'] : $apply['plist_url']; - - $apply = M('apply', 'tab_')->where(['promote_id' => $promoteId, 'game_id' => $gameId])->find(); - $url = $applyService->getLandingPageUrl($apply); - + + $url = $applyService->getLandingPageUrl($apply, $code); M('game','tab_')->where(['id' => $game['id']])->setInc('dow_num'); - - $log['game_id'] = $gameId; + $log['game_id'] = $game['id']; $log['game_name'] = $game['game_name']; $log['action'] = $url; $log['type'] = 6; @@ -109,11 +113,11 @@ class PackageController extends Controller M('user_action_log', 'tab_')->data($log)->add(); $downloadDomain = $applyService->getDownloadDomain(); - if (Request::isIOS() || Request::isIPadOS() || $force == 'ios') { + if ($game['sdk_version'] == 2) { $packageDownloadLogService = new PackageDownloadLogService(); $packageDownloadLogService->add([ 'user_id' => 0, - 'game_id' => $gameId, + 'game_id' => $game['id'], 'promote_id' => $promoteId, 'type' => 1, ]);