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
jenkins
order-group
Commits
cfe7ab6d
Commit
cfe7ab6d
authored
Dec 18, 2019
by
shuhu.hou@freemud.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
限时特价优惠语提示fixbug
parent
809b7586
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
39 deletions
+17
-39
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/TimeSalePromotionService.java
+17
-39
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/TimeSalePromotionService.java
View file @
cfe7ab6d
...
@@ -47,7 +47,7 @@ public class TimeSalePromotionService implements IPromotionService {
...
@@ -47,7 +47,7 @@ public class TimeSalePromotionService implements IPromotionService {
String
toastMsg
=
null
;
String
toastMsg
=
null
;
Map
<
String
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsMap
=
goodsList
.
parallelStream
()
Map
<
String
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsMap
=
goodsList
.
parallelStream
()
.
collect
(
Collectors
.
toMap
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
::
getGoodsId
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
.
collect
(
Collectors
.
toMap
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
::
getGoodsId
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
// 存储当前享受限时特价折扣的商品数量
// 存储当前享受限时特价折扣的商品数量
,key:goodsId; value:可享受数量
Map
<
String
,
Integer
>
numberMap
=
new
HashMap
<>();
Map
<
String
,
Integer
>
numberMap
=
new
HashMap
<>();
for
(
CartGoods
cartGoods
:
cartGoodsList
)
{
for
(
CartGoods
cartGoods
:
cartGoodsList
)
{
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods
;
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods
;
...
@@ -58,48 +58,26 @@ public class TimeSalePromotionService implements IPromotionService {
...
@@ -58,48 +58,26 @@ public class TimeSalePromotionService implements IPromotionService {
if
(
goodsDiscount
==
null
)
{
if
(
goodsDiscount
==
null
)
{
continue
;
continue
;
}
}
// 设置商品原价与商品现价的初始值
cartGoods
.
setOriginalAmount
(
goods
.
getOriginalPrice
()
*
cartGoods
.
getQty
());
cartGoods
.
setAmount
(
goods
.
getOriginalPrice
()
*
cartGoods
.
getQty
()
-
goods
.
getDiscountAmount
());
// 享受限时特价折扣的商品数量
// 享受限时特价折扣的商品数量
Integer
specialActualGoodsNumber
=
null
;
Integer
specialActualGoodsNumber
=
null
;
// 商品现价
// 商品现价
Long
goodsNowPrice
=
null
;
Long
goodsNowPrice
=
cartGoods
.
getOriginalPrice
()
-
goodsDiscount
.
getDiscount
()
/
goodsDiscount
.
getActualGoodsNumber
();
// 获取享受限时特价折扣的商品数量与商品现价
// numberMap用于暂存当前商品行可享受限时特价折扣的商品数量
if
(
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getApportionGoods
()))
{
if
((
specialActualGoodsNumber
=
numberMap
.
get
(
goods
.
getGoodsId
()))
==
null
)
{
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ApportionGoods
apportionGoods
=
getApportionGoods
(
cartGoods
,
calculationDiscountResult
.
getApportionGoods
(),
ActivityTypeEnum
.
TYPE_2
);
numberMap
.
put
(
goods
.
getGoodsId
(),
specialActualGoodsNumber
=
goodsDiscount
.
getActualGoodsNumber
());
if
(
apportionGoods
!=
null
)
{
}
specialActualGoodsNumber
=
apportionGoods
.
getGoodsQuantity
();
//若可享受数量>=当前商品行的商品数量
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ApportionGoods
.
ApportionDetails
apportionDetails
=
getApportionDetails
(
apportionGoods
.
getApportionDetails
(),
ActivityTypeEnum
.
TYPE_2
);
if
(
specialActualGoodsNumber
-
cartGoods
.
getQty
()
>=
0
)
{
if
(
apportionDetails
!=
null
)
{
cartGoods
.
setAmount
(
goodsNowPrice
*
cartGoods
.
getQty
());
goodsNowPrice
=
apportionDetails
.
getGoodsNowPrice
();
}
}
}
// 获取享受限时特价折扣的商品数量失败,重新计算=商品折扣总金额/(商品原价-商品现价)
if
(
specialActualGoodsNumber
==
null
)
{
specialActualGoodsNumber
=
(
int
)
(
goodsDiscount
.
getDiscount
()
/
(
goods
.
getOriginalPrice
()
-
goods
.
getNowPrice
()));
}
// 获取商品现价失败,从优惠信息中获取
if
(
goodsNowPrice
==
null
)
{
goodsNowPrice
=
goods
.
getNowPrice
();
}
// Map中存有上次计算剩余的享受限时特价折扣的商品数量
if
(
numberMap
.
get
(
goods
.
getGoodsId
())
!=
null
)
{
specialActualGoodsNumber
=
numberMap
.
get
(
goods
.
getGoodsId
());
}
if
(
specialActualGoodsNumber
>=
cartGoods
.
getQty
())
{
numberMap
.
put
(
goods
.
getGoodsId
(),
specialActualGoodsNumber
-
cartGoods
.
getQty
());
specialActualGoodsNumber
=
cartGoods
.
getQty
();
}
else
{
}
else
{
numberMap
.
put
(
goods
.
getGoodsId
(),
0
);
//总价=可享受数量*优惠后单价+(当前商品行的商品数量-可享受数量)*商品原价
}
cartGoods
.
setAmount
(
specialActualGoodsNumber
>
0
?
specialActualGoodsNumber
*
goodsNowPrice
+
(
cartGoods
.
getQty
()
-
specialActualGoodsNumber
)
*
cartGoods
.
getOriginalPrice
()
cartGoods
.
setAmount
(
goodsNowPrice
*
specialActualGoodsNumber
+
goods
.
getOriginalPrice
()
*
(
cartGoods
.
getQty
()
-
specialActualGoodsNumber
));
:
goods
.
getOriginalPrice
()
*
cartGoods
.
getQty
());
if
(
StringUtils
.
isEmpty
(
toastMsg
)
&&
specialActualGoodsNumber
<
goods
.
getGoodsQuantity
())
{
if
(
StringUtils
.
isEmpty
(
toastMsg
))
{
// 存在限时特价折扣
toastMsg
=
"该商品限"
+
goodsDiscount
.
getActualGoodsNumber
()
+
"份优惠 超出按照原价计算哦"
;
toastMsg
=
"该商品限"
+
specialActualGoodsNumber
+
"份优惠 超出按照原价计算哦"
;
}
}
}
numberMap
.
put
(
goods
.
getGoodsId
(),
specialActualGoodsNumber
-
cartGoods
.
getQty
());
}
}
if
(
StringUtils
.
isNotBlank
(
toastMsg
))
{
if
(
StringUtils
.
isNotBlank
(
toastMsg
))
{
shoppingCartGoodsResponseVo
.
setToastMsg
(
toastMsg
);
shoppingCartGoodsResponseVo
.
setToastMsg
(
toastMsg
);
...
@@ -144,7 +122,7 @@ public class TimeSalePromotionService implements IPromotionService {
...
@@ -144,7 +122,7 @@ public class TimeSalePromotionService implements IPromotionService {
activityDiscountsDto
.
setActivityType
(
ActivityTypeEnum
.
TYPE_2
.
getCode
());
activityDiscountsDto
.
setActivityType
(
ActivityTypeEnum
.
TYPE_2
.
getCode
());
activityDiscountsDto
.
setDiscountAmount
(
totalDiscountAmount
.
intValue
());
activityDiscountsDto
.
setDiscountAmount
(
totalDiscountAmount
.
intValue
());
cartGoods
.
getActivityDiscountsDtos
().
add
(
activityDiscountsDto
);
cartGoods
.
getActivityDiscountsDtos
().
add
(
activityDiscountsDto
);
cartGoods
.
setTotalDiscountAmount
(
cartGoods
.
getTotalDiscountAmount
()+
totalDiscountAmount
.
intValue
());
cartGoods
.
setTotalDiscountAmount
(
cartGoods
.
getTotalDiscountAmount
()
+
totalDiscountAmount
.
intValue
());
numberMap
.
put
(
cartGoods
.
getSkuId
(),
actualGoodsNumber
-
cartGoods
.
getQty
());
numberMap
.
put
(
cartGoods
.
getSkuId
(),
actualGoodsNumber
-
cartGoods
.
getQty
());
}
else
{
}
else
{
cartGoods
.
setTotalDiscountAmount
(
0
);
cartGoods
.
setTotalDiscountAmount
(
0
);
...
...
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