You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB
PHTML

5 years ago
<?php
namespace Base\Service;
use Base\Model\PromoteModel;
use Base\Model\ApplyModel;
use Base\Tool\Request;
5 years ago
class ApplyService {
private $model;
public function __construct()
{
$this->model = new ApplyModel();
}
public function cancelGame($gameId, $promoteId) {
$ids = [$promoteId];
$list = M('promote', 'tab_')->field('id')->where('parent_id=' . $promoteId . ' or grand_id=' . $promoteId)->select();
$ids = array_merge($ids, array_column($list, 'id'));
5 years ago
$save['offline_status'] = 1;
M('apply', 'tab_')->where(['game_id' => $gameId, 'promote_id' => ['in', $ids]])->save($save);
5 years ago
}
public function getDownloadUrl($apply, $game = null)
{
$host = Request::getHost();
if(empty($apply['dow_url'])) {
if ($game == null) {
$columns = ['sdk_version', 'add_game_address', 'and_dow_address', 'ios_game_address', 'ios_dow_address'];
$game = M('game','tab_')->field($columns)->where(['id' => $apply['game_id']])->find();
}
if($game['sdk_version'] == 1){
if($game['add_game_address'] != '') {
return $game['add_game_address'];
}else{
return $host . substr($game['and_dow_address'], 1);
}
} else {
if($game['ios_game_address'] != ''){
return $game['ios_game_address'];
}else{
return $host . substr($game['ios_dow_address'], 1);
}
}
}
return $host . $apply['dow_url'];
}
5 years ago
}