CRMEB/crmeb/app/jobs/ThemeExportJob.php
2026-03-23 14:57:47 +08:00

60 lines
2.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\jobs;
use app\services\diy\ThemeDownloadServices;
use app\services\diy\ThemeServices;
use crmeb\basic\BaseJobs;
use crmeb\traits\QueueTrait;
use think\facade\Log;
/**
* 主题导出队列任务
* Class ThemeExportJob
* @package app\jobs
*/
class ThemeExportJob extends BaseJobs
{
use QueueTrait;
/**
* 执行主题导出任务
* 1. 打包主题文件生成 zip
* 2. 将 download_url 写回 eb_theme_download 记录
*
* @param $info 主题信息
* @param int $recordId eb_theme_download 记录ID
* @return bool
* @author wuhaotian
* @email 442384644@qq.com
* @date 2026/3/10
*/
public function export($info, int $recordId): bool
{
try {
/** @var ThemeServices $themeServices */
$themeServices = app()->make(ThemeServices::class);
/** @var ThemeDownloadServices $themeDownloadServices */
$themeDownloadServices = app()->make(ThemeDownloadServices::class);
$downloadUrl = $themeServices->exportThemePackage($info);
// 将生成的下载地址写回下载记录
$themeDownloadServices->updateDownloadUrl($recordId, $downloadUrl);
} catch (\Throwable $e) {
Log::error('主题导出队列失败,原因:' . $e->getMessage() . ' ' . $e->getFile() . ':' . $e->getLine());
return false;
}
return true;
}
}