Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-dj-goods-listing
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4b87b740
authored
May 10, 2026
by
zhoulm
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
refactor(商品上架服务): 优化套餐商品重复检查逻辑
将基于商品ID的重复检查改为基于商品ID和部位的组合键检查,提高太阳膜商品的重复判断准确性
1 parent
de637cf7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
rpc-dj-goods-listing/src/main/java/cn/com/glsx/dj/goods/listing/service/GoodsListingProductBaseService.java
rpc-dj-goods-listing/src/main/java/cn/com/glsx/dj/goods/listing/service/GoodsListingProductBaseService.java
View file @
4b87b74
...
@@ -202,9 +202,9 @@ public class GoodsListingProductBaseService {
...
@@ -202,9 +202,9 @@ public class GoodsListingProductBaseService {
//延保类、权益类
//延保类、权益类
extendedInsuranceTypeIdList
.
addAll
(
equityTypeIdList
);
extendedInsuranceTypeIdList
.
addAll
(
equityTypeIdList
);
Set
<
String
>
upgradeGoods
Id
StrSet
=
new
HashSet
<>();
Set
<
String
>
upgradeGoods
Key
StrSet
=
new
HashSet
<>();
productBaseList
.
forEach
(
record
->{
productBaseList
.
forEach
(
record
->{
Set
<
Integer
>
upgradeGoodsId
Set
=
new
HashSet
<>();
Set
<
String
>
upgradeGoodsKey
Set
=
new
HashSet
<>();
record
.
getDetailList
().
forEach
(
o
->{
record
.
getDetailList
().
forEach
(
o
->{
UpgradeGoodsDTO
upgradeGoods
=
goodsListingProductDetailService
.
getUpgradeGoodsByUpgradeGoodsId
(
o
.
getUpgradeGoodsId
());
UpgradeGoodsDTO
upgradeGoods
=
goodsListingProductDetailService
.
getUpgradeGoodsByUpgradeGoodsId
(
o
.
getUpgradeGoodsId
());
RpcAssert
.
assertNotNull
(
upgradeGoods
,
DefaultErrorEnum
.
SERVER_ERROR
,
"升级商品不存在"
);
RpcAssert
.
assertNotNull
(
upgradeGoods
,
DefaultErrorEnum
.
SERVER_ERROR
,
"升级商品不存在"
);
...
@@ -215,10 +215,6 @@ public class GoodsListingProductBaseService {
...
@@ -215,10 +215,6 @@ public class GoodsListingProductBaseService {
}
else
{
}
else
{
RpcAssert
.
assertIsTrue
(!
extendedInsuranceTypeIdList
.
contains
(
upgradeGoods
.
getGoodsInfo
().
getGoodsType
()),
DefaultErrorEnum
.
SERVER_ERROR
,
"仅支持上架太阳膜、车衣、改色膜、精品类的商品"
);
RpcAssert
.
assertIsTrue
(!
extendedInsuranceTypeIdList
.
contains
(
upgradeGoods
.
getGoodsInfo
().
getGoodsType
()),
DefaultErrorEnum
.
SERVER_ERROR
,
"仅支持上架太阳膜、车衣、改色膜、精品类的商品"
);
}
}
if
(
Objects
.
equals
(
record
.
getProductType
(),
ProductTypeEnum
.
PACKAGE
.
getValue
()))
{
RpcAssert
.
assertIsTrue
(!
upgradeGoodsIdSet
.
contains
(
o
.
getUpgradeGoodsId
()),
DefaultErrorEnum
.
SERVER_ERROR
,
"套餐存在重复商品"
);
upgradeGoodsIdSet
.
add
(
o
.
getUpgradeGoodsId
());
}
List
<
UpgradeGoodsAreaDTO
>
upgradeGoodsAreaList
=
upgradeGoods
.
getUpgradeGoodsAreaList
();
List
<
UpgradeGoodsAreaDTO
>
upgradeGoodsAreaList
=
upgradeGoods
.
getUpgradeGoodsAreaList
();
RpcAssert
.
assertNotEmpty
(
upgradeGoodsAreaList
,
DefaultErrorEnum
.
SERVER_ERROR
,
"商品未配置适用区域"
);
RpcAssert
.
assertNotEmpty
(
upgradeGoodsAreaList
,
DefaultErrorEnum
.
SERVER_ERROR
,
"商品未配置适用区域"
);
List
<
String
>
upgradeGoodsCityCodeList
=
upgradeGoodsAreaList
.
stream
().
map
(
UpgradeGoodsAreaDTO:
:
getCityCode
).
collect
(
Collectors
.
toList
());
List
<
String
>
upgradeGoodsCityCodeList
=
upgradeGoodsAreaList
.
stream
().
map
(
UpgradeGoodsAreaDTO:
:
getCityCode
).
collect
(
Collectors
.
toList
());
...
@@ -232,12 +228,17 @@ public class GoodsListingProductBaseService {
...
@@ -232,12 +228,17 @@ public class GoodsListingProductBaseService {
if
(
isSolarFilmGoods
)
{
if
(
isSolarFilmGoods
)
{
RpcAssert
.
assertNotNull
(
o
.
getPosition
(),
DefaultErrorEnum
.
SERVER_ERROR
,
"太阳膜商品需选择部位"
);
RpcAssert
.
assertNotNull
(
o
.
getPosition
(),
DefaultErrorEnum
.
SERVER_ERROR
,
"太阳膜商品需选择部位"
);
}
}
if
(
Objects
.
equals
(
record
.
getProductType
(),
ProductTypeEnum
.
PACKAGE
.
getValue
()))
{
String
upgradeGoodsKey
=
buildUpgradeGoodsKey
(
o
,
isSolarFilmGoods
);
RpcAssert
.
assertIsTrue
(!
upgradeGoodsKeySet
.
contains
(
upgradeGoodsKey
),
DefaultErrorEnum
.
SERVER_ERROR
,
"套餐存在重复商品"
);
upgradeGoodsKeySet
.
add
(
upgradeGoodsKey
);
}
o
.
setUpgradeGoods
(
upgradeGoods
);
o
.
setUpgradeGoods
(
upgradeGoods
);
});
});
if
(
Objects
.
equals
(
record
.
getProductType
(),
ProductTypeEnum
.
PACKAGE
.
getValue
()))
{
if
(
Objects
.
equals
(
record
.
getProductType
(),
ProductTypeEnum
.
PACKAGE
.
getValue
()))
{
String
upgradeGoodsIdStr
=
StringUtils
.
join
(
upgradeGoods
Id
Set
,
","
);
String
upgradeGoodsIdStr
=
StringUtils
.
join
(
upgradeGoods
Key
Set
,
","
);
RpcAssert
.
assertIsTrue
(!
upgradeGoods
Id
StrSet
.
contains
(
upgradeGoodsIdStr
),
DefaultErrorEnum
.
SERVER_ERROR
,
"存在重复套餐"
);
RpcAssert
.
assertIsTrue
(!
upgradeGoods
Key
StrSet
.
contains
(
upgradeGoodsIdStr
),
DefaultErrorEnum
.
SERVER_ERROR
,
"存在重复套餐"
);
upgradeGoods
Id
StrSet
.
add
(
upgradeGoodsIdStr
);
upgradeGoods
Key
StrSet
.
add
(
upgradeGoodsIdStr
);
}
}
});
});
}
catch
(
RpcServiceException
rpcServiceException
)
{
}
catch
(
RpcServiceException
rpcServiceException
)
{
...
@@ -248,6 +249,14 @@ public class GoodsListingProductBaseService {
...
@@ -248,6 +249,14 @@ public class GoodsListingProductBaseService {
}
}
}
}
private
String
buildUpgradeGoodsKey
(
GoodsListingProductDetailDTO
o
,
boolean
isSolarFilmGoods
)
{
String
upgradeGoodsKey
=
String
.
valueOf
(
o
.
getUpgradeGoodsId
());
if
(
isSolarFilmGoods
)
{
upgradeGoodsKey
=
upgradeGoodsKey
.
concat
(
"-"
).
concat
(
String
.
valueOf
(
o
.
getPosition
()));
}
return
upgradeGoodsKey
;
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
GoodsListingProductBaseDTO
insertOrUpdate
(
GoodsListingProductBaseDTO
record
)
{
public
GoodsListingProductBaseDTO
insertOrUpdate
(
GoodsListingProductBaseDTO
record
)
{
RpcAssert
.
assertNotNull
(
record
,
DefaultErrorEnum
.
DATA_NULL
,
"record is null"
);
RpcAssert
.
assertNotNull
(
record
,
DefaultErrorEnum
.
DATA_NULL
,
"record is null"
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment