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.

49 lines
1.3 KiB
PHP

<?php
namespace Base\Service;
use Base\Facade\Request;
class GameService {
const DOWNLOAD_SUPER = 4;
const DOWNLOAD_BETA = 2;
const DOWNLOAD_NORMAL = 1;
public function getDownLoadWaysValue(array $downloadWays)
{
$value = 0;
foreach ($downloadWays as $downloadWay) {
$value |= $downloadWay;
}
return $value;
}
public function saveBaseGame($params)
{
$baseGame = null;
$conditions = [];
$data = [
'name' => $params['name']
];
$gameIds = [$params['id']];
if (isset($params['relation_game_id']) && $params['relation_game_id']) {
$gameIds[] = $params['relation_game_id'];
}
$conditions['_logic'] = 'or';
$conditions['android_game_id'] = ['in', $gameIds];
$conditions['ios_game_id'] = ['in', $gameIds];
if ($params['sdk_version'] == 1) {
$data['android_game_id'] = $params['id'];
} elseif ($params['sdk_version'] == 2) {
$data['ios_game_id'] = $params['id'];
}
$baseGame = M('base_game', 'tab_')->where($conditions)->find();
if (!$baseGame) {
return M('base_game', 'tab_')->add($data);
} else {
return M('base_game', 'tab_')->where(['id' => $baseGame['id']])->save($data);
}
}
}