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
85ba6314
Commit
85ba6314
authored
Jun 13, 2022
by
周晓航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化NPE
parent
e60f6782
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
35 deletions
+37
-35
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+1
-1
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/CalculationCommonService.java
+36
-34
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
85ba6314
...
...
@@ -1062,7 +1062,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
=
goodsList
.
getResult
();
// fisherman -> 储值卡互斥需求 发现bug 导致返回购物车数据不对 当前时间节点无法修复 重新请求一次
if
(
Objects
.
nonNull
(
shoppingCartInfoRequestVo
.
getEnableSharing
())
&&
shoppingCartInfoRequestVo
.
getEnableSharing
().
compareTo
(
0
)
==
0
)
{
if
(
shoppingCartGoodsResponseVo
.
getChanged
()
!=
null
&&
shoppingCartGoodsResponseVo
.
getChanged
()
.
booleanValue
()
==
true
)
{
if
(
shoppingCartGoodsResponseVo
.
getChanged
()
!=
null
&&
shoppingCartGoodsResponseVo
.
getChanged
()
==
true
)
{
goodsList
=
getGoodsList
(
shoppingCartInfoRequestVo
);
if
(
goodsList
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
goodsList
.
getCode
()))
{
return
goodsList
;
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/CalculationCommonService.java
View file @
85ba6314
...
...
@@ -70,7 +70,7 @@ public class CalculationCommonService {
,
List
<
CartGoods
>
cartGoodsList
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
String
couponCode
,
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
)
{
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
)
{
/**
* 使用促销算价赋值行记录
...
...
@@ -82,7 +82,9 @@ public class CalculationCommonService {
long
totalOriginalAmount
=
0L
,
totalAmount
=
0L
,
totalPackageAmount
=
0L
;
long
originalAmount
=
0L
,
amount
=
0L
,
packageAmount
=
0L
;
for
(
CartGoods
cartGoods
:
cartGoodsList
)
{
originalAmount
=
0L
;
amount
=
0L
;
packageAmount
=
0L
;
originalAmount
=
0L
;
amount
=
0L
;
packageAmount
=
0L
;
this
.
rowRealAmount
(
goods
,
cartGoods
,
couponCode
);
...
...
@@ -112,7 +114,7 @@ public class CalculationCommonService {
// fisehrman 总优惠金额 需要+配送券的优惠金额
if
(
discountResult
==
null
)
{
shoppingCartGoodsResponseVo
.
setTotalDiscountAmount
(
0L
);
}
else
{
}
else
{
// 需要算上配送券的优惠金额
Integer
discountAmount
=
0
;
if
(
CollectionUtils
.
isNotEmpty
(
discountResult
.
getDiscounts
()))
{
...
...
@@ -133,23 +135,23 @@ public class CalculationCommonService {
return
;
}
Goods
find
=
goods
.
stream
().
filter
((
k
)
->
Objects
.
equals
(
k
.
getCartGoodsUid
(),
cartGoods
.
getCartGoodsUid
()))
.
stream
().
filter
((
k
)
->
Objects
.
equals
(
k
.
getCartGoodsUid
(),
cartGoods
.
getCartGoodsUid
()))
.
findFirst
().
orElse
(
null
);
if
(
find
==
null
)
return
;
cartGoods
.
setAmount
(
find
.
getRealAmount
());
cartGoods
.
setCurrentCouponDiscount
(
0
);
cartGoods
.
setFinalPrice
(
find
.
getNowPrice
());
if
(
CollectionUtils
.
isNotEmpty
(
find
.
getDiscounts
())){
if
(
CollectionUtils
.
isNotEmpty
(
find
.
getDiscounts
()))
{
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount goodsDiscount = find.getDiscounts().stream()
// .filter(p -> p.getActivityCode().equals(couponCode)).findFirst().orElse(null);
// if (goodsDiscount != null){
// }
for
(
GoodsDiscount
goodsDiscount
:
find
.
getDiscounts
()){
if
(
goodsDiscount
.
getActivityCode
().
equals
(
couponCode
))
{
for
(
GoodsDiscount
goodsDiscount
:
find
.
getDiscounts
())
{
if
(
goodsDiscount
.
getActivityCode
().
equals
(
couponCode
))
{
cartGoods
.
setCurrentCouponDiscount
(
goodsDiscount
.
getDiscount
()
==
null
?
0
:
goodsDiscount
.
getDiscount
().
intValue
());
}
if
(
StringUtils
.
isNotEmpty
(
goodsDiscount
.
getCurrentMembershipLevel
()))
{
if
(
StringUtils
.
isNotEmpty
(
goodsDiscount
.
getCurrentMembershipLevel
()))
{
cartGoods
.
setCurrentMemberLevel
(
goodsDiscount
.
getCurrentMembershipLevel
());
}
}
...
...
@@ -180,14 +182,13 @@ public class CalculationCommonService {
SmallMaterial
mt
=
gChoices
.
get
(
choice
.
getGoodsId
());
if
(
mt
==
null
)
{
amount
+=
choice
.
getAmount
()
*
choice
.
getQty
();
}
else
{
}
else
{
amount
+=
mt
.
getRealAmount
();
choice
.
setCurrentCouponDiscount
(
0
);
if
(
CollectionUtils
.
isNotEmpty
(
mt
.
getDiscounts
())){
if
(
CollectionUtils
.
isNotEmpty
(
mt
.
getDiscounts
()))
{
GoodsDiscount
goodsDiscount
=
mt
.
getDiscounts
().
stream
()
.
filter
(
p
->
p
.
getActivityCode
().
equals
(
couponCode
)).
findFirst
().
orElse
(
null
);
if
(
goodsDiscount
!=
null
){
if
(
goodsDiscount
!=
null
)
{
choice
.
setCurrentCouponDiscount
(
goodsDiscount
.
getDiscount
()
==
null
?
0
:
goodsDiscount
.
getDiscount
().
intValue
());
}
}
...
...
@@ -210,10 +211,10 @@ public class CalculationCommonService {
SmallMaterial
sm
=
sChoices
.
get
(
mg
.
getSpuId
());
if
(
sm
!=
null
)
{
mg
.
setCurrentCouponDiscount
(
0
);
if
(
CollectionUtils
.
isNotEmpty
(
sm
.
getDiscounts
())){
if
(
CollectionUtils
.
isNotEmpty
(
sm
.
getDiscounts
()))
{
GoodsDiscount
goodsDiscount
=
sm
.
getDiscounts
().
stream
()
.
filter
(
p
->
p
.
getActivityCode
().
equals
(
couponCode
)).
findFirst
().
orElse
(
null
);
if
(
goodsDiscount
!=
null
){
if
(
goodsDiscount
!=
null
)
{
mg
.
setCurrentCouponDiscount
(
goodsDiscount
.
getDiscount
()
==
null
?
0
:
goodsDiscount
.
getDiscount
().
intValue
());
}
}
...
...
@@ -242,7 +243,7 @@ public class CalculationCommonService {
public
ShoppingCartGoodsDto
.
CartGoodsDetailDto
convertCartGoods2DetailGoodsList
(
Goods
calculationGoods
,
CartGoods
cartGoods
,
String
partnerId
)
{
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
this
.
convertCartGoods2DetailGoods
(
calculationGoods
,
cartGoods
,
partnerId
);
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
this
.
convertCartGoods2DetailGoods
(
calculationGoods
,
cartGoods
,
partnerId
);
return
cartGoodsDetailDto
;
}
...
...
@@ -286,13 +287,16 @@ public class CalculationCommonService {
toastMsg
=
shoppingCartInfoRequestVo
!=
null
&&
ObjectUtils
.
equals
(
SubmitPageEnum
.
YES
.
getCode
(),
shoppingCartInfoRequestVo
.
getFlag
())
?
SHOPPING_CART_EMPTY_GOODS_LIST
:
SHOPPING_CART_INVALIAD_GOODS
;
setToastMsgIfNotExist
(
shoppingCartGoodsResponseVo
,
toastMsg
);
//结算页,只有商品全部非法(即products为空)时,才提示changed为true toastMsg 不为空
Boolean
changed
=
shoppingCartGoodsResponseVo
.
getChanged
();
if
(
shoppingCartInfoRequestVo
.
getEnableSharing
().
compareTo
(
0
)
==
0
&&
Objects
.
nonNull
(
changed
)
&&
shoppingCartGoodsResponseVo
.
getChanged
().
compareTo
(
true
)
==
0
)
{
// 请求里面的 enableSharing = 0 并且 changed = true
boolean
changed
=
shoppingCartInfoRequestVo
!=
null
&&
shoppingCartInfoRequestVo
.
getEnableSharing
()
!=
null
&&
shoppingCartInfoRequestVo
.
getEnableSharing
().
compareTo
(
0
)
==
0
&&
Objects
.
nonNull
(
shoppingCartGoodsResponseVo
.
getChanged
())
&&
shoppingCartGoodsResponseVo
.
getChanged
().
compareTo
(
true
)
==
0
;
if
(
changed
)
{
shoppingCartGoodsResponseVo
.
setChanged
(
true
);
shoppingCartGoodsResponseVo
.
setToastMsg
(
"购物车数据异常,需要重新请求购物车list接口"
);
}
else
{
}
else
{
shoppingCartGoodsResponseVo
.
setChanged
(
CollectionUtils
.
isEmpty
(
cartGoodsList
));
shoppingCartGoodsResponseVo
.
setToastMsg
(
CollectionUtils
.
isEmpty
(
cartGoodsList
)
?
toastMsg
:
""
);
}
...
...
@@ -426,7 +430,7 @@ public class CalculationCommonService {
cartGoodsDetailDto
.
setSkuName
(
StringUtils
.
isEmpty
(
cartGoods
.
getSkuName
())
?
cartGoods
.
getSpuName
()
:
cartGoods
.
getSkuName
());
cartGoodsDetailDto
.
setSkuForeignName
(
StringUtils
.
isEmpty
(
cartGoods
.
getSkuForeignName
())
?
cartGoods
.
getSpuForeignName
()
:
cartGoods
.
getSkuForeignName
());
cartGoodsDetailDto
.
setIsSendGoods
(
false
);
if
(
calculationGoods
!=
null
)
{
if
(
calculationGoods
!=
null
)
{
// 修复购物车NPE 是否为赠品
cartGoodsDetailDto
.
setIsSendGoods
(
ObjectUtils
.
equals
(
1
,
calculationGoods
.
getCartGoodType
()));
}
...
...
@@ -449,13 +453,12 @@ public class CalculationCommonService {
if
(
cartGoods
.
isWeightType
())
{
cartGoodsDetailDto
.
setProductType
(
ProductType
.
WEIGHT_PRODUCT
.
getCode
());
}
if
(
calculationGoods
!=
null
)
{
if
(
calculationGoods
!=
null
)
{
cartGoodsDetailDto
.
setOriginalPrice
(
calculationGoods
.
getOriginalPrice
());
}
else
{
}
else
{
cartGoodsDetailDto
.
setOriginalPrice
(
cartGoods
.
getOriginalPrice
());
}
if
(
calculationGoods
!=
null
)
{
if
(
calculationGoods
!=
null
)
{
if
(
cartGoodsDetailDto
.
getIsSendGoods
())
{
// 由于买赠活动中,赠品有属性的时候会裂为多行,所有优惠金额不能直接用促销返回的, 需要根据实际购物车行中的数量来计算
int
discountAmt
=
calculationGoods
.
getDiscountAmount
().
intValue
();
...
...
@@ -464,13 +467,12 @@ public class CalculationCommonService {
}
else
{
cartGoodsDetailDto
.
setTotalDiscountAmount
(
calculationGoods
.
getDiscountAmount
().
intValue
());
}
}
else
{
}
else
{
cartGoodsDetailDto
.
setTotalDiscountAmount
(
cartGoods
.
getOriginalAmount
().
intValue
()
-
cartGoods
.
getAmount
().
intValue
());
}
//设置行优惠
List
<
ActivityDiscountsDto
>
activityDiscountsDtoList
=
new
ArrayList
<>();
if
(
calculationGoods
!=
null
&&
CollectionUtils
.
isNotEmpty
(
calculationGoods
.
getDiscounts
()))
{
if
(
calculationGoods
!=
null
&&
CollectionUtils
.
isNotEmpty
(
calculationGoods
.
getDiscounts
()))
{
for
(
GoodsDiscount
discount
:
calculationGoods
.
getDiscounts
())
{
ActivityDiscountsDto
activityDiscountsDto
=
new
ActivityDiscountsDto
();
activityDiscountsDto
.
setActivityCode
(
discount
.
getActivityCode
());
...
...
@@ -511,7 +513,7 @@ public class CalculationCommonService {
}
goods
.
setOriginalProductType
(
mg
.
getOriginalProductType
());
materialList
.
add
(
goods
);
cartGoodsDetailDto
.
setOriginalPrice
(
cartGoodsDetailDto
.
getOriginalPrice
()
+
goods
.
getOriginalPrice
()
*
(
goods
.
getQty
()
/
cartGoodsDetailDto
.
getQty
()));
cartGoodsDetailDto
.
setOriginalPrice
(
cartGoodsDetailDto
.
getOriginalPrice
()
+
goods
.
getOriginalPrice
()
*
(
goods
.
getQty
()
/
cartGoodsDetailDto
.
getQty
()));
cartGoodsDetailDto
.
setTotalDiscountAmount
(
cartGoodsDetailDto
.
getTotalDiscountAmount
()
+
goods
.
getTotalDiscountAmount
());
}
cartGoodsDetailDto
.
setProductType
(
ProductType
.
MATERIAL
.
getCode
());
...
...
@@ -529,9 +531,9 @@ public class CalculationCommonService {
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
>
comboLists
=
this
.
com2DetailGoods
(
gxDiscount
,
cartGoods
.
getProductComboList
(),
cartGoods
,
true
);
combs
.
addAll
(
comboLists
);
cartGoodsDetailDto
.
setProductType
(
ProductType
.
SETMEAL
.
getCode
());
if
(
calculationGoods
!=
null
)
{
if
(
calculationGoods
!=
null
)
{
originalPriceSum
=
calculationGoods
.
getOriginalPrice
();
}
else
{
}
else
{
for
(
ShoppingCartGoodsDto
.
CartGoodsDetailDto
comboList
:
comboLists
)
{
originalPriceSum
+=
(
comboList
.
getQty
()
/
cartGoods
.
getQty
())
*
comboList
.
getOriginalPrice
();
}
...
...
@@ -654,8 +656,8 @@ public class CalculationCommonService {
HashMap
<
String
,
BlockRow
>
map
=
new
HashMap
<>();
if
(
goods
==
null
)
return
map
;
//固定搭配
if
(
isFixed
)
{
if
(
CollectionUtils
.
isNotEmpty
(
goods
.
getGroupCombox
()))
{
if
(
isFixed
)
{
if
(
CollectionUtils
.
isNotEmpty
(
goods
.
getGroupCombox
()))
{
for
(
GroupCombox
gx
:
goods
.
getGroupCombox
())
{
BlockRow
blockRow
=
new
BlockRow
();
blockRow
.
setDiscountAmount
(
gx
.
getDiscountAmount
());
...
...
@@ -746,7 +748,7 @@ public class CalculationCommonService {
uid
=
goods
.
getCartGoodsUid
();
}
}
if
(
StringUtils
.
isNotBlank
(
toastMsg
))
{
if
(
StringUtils
.
isNotBlank
(
toastMsg
))
{
shoppingCartGoodsResponseVo
.
setToastMsg
(
toastMsg
);
}
shoppingCartGoodsResponseVo
.
setUid
(
uid
);
...
...
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