Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
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
bp
goods
Commits
6f1de143
Commit
6f1de143
authored
Jun 21, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:商品增加修改敏感词判断
parent
ccf41451
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
GoodsException.php
application/exception/custom/GoodsException.php
+4
-0
GoodsService.php
application/services/goods/GoodsService.php
+39
-3
No files found.
application/exception/custom/GoodsException.php
View file @
6f1de143
...
...
@@ -30,5 +30,9 @@ class GoodsException extends BaseException
16
=>
'到期时间不得小于当前时间'
,
17
=>
'商品名称重复,请重新修复'
,
18
=>
'库存设置不合理'
,
19
=>
'商品名存在敏感词,请修改后提交'
,
20
=>
'商品说明存在敏感词,请修改后提交'
,
21
=>
'商品介绍存在敏感词,请修改后提交'
,
22
=>
'规则说明存在敏感词,请修改后提交'
,
];
}
\ No newline at end of file
application/services/goods/GoodsService.php
View file @
6f1de143
...
...
@@ -146,6 +146,22 @@ class GoodsService
if
(
$skuData
[
"expiration_time"
]
<
date
(
"Y-m-d H:i:s"
))
{
throw
new
GoodsException
([
'cus'
=>
16
]);
}
$checkGoodsName
=
self
::
isHaveSensitive
(
$skuData
[
"name"
],
1
);
if
(
$checkGoodsName
)
{
throw
new
GoodsException
([
'cus'
=>
19
]);
}
$checkGoodsDesc
=
self
::
isHaveSensitive
(
$skuData
[
"desc"
],
2
);
if
(
$checkGoodsDesc
)
{
throw
new
GoodsException
([
'cus'
=>
20
]);
}
$checkGoodsIntroduce
=
self
::
isHaveSensitive
(
$skuData
[
"introduce"
],
3
);
if
(
$checkGoodsIntroduce
)
{
throw
new
GoodsException
([
'cus'
=>
21
]);
}
$checkGoodsRuleDesc
=
self
::
isHaveSensitive
(
$skuData
[
"rule_desc"
],
2
);
if
(
$checkGoodsRuleDesc
)
{
throw
new
GoodsException
([
'cus'
=>
22
]);
}
$skuParams
=
[
"goods_sku_id"
=>
$skuId
,
...
...
@@ -437,6 +453,22 @@ class GoodsService
if
(
$inventoryCount
<
0
)
{
throw
new
GoodsException
([
'cus'
=>
18
]);
}
$checkGoodsName
=
self
::
isHaveSensitive
(
$params
[
"name"
],
1
);
if
(
$checkGoodsName
)
{
throw
new
GoodsException
([
'cus'
=>
19
]);
}
$checkGoodsDesc
=
self
::
isHaveSensitive
(
$params
[
"desc"
],
2
);
if
(
$checkGoodsDesc
)
{
throw
new
GoodsException
([
'cus'
=>
20
]);
}
$checkGoodsIntroduce
=
self
::
isHaveSensitive
(
$params
[
"introduce"
],
3
);
if
(
$checkGoodsIntroduce
)
{
throw
new
GoodsException
([
'cus'
=>
21
]);
}
$checkGoodsRuleDesc
=
self
::
isHaveSensitive
(
$params
[
"rule_desc"
],
2
);
if
(
$checkGoodsRuleDesc
)
{
throw
new
GoodsException
([
'cus'
=>
22
]);
}
$skuParams
=
[
"category_1_id"
=>
$params
[
"category_1_id"
],
...
...
@@ -725,7 +757,7 @@ class GoodsService
}
/**
*
敏感词检查
*
是否存在敏感词
* $text 送查内容
* $scene 场景ID 1.标题 2.简介 3.正文 4.评论 6.昵称 7.搜索
* $businessId 1.一点 2.身边 9.VPN
...
...
@@ -735,7 +767,7 @@ class GoodsService
* @return bool|mixed
* @throws \App\Exception\custom\CodeSpecialException
*/
private
function
check
Sensitive
(
$text
,
$scene
,
$businessId
=
1
)
private
static
function
isHave
Sensitive
(
$text
,
$scene
,
$businessId
=
1
)
{
$params
=
[
'businessId'
=>
$businessId
,
...
...
@@ -744,6 +776,10 @@ class GoodsService
];
return
(
new
Sensitive
())
->
detect
(
$params
);
$res
=
(
new
Sensitive
())
->
detect
(
$params
);
if
(
empty
(
$res
[
"data"
]))
{
return
false
;
}
return
true
;
}
}
\ No newline at end of file
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