This project is a service for payment, it is mainly in charge of dealing the order from client, calculating the price and finally return bills to clients. Please help to complete the coding in this project according to the following requirements within 45 minutes.
We total have three kinds of order types: "ONLINE", "OFFLINE", "INTERNAL". Each order type has its own calculating logic, please help to implement the logic in PaymentService.pay()
;
Order Type | Logic |
---|---|
ONLINE | The total price = origin price * 85% |
OFFLINE | The total price = origin price |
INTERNAL | The total price = promotion price + (origin price for other products if any) |
Notes:
- Only when the orderType is internal, then the field "involvedPromotions" inside the Order has value;
- One order only allow maximum one promotion;
- Factory design pattern is recommended.
Please help to implement the Junit test case for the PaymentService.pay()
method.