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
595f532c
Commit
595f532c
authored
Jul 17, 2020
by
xiaoer.li@freemud.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持多买一赠一活动
parent
fbf29115
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
2 deletions
+43
-2
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/BuySendPromotionService.java
+43
-2
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/BuySendPromotionService.java
View file @
595f532c
...
@@ -24,7 +24,6 @@ import org.springframework.stereotype.Service;
...
@@ -24,7 +24,6 @@ import org.springframework.stereotype.Service;
import
java.util.*
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
/**
* All rights Reserved, Designed By www.freemud.cn
* All rights Reserved, Designed By www.freemud.cn
...
@@ -61,16 +60,32 @@ public class BuySendPromotionService implements IPromotionService {
...
@@ -61,16 +60,32 @@ public class BuySendPromotionService implements IPromotionService {
return
;
return
;
}
}
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
sendActivity
=
getSendActivity
(
sendActivityList
,
ActivityTypeEnum
.
TYPE_61
);
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
sendActivity
=
getSendActivity
(
sendActivityList
,
ActivityTypeEnum
.
TYPE_61
);
//Todo 获取多个赠品list
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
sendActivityLists
=
getSendActivityList
(
ActivityTypeEnum
.
TYPE_61
,
sendActivityList
);
if
(
sendActivity
==
null
)
{
if
(
sendActivity
==
null
)
{
return
;
return
;
}
}
//Todo 获取多个赠品list
if
(
sendActivityLists
.
size
()
==
0
)
{
return
;
}
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
.
SendGoods
>
sendGoodsList
=
sendActivity
.
getSendGoods
();
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
.
SendGoods
>
sendGoodsList
=
sendActivity
.
getSendGoods
();
if
(
CollectionUtils
.
isEmpty
(
sendGoodsList
))
{
if
(
CollectionUtils
.
isEmpty
(
sendGoodsList
))
{
return
;
return
;
}
}
Integer
maxNum
=
sendActivity
.
getMaxNum
();
Integer
maxNum
=
sendActivity
.
getMaxNum
();
List
<
String
>
activitySpuIds
=
sendGoodsList
.
stream
().
map
(
each
->
each
.
getCategory
()).
collect
(
Collectors
.
toList
());
List
<
String
>
activitySpuIds
=
sendGoodsList
.
stream
().
map
(
each
->
each
.
getCategory
()).
collect
(
Collectors
.
toList
());
Map
<
String
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
.
SendGoods
>
sendGoodsMap
=
getSendGoodsMap
(
sendGoodsList
);
//Map<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods> sendGoodsMap = getSendGoodsMap(sendGoodsList);
//Todo
Map
<
String
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
.
SendGoods
>
sendGoodsMap
=
new
HashMap
<>();
Map
<
String
,
Integer
>
maxNums
=
new
HashMap
<>();
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
activityList
:
sendActivityLists
)
{
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
.
SendGoods
sendGood
:
activityList
.
getSendGoods
())
{
sendGoodsMap
.
put
(
sendGood
.
getCategory
(),
sendGood
);
maxNums
.
put
(
sendGood
.
getCategory
(),
activityList
.
getMaxNum
());
}
}
List
<
CartGoods
>
newCartGoodsList
=
new
ArrayList
<>();
List
<
CartGoods
>
newCartGoodsList
=
new
ArrayList
<>();
for
(
CartGoods
cartGood
:
cartGoodsList
)
{
for
(
CartGoods
cartGood
:
cartGoodsList
)
{
/*if (cartGoodsList.stream().filter(c -> c.getSkuId().equals(cartGood.getSkuId())).count() >= 2){
/*if (cartGoodsList.stream().filter(c -> c.getSkuId().equals(cartGood.getSkuId())).count() >= 2){
...
@@ -92,6 +107,7 @@ public class BuySendPromotionService implements IPromotionService {
...
@@ -92,6 +107,7 @@ public class BuySendPromotionService implements IPromotionService {
Long
givePackAmount
=
0L
;
Long
givePackAmount
=
0L
;
// 优惠商品原总价格
// 优惠商品原总价格
Long
giveTotalAmount
=
0L
;
Long
giveTotalAmount
=
0L
;
/*
for (CartGoods cartGoods : newCartGoodsList) {
for (CartGoods cartGoods : newCartGoodsList) {
cartGoods.setAmount(0L);
cartGoods.setAmount(0L);
if (maxNum <= 0) {
if (maxNum <= 0) {
...
@@ -108,6 +124,18 @@ public class BuySendPromotionService implements IPromotionService {
...
@@ -108,6 +124,18 @@ public class BuySendPromotionService implements IPromotionService {
cartGoods.setOriginalAmount(cartGoods.getOriginalPrice() * cartGoods.getQty());
cartGoods.setOriginalAmount(cartGoods.getOriginalPrice() * cartGoods.getQty());
cartGoodsList.add(cartGoods);
cartGoodsList.add(cartGoods);
}
}
*/
for
(
CartGoods
cartGoods
:
newCartGoodsList
)
{
Integer
max
=
maxNums
.
get
(
cartGoods
.
getGoodsId
());
if
(
max
<=
0
)
continue
;
if
(
max
<
cartGoods
.
getQty
())
{
cartGoods
.
setQty
(
max
);
}
givePackAmount
=
givePackAmount
+
cartGoods
.
getPackPrice
()
*
cartGoods
.
getQty
();
giveTotalAmount
=
giveTotalAmount
+
cartGoods
.
getOriginalPrice
()
*
cartGoods
.
getQty
();
cartGoods
.
setOriginalAmount
(
cartGoods
.
getOriginalPrice
()
*
cartGoods
.
getQty
());
cartGoodsList
.
add
(
cartGoods
);
}
Integer
activityCartQty
=
cartGoodsList
.
stream
().
filter
(
each
->
Objects
.
equals
(
each
.
getActivityType
(),
ActivityTypeEnum
.
TYPE_61
.
getCode
())).
mapToInt
(
each
->
each
.
getQty
()).
sum
();
Integer
activityCartQty
=
cartGoodsList
.
stream
().
filter
(
each
->
Objects
.
equals
(
each
.
getActivityType
(),
ActivityTypeEnum
.
TYPE_61
.
getCode
())).
mapToInt
(
each
->
each
.
getQty
()).
sum
();
ActivityTip
activityTip
=
new
ActivityTip
();
ActivityTip
activityTip
=
new
ActivityTip
();
activityTip
.
setActivityType
(
ActivityTypeEnum
.
TYPE_61
.
getCode
());
activityTip
.
setActivityType
(
ActivityTypeEnum
.
TYPE_61
.
getCode
());
...
@@ -178,6 +206,19 @@ public class BuySendPromotionService implements IPromotionService {
...
@@ -178,6 +206,19 @@ public class BuySendPromotionService implements IPromotionService {
}
}
/**
/**
* 获取指定促销类型的SendActivity
*
* @param sendActivityList
* @param type
* @return
*/
private
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
getSendActivityList
(
ActivityTypeEnum
type
,
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
sendActivityList
)
{
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
collect
=
sendActivityList
.
stream
().
filter
(
c
->
c
.
getActivityType
().
equals
(
type
.
getCode
())).
collect
(
Collectors
.
toList
());
return
collect
;
}
/**
* 筛选出spu商品中价格最低的商品,Key=spuId
* 筛选出spu商品中价格最低的商品,Key=spuId
*
*
* @param sendGoodsList
* @param sendGoodsList
...
...
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