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
11665591
Commit
11665591
authored
Apr 30, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AI试戴生成图片返回假数据,后面联调的时候再放开
parent
7a7c3c20
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
61 deletions
+102
-61
AiTryon.php
addons/shopro/controller/user/AiTryon.php
+102
-61
No files found.
addons/shopro/controller/user/AiTryon.php
View file @
11665591
...
@@ -118,47 +118,51 @@ class AiTryon extends Common
...
@@ -118,47 +118,51 @@ class AiTryon extends Common
if
(
$res
===
0
)
{
if
(
$res
===
0
)
{
$this
->
success
(
'今日免费试戴次数已用完'
,
0
);
$this
->
success
(
'今日免费试戴次数已用完'
,
0
);
}
else
{
}
else
{
//开发时候先这样处理,AI图片生成次数有限
$this
->
success
(
'图片生成成功'
,
'http://love.island.loc/uploads/ai_images/20260430/04fd981f2110313af3ecefe9ecc3aa6c.jpg'
);
// 合成AI图
// 合成AI图
$ai
=
new
Ai
();
//
$ai = new Ai();
$res
=
$ai
->
generateImage
(
$params
,
$user
->
id
);
//
$res = $ai->generateImage($params, $user->id);
//
// 我的试戴
//
// 我的试戴
$tryonModel
=
new
AiTryOnModel
();
//
$tryonModel = new AiTryOnModel();
$tryonData
=
[
//
$tryonData = [
'user_id'
=>
$user
->
id
,
//
'user_id' => $user->id,
'goods_id'
=>
$params
[
'goods_id'
],
//
'goods_id' => $params['goods_id'],
'goods_title'
=>
$params
[
'goods_title'
],
//
'goods_title' => $params['goods_title'],
'goods_subtitle'
=>
$params
[
'goods_subtitle'
],
//
'goods_subtitle' => $params['goods_subtitle'],
'goods_image'
=>
$params
[
'jewelry_image'
],
//
'goods_image' => $params['jewelry_image'],
'ai_task_id'
=>
0
,
//
'ai_task_id' => 0,
'ai_type'
=>
0
,
//
'ai_type' => 0,
];
//
];
//
if
(
$res
[
'code'
]
===
0
)
{
//
if ($res['code'] === 0) {
//
$tryonData
[
'ai_status'
]
=
2
;
//
$tryonData['ai_status'] = 2;
$tryonData
[
'ai_err_msg'
]
=
$res
[
'msg'
];
//
$tryonData['ai_err_msg'] = $res['msg'];
$tryonModel
->
save
(
$tryonData
);
//
$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_status'] = 2;
$tryonData
[
'ai_err_msg'
]
=
'图片上传失败'
;
//
$tryonData['ai_err_msg'] = '图片上传失败';
$tryonModel
->
save
(
$tryonData
);
//
$tryonModel->save($tryonData);
$this
->
error
(
'图片上传失败'
);
//
$this->error('图片上传失败');
}
//
}
//
$tryonData
[
'ai_status'
]
=
1
;
//
$tryonData['ai_status'] = 1;
$tryonData
[
'ai_url'
]
=
config
(
'shopro.api_host'
)
.
$attachment
[
'data'
];
//
$tryonData['ai_url'] = config('shopro.api_host') . $attachment['data'];
$tryonModel
->
save
(
$tryonData
);
//
$tryonModel->save($tryonData);
//
$this
->
success
(
$res
[
'msg'
],
config
(
'shopro.api_host'
)
.
$attachment
[
'data'
]);
//
$this->success($res['msg'], config('shopro.api_host') . $attachment['data']);
}
//
}
}
}
}
}
...
@@ -167,27 +171,64 @@ class AiTryon extends Common
...
@@ -167,27 +171,64 @@ class AiTryon extends Common
*/
*/
public
function
genVideo
()
public
function
genVideo
()
{
{
if
(
!
$this
->
request
->
isPost
())
{
// if (!$this->request->isPost()) {
$this
->
error
(
''
);
// $this->error('');
}
// }
//
$params
=
$this
->
request
->
only
([
// $params = $this->request->only([
'person_image'
,
'jewelry_image'
// 'person_image', 'jewelry_image','goods_id','goods_title','goods_subtitle'
]);
// ]);
$this
->
svalidate
(
$params
,
".aiadd"
);
// $this->svalidate($params, ".aiadd");
//
$user
=
auth_user
();
// $user = auth_user();
$userService
=
new
User
();
// $userService = new User();
$res
=
$userService
->
isTry
(
$user
->
id
);
// $res = $userService->isTry($user->id);
//
if
(
$res
===
0
)
{
// if ($res === 0) {
$this
->
success
(
'今日免费试戴次数已用完'
,
0
);
// $this->success('今日免费试戴次数已用完', 0);
}
else
{
// } else {
$ai
=
new
Ai
();
// // 合成AI图
$res
=
$ai
->
generateVideo
(
$params
);
// $ai = new Ai();
// $res = $ai->generateVideo($params, $user->id);
$this
->
success
(
'视频生成成功'
,
$res
);
//
}
// // 我的试戴
// $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) {
//
// $tryonData['ai_status'] = 2;
// $tryonData['ai_err_msg'] = $res['msg'];
// $tryonModel->save($tryonData);
//
// $this->error($res['msg']);
// } else {
// // 保存图片到本地
// $upload = new Upload();
// $attachment = $upload->uploadBase64($res['data']);
//
// if($attachment['code'] == 0){
// $tryonData['ai_status'] = 2;
// $tryonData['ai_err_msg'] = '图片上传失败';
// $tryonModel->save($tryonData);
// $this->error('图片上传失败');
// }
//
// $tryonData['ai_status'] = 1;
// $tryonData['ai_url'] = config('shopro.api_host') . $attachment['data'];
// $tryonModel->save($tryonData);
//
// $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