Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loveisland
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘小敏
loveisland
Commits
1ebb5b3c
Commit
1ebb5b3c
authored
May 19, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3D试戴 调试11
parent
cf1f48d1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
88 deletions
+4
-88
AiTryon.php
addons/shopro/controller/user/AiTryon.php
+1
-1
AiVideoGen.php
addons/shopro/job/AiVideoGen.php
+1
-85
Ai.php
addons/shopro/service/user/Ai.php
+2
-2
No files found.
addons/shopro/controller/user/AiTryon.php
View file @
1ebb5b3c
...
...
@@ -164,7 +164,7 @@ class AiTryon extends Common
}
else
{
// 保存图片到本地
$aiService
=
new
Ai
();
$attachment
=
$aiService
->
saveFileLoc
(
isset
(
$res
[
'data'
])
?
$res
[
'data'
]
:
''
,
'gen_ai'
);
$attachment
=
$aiService
->
saveFileLoc
(
isset
(
$res
[
'data'
])
?
$res
[
'data'
]
:
''
,
'
.png'
,
'
gen_ai'
);
// $upload = new Upload();
// $attachment = $upload->uploadBase64($res['data']);
...
...
addons/shopro/job/AiVideoGen.php
View file @
1ebb5b3c
...
...
@@ -39,90 +39,6 @@ class AiVideoGen extends BaseJob
}
/**
* 保存远端视频文件到本地
* 暂时无用了
*/
private
function
saveVideoLoc
(
$videoUrl
){
$this
->
debug_log
(
'videoUrl: '
.
$videoUrl
);
// 1 生成存储目录(fastadmin标准uploads目录)
$upload_dir
=
'/uploads/ai_video/'
.
date
(
'Ymd'
)
.
'/'
;
$dir
=
$this
->
public_dir
.
$upload_dir
;
if
(
!
is_dir
(
$dir
))
{
mkdir
(
$dir
,
0755
,
true
);
}
// 2 生成唯一文件名
$filename
=
md5
(
time
()
.
uniqid
())
.
'.mp4'
;
$full_path
=
$this
->
public_dir
.
$upload_dir
.
$filename
;
// 3 加载视频地址
$ch
=
curl_init
(
$videoUrl
);
$fp
=
fopen
(
$full_path
,
'wb'
);
curl_setopt
(
$ch
,
CURLOPT_FILE
,
$fp
);
curl_setopt
(
$ch
,
CURLOPT_FOLLOWLOCATION
,
true
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
false
);
curl_setopt
(
$ch
,
CURLOPT_USERAGENT
,
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
);
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
300
);
// 4 写入文件
curl_exec
(
$ch
);
$error
=
curl_error
(
$ch
);
$http_code
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
// 获取HTTP状态码
curl_close
(
$ch
);
fclose
(
$fp
);
// 5 严格判断:网络错误 / HTTP状态码异常 / 文件为空
if
(
$error
||
$http_code
>=
400
||
filesize
(
$full_path
)
===
0
)
{
// 下载失败,删除产生的空文件
if
(
file_exists
(
$full_path
))
{
unlink
(
$full_path
);
}
$this
->
debug_log
(
'视频下载失败:'
.
$error
.
"HTTP状态码:
{
$http_code
}
,文件为空"
);
return
0
;
// 统一失败返回值
}
if
(
!
file_exists
(
$full_path
))
{
return
0
;
}
return
$upload_dir
.
$filename
;
}
/**
* 删除本地保存的视频文件
* @param string $videoPath 绝对路径(就是 saveVideoLoc 方法返回的路径,如:/uploads/ai_video/20250820/xxx.mp4)
* @return bool 删除成功返回 true,失败/文件不存在返回 false
*/
private
function
deleteLocalVideo
(
$videoPath
)
{
// 拼接完整物理路径(和保存时一致)
$fullPath
=
$this
->
public_dir
.
ltrim
(
$videoPath
,
'/'
);
// 1. 判断文件是否存在
if
(
!
file_exists
(
$fullPath
))
{
return
false
;
}
// 2. 判断是否是文件(防止误删目录)
if
(
!
is_file
(
$fullPath
))
{
return
false
;
}
// 3. 尝试删除文件
try
{
$deleted
=
unlink
(
$fullPath
);
return
$deleted
;
}
catch
(
\Exception
$e
)
{
// 删除失败(权限不足、文件被占用等)
return
false
;
}
}
/**
* AI视频结果处理
*/
public
function
save
(
Job
$job
,
$data
)
...
...
@@ -196,7 +112,7 @@ class AiVideoGen extends BaseJob
case
'succeeded'
:
// 保存远程视频到本地
$aiService
=
new
Ai
();
$video_url
=
$aiService
->
saveFileLoc
(
isset
(
$result
[
'content'
][
'video_url'
])
?
$result
[
'content'
][
'video_url'
]
:
''
,
'gen_ai'
);
$video_url
=
$aiService
->
saveFileLoc
(
isset
(
$result
[
'content'
][
'video_url'
])
?
$result
[
'content'
][
'video_url'
]
:
''
,
'
.mp4'
,
'
gen_ai'
);
// $video_url = $this->saveVideoLoc(isset($result['content']['video_url']) ? $result['content']['video_url'] : '');
...
...
addons/shopro/service/user/Ai.php
View file @
1ebb5b3c
...
...
@@ -60,7 +60,7 @@ class Ai
* 保存远端文件到本地
* 主要用于3D试戴 2026.05.19
*/
public
function
saveFileLoc
(
$file_url
,
$log_name
=
'gen_ai'
){
public
function
saveFileLoc
(
$file_url
,
$
file_suffix
=
'.png'
,
$
log_name
=
'gen_ai'
){
if
(
empty
(
$file_url
))
{
return
0
;
}
...
...
@@ -76,7 +76,7 @@ class Ai
}
// 2 生成唯一文件名
$filename
=
md5
(
time
()
.
uniqid
())
.
'.mp4'
;
$filename
=
md5
(
time
()
.
uniqid
())
.
$file_suffix
;
$full_path
=
$this
->
public_dir
.
$upload_dir
.
$filename
;
// 3 加载视频地址
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment