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
8d9cac8b
Commit
8d9cac8b
authored
Nov 29, 2021
by
查志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购物车新算价赠品显示bug修复
parent
248b3b66
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
22 deletions
+14
-22
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/GiftSharingService.java
+14
-22
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/GiftSharingService.java
View file @
8d9cac8b
...
...
@@ -28,7 +28,6 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -93,15 +92,6 @@ public class GiftSharingService {
return
gifts
;
}
public
Map
<
String
,
Goods
>
getDiscountForGift
(
CalculationDiscountResult
discountResult
)
{
Map
<
String
,
Goods
>
gifts
=
discountResult
.
getGoods
()
.
stream
()
.
filter
(
d
->
CalculationGoodsType
.
TYPE_1
.
getType
().
equals
(
d
.
getCartGoodType
()))
.
collect
(
Collectors
.
toMap
(
Goods:
:
getGoodsId
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
return
gifts
;
}
/**
* 赠品detail
*
...
...
@@ -179,12 +169,13 @@ public class GiftSharingService {
,
UserLoginInfoDto
userLoginInfoDto
)
{
if
(
CollectionUtils
.
isNotEmpty
(
products
))
{
Map
<
String
,
ProductBean
>
productMap
=
products
.
stream
().
collect
(
Collectors
.
toMap
(
ProductBean:
:
getPid
,
k
->
k
,
(
k1
,
k2
)
->
k1
));
List
<
CartGoods
>
list
=
new
ArrayList
<>();
Map
<
String
,
Goods
>
discountForGift
=
this
.
getDiscountForGift
(
discountResult
);
for
(
ProductBean
product
:
products
)
{
Goods
goods
=
discountForGift
.
get
(
product
.
getPid
());
for
(
Goods
goods
:
discountResult
.
getGoods
())
{
// 过滤掉非赠品的商品
if
(!
CalculationGoodsType
.
TYPE_1
.
getType
().
equals
(
goods
.
getCartGoodType
()))
continue
;
ProductBean
product
=
productMap
.
get
(
goods
.
getGoodsId
());
GoodsDiscount
discount
=
this
.
discountInfo
(
goods
);
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
new
ShoppingCartGoodsDto
.
CartGoodsDetailDto
();
CartGoods
cartGood
=
new
CartGoods
();
cartGood
.
setGoodsId
(
goods
.
getGoodsId
());
cartGood
.
setGoodsType
(
1
);
...
...
@@ -210,16 +201,17 @@ public class GiftSharingService {
cartGood
.
setClassificationName
(
product
.
getCategoryName
());
// nodeId标识activeCode,用于计算均摊时每个商品在每个活动上均摊金额
cartGood
.
setNodeId
(
discount
.
getActivityCode
());
list
.
addAll
(
buyAndGiftsPromotionService
.
setGiftExtra
(
cartGood
,
product
,
null
));
// 将有属性的赠品拆分为多行,每行一个,以支持每个赠品可以选择独立的属性
List
<
CartGoods
>
nl
=
buyAndGiftsPromotionService
.
setGiftExtra
(
cartGood
,
product
,
null
);
nl
.
forEach
(
c
->
{
// 构建优惠
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
calculationCommonService
.
convertCartGoods2DetailGoodsList
(
goods
,
c
,
activityQueryDto
.
getPartnerId
());
cartGoodsDetailDtoList
.
add
(
cartGoodsDetailDto
);
});
list
.
addAll
(
nl
);
}
// 因为有涉及到用户选择的属性,存入redis
list
=
giftCacheManager
.
resetGiftCache
(
list
,
null
,
activityQueryDto
.
getPartnerId
(),
activityQueryDto
.
getStoreId
(),
userLoginInfoDto
.
getMemberId
());
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
>
detail
=
new
ArrayList
<>();
list
.
forEach
(
c
->
{
Goods
goods
=
discountForGift
.
get
(
c
.
getGoodsId
());
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
calculationCommonService
.
convertCartGoods2DetailGoodsList
(
goods
,
c
,
activityQueryDto
.
getPartnerId
());
cartGoodsDetailDtoList
.
add
(
cartGoodsDetailDto
);
});
giftCacheManager
.
resetGiftCache
(
list
,
null
,
activityQueryDto
.
getPartnerId
(),
activityQueryDto
.
getStoreId
(),
userLoginInfoDto
.
getMemberId
());
}
}
...
...
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