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

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

parent 7a7c3c20
...@@ -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']);
// }
// }
} }
......
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