Commit 11665591 authored by 刘小敏's avatar 刘小敏

AI试戴生成图片返回假数据,后面联调的时候再放开

parent 7a7c3c20
......@@ -118,47 +118,51 @@ class AiTryon extends Common
if ($res === 0) {
$this->success('今日免费试戴次数已用完', 0);
} else {
//开发时候先这样处理,AI图片生成次数有限
$this->success('图片生成成功', 'http://love.island.loc/uploads/ai_images/20260430/04fd981f2110313af3ecefe9ecc3aa6c.jpg');
// 合成AI图
$ai = new Ai();
$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) {
$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']);
}
// $ai = new Ai();
// $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) {
//
// $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']);
// }
}
}
......@@ -167,27 +171,64 @@ class AiTryon extends Common
*/
public function genVideo()
{
if (!$this->request->isPost()) {
$this->error('');
}
$params = $this->request->only([
'person_image', 'jewelry_image'
]);
$this->svalidate($params, ".aiadd");
$user = auth_user();
$userService = new User();
$res = $userService->isTry($user->id);
if ($res === 0) {
$this->success('今日免费试戴次数已用完', 0);
} else {
$ai = new Ai();
$res = $ai->generateVideo($params);
$this->success('视频生成成功', $res);
}
// if (!$this->request->isPost()) {
// $this->error('');
// }
//
// $params = $this->request->only([
// 'person_image', 'jewelry_image','goods_id','goods_title','goods_subtitle'
// ]);
// $this->svalidate($params, ".aiadd");
//
// $user = auth_user();
// $userService = new User();
// $res = $userService->isTry($user->id);
//
// if ($res === 0) {
// $this->success('今日免费试戴次数已用完', 0);
// } else {
// // 合成AI图
// $ai = new Ai();
// $res = $ai->generateVideo($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) {
//
// $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']);
// }
// }
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment