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

AI试戴 开发代码移除,换成正式代码

parent 85eceb29
...@@ -27,27 +27,28 @@ class AiTryon extends Common ...@@ -27,27 +27,28 @@ class AiTryon extends Common
/** /**
* 保存至我的试戴 * 保存至我的试戴
* 已废弃
*/ */
public function saveMyTryon() public function saveMyTryon()
{ {
if (!$this->request->isPost()) { // if (!$this->request->isPost()) {
$this->error(''); // $this->error('');
} // }
$user = auth_user(); // $user = auth_user();
//
$params = $this->request->only([ // $params = $this->request->only([
'url', 'goods_id', 'goods_title', 'goods_sku_id', 'goods_sku_name', 'goods_sku_image' // 'url', 'goods_id', 'goods_title', 'goods_sku_id', 'goods_sku_name', 'goods_sku_image'
]); // ]);
$params['user_id'] = $user->id; // $params['user_id'] = $user->id;
//
$this->svalidate($params, ".add"); // $this->svalidate($params, ".add");
//
Db::transaction(function () use ($params) { // Db::transaction(function () use ($params) {
$userAddress = new AiTryOnModel(); // $userAddress = new AiTryOnModel();
$userAddress->save($params); // $userAddress->save($params);
}); // });
//
$this->success('保存成功' ); // $this->success('保存成功' );
} }
/** /**
...@@ -120,55 +121,55 @@ class AiTryon extends Common ...@@ -120,55 +121,55 @@ class AiTryon extends Common
$this->success('今日免费试戴次数已用完', 0); $this->success('今日免费试戴次数已用完', 0);
} else { } else {
//开发时候先这样处理,AI图片生成次数有限 // //开发时候先这样处理,AI图片生成次数有限
$this->success('图片生成成功', 'https://zhubaoshop.sydggxs.com/uploads/20260508/c92396f646bd41887329891647fcfcaf.png'); // $this->success('图片生成成功', 'https://zhubaoshop.sydggxs.com/uploads/20260508/c92396f646bd41887329891647fcfcaf.png');
// 合成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'],
// 'person_image' => $params['person_image'], 'person_image' => $params['person_image'],
// 'ai_task_id' => '', 'ai_task_id' => '',
// '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);
// //试戴次数+1 //试戴次数+1
// $userService = new User(); $userService = new User();
// $res = $userService->addTryTimes($user->id); $res = $userService->addTryTimes($user->id);
//
// $this->success($res['msg'], config('shopro.api_host') . $attachment['data']); $this->success($res['msg'], config('shopro.api_host') . $attachment['data']);
// } }
} }
} }
...@@ -177,10 +178,6 @@ class AiTryon extends Common ...@@ -177,10 +178,6 @@ class AiTryon extends Common
*/ */
public function getAiDetail() public function getAiDetail()
{ {
if (!$this->request->isGet()) {
$this->error('请用get方式请求');
}
$params = $this->request->only(['id']); $params = $this->request->only(['id']);
$this->svalidate($params, ".aidetail"); $this->svalidate($params, ".aidetail");
...@@ -220,48 +217,48 @@ class AiTryon extends Common ...@@ -220,48 +217,48 @@ class AiTryon extends Common
// 开发过程中临时代码 // 开发过程中临时代码
$this->success('视频生成中', 13); $this->success('视频生成中', 13);
// // 合成AI视频 // 合成AI视频
// $ai = new Ai(); $ai = new Ai();
// $res = $ai->generateVideo($params, $user->id); $res = $ai->generateVideo($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'],
// 'person_image' => $params['person_image'], 'person_image' => $params['person_image'],
// 'ai_type' => 1, 'ai_type' => 1,
// ]; ];
//
// 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 {
//
// // 保存一条 我的试戴 // 保存一条 我的试戴
// $tryonData['ai_status'] = 0; $tryonData['ai_status'] = 0;
// $tryonData['ai_task_id'] = isset($res['data']) ? $res['data'] : ''; $tryonData['ai_task_id'] = isset($res['data']) ? $res['data'] : '';
// $tryonModel->save($tryonData); $tryonModel->save($tryonData);
// $id = $tryonModel->id; $id = $tryonModel->id;
// //试戴次数+1 //试戴次数+1
// $userService = new User(); $userService = new User();
// $res = $userService->addTryTimes($user->id); $res = $userService->addTryTimes($user->id);
//
// // 推送队列 // 推送队列
// \think\Queue::push('\addons\shopro\job\AiVideoGen@save', ['taskid' => $res['data'], 'user' => $user], 'shopro-high'); \think\Queue::push('\addons\shopro\job\AiVideoGen@save', ['taskid' => $res['data'], 'user' => $user], 'shopro-high');
//
// $this->success($res['msg'], $id); $this->success($res['msg'], $id);
//
// } }
} }
} }
......
...@@ -45,15 +45,9 @@ class User ...@@ -45,15 +45,9 @@ class User
// 查询我的试戴列表 // 查询我的试戴列表
$res = userModel::where('id', $user_id) $res = userModel::where('id', $user_id)
->find(); ->find();
// if ($res->ai_count > 4 && $res->ai_time > Time::today()[0]) { if ($res->ai_count > 4 && $res->ai_time > Time::today()[0]) {
if ($res->ai_count > 999999 && $res->ai_time > Time::today()[0]) {
return 0; // 不可以试戴 return 0; // 不可以试戴
} else { } else {
if($res->ai_time < Time::today()[0]) {
$ai_count = 1;
} else {
$ai_count = intval($res->ai_count)+1;
}
return 1; // 可以试戴 return 1; // 可以试戴
} }
} }
......
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