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
01de3a24
Commit
01de3a24
authored
Jun 04, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
个人信息保存生日数据为空报错处理;去掉生成图片接口中的异常截获处理;上传图片视频改为50M上限;试戴列表增加3d是滴啊图片不为空限制;
parent
de371347
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
62 deletions
+63
-62
AiTryon.php
addons/shopro/controller/user/AiTryon.php
+55
-61
User.php
addons/shopro/controller/user/User.php
+5
-0
GoodsService.php
addons/shopro/service/goods/GoodsService.php
+2
-0
upload.php
application/extra/upload.php
+1
-1
No files found.
addons/shopro/controller/user/AiTryon.php
View file @
01de3a24
...
@@ -74,72 +74,66 @@ class AiTryon extends Common
...
@@ -74,72 +74,66 @@ class AiTryon extends Common
if
(
!
$this
->
request
->
isPost
())
{
if
(
!
$this
->
request
->
isPost
())
{
$this
->
error
(
''
);
$this
->
error
(
''
);
}
}
try
{
$params
=
$this
->
request
->
only
([
$params
=
$this
->
request
->
only
([
'person_image'
,
'jewelry_image'
,
'goods_id'
,
'goods_title'
,
'goods_subtitle'
'person_image'
,
'jewelry_image'
,
'goods_id'
,
'goods_title'
,
'goods_subtitle'
]);
]);
$this
->
svalidate
(
$params
,
".aiadd"
);
$this
->
svalidate
(
$params
,
".aiadd"
);
$user
=
auth_user
();
$user
=
auth_user
();
//开发过程中临时调试代码
//开发过程中临时调试代码
// \think\Queue::push('\addons\shopro\job\AiImgGen@exec', ['user' => $user->toArray(), 'id' => 245 ], 'shopro-high');
// \think\Queue::push('\addons\shopro\job\AiImgGen@exec', ['user' => $user->toArray(), 'id' => 245 ], 'shopro-high');
// $this->success('推送队列成功777');
// $this->success('推送队列成功777');
// exit;
// exit;
// $this->success('图片生成成功', 'https://zhubaoshop.sydggxs.com/uploads/20260508/c92396f646bd41887329891647fcfcaf.png');
// $this->success('图片生成成功', 'https://zhubaoshop.sydggxs.com/uploads/20260508/c92396f646bd41887329891647fcfcaf.png');
// 校验商品分类是否在允许试戴分类中
// 校验商品分类是否在允许试戴分类中
$goodsService
=
new
GoodsService
();
$goodsService
=
new
GoodsService
();
$is_allowed
=
$goodsService
->
isCategoryAllowed
(
''
,
$params
[
'goods_id'
]);
$is_allowed
=
$goodsService
->
isCategoryAllowed
(
''
,
$params
[
'goods_id'
]);
if
(
$is_allowed
===
0
)
{
if
(
$is_allowed
===
0
)
{
custom_log
(
'[AI生成图片接口] 商品所属分类不允许试戴 user_id:'
.
$user
->
id
.
' goods_id:'
.
$params
[
'goods_id'
],
'gen_ai'
);
custom_log
(
'[AI生成图片接口] 商品所属分类不允许试戴 user_id:'
.
$user
->
id
.
' goods_id:'
.
$params
[
'goods_id'
],
'gen_ai'
);
$this
->
error
(
'商品所属分类不允许试戴'
);
$this
->
error
(
'商品所属分类不允许试戴'
);
}
}
// 校验试戴次数 && 扣除积分
// 校验试戴次数 && 扣除积分
$userService
=
new
User
();
$userService
=
new
User
();
$res
=
$userService
->
isTry
(
$user
->
id
);
$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
)
{
if
(
$res
===
0
)
{
custom_log
(
'[AI生成图片接口] 免费次数已用完 user_id:'
.
$user
->
id
.
' goods_id:'
.
$params
[
'goods_id'
],
'gen_ai'
);
custom_log
(
'[AI生成图片接口] 积分不足 user_id:'
.
$user
->
id
.
' goods_id:'
.
$params
[
'goods_id'
],
'gen_ai'
);
// 免费试戴次数用完后,扣积分,试戴一次扣10积分
$this
->
error
(
'免费次数已用完,积分不足,无法试戴'
);
$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
(
'免费次数已用完,积分不足,无法试戴'
);
}
}
}
// 我的试戴
$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
);
}
}
/**
/**
...
...
addons/shopro/controller/user/User.php
View file @
01de3a24
...
@@ -100,6 +100,11 @@ class User extends Common
...
@@ -100,6 +100,11 @@ class User extends Common
$params
=
$this
->
request
->
only
([
'avatar'
,
'nickname'
,
'birthday'
]);
$params
=
$this
->
request
->
only
([
'avatar'
,
'nickname'
,
'birthday'
]);
$this
->
svalidate
(
$params
,
'.update'
);
$this
->
svalidate
(
$params
,
'.update'
);
// 处理 birthday 字段为空字符串的情况
if
(
isset
(
$params
[
'birthday'
])
&&
trim
(
$params
[
'birthday'
])
===
''
)
{
$params
[
'birthday'
]
=
null
;
}
$user
->
save
(
$params
);
$user
->
save
(
$params
);
$user
->
hidden
([
'password'
,
'salt'
,
'createtime'
,
'updatetime'
,
'deletetime'
,
'remember_token'
,
'login_fail'
,
'login_ip'
,
'login_time'
]);
$user
->
hidden
([
'password'
,
'salt'
,
'createtime'
,
'updatetime'
,
'deletetime'
,
'remember_token'
,
'login_fail'
,
'login_ip'
,
'login_time'
]);
...
...
addons/shopro/service/goods/GoodsService.php
View file @
01de3a24
...
@@ -355,6 +355,8 @@ class GoodsService
...
@@ -355,6 +355,8 @@ class GoodsService
// 默认排序
// 默认排序
$goods
=
$this
->
up
()
$goods
=
$this
->
up
()
->
categories
(
$allowed_cate_ids
)
->
categories
(
$allowed_cate_ids
)
->
whereNotNull
(
'image_3d'
)
->
where
(
'image_3d'
,
'<>'
,
''
)
->
order
(
'id'
,
'desc'
)
->
order
(
'id'
,
'desc'
)
->
paginate
(
$is_cache
);
->
paginate
(
$is_cache
);
return
$goods
;
return
$goods
;
...
...
application/extra/upload.php
View file @
01de3a24
...
@@ -17,7 +17,7 @@ return [
...
@@ -17,7 +17,7 @@ return [
/**
/**
* 最大可上传大小
* 最大可上传大小
*/
*/
'maxsize'
=>
'
1
0mb'
,
'maxsize'
=>
'
5
0mb'
,
/**
/**
* 可上传的文件类型
* 可上传的文件类型
* 如配置允许 pdf,ppt,docx,svg 等可能含有脚本的文件时,请先从服务器配置此类文件直接下载而不是预览
* 如配置允许 pdf,ppt,docx,svg 等可能含有脚本的文件时,请先从服务器配置此类文件直接下载而不是预览
...
...
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