Commit 01de3a24 authored by 刘小敏's avatar 刘小敏

个人信息保存生日数据为空报错处理;去掉生成图片接口中的异常截获处理;上传图片视频改为50M上限;试戴列表增加3d是滴啊图片不为空限制;

parent de371347
......@@ -74,72 +74,66 @@ class AiTryon extends Common
if (!$this->request->isPost()) {
$this->error('');
}
try {
$params = $this->request->only([
'person_image', 'jewelry_image','goods_id','goods_title','goods_subtitle'
]);
$this->svalidate($params, ".aiadd");
$user = auth_user();
//开发过程中临时调试代码
// \think\Queue::push('\addons\shopro\job\AiImgGen@exec', ['user' => $user->toArray(), 'id' => 245 ], 'shopro-high');
// $this->success('推送队列成功777');
// exit;
// $this->success('图片生成成功', 'https://zhubaoshop.sydggxs.com/uploads/20260508/c92396f646bd41887329891647fcfcaf.png');
// 校验商品分类是否在允许试戴分类中
$goodsService = new GoodsService();
$is_allowed = $goodsService->isCategoryAllowed('', $params['goods_id']);
if ($is_allowed === 0) {
custom_log('[AI生成图片接口] 商品所属分类不允许试戴 user_id:'.$user->id.' goods_id:'.$params['goods_id'], 'gen_ai');
$this->error('商品所属分类不允许试戴');
}
$params = $this->request->only([
'person_image', 'jewelry_image','goods_id','goods_title','goods_subtitle'
]);
$this->svalidate($params, ".aiadd");
$user = auth_user();
//开发过程中临时调试代码
// \think\Queue::push('\addons\shopro\job\AiImgGen@exec', ['user' => $user->toArray(), 'id' => 245 ], 'shopro-high');
// $this->success('推送队列成功777');
// exit;
// $this->success('图片生成成功', 'https://zhubaoshop.sydggxs.com/uploads/20260508/c92396f646bd41887329891647fcfcaf.png');
// 校验商品分类是否在允许试戴分类中
$goodsService = new GoodsService();
$is_allowed = $goodsService->isCategoryAllowed('', $params['goods_id']);
if ($is_allowed === 0) {
custom_log('[AI生成图片接口] 商品所属分类不允许试戴 user_id:'.$user->id.' goods_id:'.$params['goods_id'], 'gen_ai');
$this->error('商品所属分类不允许试戴');
}
// 校验试戴次数 && 扣除积分
$userService = new User();
$res = $userService->isTry($user->id);
// 校验试戴次数 && 扣除积分
$userService = new User();
$res = $userService->isTry($user->id);
if ($res === 0) {
custom_log('[AI生成图片接口] 免费次数已用完 user_id:'.$user->id.' goods_id:'.$params['goods_id'], 'gen_ai');
// 免费试戴次数用完后,扣积分,试戴一次扣10积分
$res = $userService->deductPoints($user->id, 10);
if ($res === 0) {
custom_log('[AI生成图片接口] 免费次数已用完 user_id:'.$user->id.' goods_id:'.$params['goods_id'], 'gen_ai');
// 免费试戴次数用完后,扣积分,试戴一次扣10积分
$res = $userService->deductPoints($user->id, 10);
if ($res === 0) {
custom_log('[AI生成图片接口] 积分不足 user_id:'.$user->id.' goods_id:'.$params['goods_id'], 'gen_ai');
$this->error('免费次数已用完,积分不足,无法试戴');
}
custom_log('[AI生成图片接口] 积分不足 user_id:'.$user->id.' goods_id:'.$params['goods_id'], 'gen_ai');
$this->error('免费次数已用完,积分不足,无法试戴');
}
// 我的试戴
$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'],
'person_image' => $params['person_image'],
'ai_task_id' => '',
'ai_type' => 0,
'ai_status' => 0,
'ai_url' => '',
'createtime' => time()
];
$id = $tryonModel->insertGetId($tryonData);
// 试戴次数+1
$userService->addTryTimes($user->id);
// 推送队列
\think\Queue::push('\addons\shopro\job\AiImgGen@exec', ['user' => $user->toArray(), 'id' => $id ], 'shopro-high');
$this->success('图片生成中', $id);
} catch (\Exception $e) {
format_log_error_custom_name($e, '[AI生成图片接口]', '', 'gen_ai');
$this->error('生成失败: ' . $e->getMessage());
}
// 我的试戴
$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'],
'person_image' => $params['person_image'],
'ai_task_id' => '',
'ai_type' => 0,
'ai_status' => 0,
'ai_url' => '',
'createtime' => time()
];
$id = $tryonModel->insertGetId($tryonData);
// 试戴次数+1
$userService->addTryTimes($user->id);
// 推送队列
\think\Queue::push('\addons\shopro\job\AiImgGen@exec', ['user' => $user->toArray(), 'id' => $id ], 'shopro-high');
$this->success('图片生成中', $id);
}
/**
......
......@@ -100,6 +100,11 @@ class User extends Common
$params = $this->request->only(['avatar', 'nickname', 'birthday']);
$this->svalidate($params, '.update');
// 处理 birthday 字段为空字符串的情况
if (isset($params['birthday']) && trim($params['birthday']) === '') {
$params['birthday'] = null;
}
$user->save($params);
$user->hidden(['password', 'salt', 'createtime', 'updatetime', 'deletetime', 'remember_token', 'login_fail', 'login_ip', 'login_time']);
......
......@@ -355,6 +355,8 @@ class GoodsService
// 默认排序
$goods = $this->up()
->categories($allowed_cate_ids)
->whereNotNull('image_3d')
->where('image_3d', '<>', '')
->order('id', 'desc')
->paginate($is_cache);
return $goods;
......
......@@ -17,7 +17,7 @@ return [
/**
* 最大可上传大小
*/
'maxsize' => '10mb',
'maxsize' => '50mb',
/**
* 可上传的文件类型
* 如配置允许 pdf,ppt,docx,svg 等可能含有脚本的文件时,请先从服务器配置此类文件直接下载而不是预览
......
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