Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
order-group
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
order-group-application
order-group
Commits
7aefb02a
Commit
7aefb02a
authored
Dec 22, 2020
by
yu.sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sunyu::update::productGroup material price calculate
parent
28acd1fa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
20 deletions
+47
-20
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartConvertAdapter.java
+32
-20
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/SetMealCalculation.java
+15
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartConvertAdapter.java
View file @
7aefb02a
...
@@ -751,7 +751,6 @@ public class ShoppingCartConvertAdapter {
...
@@ -751,7 +751,6 @@ public class ShoppingCartConvertAdapter {
productComboType
=
parentProductBean
.
getProductComboList
().
stream
().
filter
(
p
->
ObjectUtils
.
equals
(
comboxGoods
.
getGoodsId
(),
p
.
getProductId
())).
findFirst
().
orElse
(
new
ProductTypeBeanDTO
.
ProductComboType
());
productComboType
=
parentProductBean
.
getProductComboList
().
stream
().
filter
(
p
->
ObjectUtils
.
equals
(
comboxGoods
.
getGoodsId
(),
p
.
getProductId
())).
findFirst
().
orElse
(
new
ProductTypeBeanDTO
.
ProductComboType
());
}
else
{
}
else
{
Map
<
String
,
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
>
map
=
new
HashMap
<>();
Map
<
String
,
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
>
map
=
new
HashMap
<>();
// subProductTypeMap.get(comboxGoods.getSkuId()).getAdditionalGroupList().stream().map(t->t.getGroupDetail()).forEach(group->group.forEach(detailType-> map.put(detailType.getProductId(),detailType)));
parentProductBean
.
getProductGroupList
().
stream
().
map
(
t
->
t
.
getGroupDetail
()).
forEach
(
group
->
group
.
forEach
(
detailType
->
map
.
put
(
detailType
.
getProductId
(),
detailType
)));
parentProductBean
.
getProductGroupList
().
stream
().
map
(
t
->
t
.
getGroupDetail
()).
forEach
(
group
->
group
.
forEach
(
detailType
->
map
.
put
(
detailType
.
getProductId
(),
detailType
)));
groupDetailType
=
map
.
get
(
comboxGoods
.
getGoodsId
());
groupDetailType
=
map
.
get
(
comboxGoods
.
getGoodsId
());
}
}
...
@@ -793,26 +792,26 @@ public class ShoppingCartConvertAdapter {
...
@@ -793,26 +792,26 @@ public class ShoppingCartConvertAdapter {
comboxGoods
.
getProductMaterialList
().
stream
().
forEach
(
materialGood
->
materialList
.
add
(
materialMap
.
get
(
materialGood
.
getSpuId
())));
comboxGoods
.
getProductMaterialList
().
stream
().
forEach
(
materialGood
->
materialList
.
add
(
materialMap
.
get
(
materialGood
.
getSpuId
())));
List
<
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
>
productMaterialList
=
new
ArrayList
<>();
List
<
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
>
productMaterialList
=
new
ArrayList
<>();
Long
materialAmount
=
0L
;
Long
originalMaterAmount
=
0L
;
if
(
CollectionUtils
.
isNotEmpty
(
materialList
)){
if
(
CollectionUtils
.
isNotEmpty
(
materialList
)){
for
(
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
detailType
:
materialList
)
{
for
(
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
detailType
:
materialList
)
{
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
materialGoods
=
new
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
();
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
materialGoods
=
new
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
();
materialGoods
.
setCustomerCode
(
StringUtils
.
isNotEmpty
(
detailType
.
getCustomerCode
())
?
materialGoods
.
setCustomerCode
(
StringUtils
.
isNotEmpty
(
detailType
.
getCustomerCode
())
?
detailType
.
getCustomerCode
()
:
""
);
detailType
.
getCustomerCode
()
:
""
);
materialGoods
.
setAmount
(
null
!=
detailType
.
getMarkUpPrice
()
?
detailType
.
getMarkUpPrice
().
longValue
()
:
0
);
materialGoods
.
setAmount
(
null
!=
detailType
.
getMarkUpPrice
()
?
materialGoods
.
setFinalPrice
(
null
!=
detailType
.
getProductFinalPrice
()
?
detailType
.
getProductFinalPrice
().
longValue
()
:
0
);
detailType
.
getMarkUpPrice
().
longValue
()
:
0
);
materialGoods
.
setSpuName
(
StringUtils
.
isNotEmpty
(
detailType
.
getProductName
())
?
detailType
.
getProductName
()
:
""
);
materialGoods
.
setFinalPrice
(
null
!=
detailType
.
getProductFinalPrice
()
?
materialGoods
.
setSpuId
(
StringUtils
.
isNotEmpty
(
detailType
.
getProductId
())
?
detailType
.
getProductId
()
:
""
);
detailType
.
getProductFinalPrice
().
longValue
()
:
0
);
materialGoods
.
setOriginalPrice
(
null
!=
detailType
.
getProductFinalPrice
()
?
detailType
.
getProductFinalPrice
().
longValue
()
:
0
);
materialGoods
.
setSpuName
(
StringUtils
.
isNotEmpty
(
detailType
.
getProductName
())
?
materialGoods
.
setOriginalAmount
(
null
!=
detailType
.
getProductFinalPrice
()
?
detailType
.
getProductFinalPrice
().
longValue
()
*
comboxGoods
.
getQty
()
:
0
);
detailType
.
getProductName
()
:
""
);
materialGoods
.
setSpuId
(
StringUtils
.
isNotEmpty
(
detailType
.
getProductId
())
?
detailType
.
getProductId
()
:
""
);
materialGoods
.
setOriginalPrice
(
null
!=
detailType
.
getProductFinalPrice
()
?
detailType
.
getProductFinalPrice
().
longValue
()
:
0
);
materialGoods
.
setOriginalAmount
(
null
!=
detailType
.
getProductFinalPrice
()
?
detailType
.
getProductFinalPrice
().
longValue
()
:
0
);
productMaterialList
.
add
(
materialGoods
);
productMaterialList
.
add
(
materialGoods
);
materialAmount
+=
detailType
.
getProductFinalPrice
().
longValue
()
*
comboxGoods
.
getQty
();
originalMaterAmount
+=
detailType
.
getProductFinalPrice
().
longValue
()
*
comboxGoods
.
getQty
();
}
}
}
}
comboxGoods
.
setMaterialAmount
(
materialAmount
);
comboxGoods
.
setProductMaterialList
(
productMaterialList
);
comboxGoods
.
setProductMaterialList
(
productMaterialList
);
}
}
}
}
...
@@ -832,7 +831,9 @@ public class ShoppingCartConvertAdapter {
...
@@ -832,7 +831,9 @@ public class ShoppingCartConvertAdapter {
private
void
checkMaterialProductForMCoffee
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
,
ProductTypeBeanDTO
spuProduct
)
{
private
void
checkMaterialProductForMCoffee
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
,
ProductTypeBeanDTO
spuProduct
)
{
if
(
CollectionUtils
.
isEmpty
(
cartGoods
.
getProductMaterialList
()))
return
;
if
(
CollectionUtils
.
isEmpty
(
cartGoods
.
getProductMaterialList
()))
{
return
;
}
//加料信息为空
//加料信息为空
if
(
CollectionUtils
.
isEmpty
(
spuProduct
.
getAdditionalGroupList
()))
{
if
(
CollectionUtils
.
isEmpty
(
spuProduct
.
getAdditionalGroupList
()))
{
checkSkuMaterialProductForMccafe
(
cartGoods
,
spuProduct
);
checkSkuMaterialProductForMccafe
(
cartGoods
,
spuProduct
);
...
@@ -861,7 +862,9 @@ public class ShoppingCartConvertAdapter {
...
@@ -861,7 +862,9 @@ public class ShoppingCartConvertAdapter {
String
materialSubName
=
cartGoods
.
getSubName
();
String
materialSubName
=
cartGoods
.
getSubName
();
for
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
materialGoods
:
cartGoods
.
getProductMaterialList
())
{
for
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
materialGoods
:
cartGoods
.
getProductMaterialList
())
{
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
detail
=
materialHash
.
get
(
materialGoods
.
getSpuId
());
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
detail
=
materialHash
.
get
(
materialGoods
.
getSpuId
());
if
(
detail
==
null
)
continue
;
if
(
detail
==
null
)
{
continue
;
}
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
material
=
new
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
();
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
material
=
new
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
();
material
.
setSpuName
(
detail
.
getProductName
());
material
.
setSpuName
(
detail
.
getProductName
());
material
.
setSpuId
(
detail
.
getProductId
());
material
.
setSpuId
(
detail
.
getProductId
());
...
@@ -953,6 +956,11 @@ public class ShoppingCartConvertAdapter {
...
@@ -953,6 +956,11 @@ public class ShoppingCartConvertAdapter {
}
}
}
}
}
}
//可选商品组加料价格加到购物车行记录上
Long
materialAmount
=
cartGoods
.
getProductGroupList
().
stream
().
mapToLong
(
group
->
(
null
!=
group
.
getMaterialAmount
()
?
group
.
getMaterialAmount
()
:
0
)).
sum
();
cartGoods
.
setOriginalMaterialAmount
(
materialAmount
);
cartGoods
.
setMaterialAmount
(
materialAmount
);
}
}
}
}
//更新当前商品行价格
//更新当前商品行价格
...
@@ -980,12 +988,16 @@ public class ShoppingCartConvertAdapter {
...
@@ -980,12 +988,16 @@ public class ShoppingCartConvertAdapter {
cartGoods
.
setWeight
(
isSkuProduct
?
skuProduct
.
getWeight
()
:
spuProduct
.
getWeight
());
cartGoods
.
setWeight
(
isSkuProduct
?
skuProduct
.
getWeight
()
:
spuProduct
.
getWeight
());
cartGoods
.
setUnit
(
isSkuProduct
?
skuProduct
.
getUnit
()
:
spuProduct
.
getUnit
());
cartGoods
.
setUnit
(
isSkuProduct
?
skuProduct
.
getUnit
()
:
spuProduct
.
getUnit
());
cartGoods
.
setWeightType
(
CommonsConstant
.
WEIGHT_PRODUCT
.
equals
(
spuProduct
.
getWeightType
()));
cartGoods
.
setWeightType
(
CommonsConstant
.
WEIGHT_PRODUCT
.
equals
(
spuProduct
.
getWeightType
()));
cartGoods
.
setMaterialAmount
(
0L
);
if
(
null
==
cartGoods
.
getMaterialAmount
())
{
cartGoods
.
setOriginalMaterialAmount
(
0L
);
cartGoods
.
setMaterialAmount
(
0L
);
}
if
(
null
==
cartGoods
.
getOriginalMaterialAmount
())
{
cartGoods
.
setOriginalMaterialAmount
(
0L
);
}
// todo 设置加料
// todo 设置加料
this
.
checkMaterialProductForMCoffee
(
cartGoods
,
spuProduct
);
this
.
checkMaterialProductForMCoffee
(
cartGoods
,
spuProduct
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
System
.
out
.
println
(
ex
.
getLocalizedMessage
());
ErrorLog
.
infoConvertJson
(
this
.
getClass
(),
"updateCartGoodsInfoForMCoffee_Error"
,
ex
);
ErrorLog
.
infoConvertJson
(
this
.
getClass
(),
"updateCartGoodsInfoForMCoffee_Error"
,
ex
);
cartGoods
.
setCartGoodsUid
(
null
);
cartGoods
.
setCartGoodsUid
(
null
);
}
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/SetMealCalculation.java
View file @
7aefb02a
...
@@ -92,6 +92,21 @@ public class SetMealCalculation {
...
@@ -92,6 +92,21 @@ public class SetMealCalculation {
}
}
}
}
//套餐可选商品加料
if
(
CollectionUtils
.
isNotEmpty
(
cartGoods
.
getProductGroupList
())){
for
(
CartGoods
.
ComboxGoods
comboxGoods
:
cartGoods
.
getProductGroupList
()){
Long
productGroupmaterialPrice
=
0L
;
if
(
CollectionUtils
.
isNotEmpty
(
comboxGoods
.
getProductMaterialList
())){
for
(
CartGoods
.
MaterialGoods
materialGoods
:
comboxGoods
.
getProductMaterialList
()){
productGroupmaterialPrice
+=
null
!=
materialGoods
.
getFinalPrice
()
?
materialGoods
.
getFinalPrice
()
*
cartGoods
.
getQty
()
:
0
;
}
}
comboxGoods
.
setAmount
((
null
==
comboxGoods
.
getAmount
()
?
0
:
comboxGoods
.
getAmount
())+
productGroupmaterialPrice
);
materialPrice
=
materialPrice
+
productGroupmaterialPrice
;
}
}
Long
amount
=
null
!=
cartGoods
.
getFinalPrice
()
?
cartGoods
.
getFinalPrice
()*
cartGoods
.
getQty
()
+
productGroupTotalAmount
+
materialPrice
:
Long
amount
=
null
!=
cartGoods
.
getFinalPrice
()
?
cartGoods
.
getFinalPrice
()*
cartGoods
.
getQty
()
+
productGroupTotalAmount
+
materialPrice
:
productGroupTotalAmount
+
productComboTotalAmount
+
materialPrice
;
productGroupTotalAmount
+
productComboTotalAmount
+
materialPrice
;
...
...
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