|
|
|
@ -297,7 +297,6 @@ class AutoPackController extends Think
|
|
|
|
|
$map = [];
|
|
|
|
|
$map['status'] = 1;
|
|
|
|
|
$map['enable_status'] = ['in', '0,2'];
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
|
|
|
|
|
$applys = M('apply', 'tab_')->field('id,game_id,game_name,promote_id,promote_account,sdk_version')
|
|
|
|
|
->where($map)
|
|
|
|
@ -335,149 +334,6 @@ class AutoPackController extends Think
|
|
|
|
|
$message = 'SUCCESS ----- ' . $message . $result['message'];
|
|
|
|
|
} else {
|
|
|
|
|
$message = 'ERROR ----- ' . $message . $result['message'];
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
$applyModel = M('apply', 'tab_');
|
|
|
|
|
$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(100)
|
|
|
|
|
-> select();
|
|
|
|
|
|
|
|
|
|
$applyIds = array_column($apply_data, 'id');
|
|
|
|
|
$applyCount = count($applyIds);
|
|
|
|
|
if ($applyCount > 0) {
|
|
|
|
|
M('apply', 'tab_')->where(['id' => ['in', $applyIds]])->save(['enable_status' => 3]);
|
|
|
|
|
echo date('Y-m-d H:i:s') . ' PackCount: ' . $applyCount . PHP_EOL;
|
|
|
|
|
} else {
|
|
|
|
|
echo date('Y-m-d H:i:s') . ' PackCount: ' . $applyCount . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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'=>'']);
|
|
|
|
|
|
|
|
|
|
} 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
>>>>>>> hotfix/package
|
|
|
|
|
}
|
|
|
|
|
Printer::export($message);
|
|
|
|
|
}
|
|
|
|
|