记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
a2a2e25e
Commit
a2a2e25e
authored
Mar 30, 2026
by
姜秀龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
收钱 sql 报错问题处理
parent
3b0d7439
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
783 additions
and
475 deletions
+783
-475
GoblinSqbGoodsServiceImpl.java
...ervice/goblin/service/impl/GoblinSqbGoodsServiceImpl.java
+13
-37
GoblinStoreMgtGoodsImportService.java
...service/impl/manage/GoblinStoreMgtGoodsImportService.java
+180
-95
GoblinStoreMgtGoodsServiceImpl.java
...n/service/impl/manage/GoblinStoreMgtGoodsServiceImpl.java
+590
-343
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinSqbGoodsServiceImpl.java
View file @
a2a2e25e
...
@@ -9,12 +9,8 @@ import com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo;
...
@@ -9,12 +9,8 @@ import com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo;
import
com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinSqbPerfGoodsVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinSqbPerfGoodsVo
;
import
com.liquidnet.service.goblin.config.properties.ShouqianbaProperties
;
import
com.liquidnet.service.goblin.config.properties.ShouqianbaProperties
;
import
com.liquidnet.service.goblin.entity.GoblinGoods
;
import
com.liquidnet.service.goblin.entity.GoblinGoodsSku
;
import
com.liquidnet.service.goblin.entity.GoblinSqbGoodsExt
;
import
com.liquidnet.service.goblin.entity.GoblinSqbGoodsExt
;
import
com.liquidnet.service.goblin.entity.GoblinSqbPerformanceGoods
;
import
com.liquidnet.service.goblin.entity.GoblinSqbPerformanceGoods
;
import
com.liquidnet.service.goblin.mapper.GoblinGoodsMapper
;
import
com.liquidnet.service.goblin.mapper.GoblinGoodsSkuMapper
;
import
com.liquidnet.service.goblin.mapper.GoblinSqbGoodsExtMapper
;
import
com.liquidnet.service.goblin.mapper.GoblinSqbGoodsExtMapper
;
import
com.liquidnet.service.goblin.mapper.GoblinSqbPerformanceGoodsMapper
;
import
com.liquidnet.service.goblin.mapper.GoblinSqbPerformanceGoodsMapper
;
import
com.liquidnet.service.goblin.mapper.GoblinSqbPerformanceConfigMapper
;
import
com.liquidnet.service.goblin.mapper.GoblinSqbPerformanceConfigMapper
;
...
@@ -45,7 +41,6 @@ import com.liquidnet.service.goblin.util.ObjectUtil;
...
@@ -45,7 +41,6 @@ import com.liquidnet.service.goblin.util.ObjectUtil;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -58,12 +53,6 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
...
@@ -58,12 +53,6 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
@Autowired
@Autowired
private
ShouqianbaProperties
shouqianbaProperties
;
private
ShouqianbaProperties
shouqianbaProperties
;
@Autowired
private
GoblinGoodsMapper
goblinGoodsMapper
;
@Autowired
private
GoblinGoodsSkuMapper
goblinGoodsSkuMapper
;
@Autowired
@Autowired
private
GoblinSqbGoodsExtMapper
goblinSqbGoodsExtMapper
;
private
GoblinSqbGoodsExtMapper
goblinSqbGoodsExtMapper
;
...
@@ -229,6 +218,7 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
...
@@ -229,6 +218,7 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
goodsInfoVo
.
setCreatedAt
(
now
);
goodsInfoVo
.
setCreatedAt
(
now
);
goodsInfoVo
.
setSpuType
(
33
);
goodsInfoVo
.
setSpuType
(
33
);
goodsInfoVo
.
setVirtualFlg
(
"1"
);
goodsInfoVo
.
setVirtualFlg
(
"1"
);
goodsInfoVo
.
setSpuNo
(
goodsInfoVo
.
getSpuId
());
ArrayList
<
GoblinGoodsSpecVo
>
goodsSpecVoList
=
ObjectUtil
.
getGoblinGoodsSpecVoArrayList
();
ArrayList
<
GoblinGoodsSpecVo
>
goodsSpecVoList
=
ObjectUtil
.
getGoblinGoodsSpecVoArrayList
();
List
<
GoblinGoodsSkuInfoVo
>
goodsSkuInfoVoList
=
ObjectUtil
.
getGoblinGoodsSkuInfoVoArrayList
();
List
<
GoblinGoodsSkuInfoVo
>
goodsSkuInfoVoList
=
ObjectUtil
.
getGoblinGoodsSkuInfoVoArrayList
();
...
@@ -301,6 +291,7 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
...
@@ -301,6 +291,7 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
GoblinStoreMgtGoodsAddParam
addParam
=
buildMgtGoodsAddParam
(
storeId
,
perfGoodsVo
);
GoblinStoreMgtGoodsAddParam
addParam
=
buildMgtGoodsAddParam
(
storeId
,
perfGoodsVo
);
addParam
.
setSpuId
(
spuId
);
addParam
.
setSpuId
(
spuId
);
addParam
.
setSpuNo
(
spuId
);
goblinstoreMgtGoodsService
.
goodsEditSpu
(
currentUid
,
addParam
,
mgtGoodsInfoVo
);
goblinstoreMgtGoodsService
.
goodsEditSpu
(
currentUid
,
addParam
,
mgtGoodsInfoVo
);
// 3. 编辑 SKU
// 3. 编辑 SKU
...
@@ -407,6 +398,9 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
...
@@ -407,6 +398,9 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
editSkuParam
.
setSkuAppear
(
"0"
);
editSkuParam
.
setSkuAppear
(
"0"
);
editSkuParam
.
setBuyFactor
(
"0"
);
editSkuParam
.
setBuyFactor
(
"0"
);
editSkuParam
.
setSkuValidity
(
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
mgtGoodsSkuInfoVo
.
getSkuValidity
()));
editSkuParam
.
setSkuValidity
(
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
mgtGoodsSkuInfoVo
.
getSkuValidity
()));
// 设置库存,用户要求不修改之前的库存
editSkuParam
.
setStock
(
mgtGoodsSkuInfoVo
.
getStock
());
editSkuParam
.
setSkuStock
(
mgtGoodsSkuInfoVo
.
getSkuStock
());
// 库存增量逻辑
// 库存增量逻辑
/*
/*
...
@@ -484,7 +478,14 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
...
@@ -484,7 +478,14 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
GoblinStoreMgtGoodsAddParam
param
=
new
GoblinStoreMgtGoodsAddParam
();
GoblinStoreMgtGoodsAddParam
param
=
new
GoblinStoreMgtGoodsAddParam
();
param
.
setStoreId
(
storeId
);
param
.
setStoreId
(
storeId
);
param
.
setName
(
productsData
.
getTitle
());
param
.
setName
(
productsData
.
getTitle
());
// param.setIntro(productsData.getProductIntroduction());
String
intro
=
productsData
.
getProductIntroduction
();
if
(
StringUtils
.
isNotBlank
(
intro
))
{
// 简单的截断处理,防止数据库过长报错,同时优先保留文本部分(如果有的话)
if
(
intro
.
length
()
>
250
)
{
intro
=
intro
.
substring
(
0
,
250
);
}
}
param
.
setIntro
(
intro
);
param
.
setImageList
(
productsData
.
getConverImages
());
param
.
setImageList
(
productsData
.
getConverImages
());
param
.
setDetails
(
productsData
.
getProductIntroduction
());
param
.
setDetails
(
productsData
.
getProductIntroduction
());
param
.
setSpecMode
(
"1"
);
param
.
setSpecMode
(
"1"
);
...
@@ -556,34 +557,9 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
...
@@ -556,34 +557,9 @@ public class GoblinSqbGoodsServiceImpl implements IGoblinSqbGoodsService {
goblinSqbRedisUtils
.
setPerfGoods
(
performancesId
,
empty
);
goblinSqbRedisUtils
.
setPerfGoods
(
performancesId
,
empty
);
return
ResponseDto
.
success
(
empty
);
return
ResponseDto
.
success
(
empty
);
}
}
List
<
String
>
skuIds
=
relations
.
stream
().
map
(
GoblinSqbPerformanceGoods:
:
getSkuId
)
.
collect
(
Collectors
.
toList
());
List
<
String
>
spuIds
=
relations
.
stream
().
map
(
GoblinSqbPerformanceGoods:
:
getSpuId
).
distinct
()
.
collect
(
Collectors
.
toList
());
List
<
GoblinGoodsSku
>
skuList
=
goblinGoodsSkuMapper
.
selectList
(
new
LambdaQueryWrapper
<
GoblinGoodsSku
>().
in
(
GoblinGoodsSku:
:
getSkuId
,
skuIds
));
Map
<
String
,
GoblinGoodsSku
>
skuMap
=
skuList
.
stream
()
.
collect
(
Collectors
.
toMap
(
GoblinGoodsSku:
:
getSkuId
,
Function
.
identity
(),
(
a
,
b
)
->
a
));
List
<
GoblinGoods
>
spuList
=
goblinGoodsMapper
.
selectList
(
new
LambdaQueryWrapper
<
GoblinGoods
>().
in
(
GoblinGoods:
:
getSpuId
,
spuIds
));
Map
<
String
,
GoblinGoods
>
spuMap
=
spuList
.
stream
()
.
collect
(
Collectors
.
toMap
(
GoblinGoods:
:
getSpuId
,
Function
.
identity
(),
(
a
,
b
)
->
a
));
List
<
GoblinSqbPerfGoodsVo
>
result
=
new
ArrayList
<>();
List
<
GoblinSqbPerfGoodsVo
>
result
=
new
ArrayList
<>();
for
(
GoblinSqbPerformanceGoods
rel
:
relations
)
{
for
(
GoblinSqbPerformanceGoods
rel
:
relations
)
{
GoblinSqbPerfGoodsVo
vo
=
new
GoblinSqbPerfGoodsVo
();
GoblinSqbPerfGoodsVo
vo
=
new
GoblinSqbPerfGoodsVo
();
// vo.setSkuId(rel.getSkuId());
// vo.setSpuId(rel.getSpuId());
// vo.setSort(rel.getSort());
// GoblinGoodsSku sku = skuMap.get(rel.getSkuId());
// if (sku != null) {
// vo.setSkuName(sku.getName());
// vo.setPrice(sku.getPrice() != null ? sku.getPrice().longValue() : null);
// }
// GoblinGoods spu = spuMap.get(rel.getSpuId());
// if (spu != null) {
// vo.setSpuName(spu.getName());
// vo.setCoverPic(spu.getCoverPic());
// }
result
.
add
(
vo
);
result
.
add
(
vo
);
}
}
goblinSqbRedisUtils
.
setPerfGoods
(
performancesId
,
result
);
goblinSqbRedisUtils
.
setPerfGoods
(
performancesId
,
result
);
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/manage/GoblinStoreMgtGoodsImportService.java
View file @
a2a2e25e
...
@@ -59,7 +59,8 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -59,7 +59,8 @@ public class GoblinStoreMgtGoodsImportService {
*/
*/
private
static
final
String
LAST_SKU_SPEC_VALUE_STR
=
"%#V1%#V2%#V3%#V4%#V5"
;
private
static
final
String
LAST_SKU_SPEC_VALUE_STR
=
"%#V1%#V2%#V3%#V4%#V5"
;
public
String
goodsInformationDataAnalysisProcessing
(
MultipartFile
file
,
String
uid
,
String
storeId
)
throws
IOException
{
public
String
goodsInformationDataAnalysisProcessing
(
MultipartFile
file
,
String
uid
,
String
storeId
)
throws
IOException
{
String
originalFilename
=
file
.
getOriginalFilename
();
String
originalFilename
=
file
.
getOriginalFilename
();
AnalysisEventListener
<
GoblinGoodsImportDto
>
analysisEventListener
=
new
AnalysisEventListener
<
GoblinGoodsImportDto
>()
{
AnalysisEventListener
<
GoblinGoodsImportDto
>
analysisEventListener
=
new
AnalysisEventListener
<
GoblinGoodsImportDto
>()
{
List
<
GoblinGoodsSkuInfoVo
>
goodsSkuInfoVos
;
List
<
GoblinGoodsSkuInfoVo
>
goodsSkuInfoVos
;
...
@@ -74,7 +75,8 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -74,7 +75,8 @@ public class GoblinStoreMgtGoodsImportService {
if
(
exception
instanceof
ExcelDataConvertException
)
{
if
(
exception
instanceof
ExcelDataConvertException
)
{
Integer
rowIndex
=
((
ExcelDataConvertException
)
exception
).
getRowIndex
();
Integer
rowIndex
=
((
ExcelDataConvertException
)
exception
).
getRowIndex
();
Integer
columnIndex
=
((
ExcelDataConvertException
)
exception
).
getColumnIndex
();
Integer
columnIndex
=
((
ExcelDataConvertException
)
exception
).
getColumnIndex
();
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行,第%s列数据格式有误】"
,
rowIndex
+
1
,
columnIndex
+
1
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行,第%s列数据格式有误】"
,
rowIndex
+
1
,
columnIndex
+
1
));
}
}
super
.
onException
(
exception
,
context
);
super
.
onException
(
exception
,
context
);
}
}
...
@@ -83,16 +85,18 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -83,16 +85,18 @@ public class GoblinStoreMgtGoodsImportService {
public
void
invokeHead
(
Map
<
Integer
,
ReadCellData
<?>>
headMap
,
AnalysisContext
context
)
{
public
void
invokeHead
(
Map
<
Integer
,
ReadCellData
<?>>
headMap
,
AnalysisContext
context
)
{
Integer
approximateTotalRowNumber
=
context
.
readSheetHolder
().
getApproximateTotalRowNumber
();
Integer
approximateTotalRowNumber
=
context
.
readSheetHolder
().
getApproximateTotalRowNumber
();
if
(
approximateTotalRowNumber
>
501
)
{
if
(
approximateTotalRowNumber
>
501
)
{
log
.
warn
(
"店铺商品管理:批量导入数据:异常[UID={},storeId={},totalRowNumber={}]"
,
uid
,
storeId
,
approximateTotalRowNumber
);
log
.
warn
(
"店铺商品管理:批量导入数据:异常[UID={},storeId={},totalRowNumber={}]"
,
uid
,
storeId
,
approximateTotalRowNumber
);
throw
new
LiquidnetServiceException
(
"-1"
,
"超出总行数限制500"
);
throw
new
LiquidnetServiceException
(
"-1"
,
"超出总行数限制500"
);
}
else
if
(
approximateTotalRowNumber
<=
1
)
{
}
else
if
(
approximateTotalRowNumber
<=
1
)
{
throw
new
LiquidnetServiceException
(
"-1"
,
"导入文件不能为空"
);
throw
new
LiquidnetServiceException
(
"-1"
,
"导入文件不能为空"
);
}
}
log
.
info
(
"DT-IN-BEGIN:[storeId={},uid={},fileName={},totalRow={}]"
,
uid
,
storeId
,
originalFilename
,
approximateTotalRowNumber
);
log
.
info
(
"DT-IN-BEGIN:[storeId={},uid={},fileName={},totalRow={}]"
,
uid
,
storeId
,
originalFilename
,
approximateTotalRowNumber
);
goodsSkuInfoVos
=
ObjectUtil
.
getGoblinGoodsSkuInfoVoArrayList
();
goodsSkuInfoVos
=
ObjectUtil
.
getGoblinGoodsSkuInfoVoArrayList
();
goodsInfoVos
=
ObjectUtil
.
goblinGoodsInfoVoArrayList
();
goodsInfoVos
=
ObjectUtil
.
goblinGoodsInfoVoArrayList
();
//
skuBarCodeTmpList = CollectionUtil.arrayListString();
//
skuBarCodeTmpList = CollectionUtil.arrayListString();
dtoSpuSpecNameTmpList
=
CollectionUtil
.
arrayListString
();
dtoSpuSpecNameTmpList
=
CollectionUtil
.
arrayListString
();
dtoSkuSpecValueTmpList
=
CollectionUtil
.
arrayListString
();
dtoSkuSpecValueTmpList
=
CollectionUtil
.
arrayListString
();
now
=
LocalDateTime
.
now
();
now
=
LocalDateTime
.
now
();
...
@@ -106,10 +110,12 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -106,10 +110,12 @@ public class GoblinStoreMgtGoodsImportService {
}
}
Integer
rowIndex
=
analysisContext
.
readRowHolder
().
getRowIndex
();
Integer
rowIndex
=
analysisContext
.
readRowHolder
().
getRowIndex
();
GoblinGoodsInfoVo
lastGoodsInfoVo
=
CollectionUtils
.
isEmpty
(
goodsInfoVos
)
?
null
:
goodsInfoVos
.
get
(
goodsInfoVos
.
size
()
-
1
);
GoblinGoodsInfoVo
lastGoodsInfoVo
=
CollectionUtils
.
isEmpty
(
goodsInfoVos
)
?
null
:
goodsInfoVos
.
get
(
goodsInfoVos
.
size
()
-
1
);
boolean
tobeNextSpuFlg
=
null
==
lastGoodsInfoVo
||
!
lastGoodsInfoVo
.
getName
().
equals
(
dto
.
getSpuName
());
boolean
tobeNextSpuFlg
=
null
==
lastGoodsInfoVo
||
!
lastGoodsInfoVo
.
getName
().
equals
(
dto
.
getSpuName
());
goodsInformationDataAnalysisProcessingValid
(
dto
,
rowIndex
+
1
,
tobeNextSpuFlg
,
dtoSpuSpecNameTmpList
,
dtoSkuSpecValueTmpList
,
dtoSkuBarCodeTmpList
);
goodsInformationDataAnalysisProcessingValid
(
dto
,
rowIndex
+
1
,
tobeNextSpuFlg
,
dtoSpuSpecNameTmpList
,
dtoSkuSpecValueTmpList
,
dtoSkuBarCodeTmpList
);
if
(
tobeNextSpuFlg
)
{
if
(
tobeNextSpuFlg
)
{
lastGoodsInfoVo
=
goodsInformationDataAnalysisProcessingForSpu
(
dto
,
uid
,
storeId
,
now
);
lastGoodsInfoVo
=
goodsInformationDataAnalysisProcessingForSpu
(
dto
,
uid
,
storeId
,
now
);
...
@@ -119,7 +125,8 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -119,7 +125,8 @@ public class GoblinStoreMgtGoodsImportService {
goodsInfoVos
.
add
(
lastGoodsInfoVo
);
goodsInfoVos
.
add
(
lastGoodsInfoVo
);
}
}
GoblinGoodsSkuInfoVo
lastGoodsSkuInfoVo
=
goodsInformationDataAnalysisProcessingForSku
(
dto
,
lastGoodsInfoVo
,
tobeNextSpuFlg
);
GoblinGoodsSkuInfoVo
lastGoodsSkuInfoVo
=
goodsInformationDataAnalysisProcessingForSku
(
dto
,
lastGoodsInfoVo
,
tobeNextSpuFlg
);
if
(
null
!=
lastGoodsSkuInfoVo
)
{
if
(
null
!=
lastGoodsSkuInfoVo
)
{
goodsSkuInfoVos
.
add
(
lastGoodsSkuInfoVo
);
goodsSkuInfoVos
.
add
(
lastGoodsSkuInfoVo
);
}
else
{
}
else
{
...
@@ -137,16 +144,21 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -137,16 +144,21 @@ public class GoblinStoreMgtGoodsImportService {
log
.
debug
(
"dt3-2:{}"
,
JsonUtils
.
toJson
(
goodsSkuInfoVos
));
log
.
debug
(
"dt3-2:{}"
,
JsonUtils
.
toJson
(
goodsSkuInfoVos
));
}
}
if
(!
CollectionUtils
.
isEmpty
(
goodsInfoVos
))
{
if
(!
CollectionUtils
.
isEmpty
(
goodsInfoVos
))
{
// List<String> existGoodsSkuNoList = goblinMongoUtils.existGoodsSkuNoBySkuNoList(storeId, skuBarCodeTmpList);
// List<String> existGoodsSkuNoList =
// if (!CollectionUtils.isEmpty(existGoodsSkuNoList)) {
// goblinMongoUtils.existGoodsSkuNoBySkuNoList(storeId, skuBarCodeTmpList);
// if (existGoodsSkuNoList.size() > 3) {
// if (!CollectionUtils.isEmpty(existGoodsSkuNoList)) {
// throw new LiquidnetServiceException("-1", String.format("规格条码与已添加商品条码重复,重复条码如下: %s,...", StringUtils.join(existGoodsSkuNoList.subList(0, 3), ",")));
// if (existGoodsSkuNoList.size() > 3) {
// }
// throw new LiquidnetServiceException("-1",
// throw new LiquidnetServiceException("-1", String.format("规格条码与已添加商品条码重复,重复条码如下: %s", StringUtils.join(existGoodsSkuNoList, ",")));
// String.format("规格条码与已添加商品条码重复,重复条码如下: %s,...",
// }
// StringUtils.join(existGoodsSkuNoList.subList(0, 3), ",")));
log
.
info
(
"DT-IN-ToMDB:[storeId={},uid={},fileName={},spuCount={},skuCount={}]"
,
uid
,
storeId
,
originalFilename
,
goodsInfoVos
.
size
(),
goodsSkuInfoVos
.
size
());
// }
// throw new LiquidnetServiceException("-1",
// String.format("规格条码与已添加商品条码重复,重复条码如下: %s",
// StringUtils.join(existGoodsSkuNoList, ",")));
// }
log
.
info
(
"DT-IN-ToMDB:[storeId={},uid={},fileName={},spuCount={},skuCount={}]"
,
uid
,
storeId
,
originalFilename
,
goodsInfoVos
.
size
(),
goodsSkuInfoVos
.
size
());
goblinMongoUtils
.
insertMgtGoodsInfoVos
(
goodsInfoVos
);
goblinMongoUtils
.
insertMgtGoodsInfoVos
(
goodsInfoVos
);
goblinMongoUtils
.
insertMgtGoodsSkuInfoVos
(
goodsSkuInfoVos
);
goblinMongoUtils
.
insertMgtGoodsSkuInfoVos
(
goodsSkuInfoVos
);
...
@@ -160,31 +172,40 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -160,31 +172,40 @@ public class GoblinStoreMgtGoodsImportService {
LinkedList
<
Object
[]>
initGoodsSpuSpecValueObjs
=
CollectionUtil
.
linkedListObjectArr
();
LinkedList
<
Object
[]>
initGoodsSpuSpecValueObjs
=
CollectionUtil
.
linkedListObjectArr
();
for
(
int
i
=
0
,
size
=
goodsInfoVos
.
size
();
i
<
size
;
i
++)
{
for
(
int
i
=
0
,
size
=
goodsInfoVos
.
size
();
i
<
size
;
i
++)
{
GoblinGoodsInfoVo
goodsInfoVo
=
goodsInfoVos
.
get
(
i
);
GoblinGoodsInfoVo
goodsInfoVo
=
goodsInfoVos
.
get
(
i
);
initGoodsObjs
.
add
(
new
Object
[]{
goodsInfoVo
.
getSpuId
(),
goodsInfoVo
.
getSpuNo
(),
goodsInfoVo
.
getSpuBarCode
(),
goodsInfoVo
.
getName
(),
goodsInfoVo
.
getSubtitle
(),
initGoodsObjs
.
add
(
new
Object
[]
{
goodsInfoVo
.
getSpuId
(),
goodsInfoVo
.
getSpuNo
(),
goodsInfoVo
.
getSellPrice
(),
goodsInfoVo
.
getPriceGe
(),
goodsInfoVo
.
getPriceLe
(),
goodsInfoVo
.
getIntro
(),
goodsInfoVo
.
getDetails
(),
goodsInfoVo
.
getSpuBarCode
(),
goodsInfoVo
.
getName
(),
goodsInfoVo
.
getSubtitle
(),
goodsInfoVo
.
getCoverPic
(),
goodsInfoVo
.
getVideo
(),
goodsInfoVo
.
getSpecMode
(),
goodsInfoVo
.
getStoreId
(),
goodsInfoVo
.
getCateFid
(),
goodsInfoVo
.
getSellPrice
(),
goodsInfoVo
.
getPriceGe
(),
goodsInfoVo
.
getPriceLe
(),
goodsInfoVo
.
getCateSid
(),
goodsInfoVo
.
getCateTid
(),
goodsInfoVo
.
getStoreCateFid
(),
goodsInfoVo
.
getStoreCateSid
(),
goodsInfoVo
.
getStoreCateTid
(),
goodsInfoVo
.
getIntro
(),
goodsInfoVo
.
getDetails
(),
goodsInfoVo
.
getBrandId
(),
goodsInfoVo
.
getShelvesHandle
(),
goodsInfoVo
.
getShelvesTime
(),
goodsInfoVo
.
getSpuValidity
(),
goodsInfoVo
.
getVirtualFlg
(),
goodsInfoVo
.
getCoverPic
(),
goodsInfoVo
.
getVideo
(),
goodsInfoVo
.
getSpecMode
(),
goodsInfoVo
.
getStatus
(),
goodsInfoVo
.
getShelvesStatus
(),
goodsInfoVo
.
getSpuAppear
(),
goodsInfoVo
.
getShelvesAt
(),
goodsInfoVo
.
getCreatedBy
(),
goodsInfoVo
.
getStoreId
(),
goodsInfoVo
.
getCateFid
(),
goodsInfoVo
.
getCreatedAt
(),
goodsInfoVo
.
getLogisticsTemplate
()}
goodsInfoVo
.
getCateSid
(),
goodsInfoVo
.
getCateTid
(),
goodsInfoVo
.
getStoreCateFid
(),
);
goodsInfoVo
.
getStoreCateSid
(),
goodsInfoVo
.
getStoreCateTid
(),
goodsInfoVo
.
getBrandId
(),
goodsInfoVo
.
getShelvesHandle
(),
goodsInfoVo
.
getShelvesTime
(),
goodsInfoVo
.
getSpuValidity
(),
goodsInfoVo
.
getVirtualFlg
(),
goodsInfoVo
.
getStatus
(),
goodsInfoVo
.
getShelvesStatus
(),
goodsInfoVo
.
getSpuAppear
(),
goodsInfoVo
.
getShelvesAt
(),
goodsInfoVo
.
getCreatedBy
(),
goodsInfoVo
.
getCreatedAt
(),
goodsInfoVo
.
getLogisticsTemplate
()
});
if
(!
CollectionUtils
.
isEmpty
(
goodsInfoVo
.
getImageList
()))
{
if
(!
CollectionUtils
.
isEmpty
(
goodsInfoVo
.
getImageList
()))
{
goodsInfoVo
.
getImageList
().
forEach
(
imageUrl
->
initGoodsImageObjs
.
add
(
new
Object
[]{
goodsInfoVo
.
getSpuId
(),
imageUrl
}));
goodsInfoVo
.
getImageList
().
forEach
(
imageUrl
->
initGoodsImageObjs
.
add
(
new
Object
[]
{
goodsInfoVo
.
getSpuId
(),
imageUrl
}));
}
}
goodsInfoVo
.
getSpecVoList
().
forEach
(
specVo
->
{
goodsInfoVo
.
getSpecVoList
().
forEach
(
specVo
->
{
specVo
.
getSpecValues
().
forEach
(
specValues
->
{
specVo
.
getSpecValues
().
forEach
(
specValues
->
{
initGoodsSpuSpecValueObjs
.
add
(
new
Object
[]{
goodsInfoVo
.
getSpuId
(),
specVo
.
getSpecName
(),
specValues
.
getSpecVname
(),
specValues
.
getSpecVsort
()});
initGoodsSpuSpecValueObjs
.
add
(
new
Object
[]
{
goodsInfoVo
.
getSpuId
(),
specVo
.
getSpecName
(),
specValues
.
getSpecVname
(),
specValues
.
getSpecVsort
()
});
});
});
});
});
if
(
initGoodsObjs
.
size
()
==
BATCH_COUNT_SPU_SQL_TO_QUEUE
)
{
if
(
initGoodsObjs
.
size
()
==
BATCH_COUNT_SPU_SQL_TO_QUEUE
)
{
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_GOODS
.
getKey
(),
SqlMapping
.
gets
(
toMqSqls
,
initGoodsObjs
,
initGoodsImageObjs
,
initGoodsSpuSpecValueObjs
));
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_GOODS
.
getKey
(),
SqlMapping
.
gets
(
toMqSqls
,
initGoodsObjs
,
initGoodsImageObjs
,
initGoodsSpuSpecValueObjs
));
initGoodsObjs
.
clear
();
initGoodsObjs
.
clear
();
initGoodsImageObjs
.
clear
();
initGoodsImageObjs
.
clear
();
initGoodsSpuSpecValueObjs
.
clear
();
initGoodsSpuSpecValueObjs
.
clear
();
}
}
}
}
if
(
initGoodsObjs
.
size
()
>
0
)
{
if
(
initGoodsObjs
.
size
()
>
0
)
{
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_GOODS
.
getKey
(),
SqlMapping
.
gets
(
toMqSqls
,
initGoodsObjs
,
initGoodsImageObjs
,
initGoodsSpuSpecValueObjs
));
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_GOODS
.
getKey
(),
SqlMapping
.
gets
(
toMqSqls
,
initGoodsObjs
,
initGoodsImageObjs
,
initGoodsSpuSpecValueObjs
));
}
}
log
.
info
(
"DT-IN-ToSQL2:[storeId={},uid={},fileName={}]"
,
uid
,
storeId
,
originalFilename
);
log
.
info
(
"DT-IN-ToSQL2:[storeId={},uid={},fileName={}]"
,
uid
,
storeId
,
originalFilename
);
toMqSqls
.
clear
();
toMqSqls
.
clear
();
...
@@ -194,52 +215,77 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -194,52 +215,77 @@ public class GoblinStoreMgtGoodsImportService {
LinkedList
<
Object
[]>
initGoodsSkuSpecValueObjs
=
CollectionUtil
.
linkedListObjectArr
();
LinkedList
<
Object
[]>
initGoodsSkuSpecValueObjs
=
CollectionUtil
.
linkedListObjectArr
();
goodsSkuInfoVos
.
forEach
(
goodsSkuInfoVo
->
{
goodsSkuInfoVos
.
forEach
(
goodsSkuInfoVo
->
{
goblinRedisUtils
.
setSkuStock
(
null
,
goodsSkuInfoVo
.
getSkuId
(),
goodsSkuInfoVo
.
getSkuStock
());
goblinRedisUtils
.
setSkuStock
(
null
,
goodsSkuInfoVo
.
getSkuId
(),
goodsSkuInfoVo
.
getSkuStock
());
initGoodsSkuObjs
.
add
(
new
Object
[]{
goodsSkuInfoVo
.
getSkuId
(),
goodsSkuInfoVo
.
getSpuId
(),
goodsSkuInfoVo
.
getSkuNo
(),
goodsSkuInfoVo
.
getSkuBarCode
(),
goodsSkuInfoVo
.
getName
(),
initGoodsSkuObjs
.
add
(
new
Object
[]
{
goodsSkuInfoVo
.
getSkuId
(),
goodsSkuInfoVo
.
getSpuId
(),
goodsSkuInfoVo
.
getSubtitle
(),
goodsSkuInfoVo
.
getSellPrice
(),
goodsSkuInfoVo
.
getSkuPic
(),
goodsSkuInfoVo
.
getSkuIsbn
(),
goodsSkuInfoVo
.
getStock
(),
goodsSkuInfoVo
.
getSkuNo
(),
goodsSkuInfoVo
.
getSkuBarCode
(),
goodsSkuInfoVo
.
getName
(),
goodsSkuInfoVo
.
getSkuStock
(),
goodsSkuInfoVo
.
getWarningStock
(),
goodsSkuInfoVo
.
getPrice
(),
goodsSkuInfoVo
.
getPriceMember
(),
goodsSkuInfoVo
.
getWeight
(),
goodsSkuInfoVo
.
getSubtitle
(),
goodsSkuInfoVo
.
getSellPrice
(),
goodsSkuInfoVo
.
getSkuPic
(),
goodsSkuInfoVo
.
getBuyFactor
(),
goodsSkuInfoVo
.
getBuyRoster
(),
goodsSkuInfoVo
.
getBuyLimit
(),
goodsSkuInfoVo
.
getStoreId
(),
goodsSkuInfoVo
.
getSkuValidity
(),
goodsSkuInfoVo
.
getSkuIsbn
(),
goodsSkuInfoVo
.
getStock
(),
goodsSkuInfoVo
.
getVirtualFlg
(),
goodsSkuInfoVo
.
getStatus
(),
goodsSkuInfoVo
.
getShelvesStatus
(),
goodsSkuInfoVo
.
getSkuAppear
(),
goodsSkuInfoVo
.
getShelvesAt
(),
goodsSkuInfoVo
.
getSkuStock
(),
goodsSkuInfoVo
.
getWarningStock
(),
goodsSkuInfoVo
.
getPrice
(),
goodsSkuInfoVo
.
getPriceMember
(),
goodsSkuInfoVo
.
getWeight
(),
goodsSkuInfoVo
.
getBuyFactor
(),
goodsSkuInfoVo
.
getBuyRoster
(),
goodsSkuInfoVo
.
getBuyLimit
(),
goodsSkuInfoVo
.
getStoreId
(),
goodsSkuInfoVo
.
getSkuValidity
(),
goodsSkuInfoVo
.
getVirtualFlg
(),
goodsSkuInfoVo
.
getStatus
(),
goodsSkuInfoVo
.
getShelvesStatus
(),
goodsSkuInfoVo
.
getSkuAppear
(),
goodsSkuInfoVo
.
getShelvesAt
(),
uid
,
goodsSkuInfoVo
.
getCreatedAt
(),
goodsSkuInfoVo
.
getLogisticsTemplate
()
uid
,
goodsSkuInfoVo
.
getCreatedAt
(),
goodsSkuInfoVo
.
getLogisticsTemplate
()
});
});
goodsSkuInfoVo
.
getSkuSpecList
().
forEach
(
skuSpecDto
->
initGoodsSkuSpecValueObjs
.
add
(
new
Object
[]{
goodsSkuInfoVo
.
getSkuSpecList
()
goodsSkuInfoVo
.
getSpuId
(),
goodsSkuInfoVo
.
getSkuId
(),
skuSpecDto
.
getSpecName
(),
skuSpecDto
.
getSpecVname
()
.
forEach
(
skuSpecDto
->
initGoodsSkuSpecValueObjs
.
add
(
new
Object
[]
{
}));
goodsSkuInfoVo
.
getSpuId
(),
goodsSkuInfoVo
.
getSkuId
(),
skuSpecDto
.
getSpecName
(),
skuSpecDto
.
getSpecVname
()
}));
if
(
initGoodsSkuObjs
.
size
()
==
BATCH_COUNT_SKU_SQL_TO_QUEUE
)
{
if
(
initGoodsSkuObjs
.
size
()
==
BATCH_COUNT_SKU_SQL_TO_QUEUE
)
{
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_GOODS
.
getKey
(),
SqlMapping
.
gets
(
toMqSqls
,
initGoodsSkuObjs
,
initGoodsSkuSpecValueObjs
));
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_GOODS
.
getKey
(),
SqlMapping
.
gets
(
toMqSqls
,
initGoodsSkuObjs
,
initGoodsSkuSpecValueObjs
));
initGoodsSkuObjs
.
clear
();
initGoodsSkuObjs
.
clear
();
initGoodsSkuSpecValueObjs
.
clear
();
initGoodsSkuSpecValueObjs
.
clear
();
}
}
});
});
if
(
initGoodsSkuObjs
.
size
()
>
0
)
{
if
(
initGoodsSkuObjs
.
size
()
>
0
)
{
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_GOODS
.
getKey
(),
SqlMapping
.
gets
(
toMqSqls
,
initGoodsSkuObjs
,
initGoodsSkuSpecValueObjs
));
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_GOODS
.
getKey
(),
SqlMapping
.
gets
(
toMqSqls
,
initGoodsSkuObjs
,
initGoodsSkuSpecValueObjs
));
}
}
}
}
}
}
};
};
List
<
GoblinGoodsImportDto
>
readDtoList
=
EasyExcel
.
read
(
file
.
getInputStream
(),
GoblinGoodsImportDto
.
class
,
analysisEventListener
).
sheet
(
0
).
doReadSync
();
List
<
GoblinGoodsImportDto
>
readDtoList
=
EasyExcel
.
read
(
file
.
getInputStream
(),
GoblinGoodsImportDto
.
class
,
analysisEventListener
).
sheet
(
0
).
doReadSync
();
if
(
CollectionUtils
.
isEmpty
(
readDtoList
))
{
if
(
CollectionUtils
.
isEmpty
(
readDtoList
))
{
throw
new
LiquidnetServiceException
(
"-1"
,
"导入文件不能为空"
);
throw
new
LiquidnetServiceException
(
"-1"
,
"导入文件不能为空"
);
}
}
long
failureRows
=
readDtoList
.
stream
().
filter
(
r
->
StringUtils
.
isNotEmpty
(
r
.
getFailureReason
())).
count
();
long
failureRows
=
readDtoList
.
stream
().
filter
(
r
->
StringUtils
.
isNotEmpty
(
r
.
getFailureReason
())).
count
();
String
analysisResultMsg
=
String
.
format
(
"导入成功%s条数据,导入失败%s条数据"
,
readDtoList
.
size
()
-
failureRows
,
failureRows
);
String
analysisResultMsg
=
String
.
format
(
"导入成功%s条数据,导入失败%s条数据"
,
readDtoList
.
size
()
-
failureRows
,
failureRows
);
log
.
info
(
"DT-IN-END:[storeId={},uid={},fileName={},readResult:{}]"
,
uid
,
storeId
,
originalFilename
,
analysisResultMsg
);
log
.
info
(
"DT-IN-END:[storeId={},uid={},fileName={},readResult:{}]"
,
uid
,
storeId
,
originalFilename
,
analysisResultMsg
);
return
analysisResultMsg
;
return
analysisResultMsg
;
}
}
private
void
goodsInformationDataAnalysisProcessingValid
(
GoblinGoodsImportDto
dto
,
Integer
rowNum
,
boolean
tobeNextSpuFlg
,
private
void
goodsInformationDataAnalysisProcessingValid
(
GoblinGoodsImportDto
dto
,
Integer
rowNum
,
List
<
String
>
dtoSpuSpecNameTmpList
,
List
<
String
>
dtoSkuSpecValueTmpList
,
List
<
String
>
dtoSkuBarCodeTmpList
)
{
boolean
tobeNextSpuFlg
,
/* 商品编码校验|------------------------------------------------------------------------------ */
List
<
String
>
dtoSpuSpecNameTmpList
,
List
<
String
>
dtoSkuSpecValueTmpList
,
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSpuCode
())
&&
!
Pattern
.
matches
(
LnsRegex
.
Valid
.
ALPHABET_NUMBER_UNDER_50
,
dto
.
getSpuCode
()))
{
List
<
String
>
dtoSkuBarCodeTmpList
)
{
/*
* 商品编码校验|----------------------------------------------------------------------
* --------
*/
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSpuCode
())
&&
!
Pattern
.
matches
(
LnsRegex
.
Valid
.
ALPHABET_NUMBER_UNDER_50
,
dto
.
getSpuCode
()))
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品编码有误】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品编码有误】"
,
rowNum
));
}
}
/* 商品名称校验|------------------------------------------------------------------------------ */
/*
* 商品名称校验|----------------------------------------------------------------------
* --------
*/
if
(
StringUtils
.
isEmpty
(
dto
.
getSpuName
())
||
dto
.
getSpuName
().
length
()
>
30
)
{
if
(
StringUtils
.
isEmpty
(
dto
.
getSpuName
())
||
dto
.
getSpuName
().
length
()
>
30
)
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品名称有误】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品名称有误】"
,
rowNum
));
}
}
/* 商品图片校验|------------------------------------------------------------------------------ */
/*
* 商品图片校验|----------------------------------------------------------------------
* --------
*/
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSpuImgs
()))
{
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSpuImgs
()))
{
if
(
dto
.
getSpuImgs
().
startsWith
(
"【图片链接】"
))
{
if
(
dto
.
getSpuImgs
().
startsWith
(
"【图片链接】"
))
{
String
[]
spuImgsArr
=
dto
.
getSpuImgs
().
replace
(
"【图片链接】"
,
""
).
replace
(
";"
,
";"
).
split
(
";"
);
String
[]
spuImgsArr
=
dto
.
getSpuImgs
().
replace
(
"【图片链接】"
,
""
).
replace
(
";"
,
";"
).
split
(
";"
);
...
@@ -259,7 +305,10 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -259,7 +305,10 @@ public class GoblinStoreMgtGoodsImportService {
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品图片格式有误】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品图片格式有误】"
,
rowNum
));
}
}
}
}
/* 商品规格校验|------------------------------------------------------------------------------ */
/*
* 商品规格校验|----------------------------------------------------------------------
* --------
*/
if
(
StringUtils
.
isEmpty
(
dto
.
getSkuSpec
()))
{
if
(
StringUtils
.
isEmpty
(
dto
.
getSkuSpec
()))
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品规格信息缺失】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品规格信息缺失】"
,
rowNum
));
}
}
...
@@ -280,7 +329,8 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -280,7 +329,8 @@ public class GoblinStoreMgtGoodsImportService {
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品规格信息无效】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品规格信息无效】"
,
rowNum
));
}
}
String
[]
lastSpecArr
=
lastSkuSpecStr
.
split
(
":"
);
String
[]
lastSpecArr
=
lastSkuSpecStr
.
split
(
":"
);
if
(
ArrayUtils
.
isEmpty
(
lastSpecArr
)
||
lastSpecArr
.
length
!=
2
||
lastSpecArr
[
0
].
length
()
>
5
||
lastSpecArr
[
1
].
length
()
>
40
)
{
if
(
ArrayUtils
.
isEmpty
(
lastSpecArr
)
||
lastSpecArr
.
length
!=
2
||
lastSpecArr
[
0
].
length
()
>
5
||
lastSpecArr
[
1
].
length
()
>
40
)
{
// 分割出的规格(项:值)内容不规范
// 分割出的规格(项:值)内容不规范
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品规格信息有误】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品规格信息有误】"
,
rowNum
));
}
}
...
@@ -309,19 +359,33 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -309,19 +359,33 @@ public class GoblinStoreMgtGoodsImportService {
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品规格信息重复】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行商品规格信息重复】"
,
rowNum
));
}
}
dto
.
setSkuSpecDtos
(
skuSpecDtos
);
dto
.
setSkuSpecDtos
(
skuSpecDtos
);
/* 规格编码校验|------------------------------------------------------------------------------ */
/*
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSkuCode
())
&&
!
Pattern
.
matches
(
LnsRegex
.
Valid
.
ALPHABET_NUMBER_UNDER_50
,
dto
.
getSkuCode
()))
{
* 规格编码校验|----------------------------------------------------------------------
* --------
*/
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSkuCode
())
&&
!
Pattern
.
matches
(
LnsRegex
.
Valid
.
ALPHABET_NUMBER_UNDER_50
,
dto
.
getSkuCode
()))
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行规格编码格式有误】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行规格编码格式有误】"
,
rowNum
));
}
}
/* 价格校验|------------------------------------------------------------------------------ */
/*
if
(
null
==
dto
.
getPrice
()
||
dto
.
getPrice
().
compareTo
(
BigDecimal
.
valueOf
(
0.01
))
<
0
||
dto
.
getPrice
().
compareTo
(
BigDecimal
.
valueOf
(
9999999
))
>
0
)
{
* 价格校验|------------------------------------------------------------------------
* ------
*/
if
(
null
==
dto
.
getPrice
()
||
dto
.
getPrice
().
compareTo
(
BigDecimal
.
valueOf
(
0.01
))
<
0
||
dto
.
getPrice
().
compareTo
(
BigDecimal
.
valueOf
(
9999999
))
>
0
)
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行价格信息有误】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行价格信息有误】"
,
rowNum
));
}
}
/* 库存校验|------------------------------------------------------------------------------ */
/*
* 库存校验|------------------------------------------------------------------------
* ------
*/
if
(
null
==
dto
.
getStock
()
||
dto
.
getStock
()
<
0
||
dto
.
getStock
()
>
9999999
)
{
// 数据不规范停止解析并提示用户
if
(
null
==
dto
.
getStock
()
||
dto
.
getStock
()
<
0
||
dto
.
getStock
()
>
9999999
)
{
// 数据不规范停止解析并提示用户
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行库存信息有误】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行库存信息有误】"
,
rowNum
));
}
}
/* 规格图片校验|------------------------------------------------------------------------------ */
/*
* 规格图片校验|----------------------------------------------------------------------
* --------
*/
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSkuImg
()))
{
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSkuImg
()))
{
if
(
dto
.
getSkuImg
().
startsWith
(
"【图片链接】"
))
{
if
(
dto
.
getSkuImg
().
startsWith
(
"【图片链接】"
))
{
String
[]
skuImgArr
=
dto
.
getSkuImg
().
replace
(
"【图片链接】"
,
""
).
replace
(
";"
,
";"
).
split
(
";"
);
String
[]
skuImgArr
=
dto
.
getSkuImg
().
replace
(
"【图片链接】"
,
""
).
replace
(
";"
,
";"
).
split
(
";"
);
...
@@ -334,63 +398,79 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -334,63 +398,79 @@ public class GoblinStoreMgtGoodsImportService {
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行规格图片格式有误】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行规格图片格式有误】"
,
rowNum
));
}
}
}
}
/* 规格条码校验|------------------------------------------------------------------------------ */
/*
* 规格条码校验|----------------------------------------------------------------------
* --------
*/
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSkuBarCode
()))
{
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSkuBarCode
()))
{
if
(
Pattern
.
matches
(
LnsRegex
.
Valid
.
ALPHABET_NUMBER_32
,
dto
.
getSkuBarCode
()))
{
if
(
Pattern
.
matches
(
LnsRegex
.
Valid
.
ALPHABET_NUMBER_32
,
dto
.
getSkuBarCode
()))
{
// if (dtoSkuBarCodeTmpList.contains(dto.getSkuBarCode())) {
// if (dtoSkuBarCodeTmpList.contains(dto.getSkuBarCode())) {
// throw new LiquidnetServiceException("-1", String.format("数据内容不规范【第%s行表格内规格条码重复】", rowNum));
// throw new LiquidnetServiceException("-1",
// }
// String.format("数据内容不规范【第%s行表格内规格条码重复】", rowNum));
// dtoSkuBarCodeTmpList.add(dto.getSkuBarCode());
// }
// dtoSkuBarCodeTmpList.add(dto.getSkuBarCode());
}
else
{
}
else
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行规格条码格式有误】"
,
rowNum
));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"数据内容不规范【第%s行规格条码格式有误】"
,
rowNum
));
}
}
}
}
/* 校验|------------------------------------------------------------------------------ */
/*
/* 校验|------------------------------------------------------------------------------ */
* 校验|--------------------------------------------------------------------------
/* 校验|------------------------------------------------------------------------------ */
* ----
*/
/*
* 校验|--------------------------------------------------------------------------
* ----
*/
/*
* 校验|--------------------------------------------------------------------------
* ----
*/
}
}
private
GoblinGoodsInfoVo
goodsInformationDataAnalysisProcessingForSpu
(
GoblinGoodsImportDto
dt
,
String
uid
,
String
storeId
,
LocalDateTime
now
)
{
private
GoblinGoodsInfoVo
goodsInformationDataAnalysisProcessingForSpu
(
GoblinGoodsImportDto
dt
,
String
uid
,
String
storeId
,
LocalDateTime
now
)
{
GoblinGoodsInfoVo
lastGoodsInfoVo
=
GoblinGoodsInfoVo
.
getNew
();
GoblinGoodsInfoVo
lastGoodsInfoVo
=
GoblinGoodsInfoVo
.
getNew
();
lastGoodsInfoVo
.
setName
(
dt
.
getSpuName
());
//*
lastGoodsInfoVo
.
setName
(
dt
.
getSpuName
());
//
*
lastGoodsInfoVo
.
setSpuId
(
IDGenerator
.
nextSnowId
());
//*
lastGoodsInfoVo
.
setSpuId
(
IDGenerator
.
nextSnowId
());
//
*
if
(
StringUtils
.
isNotEmpty
(
dt
.
getSpuCode
()))
{
if
(
StringUtils
.
isNotEmpty
(
dt
.
getSpuCode
()))
{
lastGoodsInfoVo
.
setSpuNo
(
dt
.
getSpuCode
());
lastGoodsInfoVo
.
setSpuNo
(
dt
.
getSpuCode
());
}
else
{
}
else
{
lastGoodsInfoVo
.
setSpuNo
(
lastGoodsInfoVo
.
getSpuId
());
lastGoodsInfoVo
.
setSpuNo
(
lastGoodsInfoVo
.
getSpuId
());
}
}
//
if (StringUtils.isNotEmpty(dt.getSpuBarCode())) {
//
if (StringUtils.isNotEmpty(dt.getSpuBarCode())) {
//
lastGoodsInfoVo.setSpuBarCode(dt.getSpuBarCode());
//
lastGoodsInfoVo.setSpuBarCode(dt.getSpuBarCode());
//
} else {
//
} else {
//
lastGoodsInfoVo.setSpuBarCode(lastGoodsInfoVo.getSpuId());
//
lastGoodsInfoVo.setSpuBarCode(lastGoodsInfoVo.getSpuId());
//
}
//
}
if
(!
CollectionUtils
.
isEmpty
(
dt
.
getSpuImgList
()))
{
if
(!
CollectionUtils
.
isEmpty
(
dt
.
getSpuImgList
()))
{
lastGoodsInfoVo
.
setImageList
(
dt
.
getSpuImgList
());
lastGoodsInfoVo
.
setImageList
(
dt
.
getSpuImgList
());
lastGoodsInfoVo
.
setCoverPic
(
lastGoodsInfoVo
.
getImageList
().
get
(
0
));
lastGoodsInfoVo
.
setCoverPic
(
lastGoodsInfoVo
.
getImageList
().
get
(
0
));
}
}
lastGoodsInfoVo
.
setDetails
(
lastGoodsInfoVo
.
getName
());
lastGoodsInfoVo
.
setDetails
(
lastGoodsInfoVo
.
getName
());
lastGoodsInfoVo
.
setSpuType
(
0
);
//*
lastGoodsInfoVo
.
setSpuType
(
0
);
//
*
lastGoodsInfoVo
.
setSpecMode
(
"1"
);
//*
lastGoodsInfoVo
.
setSpecMode
(
"1"
);
//
*
lastGoodsInfoVo
.
setShelvesHandle
(
"1"
);
lastGoodsInfoVo
.
setShelvesHandle
(
"1"
);
lastGoodsInfoVo
.
setVirtualFlg
(
"0"
);
lastGoodsInfoVo
.
setVirtualFlg
(
"0"
);
lastGoodsInfoVo
.
setStatus
(
"3"
);
lastGoodsInfoVo
.
setStatus
(
"3"
);
lastGoodsInfoVo
.
setShelvesStatus
(
"0"
);
lastGoodsInfoVo
.
setShelvesStatus
(
"0"
);
lastGoodsInfoVo
.
setSpuAppear
(
"0"
);
//*
lastGoodsInfoVo
.
setSpuAppear
(
"0"
);
//
*
lastGoodsInfoVo
.
setSpuCanbuy
(
"1"
);
lastGoodsInfoVo
.
setSpuCanbuy
(
"1"
);
lastGoodsInfoVo
.
setDelFlg
(
"0"
);
lastGoodsInfoVo
.
setDelFlg
(
"0"
);
lastGoodsInfoVo
.
setCreatedAt
(
now
);
lastGoodsInfoVo
.
setCreatedAt
(
now
);
lastGoodsInfoVo
.
setCreatedBy
(
uid
);
//*
lastGoodsInfoVo
.
setCreatedBy
(
uid
);
//
*
lastGoodsInfoVo
.
setStoreId
(
storeId
);
//*
lastGoodsInfoVo
.
setStoreId
(
storeId
);
//
*
return
lastGoodsInfoVo
;
return
lastGoodsInfoVo
;
}
}
private
GoblinGoodsSkuInfoVo
goodsInformationDataAnalysisProcessingForSku
(
GoblinGoodsImportDto
dt
,
GoblinGoodsInfoVo
lastGoodsInfoVo
,
boolean
tobeNextSpuFlg
)
{
private
GoblinGoodsSkuInfoVo
goodsInformationDataAnalysisProcessingForSku
(
GoblinGoodsImportDto
dt
,
GoblinGoodsInfoVo
lastGoodsInfoVo
,
boolean
tobeNextSpuFlg
)
{
GoblinGoodsSkuInfoVo
skuInfoVo
=
GoblinGoodsSkuInfoVo
.
getNew
();
GoblinGoodsSkuInfoVo
skuInfoVo
=
GoblinGoodsSkuInfoVo
.
getNew
();
skuInfoVo
.
setName
(
""
);
skuInfoVo
.
setName
(
""
);
List
<
GoblinGoodsSpecDto
>
skuSpecDtos
=
dt
.
getSkuSpecDtos
();
List
<
GoblinGoodsSpecDto
>
skuSpecDtos
=
dt
.
getSkuSpecDtos
();
List
<
GoblinGoodsSpecVo
>
spuSpecVos
=
tobeNextSpuFlg
?
ObjectUtil
.
getGoblinGoodsSpecVoArrayList
()
:
lastGoodsInfoVo
.
getSpecVoList
();
List
<
GoblinGoodsSpecVo
>
spuSpecVos
=
tobeNextSpuFlg
?
ObjectUtil
.
getGoblinGoodsSpecVoArrayList
()
:
lastGoodsInfoVo
.
getSpecVoList
();
for
(
int
i
=
0
,
size
=
skuSpecDtos
.
size
();
i
<
size
;
i
++)
{
for
(
int
i
=
0
,
size
=
skuSpecDtos
.
size
();
i
<
size
;
i
++)
{
GoblinGoodsSpecDto
skuSpecDto
=
skuSpecDtos
.
get
(
i
);
GoblinGoodsSpecDto
skuSpecDto
=
skuSpecDtos
.
get
(
i
);
...
@@ -398,18 +478,23 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -398,18 +478,23 @@ public class GoblinStoreMgtGoodsImportService {
if
(
tobeNextSpuFlg
)
{
if
(
tobeNextSpuFlg
)
{
List
<
GoblinGoodsSpecValueVo
>
spuSpecValueVos
=
ObjectUtil
.
getGoblinGoodsSpecValueVoArrayList
();
List
<
GoblinGoodsSpecValueVo
>
spuSpecValueVos
=
ObjectUtil
.
getGoblinGoodsSpecValueVoArrayList
();
spuSpecValueVos
.
add
(
GoblinGoodsSpecValueVo
.
getNew
().
setSpecVname
(
skuSpecDto
.
getSpecVname
()).
setSpecVsort
(
1
));
spuSpecValueVos
GoblinGoodsSpecVo
spuSpecVo
=
GoblinGoodsSpecVo
.
getNew
().
setSpecName
(
skuSpecDto
.
getSpecName
()).
setSpecSort
(
i
+
1
).
setSpecValues
(
spuSpecValueVos
);
.
add
(
GoblinGoodsSpecValueVo
.
getNew
().
setSpecVname
(
skuSpecDto
.
getSpecVname
()).
setSpecVsort
(
1
));
GoblinGoodsSpecVo
spuSpecVo
=
GoblinGoodsSpecVo
.
getNew
().
setSpecName
(
skuSpecDto
.
getSpecName
())
.
setSpecSort
(
i
+
1
).
setSpecValues
(
spuSpecValueVos
);
spuSpecVos
.
add
(
spuSpecVo
);
spuSpecVos
.
add
(
spuSpecVo
);
}
else
{
}
else
{
Optional
<
GoblinGoodsSpecVo
>
hasSpecOptional
=
spuSpecVos
.
stream
().
filter
(
r
->
r
.
getSpecName
().
equals
(
skuSpecDto
.
getSpecName
())).
findAny
();
Optional
<
GoblinGoodsSpecVo
>
hasSpecOptional
=
spuSpecVos
.
stream
()
.
filter
(
r
->
r
.
getSpecName
().
equals
(
skuSpecDto
.
getSpecName
())).
findAny
();
if
(
hasSpecOptional
.
isPresent
())
{
if
(
hasSpecOptional
.
isPresent
())
{
GoblinGoodsSpecVo
spuSpecVo
=
hasSpecOptional
.
get
();
GoblinGoodsSpecVo
spuSpecVo
=
hasSpecOptional
.
get
();
List
<
GoblinGoodsSpecValueVo
>
spuSpecValueVos
=
spuSpecVo
.
getSpecValues
();
List
<
GoblinGoodsSpecValueVo
>
spuSpecValueVos
=
spuSpecVo
.
getSpecValues
();
Optional
<
GoblinGoodsSpecValueVo
>
any
=
spuSpecValueVos
.
stream
().
filter
(
r
->
r
.
getSpecVname
().
equals
(
skuSpecDto
.
getSpecVname
())).
findAny
();
Optional
<
GoblinGoodsSpecValueVo
>
any
=
spuSpecValueVos
.
stream
()
.
filter
(
r
->
r
.
getSpecVname
().
equals
(
skuSpecDto
.
getSpecVname
())).
findAny
();
if
(!
any
.
isPresent
())
{
if
(!
any
.
isPresent
())
{
spuSpecValueVos
.
add
(
GoblinGoodsSpecValueVo
.
getNew
().
setSpecVname
(
skuSpecDto
.
getSpecVname
()).
setSpecVsort
(
lastGoodsInfoVo
.
getSkuIdList
().
size
()
+
1
));
spuSpecValueVos
.
add
(
GoblinGoodsSpecValueVo
.
getNew
().
setSpecVname
(
skuSpecDto
.
getSpecVname
())
.
setSpecVsort
(
lastGoodsInfoVo
.
getSkuIdList
().
size
()
+
1
));
}
}
}
else
{
// 不匹配的规格直接跳过(默认只匹配商品第一行数据中的规格项)
}
else
{
// 不匹配的规格直接跳过(默认只匹配商品第一行数据中的规格项)
return
null
;
return
null
;
...
@@ -417,11 +502,11 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -417,11 +502,11 @@ public class GoblinStoreMgtGoodsImportService {
}
}
}
}
skuInfoVo
.
setStock
(
dt
.
getStock
());
//*
skuInfoVo
.
setStock
(
dt
.
getStock
());
//
*
skuInfoVo
.
setSkuStock
(
dt
.
getStock
());
//*
skuInfoVo
.
setSkuStock
(
dt
.
getStock
());
//
*
skuInfoVo
.
setPrice
(
dt
.
getPrice
());
//*
skuInfoVo
.
setPrice
(
dt
.
getPrice
());
//
*
skuInfoVo
.
setPriceMember
(
dt
.
getPrice
());
//*
skuInfoVo
.
setPriceMember
(
dt
.
getPrice
());
//
*
skuInfoVo
.
setSkuId
(
lastGoodsInfoVo
.
getSpuId
().
concat
(
StringUtils
.
right
(
String
.
valueOf
(
System
.
nanoTime
()),
5
)));
//*
skuInfoVo
.
setSkuId
(
lastGoodsInfoVo
.
getSpuId
().
concat
(
StringUtils
.
right
(
String
.
valueOf
(
System
.
nanoTime
()),
5
)));
//
*
if
(
StringUtils
.
isNotEmpty
(
dt
.
getSkuCode
()))
{
if
(
StringUtils
.
isNotEmpty
(
dt
.
getSkuCode
()))
{
skuInfoVo
.
setSkuNo
(
dt
.
getSkuCode
());
skuInfoVo
.
setSkuNo
(
dt
.
getSkuCode
());
}
else
{
}
else
{
...
@@ -430,7 +515,7 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -430,7 +515,7 @@ public class GoblinStoreMgtGoodsImportService {
if
(
StringUtils
.
isNotEmpty
(
dt
.
getSkuImg
()))
{
if
(
StringUtils
.
isNotEmpty
(
dt
.
getSkuImg
()))
{
skuInfoVo
.
setSkuPic
(
dt
.
getSkuImg
());
skuInfoVo
.
setSkuPic
(
dt
.
getSkuImg
());
}
else
{
}
else
{
//
skuInfoVo.setSkuPic("");// 设置默认图片
//
skuInfoVo.setSkuPic("");// 设置默认图片
}
}
if
(
StringUtils
.
isNotEmpty
(
dt
.
getSkuBarCode
()))
{
if
(
StringUtils
.
isNotEmpty
(
dt
.
getSkuBarCode
()))
{
skuInfoVo
.
setSkuBarCode
(
dt
.
getSkuBarCode
());
skuInfoVo
.
setSkuBarCode
(
dt
.
getSkuBarCode
());
...
@@ -438,18 +523,18 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -438,18 +523,18 @@ public class GoblinStoreMgtGoodsImportService {
skuInfoVo
.
setSkuBarCode
(
lastGoodsInfoVo
.
getSpuNo
());
skuInfoVo
.
setSkuBarCode
(
lastGoodsInfoVo
.
getSpuNo
());
}
}
skuInfoVo
.
setSpuId
(
lastGoodsInfoVo
.
getSpuId
());
//*
skuInfoVo
.
setSpuId
(
lastGoodsInfoVo
.
getSpuId
());
//
*
skuInfoVo
.
setSkuType
(
0
);
//*
skuInfoVo
.
setSkuType
(
0
);
//
*
skuInfoVo
.
setBuyFactor
(
"0"
);
skuInfoVo
.
setBuyFactor
(
"0"
);
skuInfoVo
.
setBuyLimit
(
0
);
skuInfoVo
.
setBuyLimit
(
0
);
skuInfoVo
.
setStatus
(
"3"
);
skuInfoVo
.
setStatus
(
"3"
);
skuInfoVo
.
setShelvesStatus
(
lastGoodsInfoVo
.
getShelvesStatus
());
skuInfoVo
.
setShelvesStatus
(
lastGoodsInfoVo
.
getShelvesStatus
());
skuInfoVo
.
setSoldoutStatus
(
"0"
);
//*
skuInfoVo
.
setSoldoutStatus
(
"0"
);
//
*
skuInfoVo
.
setSkuAppear
(
"0"
);
//*
skuInfoVo
.
setSkuAppear
(
"0"
);
//
*
skuInfoVo
.
setSkuCanbuy
(
"1"
);
skuInfoVo
.
setSkuCanbuy
(
"1"
);
skuInfoVo
.
setDelFlg
(
"0"
);
skuInfoVo
.
setDelFlg
(
"0"
);
skuInfoVo
.
setCreatedAt
(
lastGoodsInfoVo
.
getCreatedAt
());
//*
skuInfoVo
.
setCreatedAt
(
lastGoodsInfoVo
.
getCreatedAt
());
//
*
skuInfoVo
.
setCreatedBy
(
lastGoodsInfoVo
.
getCreatedBy
());
//*
skuInfoVo
.
setCreatedBy
(
lastGoodsInfoVo
.
getCreatedBy
());
//
*
skuInfoVo
.
setStoreId
(
lastGoodsInfoVo
.
getStoreId
());
skuInfoVo
.
setStoreId
(
lastGoodsInfoVo
.
getStoreId
());
skuInfoVo
.
setSkuSpecList
(
skuSpecDtos
);
skuInfoVo
.
setSkuSpecList
(
skuSpecDtos
);
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/manage/GoblinStoreMgtGoodsServiceImpl.java
View file @
a2a2e25e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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