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
3751f1d2
Commit
3751f1d2
authored
Jun 16, 2021
by
徐康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并商品
parent
43bf2bd1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
+27
-1
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+1
-1
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
+26
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
3751f1d2
...
@@ -952,7 +952,7 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -952,7 +952,7 @@ public class ShoppingCartMCoffeeServiceImpl {
cartGoodsList
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
payCardPrice
);
cartGoodsList
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
payCardPrice
);
//如果促销返回的商品里有月享卡2.0的虚拟商品,重新保存一次购物车
//如果促销返回的商品里有月享卡2.0的虚拟商品,重新保存一次购物车
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
)
&&
cartGoodsList
.
stream
().
anyMatch
(
cartGoods
->
cartGoods
.
getSkuId
().
equals
(
"9999"
))){
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
)
&&
cartGoodsList
.
stream
().
anyMatch
(
cartGoods
->
cartGoods
.
getSkuId
().
equals
(
"9999"
)
||
cartGoods
.
getSkuId
().
equals
(
"9998"
)
)){
// 重新存储最新购物车
// 重新存储最新购物车
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
sessionId
,
""
,
shoppingCartBaseService
);
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
sessionId
,
""
,
shoppingCartBaseService
);
}
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
View file @
3751f1d2
...
@@ -18,6 +18,7 @@ import cn.freemud.utils.BarcodeUtil;
...
@@ -18,6 +18,7 @@ import cn.freemud.utils.BarcodeUtil;
import
cn.freemud.utils.ExceptionUtils
;
import
cn.freemud.utils.ExceptionUtils
;
import
cn.freemud.utils.LogUtil
;
import
cn.freemud.utils.LogUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.freemud.application.sdk.api.log.ApiLog
;
import
com.freemud.application.sdk.api.log.ApiLog
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -167,6 +169,7 @@ public class CouponDiscountCalculation {
...
@@ -167,6 +169,7 @@ public class CouponDiscountCalculation {
List
<
CartGoods
>
newCartGoodsList
=
new
ArrayList
<>();
List
<
CartGoods
>
newCartGoodsList
=
new
ArrayList
<>();
boolean
haveB3S1Fav
=
false
;
for
(
int
i
=
0
;
i
<
cartGoodsList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
cartGoodsList
.
size
();
i
++)
{
CartGoods
cartGoods
=
cartGoodsList
.
get
(
i
);
CartGoods
cartGoods
=
cartGoodsList
.
get
(
i
);
cartGoods
.
setIsB3S1CouponGoods
(
0
);
cartGoods
.
setIsB3S1CouponGoods
(
0
);
...
@@ -202,6 +205,7 @@ public class CouponDiscountCalculation {
...
@@ -202,6 +205,7 @@ public class CouponDiscountCalculation {
Optional
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
>
b3S1DiscountOptional
=
discountsNew
.
stream
()
Optional
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
>
b3S1DiscountOptional
=
discountsNew
.
stream
()
.
filter
(
t
->
ActivityTypeEnum
.
TYPE_35
.
getCode
().
equals
(
t
.
getType
())).
findFirst
();
.
filter
(
t
->
ActivityTypeEnum
.
TYPE_35
.
getCode
().
equals
(
t
.
getType
())).
findFirst
();
if
(
b3S1DiscountOptional
.
isPresent
())
{
if
(
b3S1DiscountOptional
.
isPresent
())
{
haveB3S1Fav
=
true
;
if
(
cartGoods
.
getQty
()
>
b3S1DiscountOptional
.
get
().
getActualGoodsNumber
())
{
if
(
cartGoods
.
getQty
()
>
b3S1DiscountOptional
.
get
().
getActualGoodsNumber
())
{
int
newNum
=
cartGoods
.
getQty
()
-
b3S1DiscountOptional
.
get
().
getActualGoodsNumber
();
int
newNum
=
cartGoods
.
getQty
()
-
b3S1DiscountOptional
.
get
().
getActualGoodsNumber
();
cartGoods
.
setQty
(
b3S1DiscountOptional
.
get
().
getActualGoodsNumber
());
cartGoods
.
setQty
(
b3S1DiscountOptional
.
get
().
getActualGoodsNumber
());
...
@@ -225,6 +229,28 @@ public class CouponDiscountCalculation {
...
@@ -225,6 +229,28 @@ public class CouponDiscountCalculation {
}
}
cartGoodsList
.
addAll
(
newCartGoodsList
);
cartGoodsList
.
addAll
(
newCartGoodsList
);
if
(
haveB3S1Fav
)
{
List
<
CartGoods
>
nowCartGoodsList
=
new
ArrayList
<>();
AtomicBoolean
changed
=
new
AtomicBoolean
();
changed
.
set
(
false
);
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
)){
ApiLog
.
debug
(
"合并买3赠1商品券 【merge-before】 : {} "
,
JSONObject
.
toJSONString
(
cartGoodsList
));
cartGoodsList
.
forEach
(
newCartGood
->
{
int
index
;
if
((
index
=
nowCartGoodsList
.
indexOf
(
newCartGood
))
>=
0
)
{
changed
.
set
(
true
);
nowCartGoodsList
.
get
(
index
).
setQty
(
nowCartGoodsList
.
get
(
index
).
getQty
()
+
newCartGood
.
getQty
());
}
else
{
nowCartGoodsList
.
add
(
newCartGood
);
}
});
}
if
(
changed
.
get
())
{
cartGoodsList
.
clear
();
cartGoodsList
.
addAll
(
nowCartGoodsList
);
}
}
// 当couponCode不为空时,需计算优惠价格
// 当couponCode不为空时,需计算优惠价格
long
couponDiscount
=
0
;
long
couponDiscount
=
0
;
if
(
CollectionUtils
.
isNotEmpty
(
couponDiscounts
))
{
if
(
CollectionUtils
.
isNotEmpty
(
couponDiscounts
))
{
...
...
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