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
00b514ba
Commit
00b514ba
authored
May 30, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加AI试戴商品图;日志权限配置;AI试戴成图片优化;
parent
059352bf
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
57 deletions
+102
-57
AiTryon.php
addons/shopro/controller/user/AiTryon.php
+90
-55
Ai.php
addons/shopro/service/user/Ai.php
+1
-0
Goods.php
application/admin/controller/shopro/goods/Goods.php
+2
-2
add.html
application/admin/view/shopro/goods/goods/add.html
+6
-0
config.php
application/config.php
+2
-0
goods.js
public/assets/js/backend/shopro/goods/goods.js
+1
-0
No files found.
addons/shopro/controller/user/AiTryon.php
View file @
00b514ba
...
@@ -74,65 +74,72 @@ class AiTryon extends Common
...
@@ -74,65 +74,72 @@ class AiTryon extends Common
if
(
!
$this
->
request
->
isPost
())
{
if
(
!
$this
->
request
->
isPost
())
{
$this
->
error
(
''
);
$this
->
error
(
''
);
}
}
$params
=
$this
->
request
->
only
([
'person_image'
,
'jewelry_image'
,
'goods_id'
,
'goods_title'
,
'goods_subtitle'
]);
$this
->
svalidate
(
$params
,
".aiadd"
);
$user
=
auth_user
();
try
{
//开发过程中临时调试代码
$params
=
$this
->
request
->
only
([
// \think\Queue::push('\addons\shopro\job\AiImgGen@exec', ['user' => $user->toArray(), 'id' => 245 ], 'shopro-high');
'person_image'
,
'jewelry_image'
,
'goods_id'
,
'goods_title'
,
'goods_subtitle'
// $this->success('推送队列成功777');
]);
// exit;
$this
->
svalidate
(
$params
,
".aiadd"
);
// $this->success('图片生成成功', 'https://zhubaoshop.sydggxs.com/uploads/20260508/c92396f646bd41887329891647fcfcaf.png');
$user
=
auth_user
();
// 校验商品分类是否在允许试戴分类中
$goodsService
=
new
GoodsService
();
//开发过程中临时调试代码
$is_allowed
=
$goodsService
->
isCategoryAllowed
(
''
,
$params
[
'goods_id'
]);
// \think\Queue::push('\addons\shopro\job\AiImgGen@exec', ['user' => $user->toArray(), 'id' => 245 ], 'shopro-high');
if
(
$is_allowed
===
0
)
{
// $this->success('推送队列成功777');
custom_log
(
'[AI生成图片接口] 商品所属分类不允许试戴 user_id:'
.
$user
->
id
.
' goods_id:'
.
$params
[
'goods_id'
],
'gen_ai'
);
// exit;
$this
->
error
(
'商品所属分类不允许试戴'
);
// $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
();
$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'
);
$this
->
error
(
'免费次数已用完,积分不足,无法试戴'
);
// 免费试戴次数用完后,扣积分,试戴一次扣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
(
'免费次数已用完,积分不足,无法试戴'
);
}
}
}
}
// 我的试戴
$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
);
// 我的试戴
$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
());
}
}
}
/**
/**
...
@@ -146,7 +153,7 @@ class AiTryon extends Common
...
@@ -146,7 +153,7 @@ class AiTryon extends Common
$res
=
AiTryOnModel
::
get
(
$params
[
'id'
]);
$res
=
AiTryOnModel
::
get
(
$params
[
'id'
]);
switch
(
$res
->
ai_status
){
switch
(
$res
->
ai_status
){
case
0
:
case
0
:
$this
->
success
(
'
IA
结果生成中'
);
$this
->
success
(
'
AI
结果生成中'
);
break
;
break
;
case
1
:
case
1
:
$this
->
success
(
'AI试戴详情'
,
$res
);
$this
->
success
(
'AI试戴详情'
,
$res
);
...
@@ -227,4 +234,32 @@ class AiTryon extends Common
...
@@ -227,4 +234,32 @@ class AiTryon extends Common
}
}
/**
* 删除AI试戴记录(逻辑删除)
*/
public
function
delete
()
{
$params
=
$this
->
request
->
only
([
'id'
]);
$this
->
svalidate
(
$params
,
".aidetail"
);
$user
=
auth_user
();
// 查询试戴记录
$tryon
=
AiTryOnModel
::
where
(
'id'
,
$params
[
'id'
])
->
where
(
'user_id'
,
$user
->
id
)
->
where
(
'deletetime'
,
'null'
)
->
find
();
if
(
!
$tryon
)
{
$this
->
error
(
'记录不存在或已删除'
);
}
// 执行逻辑删除
$tryon
->
deletetime
=
time
();
$tryon
->
save
();
$this
->
success
(
'删除成功'
);
}
}
}
addons/shopro/service/user/Ai.php
View file @
00b514ba
...
@@ -209,6 +209,7 @@ class Ai
...
@@ -209,6 +209,7 @@ class Ai
"response_format"
=>
$response_format
,
"response_format"
=>
$response_format
,
"size"
=>
"2K"
,
"size"
=>
"2K"
,
"num"
=>
1
,
"num"
=>
1
,
"watermark"
=>
false
,
],
],
'timeout'
=>
300
,
'timeout'
=>
300
,
'verify'
=>
false
,
// 关闭 SSL 证书验证
'verify'
=>
false
,
// 关闭 SSL 证书验证
...
...
application/admin/controller/shopro/goods/Goods.php
View file @
00b514ba
...
@@ -116,7 +116,7 @@ class Goods extends Common
...
@@ -116,7 +116,7 @@ class Goods extends Common
}
}
$params
=
$this
->
request
->
only
([
$params
=
$this
->
request
->
only
([
'type'
,
'title'
,
'subtitle'
,
'category_ids'
,
'image'
,
'images'
,
'image_wh'
,
'params'
,
'type'
,
'title'
,
'subtitle'
,
'category_ids'
,
'image'
,
'images'
,
'image_wh'
,
'params'
,
'image_3d'
,
'original_price'
,
'price'
,
'is_sku'
,
'limit_type'
,
'limit_num'
,
'sales_show_type'
,
'original_price'
,
'price'
,
'is_sku'
,
'limit_type'
,
'limit_num'
,
'sales_show_type'
,
'stock_show_type'
,
'show_sales'
,
'service_ids'
,
'dispatch_type'
,
'dispatch_id'
,
'is_offline'
,
'status'
,
'weigh'
,
'stock_show_type'
,
'show_sales'
,
'service_ids'
,
'dispatch_type'
,
'dispatch_id'
,
'is_offline'
,
'status'
,
'weigh'
,
]);
// likes, views, sales,
]);
// likes, views, sales,
...
@@ -184,7 +184,7 @@ class Goods extends Common
...
@@ -184,7 +184,7 @@ class Goods extends Common
}
}
$params
=
$this
->
request
->
only
([
$params
=
$this
->
request
->
only
([
'type'
,
'title'
,
'subtitle'
,
'image'
,
'images'
,
'image_wh'
,
'params'
,
'type'
,
'title'
,
'subtitle'
,
'image'
,
'images'
,
'image_wh'
,
'params'
,
'category_ids'
,
'image_3d'
,
'original_price'
,
'price'
,
'is_sku'
,
'limit_type'
,
'limit_num'
,
'sales_show_type'
,
'original_price'
,
'price'
,
'is_sku'
,
'limit_type'
,
'limit_num'
,
'sales_show_type'
,
'stock_show_type'
,
'show_sales'
,
'service_ids'
,
'dispatch_type'
,
'dispatch_id'
,
'is_offline'
,
'status'
,
'weigh'
,
'recommend'
'stock_show_type'
,
'show_sales'
,
'service_ids'
,
'dispatch_type'
,
'dispatch_id'
,
'is_offline'
,
'status'
,
'weigh'
,
'recommend'
]);
// likes, views, sales,
]);
// likes, views, sales,
...
...
application/admin/view/shopro/goods/goods/add.html
View file @
00b514ba
...
@@ -341,6 +341,12 @@
...
@@ -341,6 +341,12 @@
作用于商品详情顶部轮播显示,
<br
/>
轮播图可以拖拽调整顺序
作用于商品详情顶部轮播显示,
<br
/>
轮播图可以拖拽调整顺序
</div>
</div>
</el-form-item>
</el-form-item>
<el-form-item
label=
"3D试戴图"
prop=
"image_3d"
>
<sa-uploader
v-model=
"form.model.image_3d"
type=
"image"
></sa-uploader>
<div
class=
"warning"
>
用于AI试戴功能的商品图片
</div>
</el-form-item>
<el-form-item
label=
"商品分类"
>
<el-form-item
label=
"商品分类"
>
<div
class=
"sa-w-360"
>
<div
class=
"sa-w-360"
>
<el-popover
popper-class=
"category-tooltip sa-popper"
effect=
"light"
<el-popover
popper-class=
"category-tooltip sa-popper"
effect=
"light"
...
...
application/config.php
View file @
00b514ba
...
@@ -172,6 +172,8 @@ return [
...
@@ -172,6 +172,8 @@ return [
'path'
=>
LOG_PATH
,
'path'
=>
LOG_PATH
,
// 日志记录级别
// 日志记录级别
'level'
=>
[],
'level'
=>
[],
// 日志文件权限(设置为 777 让所有用户可写)
'file_permission'
=>
0777
,
],
],
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | Trace设置 开启 app_trace 后 有效
// | Trace设置 开启 app_trace 后 有效
...
...
public/assets/js/backend/shopro/goods/goods.js
View file @
00b514ba
...
@@ -445,6 +445,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
...
@@ -445,6 +445,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
type
:
'normal'
,
// 商品类型
type
:
'normal'
,
// 商品类型
image
:
''
,
image
:
''
,
images
:
[],
images
:
[],
image_3d
:
''
,
title
:
''
,
title
:
''
,
subtitle
:
''
,
subtitle
:
''
,
category_ids
:
''
,
category_ids
:
''
,
...
...
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