|
|
@ -69,36 +69,40 @@ class PackageController extends Controller
|
|
|
|
$this->error('链接已失效');
|
|
|
|
$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 = [];
|
|
|
|
$map['status'] = 1;
|
|
|
|
$map['status'] = 1;
|
|
|
|
$map['enable_status'] = 1;
|
|
|
|
$map['enable_status'] = 1;
|
|
|
|
$map['game_id'] = $gameId;
|
|
|
|
$map['game_id'] = $game['id'];
|
|
|
|
$map['promote_id'] = $promoteId;
|
|
|
|
$map['promote_id'] = $promoteId;
|
|
|
|
$columns = ['game_id', 'promote_id', 'promote_account', 'pack_url', 'plist_url', 'status', 'enable_status'];
|
|
|
|
$apply = M('apply','tab_')->where($map)->find();
|
|
|
|
$apply = M('apply','tab_')->field($columns)->where($map)->find();
|
|
|
|
|
|
|
|
if (!$apply) {
|
|
|
|
if (!$apply) {
|
|
|
|
$this->redirect("package/downloadError", ['message' => '该链接已经停止使用']);
|
|
|
|
$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'];
|
|
|
|
$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, $code);
|
|
|
|
$url = $applyService->getLandingPageUrl($apply);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
M('game','tab_')->where(['id' => $game['id']])->setInc('dow_num');
|
|
|
|
M('game','tab_')->where(['id' => $game['id']])->setInc('dow_num');
|
|
|
|
|
|
|
|
$log['game_id'] = $game['id'];
|
|
|
|
$log['game_id'] = $gameId;
|
|
|
|
|
|
|
|
$log['game_name'] = $game['game_name'];
|
|
|
|
$log['game_name'] = $game['game_name'];
|
|
|
|
$log['action'] = $url;
|
|
|
|
$log['action'] = $url;
|
|
|
|
$log['type'] = 6;
|
|
|
|
$log['type'] = 6;
|
|
|
@ -109,11 +113,14 @@ class PackageController extends Controller
|
|
|
|
M('user_action_log', 'tab_')->data($log)->add();
|
|
|
|
M('user_action_log', 'tab_')->data($log)->add();
|
|
|
|
|
|
|
|
|
|
|
|
$downloadDomain = $applyService->getDownloadDomain();
|
|
|
|
$downloadDomain = $applyService->getDownloadDomain();
|
|
|
|
if (Request::isIOS() || Request::isIPadOS() || $force == 'ios') {
|
|
|
|
if ($game['sdk_version'] == 2) {
|
|
|
|
|
|
|
|
/* if (!Request::getMobileDetect()->is('Safari')) {
|
|
|
|
|
|
|
|
return $this->display('open_in_safari');
|
|
|
|
|
|
|
|
} */
|
|
|
|
$packageDownloadLogService = new PackageDownloadLogService();
|
|
|
|
$packageDownloadLogService = new PackageDownloadLogService();
|
|
|
|
$packageDownloadLogService->add([
|
|
|
|
$packageDownloadLogService->add([
|
|
|
|
'user_id' => 0,
|
|
|
|
'user_id' => 0,
|
|
|
|
'game_id' => $gameId,
|
|
|
|
'game_id' => $game['id'],
|
|
|
|
'promote_id' => $promoteId,
|
|
|
|
'promote_id' => $promoteId,
|
|
|
|
'type' => 1,
|
|
|
|
'type' => 1,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|