master
ELF 5 years ago
parent 53e0395674
commit 37ef999710

@ -20,6 +20,7 @@ use BaiduBce\Auth\SignOptions;
use BaiduBce\Log\LogFactory;
use Think\Think;
use Base\Service\GameSourceService;
use Base\Tool\Printer;
/**
* 后台首页控制器
@ -309,23 +310,35 @@ class AutoPackController extends Think
->limit(200)
->select();
if (count($applys) == 0) {
Printer::export('无等待队列', true);
}
$applyIds = array_column($applys, 'id');
$gameIds = array_unique(array_column($applys, 'game_id'));
$games = M('game', 'tab_')->field(['id', 'game_appid'])->where(['id' => ['in', $gameIds]])->find();
$games = M('game', 'tab_')->field(['id', 'game_appid'])->where(['id' => ['in', $gameIds]])->select();
$games = index_by_column('id', $games);
$launchCountList = $launchModel->field(['apply_id', 'count(*) count'])->where(['apply_id' => ['in', $applyIds]])->group('apply_id')->select();
$launchCountList = index_by_column('apply_id', $launchCountList);
$gameSources = M('game_source', 'tab_')->field(['id', 'file_name', 'source_version', 'file_type', 'bao_name'])->where(['id' => ['game_id', $gameIds]])->find();
$gameSources = M('game_source', 'tab_')->field(['id', 'file_name', 'source_version', 'file_type', 'bao_name', 'game_id'])->where(['game_id' => ['in', $gameIds]])->select();
$gameSources = index_by_column('game_id', $gameSources);
$gameSourceService = new GameSourceService();
if (!empty($applys)) {
foreach ($applys as $apply) {
$gameSource = $gameSources[$apply['game_id']] ?? null;
$game = $games[$apply['game_id']]['game_appid'];
$game = $games[$apply['game_id']];
$launchCount = $launchCountList[$apply['id']] ?? 0;
$gameSourceService->channelPack($gameSource, $game, $apply, $launchCount);
$result = $gameSourceService->channelPack($gameSource, $game, $apply, $launchCount);
$message = '游戏['. $apply['game_id'] . '],渠道['. $apply['promote_id'] . ']打包,';
if ($result['status']) {
$message = 'SUCCESS ----- ' . $message . $result['message'];
} else {
$message = 'ERROR ----- ' . $message . $result['message'];
}
Printer::export($message);
}
}
}

@ -0,0 +1,27 @@
<?php
/**
* 定时自动完成
*/
namespace Admin\Controller;
use Admin\Model\SpendModel;
use Think\Think;
use Org\RedisSDK\Redis;
class AutoController extends Think {
protected function _initialize()
{
C(api('Config/lists'));
}
public function modifyUserRole()
{
M('user_play_info', 'tab_')->select(['game_id', 'server_id', 'role_id'])->group('game_id, server_id, role_id')->having('count(*)>1')->select();
}
public function modifyRecharge()
{
}
}

@ -33,8 +33,7 @@ class ApplyService {
$data['enable_status'] = 1;
$data['dispose_id'] = 0;
$data['dispose_time'] = time();
$data['plist_url'] = $plist_url;
$res = M('Apply', 'tab_')->save($data);
return $res;
$data['plist_url'] = $plistUrl;
return M('Apply', 'tab_')->save($data);
}
}

@ -101,7 +101,7 @@ class GameSourceService {
} else {
return [
'status' => false,
'message' => '打包失败上传OSS失败',
'message' => '打包失败上传OSS失败' . $result['message'],
];
}
@ -123,7 +123,7 @@ class GameSourceService {
} else {
return [
'status' => false,
'message' => '打包失败生成plist文件失败',
'message' => '打包失败生成plist文件失败' . $result['message'],
];
}
@ -134,7 +134,7 @@ class GameSourceService {
} else {
return [
'status' => false,
'message' => '打包失败生成原包plist文件失败',
'message' => '打包失败生成原包plist文件失败' . $result['message'],
];
}
}
@ -170,15 +170,16 @@ class GameSourceService {
$savePath = '';
$fileName = 'game_package' . $apply['game_id'] . '-' . $apply['promote_id'];
if ($apply['sdk_version'] == 1) {
$savePath = 'Uploads/GamePack/' . $fileName . '.apk';
$fileName .= '.apk';
$savePath = 'Uploads/GamePack/' . $fileName;
} else {
$savePath = 'Uploads/IosGamePack/' . $fileName . '.ipa';
$fileName .= '.ipa';
$savePath = 'Uploads/IosGamePack/' . $fileName;
}
$channelConfigFile = $this->getChannelConfigFile($gameSource);
$relativePath = './' . $savePath;
$localPath = ROOTTT . $savePath;
copy($gameSourceUrl, $localPath);
$packData = [
'game_id' => $apply['game_id'],
'game_name' => $apply['game_name'],
@ -187,6 +188,8 @@ class GameSourceService {
'promote_account' => $apply['promote_account'],
'source_version' => $gameSource['source_version'],
];
$channelConfigFile = $this->getChannelConfigFile($gameSource);
$status = $this->packChannelInfo($localPath, $channelConfigFile, $packData);
if (!$status) {
return [
@ -194,14 +197,15 @@ class GameSourceService {
'message' => '打包失败,加入渠道信息失败!',
];
}
$result = $this->uploadPackage($localPath, $savePath, true);
$distFilePath = 'GamePack/' . $fileName;
$result = $this->uploadPackage($localPath, $distFilePath, false);
if ($result['status']) {
$packageUrl = $result['data']['url'];
$packageUrl = $packageUrl == '@' ? $relativePath : $packageUrl;
} else {
return [
'status' => false,
'message' => '打包失败上传OSS失败',
'message' => '打包失败上传OSS失败' . $result['message'],
];
}
$plistInfo = ['game_id' => $apply['game_id'], 'promote_id' => $apply['promote_id']];
@ -222,10 +226,11 @@ class GameSourceService {
} else {
return [
'status' => false,
'message' => '打包失败生成plist文件失败',
'message' => '打包失败生成plist文件失败' . $result['message'],
];
}
}
$applyService = new ApplyService();
$applyService->updateAfterPack($apply, $packageUrl, $plistUrl);
return [
'status' => true,

@ -0,0 +1,109 @@
<?php
namespace Base\Tool;
class Base62
{
const ENCODES = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/';
private static function getCharArray($string)
{
$list = [];
$length = strlen($string);
for ($i = 0; $i < $length; $i++) {
$list[] = $string[$i];
}
return $list;
}
private static function getIndexChars($string) {
$length = strlen($string);
$chars = [];
for($i = 0; $i < 256; $i++) {
$chars[] = 0;
}
for($i = 0; $i < $length; $i++) {
$chars[$string[$i]] = $i ;
}
return $chars;
}
public static function encode($string)
{
$encodes = self::getCharArray(self::ENCODES);
$bytes = self::stringToBytes($string);
$pos = 0;
$val = 0;
$result = [];
for ($i = 0; $i < count($bytes); $i++) {
$val = ($val << 8) | ($bytes[$i] & 0xFF);
$pos += 8;
while ($pos > 5) {
$char = $encodes[$val >> ($pos -= 6)];
$result[] = (
$char == 'i' ? "ia" :
$char == '+' ? "ib" :
$char == '/' ? "ic" : $char
);
$val &= ((1 << $pos) - 1);
}
}
if ($pos > 0) {
$char = $encodes[$val << (6 - $pos)];
$result[] = (
$char == 'i' ? "ia" :
$char == '+' ? "ib" :
$char == '/' ? "ic" : $char
);
}
return implode('', $result);
}
public static function decode($string, $decodes)
{
$decodes = self::getIndexChars(self::ENCODES);
$chars = self::getCharArray($string);
$pos = 0;
$val = 0;
$bytes = [];
for ($i = 0; $i < count($chars); $i++) {
$char = $chars[$i];
if ($char == 'i') {
$char = $chars[++$i];
$char =
$char == 'a' ? 'i' :
$char == 'b' ? '+' :
$char == 'c' ? '/' : $chars[--$i];
}
$val = ($val << 6) | $decodes[$char];
$pos += 6;
while ($pos > 7) {
$bytes[] = $val >> ($pos -= 8);
$val &= ((1 << $pos) - 1);
}
}
return self::bytesToString($bytes);
}
private static function bytesToString($bytes) {
$string = '';
foreach($bytes as $byte) {
$string .= chr($byte);
}
return $string;
}
private static function stringToBytes($string) {
$length = strlen($string);
$bytes = array();
for($i = 0; $i < $length; $i++) {
if(ord($string[$i]) >= 128){
$byte = ord($string[$i]) - 256;
}else{
$byte = ord($string[$i]);
}
$bytes[] = $byte ;
}
return $bytes;
}
}

@ -0,0 +1,13 @@
<?php
namespace Base\Tool;
class Printer
{
public static function export($content, $isExit = false)
{
echo $content . ' ----- ' . date('Y-m-d H:i:s') . PHP_EOL;
if ($isExit) {
exit(0);
}
}
}
Loading…
Cancel
Save