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
e44d0ca0
Commit
e44d0ca0
authored
Nov 06, 2020
by
huiyang.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 买三赠一开发2
parent
5e0e5b74
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
68 deletions
+88
-68
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/enums/SaveCouponType.java
+1
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+26
-65
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CalculationServiceImpl.java
+2
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
+59
-3
No files found.
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/enums/SaveCouponType.java
View file @
e44d0ca0
...
...
@@ -6,6 +6,7 @@ public enum SaveCouponType {
FREIGHT_COUPON
(
2
,
"运费券"
),
MON_COUPON
(
3
,
"随单购月卡"
),
THREE_TO_ONE_COUPON
(
4
,
"买三赠一券"
),
THREE_TO_ONE_ACTIVITY_CODE
(
5
,
"买三赠一券虚拟活动号"
),
;
private
Integer
code
;
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
e44d0ca0
...
...
@@ -191,11 +191,9 @@ public class ShoppingCartMCoffeeServiceImpl {
setToastMsgIfNotExist
(
shoppingCartGoodsResponseVo
,
ShoppingCartConstant
.
HAS_GOODS_COUPON_WHEN_ADD_SPECIAL_GOODS
);
}
if
(
StringUtils
.
isNotEmpty
(
threeToOneCouponCode
))
{
if
(
StringUtils
.
isNotEmpty
(
threeToOneActivityCode
)){
threeToOneCouponCode
=
threeToOneCouponCode
+
","
+
threeToOneActivityCode
;
}
if
(
StringUtils
.
isNotEmpty
(
threeToOneCouponCode
)
&&
StringUtils
.
isNotEmpty
(
threeToOneActivityCode
))
{
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
threeToOneCouponCode
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_COUPON
.
getCode
());
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
threeToOneActivityCode
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_ACTIVITY_CODE
.
getCode
());
}
// 购物车数据更新(保存商品原价)
...
...
@@ -321,7 +319,7 @@ public class ShoppingCartMCoffeeServiceImpl {
String
freightCouponCode
=
assortmentSdkService
.
getShoppingCartCoupon
(
partnerId
,
storeId
,
userId
,
shoppingCartBaseService
,
SaveCouponType
.
FREIGHT_COUPON
.
getCode
());
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
freightCouponCode
,
null
,
null
,
null
);
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
freightCouponCode
,
null
,
null
,
null
,
null
);
// 促销活动的优惠金额计算
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
storeId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
couponCode
,
cartGoodsList
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
null
);
...
...
@@ -395,16 +393,16 @@ public class ShoppingCartMCoffeeServiceImpl {
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
freightCouponCode
,
shoppingCartBaseService
,
SaveCouponType
.
FREIGHT_COUPON
.
getCode
());
}
if
(
StringUtils
.
isEmpty
(
buyThreeGiveOneCouponCode
))
{
if
(
StringUtils
.
isEmpty
(
buyThreeGiveOneCouponCode
)
&&
StringUtils
.
isEmpty
(
buyThreeGiveOneActivityCode
)
)
{
buyThreeGiveOneCouponCode
=
assortmentSdkService
.
getShoppingCartCoupon
(
partnerId
,
storeId
,
userId
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_COUPON
.
getCode
());
buyThreeGiveOneActivityCode
=
assortmentSdkService
.
getShoppingCartCoupon
(
partnerId
,
storeId
,
userId
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_ACTIVITY_CODE
.
getCode
());
}
else
{
if
(
"remove"
.
equals
(
buyThreeGiveOneCouponCode
))
{
buyThreeGiveOneCouponCode
=
""
;
}
if
(
StringUtils
.
isNotEmpty
(
buyThreeGiveOneCouponCode
)
&&
StringUtils
.
isNotEmpty
(
buyThreeGiveOneActivityCode
)){
buyThreeGiveOneCouponCode
=
buyThreeGiveOneCouponCode
+
","
+
buyThreeGiveOneActivityCode
;
buyThreeGiveOneActivityCode
=
""
;
}
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
buyThreeGiveOneCouponCode
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_COUPON
.
getCode
());
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
buyThreeGiveOneActivityCode
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_ACTIVITY_CODE
.
getCode
());
}
if
(
CollectionUtils
.
isEmpty
(
couponTypeList
)){
...
...
@@ -436,55 +434,12 @@ public class ShoppingCartMCoffeeServiceImpl {
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
code
,
shoppingCartBaseService
,
SaveCouponType
.
MON_COUPON
.
getCode
());
}
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
shoppingCartInfoRequestVo
.
getFreightCouponCode
(),
code
,
buyThreeGiveOneCouponCode
,
shoppingCartInfoRequestVo
.
getCouponTypeList
());
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
shoppingCartInfoRequestVo
.
getFreightCouponCode
(),
code
,
buyThreeGiveOneCouponCode
,
buyThreeGiveOneActivityCode
,
shoppingCartInfoRequestVo
.
getCouponTypeList
());
// 促销活动的优惠金额计算
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
=
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
storeId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
null
,
cartGoodsList
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
payCardPrice
);
if
(
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getDiscounts
()))
{
// 对促销返回的数据进行拆分
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
discounts
=
calculationDiscountResult
.
getDiscounts
().
stream
().
filter
(
discount
->
ActivityTypeEnum
.
TYPE_35
.
getCode
().
equals
(
discount
.
getType
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
discounts
)
){
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsList
=
calculationDiscountResult
.
getGoods
();
if
(
CollectionUtils
.
isNotEmpty
(
goodsList
))
{
Map
<
String
,
CartGoods
>
goodsCartMap
=
cartGoodsList
.
parallelStream
().
collect
(
Collectors
.
toMap
(
CartGoods:
:
getCartGoodsUid
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
List
<
CartGoods
>
cartGoodsListNew
=
new
ArrayList
<>();
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods:
goodsList
)
{
CartGoods
cartGoods
=
goodsCartMap
.
get
(
goods
.
getCartGoodsUid
());
if
(
cartGoods
==
null
)
continue
;
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
>
collect
=
goods
.
getDiscounts
().
stream
().
filter
(
s
->
ActivityTypeEnum
.
TYPE_35
.
getCode
().
equals
(
s
.
getType
())).
collect
(
Collectors
.
toList
());
int
sum
=
collect
.
stream
().
mapToInt
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
::
getActualGoodsNumber
).
sum
();
if
(
CollectionUtils
.
isNotEmpty
(
collect
)
){
if
(
sum
>
0
&&
sum
<
goods
.
getGoodsQuantity
())
{
Integer
qty
=
cartGoods
.
getQty
();
//需要拆分
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
goodsDiscount:
collect
)
{
CartGoods
cartGoods1
=
new
CartGoods
();
BeanUtils
.
copyProperties
(
cartGoods
,
cartGoods1
);
cartGoods1
.
setQty
(
goodsDiscount
.
getActualGoodsNumber
());
cartGoodsListNew
.
add
(
cartGoods1
);
qty
=
qty
-
goodsDiscount
.
getActualGoodsNumber
();
}
cartGoods
.
setQty
(
qty
);
cartGoodsListNew
.
add
(
cartGoods
);
}
}
else
{
cartGoodsListNew
.
add
(
cartGoods
);
}
}
// 重新存储最新购物车
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsListNew
,
sessionId
,
""
,
shoppingCartBaseService
);
}
}
}
//设置更新响应信息
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
cartGoodsList
,
shoppingCartGoodsResponseVo
.
getToastMsg
(),
ShoppingCartConstant
.
QUERY_INFO
,
shoppingCartInfoRequestVo
);
...
...
@@ -492,11 +447,12 @@ public class ShoppingCartMCoffeeServiceImpl {
shoppingCartGoodsResponseVo
.
setCouponCode
(
""
);
shoppingCartGoodsResponseVo
.
setFreightCouponCode
(
""
);
shoppingCartGoodsResponseVo
.
setBuyThreeGiveOneActivityCode
(
buyThreeGiveOneActivityCode
);
shoppingCartGoodsResponseVo
.
setBuyThreeGiveOneCouponCode
(
buyThreeGiveOneCouponCode
);
shoppingCartGoodsResponseVo
.
setBuyThreeGiveOneCouponCode
(
""
);
shoppingCartGoodsResponseVo
.
setCouponTypeList
(
couponTypeList
);
if
(
StringUtils
.
isNotEmpty
(
couponCode
)
||
StringUtils
.
isNotEmpty
(
freightCouponCode
))
{
if
(
StringUtils
.
isNotEmpty
(
couponCode
)
||
StringUtils
.
isNotEmpty
(
freightCouponCode
)
||
StringUtils
.
isNotEmpty
(
buyThreeGiveOneCouponCode
)
)
{
String
finalCouponCode
=
couponCode
;
String
finalFreightCouponCode
=
freightCouponCode
;
String
finalBuyThreeGiveOneCouponCode
=
buyThreeGiveOneCouponCode
;
if
(
null
!=
calculationDiscountResult
&&
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getDiscounts
()))
{
calculationDiscountResult
.
getDiscounts
().
stream
().
forEach
(
o
->
{
if
(
o
.
getActivityCode
().
equals
(
finalCouponCode
))
{
...
...
@@ -505,6 +461,9 @@ public class ShoppingCartMCoffeeServiceImpl {
if
(
o
.
getActivityCode
().
equals
(
finalFreightCouponCode
))
{
shoppingCartGoodsResponseVo
.
setFreightCouponCode
(
finalFreightCouponCode
);
}
if
(
o
.
getActivityCode
().
equals
(
finalBuyThreeGiveOneCouponCode
))
{
shoppingCartGoodsResponseVo
.
setBuyThreeGiveOneCouponCode
(
finalBuyThreeGiveOneCouponCode
);
}
});
}
}
...
...
@@ -514,6 +473,10 @@ public class ShoppingCartMCoffeeServiceImpl {
if
(
ObjectUtils
.
notEqual
(
shoppingCartGoodsResponseVo
.
getFreightCouponCode
(),
freightCouponCode
))
{
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
shoppingCartGoodsResponseVo
.
getFreightCouponCode
(),
shoppingCartBaseService
,
SaveCouponType
.
FREIGHT_COUPON
.
getCode
());
}
if
(
ObjectUtils
.
notEqual
(
shoppingCartGoodsResponseVo
.
getBuyThreeGiveOneCouponCode
(),
buyThreeGiveOneCouponCode
))
{
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
""
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_COUPON
.
getCode
());
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
""
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_ACTIVITY_CODE
.
getCode
());
}
return
ResponseUtil
.
success
(
shoppingCartGoodsResponseVo
);
}
...
...
@@ -579,7 +542,7 @@ public class ShoppingCartMCoffeeServiceImpl {
payCardPrice
=
Long
.
valueOf
(
payCardFee
);
}
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
null
,
null
,
cartGoodsList
,
null
,
buyMonthlyCard
,
null
,
null
);
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
null
,
null
,
cartGoodsList
,
null
,
buyMonthlyCard
,
null
,
null
,
null
);
// 促销活动的优惠金额计算
calculationService
.
updateShoppingCartGoodsDiscount
(
requestVo
.
getPartnerId
(),
requestVo
.
getStoreId
(),
requestVo
.
getUserId
(),
requestVo
.
getAppId
(),
requestVo
.
getOrderType
(),
assortmentCustomerInfoVo
.
isMemberPaid
(),
requestVo
.
getMenuType
(),
requestVo
.
getReceiveId
(),
null
,
cartGoodsList
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
payCardPrice
);
...
...
@@ -743,7 +706,7 @@ public class ShoppingCartMCoffeeServiceImpl {
}
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
shoppingCartInfoRequestVo
.
getFreightCouponCode
(),
code
,
null
,
null
);
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
shoppingCartInfoRequestVo
.
getFreightCouponCode
(),
code
,
null
,
null
,
null
);
//加价购商品
List
<
ShoppingCartInfoRequestVo
.
SendGoods
>
sendGoodsList
=
shoppingCartInfoRequestVo
.
getSendGoods
();
...
...
@@ -814,7 +777,7 @@ public class ShoppingCartMCoffeeServiceImpl {
//清空商品券商品
clearCartCouponGoods
(
partnerId
,
toStoreId
,
userId
,
sessionId
,
cartGoodsList
);
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
null
,
null
,
null
,
null
);
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
null
,
null
,
null
,
null
,
null
);
// 促销活动的优惠金额计算
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
toStoreId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
null
,
...
...
@@ -831,7 +794,7 @@ public class ShoppingCartMCoffeeServiceImpl {
//清空商品券商品
clearCartCouponGoods
(
partnerId
,
toStoreId
,
userId
,
sessionId
,
cartGoodsList
);
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
null
,
null
,
null
,
null
);
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
null
,
null
,
null
,
null
,
null
);
// 促销活动的优惠金额计算
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
toStoreId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
null
,
...
...
@@ -1519,7 +1482,7 @@ public class ShoppingCartMCoffeeServiceImpl {
}
private
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
getCoupon
(
String
couponCode
,
String
activityCode
,
List
<
CartGoods
>
cartGoodsList
,
String
freightCouponCode
,
String
buyMonthlyCard
,
String
threeToOneCouponCode
,
List
<
CouponTypeVo
>
couponTypeList
)
{
String
threeToOneCouponCode
,
String
buyThreeGiveOneActivityCode
,
List
<
CouponTypeVo
>
couponTypeList
)
{
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotEmpty
(
couponCode
))
{
...
...
@@ -1541,10 +1504,8 @@ public class ShoppingCartMCoffeeServiceImpl {
}
if
(
StringUtils
.
isNotEmpty
(
threeToOneCouponCode
))
{
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
coupon
=
new
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
();
List
<
String
>
split
=
Arrays
.
asList
(
threeToOneCouponCode
.
split
(
","
));
coupon
.
setCode
(
split
.
get
(
0
));
if
(
split
.
size
()
>
1
)
coupon
.
setActivityCode
(
split
.
get
(
1
));
coupon
.
setCode
(
threeToOneCouponCode
);
coupon
.
setActivityCode
(
buyThreeGiveOneActivityCode
);
coupons
.
add
(
coupon
);
}
if
(
CollectionUtils
.
isNotEmpty
(
couponTypeList
))
{
...
...
@@ -1791,7 +1752,7 @@ public class ShoppingCartMCoffeeServiceImpl {
}
}
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
null
,
null
,
null
,
null
);
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
null
,
null
,
null
,
null
,
null
);
// 促销活动的优惠金额计算
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
storeId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
null
,
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CalculationServiceImpl.java
View file @
e44d0ca0
...
...
@@ -114,6 +114,8 @@ public class CalculationServiceImpl {
//加料
materialCalculation
.
updateShoppingCartGoodsApportion
(
calculationDiscount
,
cartGoodsList
);
//买三赠一券
couponDiscountCalculation
.
updateBuyThreeToOneShoppingCartGoodsDiscount
(
calculationDiscount
,
cartGoodsList
,
shoppingCartGoodsResponseVo
);
return
calculationDiscount
;
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
View file @
e44d0ca0
...
...
@@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
...
...
@@ -78,8 +79,7 @@ public class CouponDiscountCalculation {
if
(
calculationDiscountResult
==
null
||
CollectionUtils
.
isEmpty
(
calculationDiscountResult
.
getDiscounts
())
||
!
calculationDiscountResult
.
getDiscounts
().
stream
().
anyMatch
(
discount
->
(
ActivityTypeEnum
.
TYPE_3
.
getCode
().
equals
(
discount
.
getType
())
||(
ActivityTypeEnum
.
TYPE_31
.
getCode
().
equals
(
discount
.
getType
()))
||
(
ActivityTypeEnum
.
TYPE_32
.
getCode
().
equals
(
discount
.
getType
()))
||
(
ActivityTypeEnum
.
TYPE_35
.
getCode
().
equals
(
discount
.
getType
()))
)))
{
||(
ActivityTypeEnum
.
TYPE_31
.
getCode
().
equals
(
discount
.
getType
()))
||
(
ActivityTypeEnum
.
TYPE_32
.
getCode
().
equals
(
discount
.
getType
()))
)))
{
return
;
}
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsList
=
calculationDiscountResult
.
getGoods
();
...
...
@@ -93,7 +93,7 @@ public class CouponDiscountCalculation {
return
;
}
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
couponDiscounts
=
discounts
.
stream
().
filter
(
discount
->
(
ActivityTypeEnum
.
TYPE_3
.
getCode
().
equals
(
discount
.
getType
())
||
(
ActivityTypeEnum
.
TYPE_31
.
getCode
().
equals
(
discount
.
getType
()))
||
(
ActivityTypeEnum
.
TYPE_32
.
getCode
().
equals
(
discount
.
getType
())
)
||
(
ActivityTypeEnum
.
TYPE_35
.
getCode
().
equals
(
discount
.
getType
())
))).
collect
(
Collectors
.
toList
());
||
(
ActivityTypeEnum
.
TYPE_31
.
getCode
().
equals
(
discount
.
getType
()))
||
(
ActivityTypeEnum
.
TYPE_32
.
getCode
().
equals
(
discount
.
getType
())
))).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
couponDiscounts
))
{
return
;
}
...
...
@@ -607,4 +607,60 @@ public class CouponDiscountCalculation {
return
couponPromotionVO
;
}
/**
* 买三赠一券
* @param calculationDiscount
* @param cartGoodsList
* @param shoppingCartGoodsResponseVo
*/
public
void
updateBuyThreeToOneShoppingCartGoodsDiscount
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscount
,
List
<
CartGoods
>
cartGoodsList
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
)
{
List
<
CartGoods
>
cartGoodsListNew
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
calculationDiscount
.
getDiscounts
()))
{
// 对促销返回的数据进行拆分
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
discounts
=
calculationDiscount
.
getDiscounts
().
stream
().
filter
(
discount
->
ActivityTypeEnum
.
TYPE_35
.
getCode
().
equals
(
discount
.
getType
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
discounts
)
){
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsList
=
calculationDiscount
.
getGoods
();
if
(
CollectionUtils
.
isNotEmpty
(
goodsList
))
{
Map
<
String
,
CartGoods
>
goodsCartMap
=
cartGoodsList
.
parallelStream
().
collect
(
Collectors
.
toMap
(
CartGoods:
:
getCartGoodsUid
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods:
goodsList
)
{
CartGoods
cartGoods
=
goodsCartMap
.
get
(
goods
.
getCartGoodsUid
());
if
(
cartGoods
==
null
)
continue
;
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
>
collect
=
goods
.
getDiscounts
().
stream
().
filter
(
s
->
ActivityTypeEnum
.
TYPE_35
.
getCode
().
equals
(
s
.
getType
())).
collect
(
Collectors
.
toList
());
int
sum
=
collect
.
stream
().
mapToInt
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
::
getActualGoodsNumber
).
sum
();
if
(
CollectionUtils
.
isNotEmpty
(
collect
)
){
if
(
sum
>
0
&&
sum
<
goods
.
getGoodsQuantity
())
{
Integer
qty
=
cartGoods
.
getQty
();
//需要拆分
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
goodsDiscount:
collect
)
{
CartGoods
cartGoods1
=
new
CartGoods
();
BeanUtils
.
copyProperties
(
cartGoods
,
cartGoods1
);
cartGoods1
.
setQty
(
goodsDiscount
.
getActualGoodsNumber
());
Long
count
=
cartGoods
.
getOriginalPrice
()
*
goodsDiscount
.
getActualGoodsNumber
();
cartGoods1
.
setAmount
(
count
-
goodsDiscount
.
getDiscount
());
cartGoods1
.
setCouponName
(
goodsDiscount
.
getActivityName
());
cartGoods1
.
setOriginalAmount
(
count
);
cartGoodsListNew
.
add
(
cartGoods1
);
qty
=
qty
-
goodsDiscount
.
getActualGoodsNumber
();
}
cartGoods
.
setQty
(
qty
);
cartGoods
.
setCouponName
(
""
);
}
}
}
}
}
}
cartGoodsList
.
addAll
(
cartGoodsListNew
);
//筛选数量不为0商品
cartGoodsList
=
cartGoodsList
.
stream
().
filter
(
cartGoods
->
cartGoods
.
getQty
()
!=
0
).
collect
(
Collectors
.
toList
());
}
}
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