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
7a7c3c20
Commit
7a7c3c20
authored
Apr 30, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AI试戴生成图片接口优化
parent
a6360472
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
AiTryon.php
addons/shopro/controller/user/AiTryon.php
+25
-14
No files found.
addons/shopro/controller/user/AiTryon.php
View file @
7a7c3c20
...
@@ -107,7 +107,7 @@ class AiTryon extends Common
...
@@ -107,7 +107,7 @@ class AiTryon extends Common
}
}
$params
=
$this
->
request
->
only
([
$params
=
$this
->
request
->
only
([
'person_image'
,
'jewelry_image'
,
'goods_id'
,
'goods_title'
,
'goods_subtitle'
,
'goods_image'
'person_image'
,
'jewelry_image'
,
'goods_id'
,
'goods_title'
,
'goods_subtitle'
]);
]);
$this
->
svalidate
(
$params
,
".aiadd"
);
$this
->
svalidate
(
$params
,
".aiadd"
);
...
@@ -122,29 +122,40 @@ class AiTryon extends Common
...
@@ -122,29 +122,40 @@ class AiTryon extends Common
$ai
=
new
Ai
();
$ai
=
new
Ai
();
$res
=
$ai
->
generateImage
(
$params
,
$user
->
id
);
$res
=
$ai
->
generateImage
(
$params
,
$user
->
id
);
// 我的试戴
$tryonModel
=
new
AiTryOnModel
();
$tryonData
=
[
'user_id'
=>
$user
->
id
,
'goods_id'
=>
$params
[
'goods_id'
],
'goods_title'
=>
$params
[
'goods_title'
],
'goods_subtitle'
=>
$params
[
'goods_subtitle'
],
'goods_image'
=>
$params
[
'jewelry_image'
],
'ai_task_id'
=>
0
,
'ai_type'
=>
0
,
];
if
(
$res
[
'code'
]
===
0
)
{
if
(
$res
[
'code'
]
===
0
)
{
$tryonData
[
'ai_status'
]
=
2
;
$tryonData
[
'ai_err_msg'
]
=
$res
[
'msg'
];
$tryonModel
->
save
(
$tryonData
);
$this
->
error
(
$res
[
'msg'
]);
$this
->
error
(
$res
[
'msg'
]);
}
else
{
}
else
{
// 保存图片到本
服务器
// 保存图片到本
地
$upload
=
new
Upload
();
$upload
=
new
Upload
();
$attachment
=
$upload
->
uploadBase64
(
$res
[
'data'
]);
$attachment
=
$upload
->
uploadBase64
(
$res
[
'data'
]);
if
(
$attachment
[
'code'
]
==
0
){
if
(
$attachment
[
'code'
]
==
0
){
$tryonData
[
'ai_status'
]
=
2
;
$tryonData
[
'ai_err_msg'
]
=
'图片上传失败'
;
$tryonModel
->
save
(
$tryonData
);
$this
->
error
(
'图片上传失败'
);
$this
->
error
(
'图片上传失败'
);
}
}
$userAddress
=
new
AiTryOnModel
();
$tryonData
[
'ai_status'
]
=
1
;
$userAddress
->
save
([
$tryonData
[
'ai_url'
]
=
config
(
'shopro.api_host'
)
.
$attachment
[
'data'
];
'ai_url'
=>
config
(
'shopro.api_host'
)
.
$attachment
[
'data'
],
$tryonModel
->
save
(
$tryonData
);
'user_id'
=>
$user
->
id
,
'goods_id'
=>
$params
[
'goods_id'
],
'goods_title'
=>
$params
[
'goods_title'
],
'goods_subtitle'
=>
$params
[
'goods_subtitle'
],
'goods_image'
=>
$params
[
'goods_image'
],
'ai_status'
=>
1
,
'ai_task_id'
=>
0
,
'ai_type'
=>
0
,
]);
$this
->
success
(
$res
[
'msg'
],
config
(
'shopro.api_host'
)
.
$attachment
[
'data'
]);
$this
->
success
(
$res
[
'msg'
],
config
(
'shopro.api_host'
)
.
$attachment
[
'data'
]);
}
}
...
...
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