Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ecommerce-maven
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ascend
ecommerce-maven
Commits
a5671314
Commit
a5671314
authored
May 12, 2021
by
Christopher Cottier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
promotions applied to items upon ordering
parent
3a54dfd3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
OrderService.java
...main/java/com/nisum/ecomservice/service/OrderService.java
+14
-13
No files found.
ecom-service/src/main/java/com/nisum/ecomservice/service/OrderService.java
View file @
a5671314
...
...
@@ -51,27 +51,28 @@ public class OrderService {
orderItem
.
setItemQuantity
(
quantity
);
//set promotion if applicable
return
orderItem
;
}).
flatMap
(
orderItem
->
{
Flux
<
Promotion
>
promotionFlux
=
productService
.
getPromotionBySkus
(
Arrays
.
asList
(
orderItem
.
getItemSku
()));
promotionFlux
Mono
<
OrderItem
>
orderItemMono
=
promotionFlux
.
collectList
()
.
map
(
promotionList
->
{
System
.
out
.
println
(
"Give me promo list"
);
if
(
promotionList
.
size
()
==
0
)
{
return
promotionList
;}
Promotion
promotion
=
promotionList
.
get
(
0
);
if
(
orderItem
.
getItemQuantity
().
intValue
()
>=
promotion
.
getMinimumQuantity
().
intValue
())
{
Float
originalPrice
=
orderItem
.
getItemPrice
();
Float
newPrice
=
originalPrice
*
(
promotion
.
getDiscountPercentage
()
/
100
);
orderItem
.
setItemPrice
(
newPrice
);
if
(
promotionList
.
size
()
>
0
)
{
Promotion
promotion
=
promotionList
.
get
(
0
);
if
(
orderItem
.
getItemQuantity
().
intValue
()
>=
promotion
.
getMinimumQuantity
().
intValue
())
{
Float
originalPrice
=
orderItem
.
getItemPrice
();
Float
newPrice
=
originalPrice
*
((
100
-
promotion
.
getDiscountPercentage
())
/
100
);
orderItem
.
setItemPrice
(
newPrice
);
}
}
return
promotion
;
}).
subscribe
();
return
orderItem
;
return
orderItem
;
});
return
orderItemMono
;
});
//
//
falttens the things
Mono
<
Mono
<
Order
>>
map
=
orderItems
.
collectList
().
map
(
itemList
->
{
OrderSubmission
orderSubmission
=
new
OrderSubmission
();
...
...
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