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
b3a5f6f0
Commit
b3a5f6f0
authored
May 18, 2021
by
张跃
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购物车算价
parent
5e14d013
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/TimeSalePromotionService.java
+7
-7
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/TimeSalePromotionService.java
View file @
b3a5f6f0
...
@@ -46,7 +46,7 @@ public class TimeSalePromotionService implements IPromotionService {
...
@@ -46,7 +46,7 @@ public class TimeSalePromotionService implements IPromotionService {
Map
<
String
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsMap
=
goodsList
.
parallelStream
()
Map
<
String
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsMap
=
goodsList
.
parallelStream
()
.
collect
(
Collectors
.
toMap
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
::
getCartGoodsUid
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
.
collect
(
Collectors
.
toMap
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
::
getCartGoodsUid
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
// 存储当前享受限时特价折扣的商品数量,key:goodsId; value:可享受数量
// 存储当前享受限时特价折扣的商品数量,key:goodsId; value:可享受数量
Map
<
String
,
Integer
>
numberMap
=
new
HashMap
<>();
//
Map<String, Integer> numberMap = new HashMap<>();
List
<
Integer
>
discounts
=
Arrays
.
asList
(
ActivityTypeEnum
.
TYPE_2
.
getCode
(),
ActivityTypeEnum
.
TYPE_21
.
getCode
(),
ActivityTypeEnum
.
TYPE_22
.
getCode
());
List
<
Integer
>
discounts
=
Arrays
.
asList
(
ActivityTypeEnum
.
TYPE_2
.
getCode
(),
ActivityTypeEnum
.
TYPE_21
.
getCode
(),
ActivityTypeEnum
.
TYPE_22
.
getCode
());
String
uid
=
""
;
String
uid
=
""
;
for
(
CartGoods
cartGoods
:
cartGoodsList
)
{
for
(
CartGoods
cartGoods
:
cartGoodsList
)
{
...
@@ -59,13 +59,13 @@ public class TimeSalePromotionService implements IPromotionService {
...
@@ -59,13 +59,13 @@ public class TimeSalePromotionService implements IPromotionService {
continue
;
continue
;
}
}
// 享受限时特价折扣的商品数量
// 享受限时特价折扣的商品数量
Integer
specialActualGoodsNumber
=
null
;
Integer
specialActualGoodsNumber
=
goodsDiscount
.
getActualGoodsNumber
()
;
// 商品现价
// 商品现价
Long
goodsNowPrice
=
cartGoods
.
getOriginalPrice
()
-
goodsDiscount
.
getDiscount
()
/
goodsDiscount
.
getActualGoodsNumber
();
Long
goodsNowPrice
=
cartGoods
.
getOriginalPrice
()
-
goodsDiscount
.
getDiscount
()
/
goodsDiscount
.
getActualGoodsNumber
();
// numberMap用于暂存当前商品行可享受限时特价折扣的商品数量
// numberMap用于暂存当前商品行可享受限时特价折扣的商品数量
if
((
specialActualGoodsNumber
=
numberMap
.
get
(
goods
.
getGoodsId
()))
==
null
)
{
//
if ((specialActualGoodsNumber = numberMap.get(goods.getGoodsId())) == null) {
numberMap
.
put
(
goods
.
getGoodsId
(),
specialActualGoodsNumber
=
goodsDiscount
.
getActualGoodsNumber
());
//
numberMap.put(goods.getGoodsId(), specialActualGoodsNumber=goodsDiscount.getActualGoodsNumber());
}
//
}
//若可享受数量>=当前商品行的商品数量
//若可享受数量>=当前商品行的商品数量
if
(
specialActualGoodsNumber
-
cartGoods
.
getQty
()
>=
0
)
{
if
(
specialActualGoodsNumber
-
cartGoods
.
getQty
()
>=
0
)
{
cartGoods
.
setAmount
(
goodsNowPrice
*
cartGoods
.
getQty
());
cartGoods
.
setAmount
(
goodsNowPrice
*
cartGoods
.
getQty
());
...
@@ -78,7 +78,7 @@ public class TimeSalePromotionService implements IPromotionService {
...
@@ -78,7 +78,7 @@ public class TimeSalePromotionService implements IPromotionService {
uid
=
goods
.
getCartGoodsUid
();
uid
=
goods
.
getCartGoodsUid
();
}
}
}
}
numberMap
.
put
(
goods
.
getGoodsId
(),
specialActualGoodsNumber
-
cartGoods
.
getQty
());
//
numberMap.put(goods.getGoodsId(), specialActualGoodsNumber - cartGoods.getQty());
}
}
if
(
StringUtils
.
isNotBlank
(
toastMsg
))
{
if
(
StringUtils
.
isNotBlank
(
toastMsg
))
{
shoppingCartGoodsResponseVo
.
setToastMsg
(
toastMsg
);
shoppingCartGoodsResponseVo
.
setToastMsg
(
toastMsg
);
...
...
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