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
f4f1a113
Commit
f4f1a113
authored
Apr 26, 2021
by
徐康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
套餐价格重新计算
parent
7bacec2a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
48 deletions
+20
-48
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartConvertAdapter.java
+16
-24
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/SetMealCalculation.java
+4
-24
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartConvertAdapter.java
View file @
f4f1a113
...
@@ -27,6 +27,7 @@ import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
...
@@ -27,6 +27,7 @@ import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant
;
import
com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest
;
import
com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
...
@@ -38,6 +39,7 @@ import java.util.stream.Collectors;
...
@@ -38,6 +39,7 @@ import java.util.stream.Collectors;
import
java.util.stream.LongStream
;
import
java.util.stream.LongStream
;
@Component
@Component
@Slf4j
public
class
ShoppingCartConvertAdapter
{
public
class
ShoppingCartConvertAdapter
{
private
static
final
String
ATTRIBUTEID
=
"attributeId"
;
private
static
final
String
ATTRIBUTEID
=
"attributeId"
;
...
@@ -1050,28 +1052,16 @@ public class ShoppingCartConvertAdapter {
...
@@ -1050,28 +1052,16 @@ public class ShoppingCartConvertAdapter {
}
}
}
}
}
}
//可选商品组加料价格加到购物车行记录上
Long
materialAmount
=
cartGoods
.
getProductGroupList
().
stream
().
mapToLong
(
group
->
(
null
!=
group
.
getMaterialAmount
()
?
group
.
getMaterialAmount
()
:
0
)).
sum
();
cartGoods
.
setOriginalMaterialAmount
(
materialAmount
);
cartGoods
.
setMaterialAmount
(
materialAmount
);
cartGoods
.
setOriginalAmount
(
cartGoods
.
getOriginalPrice
()*
cartGoods
.
getQty
()
+
materialAmount
);
}
}
}
}
//更新当前商品行价格
//更新当前商品行价格
Long
newOrigOriginalPrice
=
0L
;
Long
newOrigOriginalPrice
=
0L
;
if
(
isSetMealProduct
)
{
if
(
isSetMealProduct
)
{
Long
comboxGoodsFinalPrice
=
cartGoods
.
getProductComboList
().
stream
().
mapToLong
(
t
->
t
.
getFinalPrice
()).
sum
();
cartGoods
.
setOriginalPrice
(
null
!=
cartGoods
.
getOriginalPrice
()?
cartGoods
.
getOriginalPrice
()
:
0
);
Long
comboxGoodsOriginalPrice
=
cartGoods
.
getProductComboList
().
stream
().
mapToLong
(
t
->
t
.
getOriginalAmount
()).
sum
();
cartGoods
.
setOriginalAmount
(
cartGoods
.
getOriginalPrice
()*
cartGoods
.
getQty
());
Long
groupGoodsOriginalPrice
=
cartGoods
.
getProductGroupList
().
stream
().
mapToLong
(
t
->
t
.
getOriginalAmount
()).
sum
();
Long
groupGoodsFinalPrice
=
cartGoods
.
getProductGroupList
().
stream
().
mapToLong
(
t
->
t
.
getFinalPrice
()).
sum
();
cartGoods
.
setOriginalPrice
(
null
!=
cartGoods
.
getOriginalPrice
()?
cartGoods
.
getOriginalPrice
()
:
comboxGoodsOriginalPrice
);
cartGoods
.
setOriginalAmount
((
cartGoods
.
getOriginalPrice
()+
groupGoodsOriginalPrice
)*
cartGoods
.
getQty
());
//咨询商品服务,套餐售价取originalPrice
//咨询商品服务,套餐售价取originalPrice
cartGoods
.
setFinalPrice
(
null
!=
cartGoods
.
getOriginalPrice
()
?
cartGoods
.
getOriginalPrice
()
:
cartGoods
.
setFinalPrice
(
null
!=
cartGoods
.
getOriginalPrice
()
?
cartGoods
.
getOriginalPrice
()
:
0
);
comboxGoodsFinalPrice
);
cartGoods
.
setAmount
(
cartGoods
.
getFinalPrice
()
*
cartGoods
.
getQty
());
cartGoods
.
setAmount
((
cartGoods
.
getFinalPrice
()+
groupGoodsFinalPrice
)
*
cartGoods
.
getQty
());
}
else
{
}
else
{
newOrigOriginalPrice
=
isSkuProduct
?
skuProduct
.
getFinalPrice
()
:
spuProduct
.
getFinalPrice
();
newOrigOriginalPrice
=
isSkuProduct
?
skuProduct
.
getFinalPrice
()
:
spuProduct
.
getFinalPrice
();
cartGoods
.
setOriginalPrice
(
newOrigOriginalPrice
);
cartGoods
.
setOriginalPrice
(
newOrigOriginalPrice
);
...
@@ -1083,21 +1073,23 @@ public class ShoppingCartConvertAdapter {
...
@@ -1083,21 +1073,23 @@ 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
()));
if
(
null
==
cartGoods
.
getMaterialAmount
())
{
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
());
log
.
error
(
"updateCartGoodsInfoForMCoffee_Error {} "
,
getExceptionInfo
(
ex
));
ErrorLog
.
infoConvertJson
(
this
.
getClass
(),
"updateCartGoodsInfoForMCoffee_Error"
,
ex
);
cartGoods
.
setCartGoodsUid
(
null
);
cartGoods
.
setCartGoodsUid
(
null
);
}
}
}
}
private
String
getExceptionInfo
(
Exception
e
)
{
StringBuilder
sb
=
new
StringBuilder
();
StackTraceElement
[]
trace
=
e
.
getStackTrace
();
for
(
StackTraceElement
traceElement
:
trace
)
{
sb
.
append
(
"\tat "
+
traceElement
);
}
return
sb
.
toString
();
}
private
void
updateComboxGoodsInfoFor
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
ComboxGoods
comboxGoods
,
ProductTypeBeanDTO
productBeanDTO
,
boolean
isComboxGoods
)
{
private
void
updateComboxGoodsInfoFor
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
ComboxGoods
comboxGoods
,
ProductTypeBeanDTO
productBeanDTO
,
boolean
isComboxGoods
)
{
if
(
CollectionUtils
.
isEmpty
(
productBeanDTO
.
getSkuList
())){
if
(
CollectionUtils
.
isEmpty
(
productBeanDTO
.
getSkuList
())){
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/SetMealCalculation.java
View file @
f4f1a113
...
@@ -48,8 +48,6 @@ public class SetMealCalculation {
...
@@ -48,8 +48,6 @@ public class SetMealCalculation {
if
(
CollectionUtils
.
isEmpty
(
setMealProducts
))
{
if
(
CollectionUtils
.
isEmpty
(
setMealProducts
))
{
return
;
return
;
}
}
//套餐可选商品现价
long
productGroupTotalAmount
=
0L
;
// 存储当前享受限时特价折扣的商品数量
// 存储当前享受限时特价折扣的商品数量
Map
<
String
,
Integer
>
numberMap
=
new
HashMap
<>();
Map
<
String
,
Integer
>
numberMap
=
new
HashMap
<>();
// 当前商品行现价
// 当前商品行现价
...
@@ -63,18 +61,6 @@ public class SetMealCalculation {
...
@@ -63,18 +61,6 @@ public class SetMealCalculation {
}
}
// cartGoods.setOriginalAmount(cartGoods.getOriginalPrice() * cartGoods.getQty());
// cartGoods.setOriginalAmount(cartGoods.getOriginalPrice() * cartGoods.getQty());
cartGoods
.
setPackPrice
(
cartGoods
.
getPackPrice
()
*
cartGoods
.
getQty
());
cartGoods
.
setPackPrice
(
cartGoods
.
getPackPrice
()
*
cartGoods
.
getQty
());
// 可选商品现总价
productGroupTotalAmount
=
0
l
;
long
productGroupAmount
=
null
==
cartGoods
.
getProductGroupList
()
?
0
:
cartGoods
.
getProductGroupList
().
stream
().
mapToLong
(
t
->
(
null
!=
t
.
getFinalPrice
()
?
t
.
getFinalPrice
():
0
)
*
(
null
!=
t
.
getQty
()
?
t
.
getQty
():
0
)).
sum
();
productGroupTotalAmount
+=
productGroupAmount
*
cartGoods
.
getQty
();
// 固定商品现总价
long
productComboAmount
=
cartGoods
.
getProductComboList
().
stream
().
mapToLong
(
t
->
(
null
!=
t
.
getFinalPrice
()
?
t
.
getFinalPrice
():
0
)
*
(
null
!=
t
.
getQty
()
?
t
.
getQty
():
0
)).
sum
();
long
productComboTotalAmount
=
productComboAmount
*
cartGoods
.
getQty
();
long
materialPrice
=
0
l
;
long
materialPrice
=
0
l
;
//套餐固定商品加料
//套餐固定商品加料
...
@@ -112,17 +98,11 @@ public class SetMealCalculation {
...
@@ -112,17 +98,11 @@ public class SetMealCalculation {
||
(
null
!=
calculationDiscountResult
.
getMonthlyEnjoyCardDiscount
()
||
(
null
!=
calculationDiscountResult
.
getMonthlyEnjoyCardDiscount
()
&&
StringUtils
.
isNotBlank
(
calculationDiscountResult
.
getMonthlyEnjoyCardDiscount
().
getCouponCode
())
&&
StringUtils
.
isNotBlank
(
calculationDiscountResult
.
getMonthlyEnjoyCardDiscount
().
getCouponCode
())
&&
cartGoods
.
getCouponCode
().
equals
(
calculationDiscountResult
.
getMonthlyEnjoyCardDiscount
().
getCouponCode
())))
{
&&
cartGoods
.
getCouponCode
().
equals
(
calculationDiscountResult
.
getMonthlyEnjoyCardDiscount
().
getCouponCode
())))
{
Long
amount
=
null
!=
cartGoods
.
getFinalPrice
()
?
cartGoods
.
getFinalPrice
()
*
cartGoods
.
getQty
()
+
productGroupTotalAmount
+
materialPrice
:
cartGoods
.
setAmount
(
cartGoods
.
getAmount
()
+
materialPrice
);
productGroupTotalAmount
+
productComboTotalAmount
+
materialPrice
;
cartGoods
.
setOriginalAmount
(
cartGoods
.
getOriginalAmount
()
+
materialPrice
);
cartGoods
.
setAmount
(
amount
);
}
}
Long
comboOriginalPriceAmount
=
null
!=
cartGoods
.
getOriginalAmount
()
?
cartGoods
.
getOriginalAmount
()
:
cartGoods
.
setOriginalPrice
(
cartGoods
.
getOriginalPrice
());
productComboTotalAmount
;
cartGoods
.
setFinalPrice
(
cartGoods
.
getFinalPrice
());
cartGoods
.
setOriginalAmount
(
productGroupTotalAmount
+
comboOriginalPriceAmount
+
materialPrice
);
cartGoods
.
setOriginalPrice
(
null
!=
cartGoods
.
getOriginalPrice
()
?
cartGoods
.
getOriginalPrice
()
:
productComboTotalAmount
);
cartGoods
.
setFinalPrice
(
null
!=
cartGoods
.
getFinalPrice
()
?
cartGoods
.
getFinalPrice
()
:
productComboTotalAmount
);
// 套餐(固定商品)现价
// 套餐(固定商品)现价
// String toastMsg = getTotalAmount(cartGoods, productGroupAmount, numberMap, goodsMap);
// String toastMsg = getTotalAmount(cartGoods, productGroupAmount, numberMap, goodsMap);
...
...
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