|
|
|
<?php
|
|
|
|
namespace Base\Service;
|
|
|
|
|
|
|
|
use Base\Model\PromoteModel;
|
|
|
|
use Base\Model\ApplyModel;
|
|
|
|
use Base\Tool\Request;
|
|
|
|
|
|
|
|
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'));
|
|
|
|
|
|
|
|
$save['offline_status'] = 1;
|
|
|
|
|
|
|
|
M('apply', 'tab_')->where(['game_id' => $gameId, 'promote_id' => ['in', $ids]])->save($save);
|
|
|
|
}
|
|
|
|
|
|
|
|
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'];
|
|
|
|
}
|
|
|
|
}
|