|
|
|
@ -19,6 +19,8 @@ use BaiduBce\Services\Bos\BosOptions;
|
|
|
|
|
use BaiduBce\Auth\SignOptions;
|
|
|
|
|
use BaiduBce\Log\LogFactory;
|
|
|
|
|
use Think\Think;
|
|
|
|
|
use Base\Service\GameSourceService;
|
|
|
|
|
use Base\Tool\Printer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 后台首页控制器
|
|
|
|
@ -48,10 +50,10 @@ class AutoPackController extends Think
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->checkPackageStatus();
|
|
|
|
|
$this->app_package();//app渠道自动打包
|
|
|
|
|
// $this->app_package();//app渠道自动打包
|
|
|
|
|
$this->channel();
|
|
|
|
|
$this->launch_package(false);
|
|
|
|
|
$this->leak_detection();
|
|
|
|
|
// $this->launch_package(false);
|
|
|
|
|
// $this->leak_detection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -74,12 +76,10 @@ class AutoPackController extends Think
|
|
|
|
|
->where('1=1')
|
|
|
|
|
->group('l.id')
|
|
|
|
|
->select();
|
|
|
|
|
if(!empty($launchGameIds)) {
|
|
|
|
|
|
|
|
|
|
if(!empty($launchGameIds)) {
|
|
|
|
|
$ids = array_column($launchGameIds, 'id');
|
|
|
|
|
|
|
|
|
|
$launchModel->where(['id'=>['in',$ids]])->setField('launch_packge', 2);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$launchIds = $launchModel
|
|
|
|
@ -92,18 +92,18 @@ class AutoPackController extends Think
|
|
|
|
|
->group('apply_id')
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$launchId='';
|
|
|
|
|
$launchId = [];
|
|
|
|
|
foreach ($launchIds as $launchValue) {
|
|
|
|
|
foreach ($launchAllIds as $launchAllValue) {
|
|
|
|
|
if($launchValue['apply_id'] == $launchAllValue['apply_id']
|
|
|
|
|
&& $launchValue['count'] == $launchAllValue['count']) {
|
|
|
|
|
$launchId[]=$launchValue['apply_id'];
|
|
|
|
|
$launchId[] = $launchValue['apply_id'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($launchId)) {
|
|
|
|
|
$applyModel->where(['id'=>['in',$launchId]])->setField('enable_status', 1);
|
|
|
|
|
$applyModel->where(['id'=> ['in',$launchId]])->setField('enable_status', 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -292,14 +292,6 @@ class AutoPackController extends Think
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 渠道游戏打包
|
|
|
|
|
*
|
|
|
|
|
* 针对每个申请游戏检测是否存在投放申请:有则更改投放申请状态,使其进入准备打包状态;无则进行渠道游戏打包
|
|
|
|
|
*
|
|
|
|
|
* @author: 鹿文学[lwx]<fyj301415926@126.com>
|
|
|
|
|
* @since: 2019\4\17 0017 14:27
|
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
* @throws \think\exception\DbException
|
|
|
|
|
*/
|
|
|
|
|
private function channel() {
|
|
|
|
|
$zip = new \ZipArchive();
|
|
|
|
@ -311,140 +303,44 @@ class AutoPackController extends Think
|
|
|
|
|
$gameSourceModel = M('Game_source', 'tab_');
|
|
|
|
|
$launchModel = M('apply_launch', 'tab_');
|
|
|
|
|
|
|
|
|
|
$apply_data = $applyModel
|
|
|
|
|
-> field('id,game_id,game_name,promote_id,promote_account,sdk_version')
|
|
|
|
|
-> where($map)
|
|
|
|
|
-> order('bale_sort desc,id desc')
|
|
|
|
|
-> limit(200)
|
|
|
|
|
-> select();
|
|
|
|
|
|
|
|
|
|
if (!empty($apply_data)) {
|
|
|
|
|
foreach ($apply_data as $key => $value) {
|
|
|
|
|
|
|
|
|
|
$game_so = $gameSourceModel
|
|
|
|
|
-> field('id,file_name,source_version')
|
|
|
|
|
-> where(['game_id' => $value['game_id']])
|
|
|
|
|
-> find();
|
|
|
|
|
|
|
|
|
|
if (!file_exists(get_game_source_file_url($value['game_id'])) || null == $game_so) {
|
|
|
|
|
$applyModel -> where(['id' => $value['id']]) -> setField('enable_status', -1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 检测是否存在投放申请,存在则更改投放申请信息,否则进行渠道打包 */
|
|
|
|
|
$launchCount = $launchModel->where(['apply_id'=>$value['id']])->count();
|
|
|
|
|
|
|
|
|
|
if($launchCount>0) {
|
|
|
|
|
$applyModel->where(['id' => $value['id']]) -> setField('enable_status', 3);
|
|
|
|
|
|
|
|
|
|
$launchModel->where(['apply_id'=>$value['id'], 'launch_packge'=>['in',[0,2,3]]])->save(['launch_packge'=>2,'launch_down_url'=>'','launch_plist_url'=>'']);
|
|
|
|
|
|
|
|
|
|
$applys = $applyModel
|
|
|
|
|
->field('id,game_id,game_name,promote_id,promote_account,sdk_version')
|
|
|
|
|
->where($map)
|
|
|
|
|
->order('bale_sort desc,id desc')
|
|
|
|
|
->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]])->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', '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']];
|
|
|
|
|
$launchCount = $launchCountList[$apply['id']] ?? 0;
|
|
|
|
|
$result = $gameSourceService->channelPack($gameSource, $game, $apply, $launchCount);
|
|
|
|
|
$message = '游戏['. $apply['game_id'] . '],渠道['. $apply['promote_id'] . ']打包,';
|
|
|
|
|
if ($result['status']) {
|
|
|
|
|
$message = 'SUCCESS ----- ' . $message . $result['message'];
|
|
|
|
|
} else {
|
|
|
|
|
$applyModel -> where(['id' => $value['id']]) -> setField('enable_status', 3);
|
|
|
|
|
|
|
|
|
|
if ($value['sdk_version'] == 1) {
|
|
|
|
|
$str_ver = ".apk";
|
|
|
|
|
$file_name = "GamePack";
|
|
|
|
|
$url_ver = "META-INF/mch.properties";
|
|
|
|
|
} else {
|
|
|
|
|
$zip_open_game_source = zip_open(get_game_source_file_url($value['game_id']));
|
|
|
|
|
if ($zip_open_game_source) {
|
|
|
|
|
while ($zip_entry = zip_read($zip_open_game_source)) {
|
|
|
|
|
if (preg_match("/.app/", zip_entry_name($zip_entry))) {
|
|
|
|
|
$ios_app = substr(zip_entry_name($zip_entry), 8) . "<br/>";
|
|
|
|
|
}
|
|
|
|
|
$new_ios_1 = explode("/", $ios_app);
|
|
|
|
|
}
|
|
|
|
|
zip_close($zip_open_game_source);
|
|
|
|
|
}
|
|
|
|
|
$str_ver = ".ipa";
|
|
|
|
|
$file_name = "IosGamePack";
|
|
|
|
|
$url_ver = "Payload/" . $new_ios_1[0] . "/_CodeSignature/TXChannel";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$new_name = "game_package" . $value['game_id'] . "-" . $value['promote_id'] . $str_ver;
|
|
|
|
|
$to = "./Uploads/" . $file_name . "/" . $new_name;
|
|
|
|
|
$localPath = ROOTTT . ltrim($to, './');
|
|
|
|
|
copy(get_game_source_file_url($value['game_id']), $localPath);
|
|
|
|
|
$zip_res = $zip -> open(ROOTTT . ltrim($to, './'), \ZipArchive::CREATE);
|
|
|
|
|
if ($zip_res == true) {
|
|
|
|
|
#打包数据
|
|
|
|
|
$pack_data = array(
|
|
|
|
|
"game_id" => $value["game_id"],
|
|
|
|
|
"game_name" => $value['game_name'],
|
|
|
|
|
"game_appid" => get_game_appid($value["game_id"], "id"),
|
|
|
|
|
"promote_id" => $value['promote_id'],
|
|
|
|
|
"promote_account" => $value['promote_account'],
|
|
|
|
|
"source_version" => $game_so['source_version'],
|
|
|
|
|
);
|
|
|
|
|
$zip -> addFromString($url_ver, json_encode($pack_data));
|
|
|
|
|
$zip -> close();
|
|
|
|
|
|
|
|
|
|
$newname = "game_package" . $value["game_id"] . "-" . $value['promote_id'] . $str_ver;
|
|
|
|
|
|
|
|
|
|
if (get_tool_status("oss_storage") == 1) {
|
|
|
|
|
|
|
|
|
|
if (C("oss_storage.is_cname")) {
|
|
|
|
|
$to = "http://" . C("oss_storage.domain") . "/" . str_replace("IosGamePack", "GamePack", $file_name) . "/" . $newname;
|
|
|
|
|
} else {
|
|
|
|
|
$to = "https://" . C("oss_storage.bucket") . "." . C("oss_storage.domain") . "/" . str_replace("IosGamePack", "GamePack", $file_name) . "/" . $newname;
|
|
|
|
|
$to = str_replace('-internal', '', $to);
|
|
|
|
|
}
|
|
|
|
|
if (!empty(C('oss_storage.bd_domain')) && strlen(C('oss_storage.bd_domain')) > 5) {
|
|
|
|
|
$to = C('oss_storage.bd_domain') . "/GamePack/" . $newname;
|
|
|
|
|
}
|
|
|
|
|
$new_to = ROOTTT . "Uploads/" . $file_name . "/" . $newname;
|
|
|
|
|
$updata['savename'] = $newname;
|
|
|
|
|
$updata['path'] = $new_to;
|
|
|
|
|
$this -> upload_game_pak_oss($updata);
|
|
|
|
|
|
|
|
|
|
if (file_exists($new_to)) {
|
|
|
|
|
@unlink($new_to);
|
|
|
|
|
}
|
|
|
|
|
} elseif (get_tool_status("qiniu_storage") == 1) {
|
|
|
|
|
|
|
|
|
|
$this -> dleteQiNiuFile($newname);
|
|
|
|
|
$url = $this -> upQiNiuFile($newname, ROOTTT . ltrim($to, './'));
|
|
|
|
|
if (empty($url)) {
|
|
|
|
|
$this -> error('七牛错误,请检查七牛配置,并确保七牛空间权限正确!');
|
|
|
|
|
}
|
|
|
|
|
@unlink(ROOTTT . ltrim($to, './'));
|
|
|
|
|
$to = "http://" . $url;
|
|
|
|
|
|
|
|
|
|
} elseif (get_tool_status("cos_storage") == 1) {
|
|
|
|
|
|
|
|
|
|
$new_to = ROOTTT . "Uploads/" . $file_name . "/" . $newname;
|
|
|
|
|
|
|
|
|
|
$updata['path'] = $new_to;
|
|
|
|
|
$updata['savename'] = 'GamePack/'. $newname;
|
|
|
|
|
|
|
|
|
|
$to = $this->upload_cos($updata);
|
|
|
|
|
|
|
|
|
|
} elseif (get_tool_status("bos_storage") == 1) {
|
|
|
|
|
$newname = "game_package" . $value["game_id"] . "-" . $value['promote_id'] . $str_ver;
|
|
|
|
|
$to = "http://" . C("bos_storage.bucket") . "." . C("bos_storage.domain") . "/" . $file_name . "/" . $newname;
|
|
|
|
|
$to = str_replace('-internal', '', $to);
|
|
|
|
|
$new_to = ROOTTT . "Uploads/" . $file_name . "/" . $newname;
|
|
|
|
|
$updata['savename'] = $newname;
|
|
|
|
|
$updata['path'] = $new_to;
|
|
|
|
|
$this -> upload_bos($updata);
|
|
|
|
|
}
|
|
|
|
|
$promote = array('game_id' => $value['game_id'], 'promote_id' => $value['promote_id']);
|
|
|
|
|
$plist_url = '';
|
|
|
|
|
if ($value['sdk_version'] == 2) {
|
|
|
|
|
$plist_url = $this -> create_plist($promote['game_id'], $promote['promote_id'], get_payload_name($value['game_id']), $to);
|
|
|
|
|
}
|
|
|
|
|
$jieguo = $this -> updateinfo($value['id'], $to, $promote, $plist_url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$message = 'ERROR ----- ' . $message . $result['message'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Printer::export($message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -456,21 +352,26 @@ class AutoPackController extends Think
|
|
|
|
|
$map['a.status'] = 1;
|
|
|
|
|
$map['a.enable_status'] = 1;
|
|
|
|
|
$map['al.launch_packge'] = array('in', [0, 2, 3]);
|
|
|
|
|
$apply = $applymodel -> alias('a')
|
|
|
|
|
-> field('a.id,a.game_id,a.game_name,a.promote_account,a.pack_url,a.plist_url,a.promote_id,a.sdk_version,a.enable_status')
|
|
|
|
|
-> join('tab_apply_launch as al on (al.apply_id=a.id) ')
|
|
|
|
|
-> where($map) -> limit(3) -> group('a.id') -> select();
|
|
|
|
|
$apply = $applymodel->alias('a')
|
|
|
|
|
->field('a.id,a.game_id,a.game_name,a.promote_account,a.pack_url,a.plist_url,a.promote_id,a.sdk_version,a.enable_status')
|
|
|
|
|
->join('tab_apply_launch as al on (al.apply_id=a.id) ')
|
|
|
|
|
->where($map)
|
|
|
|
|
->limit(300)
|
|
|
|
|
->group('a.id')
|
|
|
|
|
->select();
|
|
|
|
|
foreach ($apply as $key => $value) {
|
|
|
|
|
$game_so = $game_somodel -> field('id,file_name,source_version') -> where(['game_id' => $value['game_id']]) -> find();
|
|
|
|
|
if (!file_exists(get_game_source_file_url($value['game_id'])) || null == $game_so) {
|
|
|
|
|
$gameSource = $gameSourceModel
|
|
|
|
|
->field('id,file_name,source_version,file_type')
|
|
|
|
|
->where(['game_id' => $value['game_id']])
|
|
|
|
|
->find();
|
|
|
|
|
$gameSourceUrl = $gameSourceService->getGameSourceUrl($gameSource);
|
|
|
|
|
if ($gameSource || !file_exists($gameSourceUrl)) {
|
|
|
|
|
M('apply', 'tab_') -> where(['id' => $value['id']]) -> setField('enable_status', -1);
|
|
|
|
|
$launchmodel -> where(['apply_id' => $value['id']]) -> setField('launch_packge', 0);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$url = get_game_source_file_url($value['game_id']);
|
|
|
|
|
if (!empty($url) && is_file($url)) {
|
|
|
|
|
|
|
|
|
|
if (!empty($gameSourceUrl) && is_file($gameSourceUrl)) {
|
|
|
|
|
|
|
|
|
|
$launch = $launchmodel -> where(['apply_id' => $value['id'], 'launch_packge' => array('in', [0, 2, 3])]) -> select();
|
|
|
|
|
$zip = new \ZipArchive();
|
|
|
|
@ -478,19 +379,19 @@ class AutoPackController extends Think
|
|
|
|
|
|
|
|
|
|
if ($value['sdk_version'] == 1) {
|
|
|
|
|
if (!empty($v['game_source_filename'])) {
|
|
|
|
|
if ($v['game_source_filename'] == $game_so['file_name']) {
|
|
|
|
|
if ($v['game_source_filename'] == $gameSource['file_name']) {
|
|
|
|
|
if (!empty($v['launch_down_url'])) {
|
|
|
|
|
$launchmodel -> where(['id' => $v['id']]) -> setField(['launch_packge' => 1]);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$str_ver = ".apk";
|
|
|
|
|
$str_ver = '.apk';
|
|
|
|
|
$file_name = "GamePack";
|
|
|
|
|
$url_ver = "META-INF/mch.properties";
|
|
|
|
|
} else {
|
|
|
|
|
if (!empty($v['game_source_filename'])) {
|
|
|
|
|
if ($v['game_source_filename'] == $game_so['file_name']) {
|
|
|
|
|
if ($v['game_source_filename'] == $gameSource['file_name']) {
|
|
|
|
|
if (!empty($v['launch_plist_url'])) {
|
|
|
|
|
if (!empty($v['launch_down_url'])) {
|
|
|
|
|
$launchmodel -> where(['id' => $v['id']]) -> setField(['launch_packge' => 1]);
|
|
|
|
@ -499,7 +400,7 @@ class AutoPackController extends Think
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$zip_open_game_source = zip_open($url);
|
|
|
|
|
$zip_open_game_source = zip_open($gameSourceUrl);
|
|
|
|
|
if ($zip_open_game_source) {
|
|
|
|
|
while ($zip_entry = zip_read($zip_open_game_source)) {
|
|
|
|
|
if (preg_match("/.app/", zip_entry_name($zip_entry))) {
|
|
|
|
@ -516,7 +417,7 @@ class AutoPackController extends Think
|
|
|
|
|
}
|
|
|
|
|
$new_name = "game_package" . $value['game_id'] . "-" . $value['promote_id'] . "-" . $v['platform_id'] . "-" . $v['position'] . $str_ver;
|
|
|
|
|
$to = "./Uploads/" . $file_name . "/" . $new_name;
|
|
|
|
|
copy($url, ROOTTT . ltrim($to, './'));
|
|
|
|
|
copy($gameSourceUrl, ROOTTT . ltrim($to, './'));
|
|
|
|
|
$zip_res = $zip -> open(ROOTTT . ltrim($to, './'), \ZipArchive::CREATE);
|
|
|
|
|
if ($zip_res == true) {
|
|
|
|
|
#打包数据
|
|
|
|
@ -526,7 +427,7 @@ class AutoPackController extends Think
|
|
|
|
|
"game_appid" => get_game_appid($value["game_id"], "id"),
|
|
|
|
|
"promote_id" => $value['promote_id'],
|
|
|
|
|
"promote_account" => $value['promote_account'],
|
|
|
|
|
"source_version" => $game_so['source_version'],
|
|
|
|
|
"source_version" => $gameSource['source_version'],
|
|
|
|
|
'launch_id' => $v['platform_id'],
|
|
|
|
|
'position' => $v['position'],
|
|
|
|
|
);
|
|
|
|
@ -595,7 +496,7 @@ class AutoPackController extends Think
|
|
|
|
|
if ($value['sdk_version'] == 2) {
|
|
|
|
|
$plist_url = $this -> create_plist($promote['game_id'], $promote['promote_id'], get_payload_name($value['game_id']), $to, $v['platform_id'], $v['position']);
|
|
|
|
|
}
|
|
|
|
|
$jg = $this -> update_launch_info(['platform_id' => $v['platform_id'], 'apply_id' => $value['id'], 'position'=>$v['position']], $to, $plist_url, $game_so['file_name']);
|
|
|
|
|
$jg = $this -> update_launch_info(['platform_id' => $v['platform_id'], 'apply_id' => $value['id'], 'position'=>$v['position']], $to, $plist_url, $gameSource['file_name']);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -643,7 +544,7 @@ class AutoPackController extends Think
|
|
|
|
|
{
|
|
|
|
|
$map['status'] = 1;
|
|
|
|
|
$map['enable_status'] = 2;
|
|
|
|
|
$arr_id = M('app_apply', 'tab_') -> field('id') -> where($map) -> order('id desc') -> limit(3) -> select();
|
|
|
|
|
$arr_id = M('app_apply', 'tab_')->field('id')->where($map)->order('id desc')->limit(300)->select();
|
|
|
|
|
if (empty($arr_id)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -722,8 +623,6 @@ class AutoPackController extends Think
|
|
|
|
|
$apply_data['dow_url'] = $to;
|
|
|
|
|
$apply_data['enable_status'] = 1;
|
|
|
|
|
M('app_apply', 'tab_') -> save($apply_data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -736,7 +635,7 @@ class AutoPackController extends Think
|
|
|
|
|
*/
|
|
|
|
|
public function updateinfo($id, $pack_url, $promote, $plist_url)
|
|
|
|
|
{
|
|
|
|
|
$model = M('Apply', "tab_");
|
|
|
|
|
$data = [];
|
|
|
|
|
$data['id'] = $id;
|
|
|
|
|
$data['pack_url'] = $pack_url;
|
|
|
|
|
$data['dow_url'] = '/index.php?s=/Home/Down/down_file/game_id/' . $promote['game_id'] . '/promote_id/' . $promote['promote_id'];
|
|
|
|
@ -745,7 +644,7 @@ class AutoPackController extends Think
|
|
|
|
|
$data['dispose_id'] = UID;
|
|
|
|
|
$data['dispose_time'] = NOW_TIME;
|
|
|
|
|
$data['plist_url'] = $plist_url;
|
|
|
|
|
$res = $model -> save($data);
|
|
|
|
|
$res = M('Apply', 'tab_')->save($data);
|
|
|
|
|
return $res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|