Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
lanbaoming
jiedao-api-boot-master
Commits
416d4f6d
Commit
416d4f6d
authored
Aug 23, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
70dfec54
4b0575aa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
611 additions
and
698 deletions
+611
-698
BasePrice.java
...udao/module/product/dal/dataobject/product/BasePrice.java
+18
-0
ProductPriceExcelExportListener.java
...ule/product/listener/ProductPriceExcelExportListener.java
+133
-132
ProductPriceServiceImpl.java
...product/service/product/impl/ProductPriceServiceImpl.java
+458
-566
ProductPriceReqBaseVO.java
...module/product/vo/productPrice/ProductPriceReqBaseVO.java
+2
-0
No files found.
yudao-module-product/yudao-module-product-core/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/product/BasePrice.java
View file @
416d4f6d
...
...
@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.List
;
@Data
public
class
BasePrice
extends
BaseDO
{
...
...
@@ -92,4 +93,21 @@ public class BasePrice extends BaseDO {
@JsonIgnore
private
int
productPriceEmptyType
=
0
;
@ApiModelProperty
(
value
=
"特殊需求列表"
)
@TableField
(
exist
=
false
)
private
List
<
ProductPriceSpecialDO
>
specialDOList
;
@ApiModelProperty
(
value
=
"运费包装价格列表"
)
@TableField
(
exist
=
false
)
private
List
<
ProductPricePackagingDO
>
freightPricePackagingList
;
@ApiModelProperty
(
value
=
"清关费包装价格列表"
)
@TableField
(
exist
=
false
)
private
List
<
ProductPricePackagingDO
>
clearancePricePackagingList
;
@ApiModelProperty
(
value
=
"全包价包装价格列表"
)
@TableField
(
exist
=
false
)
private
List
<
ProductPricePackagingDO
>
fullPricePackagingList
;
}
yudao-module-product/yudao-module-product-core/src/main/java/cn/iocoder/yudao/module/product/listener/ProductPriceExcelExportListener.java
View file @
416d4f6d
...
...
@@ -193,7 +193,7 @@ public class ProductPriceExcelExportListener {
StringBuilder
ytqgfSb
=
new
StringBuilder
();
StringBuilder
ddyfSb
=
new
StringBuilder
();
StringBuilder
ddqgfSb
=
new
StringBuilder
();
if
(
item
.
getPriceType
()
==
0
)
{
if
(
CollectionUtil
.
isNotEmpty
(
yfStepList
))
{
yfStepList
.
sort
(
Comparator
.
comparing
(
ProductPriceStepDO:
:
getRankNum
));
for
(
int
j
=
1
;
j
<=
yfStepList
.
size
();
j
++)
{
...
...
@@ -232,7 +232,7 @@ public class ProductPriceExcelExportListener {
String
unit
=
""
;
if
(
weightUnit
!=
null
)
{
UnitDO
unitDO
=
unitMap
.
get
(
weightUnit
.
intValue
());
unit
=
Objects
.
nonNull
(
unitDO
)?
unitDO
.
getTitleZh
():
"空"
;
unit
=
Objects
.
nonNull
(
unitDO
)
?
unitDO
.
getTitleZh
()
:
"空"
;
}
BigDecimal
startNum
=
stepDO
.
getStartNum
();
BigDecimal
endNum
=
stepDO
.
getEndNum
();
...
...
@@ -282,7 +282,7 @@ public class ProductPriceExcelExportListener {
String
unit
=
""
;
if
(
weightUnit
!=
null
)
{
UnitDO
unitDO
=
unitMap
.
get
(
weightUnit
.
intValue
());
unit
=
unitDO
.
getTitleZh
()
;
unit
=
Objects
.
nonNull
(
unitDO
)
?
unitDO
.
getTitleZh
()
:
"空"
;
}
BigDecimal
startNum
=
stepDO
.
getStartNum
();
BigDecimal
endNum
=
stepDO
.
getEndNum
();
...
...
@@ -293,7 +293,8 @@ public class ProductPriceExcelExportListener {
}
}
}
}
if
(
item
.
getPriceType
()
==
1
)
{
if
(
CollectionUtil
.
isNotEmpty
(
qbjStepList
)
&&
item
.
getPriceType
()
==
1
)
{
qbjStepList
.
sort
(
Comparator
.
comparing
(
ProductPriceStepDO:
:
getRankNum
));
for
(
int
j
=
1
;
j
<=
qbjStepList
.
size
();
j
++)
{
...
...
@@ -343,7 +344,7 @@ public class ProductPriceExcelExportListener {
}
}
}
}
transportPrice
=
transportPriceSb
.
toString
();
clearancePrice
=
clearancePriceSb
.
toString
();
...
...
yudao-module-product/yudao-module-product-core/src/main/java/cn/iocoder/yudao/module/product/service/product/impl/ProductPriceServiceImpl.java
View file @
416d4f6d
...
...
@@ -1618,7 +1618,12 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
//设置特殊需求列表
productPriceRespVO
.
setSpecialList
(
productPriceSpecialService
.
getProductPriceSpecialList
(
id
));
List
<
ProductPricePackagingDO
>
packagingDOList
=
productPricePackagingMapper
.
selectList
(
new
LambdaQueryWrapperX
<
ProductPricePackagingDO
>().
eq
(
ProductPricePackagingDO:
:
getProductPriceId
,
id
));
if
(
CollectionUtil
.
isNotEmpty
(
packagingDOList
))
{
productPriceRespVO
.
setFreightPricePackagingList
(
packagingDOList
.
stream
().
filter
(
p
->
p
.
getPriceType
()
==
PriceTypeEnum
.
FREIGHT
.
getPriceType
()).
collect
(
toList
()));
productPriceRespVO
.
setClearancePricePackagingList
(
packagingDOList
.
stream
().
filter
(
p
->
p
.
getPriceType
()
==
PriceTypeEnum
.
CLEARANCE
.
getPriceType
()).
collect
(
toList
()));
productPriceRespVO
.
setFullPricePackagingList
(
packagingDOList
.
stream
().
filter
(
p
->
p
.
getPriceType
()
==
PriceTypeEnum
.
FULL_PRICE
.
getPriceType
()).
collect
(
toList
()));
}
List
<
ProductPriceStepDO
>
priceStepDOList
=
productPriceStepService
.
getProductPriceStepList
(
id
);
List
<
Long
>
stepIdList
=
priceStepDOList
.
stream
()
...
...
@@ -3458,6 +3463,7 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
lineChannelList
.
add
(
vo
);
createReqVO
.
setLineChannelList
(
lineChannelList
);
ProductPriceRespVO
respVO
=
this
.
getProductPriceDetail
(
price
.
getId
());
price
.
setSpecialDOList
(
respVO
.
getSpecialList
());
//阶梯运费价格列表
List
<
ProductPriceStepDO
>
freightPriceStepList
=
new
ArrayList
<>();
//阶梯清关费价格列表
...
...
@@ -3467,134 +3473,22 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
ProductPriceStepDO
freightPriceStep
=
new
ProductPriceStepDO
();
ProductPriceStepDO
clear
=
new
ProductPriceStepDO
();
if
(
createReqVO
.
getPriceType
()
==
1
)
{
price
.
setFullPricePackagingList
(
respVO
.
getFullPricePackagingList
());
if
(
CollectionUtil
.
isNotEmpty
(
respVO
.
getFullPriceStepList
()))
{
// respVO.getFullPriceStepList().forEach(pack -> {
// ProductPriceStepDO priceStepDO = new ProductPriceStepDO();
// BeanUtils.copyProperties(pack, priceStepDO);
// priceStepDO.setId(null);
// priceStepDO.setStartNum(BigDecimal.valueOf(0));
// priceStepDO.setEndNum(BigDecimal.valueOf(0));
// priceStepDO.setWeightUnit(price.getTransportPriceUnit());
// priceStepDO.setAllPrice(respVO.getAllPrice());
// priceStepDO.setAllPriceUnit(respVO.getAllPriceUnit());
// priceStepDO.setAllVolumeUnit(respVO.getAllVolumeUnit());
// if (CollectionUtil.isNotEmpty(respVO.getSpecialList())) {
// List<ProductPriceStepSpecialDO> specialList = new ArrayList<>();
// respVO.getSpecialList().forEach(sp -> {
// ProductPriceStepSpecialDO specialDO = new ProductPriceStepSpecialDO();
// BeanUtils.copyProperties(sp, specialDO);
// specialDO.setId(null);
// specialList.add(specialDO);
// });
// priceStepDO.setSpecialList(specialList);
// }
// fullPriceStepList.add(priceStepDO);
// });
createReqVO
.
setFullPriceStepList
(
respVO
.
getFullPriceStepList
());
}
}
else
{
// if (CollectionUtil.isEmpty(respVO.getFreightPriceStepList())) {
// BeanUtils.copyProperties(price, freightPriceStep);
// freightPriceStep.setStartNum(BigDecimal.valueOf(0));
// freightPriceStep.setEndNum(BigDecimal.valueOf(0));
// freightPriceStep.setRankNum(1);
// freightPriceStep.setWeightUnit(price.getTransportPriceUnit());
// freightPriceStep.setProductPriceId(price.getId());
// if (CollectionUtil.isNotEmpty(respVO.getSpecialList())) {
// List<ProductPriceStepSpecialDO> specialDOList = new ArrayList<>();
// respVO.getSpecialList().forEach(sp -> {
// ProductPriceStepSpecialDO d = new ProductPriceStepSpecialDO();
// BeanUtils.copyProperties(sp, d);
// specialDOList.add(d);
// });
// specialDOList.stream().distinct();
// freightPriceStep.setSpecialList(specialDOList);
// }
// //
// if (CollectionUtil.isNotEmpty(respVO.getFreightPricePackagingList())) {
// List<ProductPriceStepPackagingDO> stepPackagingDOS = new ArrayList<>();
// respVO.getFreightPricePackagingList().forEach(pack -> {
// ProductPriceStepPackagingDO packagingDO = new ProductPriceStepPackagingDO();
// BeanUtils.copyProperties(pack, packagingDO);
// stepPackagingDOS.add(packagingDO);
// });
// stepPackagingDOS.stream().distinct();
// freightPriceStep.setPackagingList(stepPackagingDOS);
// }
// if (respVO.getPriceType() == 1) {
// if (CollectionUtil.isNotEmpty(respVO.getFullPricePackagingList())) {
// List<ProductPriceStepPackagingDO> specialDOList = new ArrayList<>();
// respVO.getFullPricePackagingList().forEach(pack -> {
// ProductPriceStepPackagingDO packagingDO = new ProductPriceStepPackagingDO();
// BeanUtils.copyProperties(pack, packagingDO);
// packagingDO.setId(null);
//
// specialDOList.add(packagingDO);
// });
//
// freightPriceStep.setPackagingList(specialDOList);
//
// }
// } else {
//
// }
// freightPriceStepList.add(freightPriceStep);
//
// createReqVO.setFreightPriceStepList(freightPriceStepList);
// } else {
// createReqVO.setFreightPriceStepList(respVO.getFreightPriceStepList());
// }
price
.
setFreightPricePackagingList
(
respVO
.
getFullPricePackagingList
());
price
.
setClearancePricePackagingList
(
respVO
.
getFullPricePackagingList
());
if
(
CollectionUtil
.
isNotEmpty
(
respVO
.
getFreightPriceStepList
()))
{
createReqVO
.
setFreightPriceStepList
(
respVO
.
getFreightPriceStepList
());
}
// if (CollectionUtil.isEmpty(respVO.getClearancePriceStepList())) {
// BeanUtils.copyProperties(price, clear);
// clear.setStartNum(BigDecimal.valueOf(0));
// clear.setEndNum(BigDecimal.valueOf(0));
// clear.setRankNum(2);
// clear.setWeightUnit(price.getClearancePriceUnit());
// clear.setProductPriceId(price.getId());
//
// if (CollectionUtil.isNotEmpty(respVO.getClearancePricePackagingList())) {
// List<ProductPriceStepPackagingDO> stepPackagingDOS = new ArrayList<>();
// respVO.getClearancePricePackagingList().forEach(pack -> {
// ProductPriceStepPackagingDO packagingDO = new ProductPriceStepPackagingDO();
// BeanUtils.copyProperties(pack, packagingDO);
// stepPackagingDOS.add(packagingDO);
// });
// stepPackagingDOS.stream().distinct();
// clear.setPackagingList(stepPackagingDOS);
// }
//
// clearancePriceStepList.add(clear);
// createReqVO.setClearancePriceStepList(clearancePriceStepList);
// } else {
// createReqVO.setClearancePriceStepList(respVO.getClearancePriceStepList());
// }
if
(
CollectionUtil
.
isNotEmpty
(
respVO
.
getClearancePriceStepList
()))
{
createReqVO
.
setClearancePriceStepList
(
respVO
.
getClearancePriceStepList
());
}
}
// if(CollectionUtil.isNotEmpty(respVO.getFullPricePackagingList())){
//
// respVO.getFullPricePackagingList().forEach(pack->{
// ProductPriceStepDO packagingDO = new ProductPriceStepDO() ;
// BeanUtils.copyProperties(pack,packagingDO);
// packagingDO.setId(null);
//
// packagingDO.setTransportPrice(pack.getPackagingPrice());
// packagingDO.setTransportPriceUnit(pack.getPackagingPriceUnit());
//
// fullPriceStepList.add(packagingDO) ;
// });
//
// createReqVO.setFullPriceStepList(fullPriceStepList);
// }
//ProductDO productDO = checkUpdateStatus(lineChannelList, createReqVO.getProductId());
ProductDO
productDO
=
productService
.
getProduct
(
createReqVO
.
getProductId
());
WarehouseLineSearchVO
searchVO
=
new
WarehouseLineSearchVO
();
...
...
@@ -3608,8 +3502,9 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
createReqVO
.
setSync
(
true
);
createReqVO
.
setBatch
(
false
);
copyPriceUpdateAir
(
createReqVO
,
vo
,
warehouseLineList
,
product
List
,
product
DO
,
price
);
}
}
...
...
@@ -3622,47 +3517,34 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
*
* @param createReqVO
* @param warehouseLineList
* @param product
List
* @param product
DO
* @param productPrice
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
copyPriceUpdateAir
(
ProductPriceAirCreateReqVO
createReqVO
,
Li
st
<
WarehouseLineDO
>
warehouseLineList
,
List
<
ProductDO
>
productList
,
ProductPriceDO
productPrice
)
{
public
void
copyPriceUpdateAir
(
ProductPriceAirCreateReqVO
createReqVO
,
Li
neChannelVo
vo
,
List
<
WarehouseLineDO
>
warehouseLineList
,
ProductDO
productDO
,
ProductPriceDO
productPrice
)
{
long
t1
=
System
.
currentTimeMillis
();
Long
loginUserId
=
SecurityFrameworkUtils
.
getLoginUserId
();
checkAndUpdateStepToMainPrice
(
productPrice
,
createReqVO
);
List
<
LineChannelVo
>
lineChannelList
=
createReqVO
.
getLineChannelList
();
Set
<
Long
>
lineIdList
=
lineChannelList
.
stream
()
.
map
(
LineChannelVo:
:
getLineId
)
.
collect
(
Collectors
.
toSet
());
Map
<
Long
,
String
>
lineTransportTypeMap
=
warehouseLineList
.
stream
()
.
collect
(
Collectors
.
toMap
(
WarehouseLineDO:
:
getId
,
WarehouseLineDO:
:
getTransportType
));
List
<
Long
>
idList
=
productList
.
stream
()
.
map
(
ProductDO:
:
getId
)
.
collect
(
toList
());
//这个产品这么多线路已有的价格
List
<
ProductPriceDO
>
dbPriceList
=
productPriceMapper
.
selectList
(
new
LambdaQueryWrapperX
<
ProductPriceDO
>()
.
in
(
ProductPriceDO:
:
getWarehouseLineId
,
lineIdList
)
.
in
(
ProductPriceDO:
:
getProductId
,
idList
));
.
eq
(
ProductPriceDO:
:
getWarehouseLineId
,
vo
.
getLineId
()
)
.
eq
(
ProductPriceDO:
:
getProductId
,
productDO
.
getId
()
));
Map
<
String
,
ProductPriceDO
>
productLineChannelMap
=
dbPriceList
.
stream
()
.
collect
(
Collectors
.
toMap
(
t
->
t
.
getProductId
()
+
"-"
+
t
.
getWarehouseLineId
()
+
"-"
+
t
.
getShippingChannelId
(),
v
->
v
,
(
v1
,
v2
)
->
v2
));
List
<
ProductPriceDO
>
insertList
=
new
ArrayList
<>();
List
<
ProductPriceDO
>
updateList
=
new
ArrayList
<>();
List
<
ProductPriceDO
>
snapshotList
=
new
ArrayList
<>();
Date
current
=
new
Date
();
for
(
Long
productId
:
idList
)
{
for
(
LineChannelVo
lineChannel
:
lineChannelList
)
{
Long
lineId
=
lineChannel
.
getLineId
();
Long
shippingChannelId
=
lineChannel
.
getShippingChannelId
();
String
key
=
productId
+
"-"
+
lineId
+
"-"
+
shippingChannelId
;
Long
lineId
=
vo
.
getLineId
();
Long
shippingChannelId
=
vo
.
getShippingChannelId
();
String
key
=
productDO
.
getId
()
+
"-"
+
lineId
+
"-"
+
shippingChannelId
;
ProductPriceDO
dbItem
;
if
(
productLineChannelMap
.
containsKey
(
key
))
{
...
...
@@ -3673,10 +3555,10 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
snapshotList
.
add
(
snapshot
);
dbItem
.
setUpdater
(
String
.
valueOf
(
loginUserId
));
updateColumn
(
dbItem
,
productPrice
);
updateList
.
ad
d
(
dbItem
);
productPriceMapper
.
updateByI
d
(
dbItem
);
}
else
{
dbItem
=
ObjectUtil
.
clone
(
productPrice
);
dbItem
.
setProductId
(
productId
);
dbItem
.
setProductId
(
productDO
.
getId
()
);
dbItem
.
setWarehouseLineId
(
lineId
);
dbItem
.
setShippingChannelId
(
shippingChannelId
);
...
...
@@ -3707,42 +3589,35 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
dbItem
.
setBlacklist
(
0
);
dbItem
.
setStatus
(
0
);
dbItem
.
setCreateTime
(
current
);
insertList
.
add
(
dbItem
);
productPriceMapper
.
insert
(
dbItem
);
}
dbItem
.
setUpdateTime
(
current
);
String
transportType
=
lineTransportTypeMap
.
get
(
lineId
);
initBasePrice
(
dbItem
,
transportType
);
}
}
if
(
CollectionUtil
.
isNotEmpty
(
insertList
))
{
productPriceMapper
.
insertBatchSomeColumn
(
insertList
);
}
if
(
CollectionUtil
.
isNotEmpty
(
updateList
))
{
productPriceMapper
.
updateBatch
(
updateList
);
}
List
<
ProductPriceDO
>
productPriceList
=
new
ArrayList
<>();
productPriceList
.
addAll
(
insertList
);
productPriceList
.
addAll
(
updateList
);
Map
<
Long
,
String
>
priceTransportTypeMap
=
new
HashMap
<>();
productPriceList
.
forEach
(
t
->
priceTransportTypeMap
.
put
(
t
.
getId
(),
lineTransportTypeMap
.
get
(
t
.
getWarehouseLineId
())));
//添加修改日志,需要查询特需和阶梯,所以需要在修改之前执行
batchAddSnapshot
(
snapshotList
);
List
<
Long
>
productPriceIdList
=
productPriceList
.
stream
().
map
(
ProductPriceDO:
:
getId
).
collect
(
Collectors
.
toList
());
dbItem
.
setSpecialDOList
(
productPrice
.
getSpecialDOList
());
if
(
productPrice
.
getPriceType
()
==
1
)
{
dbItem
.
setFullPricePackagingList
(
productPrice
.
getFullPricePackagingList
());
}
else
{
dbItem
.
setFreightPricePackagingList
(
productPrice
.
getFullPricePackagingList
());
dbItem
.
setClearancePricePackagingList
(
productPrice
.
getFullPricePackagingList
());
}
List
<
ProductPriceStepDO
>
allStepList
=
buildCopyAllStepList
(
createReqVO
);
copyClearAndSavePriceStepList
(
productPriceIdList
,
allStepList
,
priceTransportTypeMap
,
createReqVO
.
isBatch
());
copyClearAndSavePriceStepList
(
dbItem
,
allStepList
,
lineTransportTypeMap
.
get
(
dbItem
.
getWarehouseLineId
())
,
createReqVO
.
isBatch
());
long
t2
=
System
.
currentTimeMillis
();
log
.
info
(
"路线处理耗时:"
+
(
t2
-
t1
));
deleteKey
(
idList
,
lineChannelList
);
deleteKey
(
Collections
.
singletonList
(
productDO
.
getId
()),
Collections
.
singletonList
(
vo
)
);
handleOrderException
(
productPriceIdList
,
handleOrderException
(
Collections
.
singletonList
(
dbItem
.
getId
())
,
createReqVO
.
isSync
());
}
private
void
copyClearAndSavePriceStepList
(
List
<
Long
>
productPriceIdList
,
List
<
ProductPriceStepDO
>
stepList
,
Map
<
Long
,
String
>
priceTransportTypeMap
,
boolean
batchUpdate
)
{
private
void
copyClearAndSavePriceStepList
(
ProductPriceDO
productPriceDO
,
List
<
ProductPriceStepDO
>
stepList
,
String
transportType
,
boolean
batchUpdate
)
{
if
(
productPriceDO
.
getStepPrice
()
==
1
)
{
if
(
stepList
==
null
)
stepList
=
new
ArrayList
<>();
stepList
=
stepList
.
stream
()
...
...
@@ -3750,146 +3625,28 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
t
.
getWeightUnit
()
!=
null
&&
t
.
getEndNum
()
!=
null
)
.
collect
(
Collectors
.
toList
());
}
if
(
productPriceDO
.
getStepPrice
()
==
1
&&
CollectionUtil
.
isEmpty
(
stepList
))
return
;
if
(
CollectionUtil
.
isEmpty
(
stepList
))
return
;
List
<
ProductPriceStepDO
>
insertList1
=
new
ArrayList
<>();
List
<
ProductPriceStepDO
>
updateList
=
new
ArrayList
<>();
List
<
ProductPricePackagingDO
>
productPricePackagingDOS
=
new
ArrayList
<>();
List
<
ProductPriceSpecialDO
>
priceSpecialUpdate
=
new
ArrayList
<>();
if
(
productPriceDO
.
getStepPrice
()
==
1
)
{
Collection
<
Integer
>
priceTypes
=
stepList
.
stream
()
.
map
(
ProductPriceStepDO:
:
getPriceType
)
.
collect
(
Collectors
.
toSet
());
priceTypes
.
add
(
PriceTypeEnum
.
FULL_PRICE
.
getPriceType
());
List
<
ProductPriceStepDO
>
dbStepList
=
productPriceStepMapper
.
selectList
(
new
LambdaQueryWrapper
<
ProductPriceStepDO
>()
.
in
(
ProductPriceStepDO:
:
getProductPriceId
,
productPriceIdList
)
.
eq
(
ProductPriceStepDO:
:
getProductPriceId
,
productPriceDO
.
getId
()
)
.
in
(
ProductPriceStepDO:
:
getPriceType
,
priceTypes
)
);
Map
<
Long
,
List
<
ProductPriceStepDO
>>
dbStepMap
=
dbStepList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
ProductPriceStepDO:
:
getProductPriceId
));
List
<
ProductPriceStepDO
>
insertList1
=
new
ArrayList
<>();
List
<
ProductPriceStepDO
>
updateList
=
new
ArrayList
<>();
List
<
ProductPricePackagingDO
>
productPricePackagingDOS
=
new
ArrayList
<>();
for
(
Long
productPriceId
:
productPriceIdList
)
{
String
transportType
=
priceTransportTypeMap
.
get
(
productPriceId
);
List
<
ProductPriceStepDO
>
dbPriceStepList
=
dbStepMap
.
get
(
productPriceId
);
if
(
CollectionUtil
.
isEmpty
(
dbPriceStepList
))
{
for
(
ProductPriceStepDO
stepItem
:
stepList
)
{
if
(
stepItem
.
getTransportPrice
()
==
null
&&
stepItem
.
getClearancePrice
()
==
null
&&
stepItem
.
getAllPrice
()
==
null
)
continue
;
ProductPriceStepDO
dbItem
=
ObjectUtil
.
clone
(
stepItem
);
dbItem
.
setId
(
null
);
dbItem
.
setProductPriceId
(
productPriceId
);
initBasePrice
(
dbItem
,
transportType
);
insertList1
.
add
(
dbItem
);
if
(
CollectionUtil
.
isNotEmpty
(
stepItem
.
getPackagingList
()))
{
stepItem
.
getPackagingList
().
forEach
(
pg
->
{
ProductPricePackagingDO
pricePackagingDO
=
new
ProductPricePackagingDO
();
BeanUtils
.
copyProperties
(
pg
,
pricePackagingDO
);
pricePackagingDO
.
setId
(
null
);
productPricePackagingDOS
.
add
(
pricePackagingDO
);
});
}
}
}
else
{
//更新
for
(
ProductPriceStepDO
stepItem
:
stepList
)
{
boolean
update
=
false
;
for
(
ProductPriceStepDO
dbStepItem
:
dbPriceStepList
)
{
if
(!
stepItem
.
getPriceType
().
equals
(
dbStepItem
.
getPriceType
()))
continue
;
if
(
stepItem
.
getStartNum
().
intValue
()
!=
dbStepItem
.
getStartNum
().
intValue
()
||
stepItem
.
getEndNum
().
intValue
()
!=
dbStepItem
.
getEndNum
().
intValue
()
||
stepItem
.
getWeightUnit
().
longValue
()
!=
dbStepItem
.
getWeightUnit
().
longValue
())
{
continue
;
}
//更新
update
=
true
;
dbStepItem
.
setSpecialList
(
stepItem
.
getSpecialList
());
dbStepItem
.
setPackagingList
(
stepItem
.
getPackagingList
());
updateList
.
add
(
dbStepItem
);
if
(
stepItem
.
getTransportPrice
()
==
null
&&
stepItem
.
getClearancePrice
()
==
null
&&
stepItem
.
getAllPrice
()
==
null
)
continue
;
if
(
stepItem
.
getTransportPrice
()
!=
null
)
{
dbStepItem
.
setTransportPrice
(
stepItem
.
getTransportPrice
());
}
if
(
stepItem
.
getTransportPriceUnit
()
!=
null
)
{
dbStepItem
.
setTransportPriceUnit
(
stepItem
.
getTransportPriceUnit
());
}
if
(
stepItem
.
getTransportVolumeUnit
()
!=
null
)
{
dbStepItem
.
setTransportVolumeUnit
(
stepItem
.
getTransportVolumeUnit
());
}
if
(
stepItem
.
getClearancePrice
()
!=
null
)
{
dbStepItem
.
setClearancePrice
(
stepItem
.
getClearancePrice
());
}
if
(
stepItem
.
getClearancePriceUnit
()
!=
null
)
{
dbStepItem
.
setClearancePriceUnit
(
stepItem
.
getClearancePriceUnit
());
}
if
(
stepItem
.
getClearanceVolumeUnit
()
!=
null
)
{
dbStepItem
.
setClearanceVolumeUnit
(
stepItem
.
getClearanceVolumeUnit
());
}
if
(
stepItem
.
getAllPrice
()
!=
null
)
{
dbStepItem
.
setAllPrice
(
stepItem
.
getAllPrice
());
}
if
(
stepItem
.
getAllPriceUnit
()
!=
null
)
{
dbStepItem
.
setAllPriceUnit
(
stepItem
.
getAllPriceUnit
());
}
if
(
stepItem
.
getAllVolumeUnit
()
!=
null
)
{
dbStepItem
.
setAllVolumeUnit
(
stepItem
.
getAllVolumeUnit
());
}
if
(
stepItem
.
getPriceType
()
!=
null
)
{
dbStepItem
.
setPriceType
(
stepItem
.
getPriceType
());
}
if
(
stepItem
.
getRankNum
()
!=
null
)
{
dbStepItem
.
setRankNum
(
stepItem
.
getRankNum
());
}
break
;
}
if
(!
update
)
{
ProductPriceStepDO
dbItem
=
ObjectUtil
.
clone
(
stepItem
);
dbItem
.
setId
(
null
);
dbItem
.
setProductPriceId
(
productPriceId
);
initBasePrice
(
dbItem
,
transportType
);
insertList1
.
add
(
dbItem
);
}
// if(stepItem.getPriceType()==1){
//
// ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO() ;
// BeanUtils.copyProperties(stepItem,pricePackagingDO);
// pricePackagingDO.setId(null);
// pricePackagingDO.setProductPriceId(productPriceId) ;
// productPricePackagingDOS.add(pricePackagingDO);
//
// }else {
// if(CollectionUtil.isNotEmpty(stepItem.getPackagingList())){
// stepItem.getPackagingList().forEach(pg->{
// ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO() ;
// BeanUtils.copyProperties(pg,pricePackagingDO);
// pricePackagingDO.setId(null);
// pricePackagingDO.setProductPriceId(productPriceId) ;
// pricePackagingDO.setPriceType(stepItem.getPriceType()) ;
// productPricePackagingDOS.add(pricePackagingDO);
//
// });
// }
// }
if
(
CollectionUtil
.
isNotEmpty
(
stepItem
.
getPackagingList
()))
{
stepItem
.
getPackagingList
().
forEach
(
pg
->
{
ProductPricePackagingDO
pricePackagingDO
=
new
ProductPricePackagingDO
();
BeanUtils
.
copyProperties
(
pg
,
pricePackagingDO
);
pricePackagingDO
.
setId
(
null
);
pricePackagingDO
.
setProductPriceId
(
productPriceId
);
pricePackagingDO
.
setPriceType
(
stepItem
.
getPriceType
());
productPricePackagingDOS
.
add
(
pricePackagingDO
);
});
}
}
}
}
copyStepPrice
(
stepList
,
transportType
,
productPriceDO
,
dbStepMap
,
insertList1
,
productPricePackagingDOS
,
updateList
);
if
(
CollectionUtil
.
isNotEmpty
(
insertList1
))
{
productPriceStepMapper
.
insertBatchSomeColumn
(
insertList1
);
}
...
...
@@ -3937,11 +3694,8 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
List
<
ProductPriceStepSpecialDO
>
specialInsertList
=
new
ArrayList
<>();
List
<
ProductPriceStepSpecialDO
>
specialUpdateList
=
new
ArrayList
<>();
List
<
ProductPriceSpecialDO
>
priceSpecialInsert
=
new
ArrayList
<>();
List
<
ProductPriceSpecialDO
>
priceSpecialUpdate
=
new
ArrayList
<>();
for
(
ProductPriceStepDO
stepDO
:
insertList1
)
{
String
transportType
=
priceTransportTypeMap
.
get
(
stepDO
.
getProductPriceId
());
List
<
ProductPriceStepSpecialDO
>
productPriceStepSpecialDOS
=
stepDO
.
getSpecialList
();
//过滤掉价格为空的数据
if
(
CollectionUtil
.
isNotEmpty
(
productPriceStepSpecialDOS
))
{
...
...
@@ -3966,12 +3720,6 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
dbItem
.
setProductPriceId
(
stepDO
.
getProductPriceId
());
dbItem
.
setProductPriceStepId
(
stepDO
.
getId
());
initBasePrice
(
dbItem
,
transportType
);
//线路价格特需
ProductPriceSpecialDO
priceSpecialDO
=
new
ProductPriceSpecialDO
();
BeanUtils
.
copyProperties
(
dbItem
,
priceSpecialDO
);
priceSpecialDO
.
setId
(
null
);
priceSpecialInsert
.
add
(
priceSpecialDO
);
specialInsertList
.
add
(
dbItem
);
}
else
{
if
(
stepSpecialDO
.
getTransportPrice
()
!=
null
)
{
...
...
@@ -4001,44 +3749,20 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
if
(
stepSpecialDO
.
getAllVolumeUnit
()
!=
null
)
{
dbStepSpecialDO
.
setAllVolumeUnit
(
stepSpecialDO
.
getAllVolumeUnit
());
}
ProductPriceSpecialDO
priceSpecialDO
=
new
ProductPriceSpecialDO
();
BeanUtils
.
copyProperties
(
dbStepSpecialDO
,
priceSpecialDO
);
priceSpecialDO
.
setId
(
null
);
priceSpecialUpdate
.
add
(
priceSpecialDO
);
specialUpdateList
.
add
(
dbStepSpecialDO
);
}
}
}
}
// List<ProductPriceSpecialDO> priceSpecialInsert = new ArrayList<>();
// List<ProductPriceSpecialDO> priceSpecialUpdate = new ArrayList<>();
if
(
CollectionUtil
.
isNotEmpty
(
specialInsertList
))
{
productPriceStepSpecialMapper
.
insertBatchSomeColumn
(
specialInsertList
);
}
if
(
CollectionUtil
.
isNotEmpty
(
specialUpdateList
))
{
productPriceStepSpecialMapper
.
updateBatch
(
specialUpdateList
);
}
if
(
CollectionUtil
.
isNotEmpty
(
priceSpecialInsert
))
{
productPriceSpecialMapper
.
insertBatch
(
priceSpecialInsert
);
}
if
(
CollectionUtil
.
isNotEmpty
(
priceSpecialUpdate
))
{
productPriceSpecialMapper
.
physicsDelete
(
priceSpecialUpdate
.
get
(
0
).
getProductPriceId
().
toString
());
;
productPriceSpecialMapper
.
insertBatch
(
priceSpecialUpdate
);
}
if
(
CollectionUtil
.
isNotEmpty
(
productPricePackagingDOS
))
{
productPricePackagingMapper
.
physicsDelete
(
productPricePackagingDOS
.
get
(
0
).
getProductPriceId
().
toString
());
productPricePackagingMapper
.
insertBatch
(
productPricePackagingDOS
);
}
List
<
ProductPriceStepPackagingDO
>
stepPackagingList
=
insertList1
.
stream
()
.
map
(
ProductPriceStepDO:
:
getPackagingList
)
.
filter
(
CollectionUtil:
:
isNotEmpty
)
...
...
@@ -4146,6 +3870,174 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
productPriceStepPackagingMapper
.
physicsDeleteById
(
Joiner
.
on
(
","
).
join
(
dbPackingIdList
));
}
}
}
else
{
if
(
CollectionUtil
.
isNotEmpty
(
productPriceDO
.
getSpecialDOList
()))
{
for
(
ProductPriceSpecialDO
specialDO
:
productPriceDO
.
getSpecialDOList
())
{
ProductPriceSpecialDO
priceSpecialDO
=
new
ProductPriceSpecialDO
();
BeanUtils
.
copyProperties
(
specialDO
,
priceSpecialDO
);
priceSpecialDO
.
setId
(
null
);
priceSpecialDO
.
setProductPriceId
(
productPriceDO
.
getId
());
priceSpecialUpdate
.
add
(
priceSpecialDO
);
}
}
if
(
CollectionUtil
.
isNotEmpty
(
productPriceDO
.
getFreightPricePackagingList
()))
{
for
(
ProductPricePackagingDO
packagingDO
:
productPriceDO
.
getFreightPricePackagingList
())
{
ProductPricePackagingDO
pricePackagingDO
=
new
ProductPricePackagingDO
();
BeanUtils
.
copyProperties
(
packagingDO
,
pricePackagingDO
);
pricePackagingDO
.
setId
(
null
);
pricePackagingDO
.
setProductPriceId
(
productPriceDO
.
getId
());
productPricePackagingDOS
.
add
(
pricePackagingDO
);
}
}
if
(
CollectionUtil
.
isNotEmpty
(
productPriceDO
.
getClearancePricePackagingList
()))
{
for
(
ProductPricePackagingDO
packagingDO
:
productPriceDO
.
getClearancePricePackagingList
())
{
ProductPricePackagingDO
pricePackagingDO
=
new
ProductPricePackagingDO
();
BeanUtils
.
copyProperties
(
packagingDO
,
pricePackagingDO
);
pricePackagingDO
.
setId
(
null
);
pricePackagingDO
.
setProductPriceId
(
productPriceDO
.
getId
());
productPricePackagingDOS
.
add
(
pricePackagingDO
);
}
}
if
(
CollectionUtil
.
isNotEmpty
(
productPriceDO
.
getFullPricePackagingList
()))
{
for
(
ProductPricePackagingDO
packagingDO
:
productPriceDO
.
getFullPricePackagingList
())
{
ProductPricePackagingDO
pricePackagingDO
=
new
ProductPricePackagingDO
();
BeanUtils
.
copyProperties
(
packagingDO
,
pricePackagingDO
);
pricePackagingDO
.
setId
(
null
);
pricePackagingDO
.
setProductPriceId
(
productPriceDO
.
getId
());
productPricePackagingDOS
.
add
(
pricePackagingDO
);
}
}
if
(
CollectionUtil
.
isNotEmpty
(
priceSpecialUpdate
))
{
productPriceSpecialMapper
.
physicsDelete
(
productPriceDO
.
getId
().
toString
());
productPriceSpecialMapper
.
insertBatch
(
priceSpecialUpdate
);
}
if
(
CollectionUtil
.
isNotEmpty
(
productPricePackagingDOS
))
{
productPricePackagingMapper
.
physicsDelete
(
productPriceDO
.
getId
().
toString
());
productPricePackagingMapper
.
insertBatch
(
productPricePackagingDOS
);
}
}
}
private
void
copyStepPrice
(
List
<
ProductPriceStepDO
>
stepList
,
String
transportType
,
ProductPriceDO
productPriceDO
,
Map
<
Long
,
List
<
ProductPriceStepDO
>>
dbStepMap
,
List
<
ProductPriceStepDO
>
insertList1
,
List
<
ProductPricePackagingDO
>
productPricePackagingDOS
,
List
<
ProductPriceStepDO
>
updateList
)
{
List
<
ProductPriceStepDO
>
dbPriceStepList
=
dbStepMap
.
get
(
productPriceDO
.
getId
());
if
(
CollectionUtil
.
isEmpty
(
dbPriceStepList
))
{
for
(
ProductPriceStepDO
stepItem
:
stepList
)
{
if
(
stepItem
.
getTransportPrice
()
==
null
&&
stepItem
.
getClearancePrice
()
==
null
&&
stepItem
.
getAllPrice
()
==
null
)
continue
;
ProductPriceStepDO
dbItem
=
ObjectUtil
.
clone
(
stepItem
);
dbItem
.
setId
(
null
);
dbItem
.
setProductPriceId
(
productPriceDO
.
getId
());
initBasePrice
(
dbItem
,
transportType
);
insertList1
.
add
(
dbItem
);
if
(
CollectionUtil
.
isNotEmpty
(
stepItem
.
getPackagingList
()))
{
stepItem
.
getPackagingList
().
forEach
(
pg
->
{
ProductPricePackagingDO
pricePackagingDO
=
new
ProductPricePackagingDO
();
BeanUtils
.
copyProperties
(
pg
,
pricePackagingDO
);
pricePackagingDO
.
setId
(
null
);
productPricePackagingDOS
.
add
(
pricePackagingDO
);
});
}
}
}
else
{
//更新
for
(
ProductPriceStepDO
stepItem
:
stepList
)
{
boolean
update
=
false
;
for
(
ProductPriceStepDO
dbStepItem
:
dbPriceStepList
)
{
if
(!
stepItem
.
getPriceType
().
equals
(
dbStepItem
.
getPriceType
()))
continue
;
if
(
stepItem
.
getStartNum
().
intValue
()
!=
dbStepItem
.
getStartNum
().
intValue
()
||
stepItem
.
getEndNum
().
intValue
()
!=
dbStepItem
.
getEndNum
().
intValue
()
||
stepItem
.
getWeightUnit
().
longValue
()
!=
dbStepItem
.
getWeightUnit
().
longValue
())
{
continue
;
}
//更新
update
=
true
;
dbStepItem
.
setSpecialList
(
stepItem
.
getSpecialList
());
dbStepItem
.
setPackagingList
(
stepItem
.
getPackagingList
());
updateList
.
add
(
dbStepItem
);
if
(
stepItem
.
getTransportPrice
()
==
null
&&
stepItem
.
getClearancePrice
()
==
null
&&
stepItem
.
getAllPrice
()
==
null
)
continue
;
if
(
stepItem
.
getTransportPrice
()
!=
null
)
{
dbStepItem
.
setTransportPrice
(
stepItem
.
getTransportPrice
());
}
if
(
stepItem
.
getTransportPriceUnit
()
!=
null
)
{
dbStepItem
.
setTransportPriceUnit
(
stepItem
.
getTransportPriceUnit
());
}
if
(
stepItem
.
getTransportVolumeUnit
()
!=
null
)
{
dbStepItem
.
setTransportVolumeUnit
(
stepItem
.
getTransportVolumeUnit
());
}
if
(
stepItem
.
getClearancePrice
()
!=
null
)
{
dbStepItem
.
setClearancePrice
(
stepItem
.
getClearancePrice
());
}
if
(
stepItem
.
getClearancePriceUnit
()
!=
null
)
{
dbStepItem
.
setClearancePriceUnit
(
stepItem
.
getClearancePriceUnit
());
}
if
(
stepItem
.
getClearanceVolumeUnit
()
!=
null
)
{
dbStepItem
.
setClearanceVolumeUnit
(
stepItem
.
getClearanceVolumeUnit
());
}
if
(
stepItem
.
getAllPrice
()
!=
null
)
{
dbStepItem
.
setAllPrice
(
stepItem
.
getAllPrice
());
}
if
(
stepItem
.
getAllPriceUnit
()
!=
null
)
{
dbStepItem
.
setAllPriceUnit
(
stepItem
.
getAllPriceUnit
());
}
if
(
stepItem
.
getAllVolumeUnit
()
!=
null
)
{
dbStepItem
.
setAllVolumeUnit
(
stepItem
.
getAllVolumeUnit
());
}
if
(
stepItem
.
getPriceType
()
!=
null
)
{
dbStepItem
.
setPriceType
(
stepItem
.
getPriceType
());
}
if
(
stepItem
.
getRankNum
()
!=
null
)
{
dbStepItem
.
setRankNum
(
stepItem
.
getRankNum
());
}
break
;
}
if
(!
update
)
{
ProductPriceStepDO
dbItem
=
ObjectUtil
.
clone
(
stepItem
);
dbItem
.
setId
(
null
);
dbItem
.
setProductPriceId
(
productPriceDO
.
getId
());
initBasePrice
(
dbItem
,
transportType
);
insertList1
.
add
(
dbItem
);
}
// if(stepItem.getPriceType()==1){
//
// ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO() ;
// BeanUtils.copyProperties(stepItem,pricePackagingDO);
// pricePackagingDO.setId(null);
// pricePackagingDO.setProductPriceId(productPriceId) ;
// productPricePackagingDOS.add(pricePackagingDO);
//
// }else {
// if(CollectionUtil.isNotEmpty(stepItem.getPackagingList())){
// stepItem.getPackagingList().forEach(pg->{
// ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO() ;
// BeanUtils.copyProperties(pg,pricePackagingDO);
// pricePackagingDO.setId(null);
// pricePackagingDO.setProductPriceId(productPriceId) ;
// pricePackagingDO.setPriceType(stepItem.getPriceType()) ;
// productPricePackagingDOS.add(pricePackagingDO);
//
// });
// }
// }
if
(
CollectionUtil
.
isNotEmpty
(
stepItem
.
getPackagingList
()))
{
stepItem
.
getPackagingList
().
forEach
(
pg
->
{
ProductPricePackagingDO
pricePackagingDO
=
new
ProductPricePackagingDO
();
BeanUtils
.
copyProperties
(
pg
,
pricePackagingDO
);
pricePackagingDO
.
setId
(
null
);
pricePackagingDO
.
setProductPriceId
(
productPriceDO
.
getId
());
pricePackagingDO
.
setPriceType
(
stepItem
.
getPriceType
());
productPricePackagingDOS
.
add
(
pricePackagingDO
);
});
}
}
}
}
/**
...
...
yudao-module-product/yudao-module-product-core/src/main/java/cn/iocoder/yudao/module/product/vo/productPrice/ProductPriceReqBaseVO.java
View file @
416d4f6d
package
cn
.
iocoder
.
yudao
.
module
.
product
.
vo
.
productPrice
;
import
cn.iocoder.yudao.module.product.dal.dataobject.product.ProductPricePackagingDO
;
import
cn.iocoder.yudao.module.product.dal.dataobject.product.ProductPriceSpecialDO
;
import
cn.iocoder.yudao.module.product.dal.dataobject.product.ProductPriceStepDO
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
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