use of com.ncedu.fooddelivery.api.v1.errors.orderRegistration.OrderCostChangedEx in project 2021-msk-food-delivery by netcracker-edu.
the class OrderServiceImpl1 method checkOrderDataActuality.
private void checkOrderDataActuality(CreateOrderDTO dto) {
Double clientCost = dto.getOverallCost();
Double clientDiscount = dto.getDiscount();
Double clientHighDemandCoeff = dto.getHighDemandCoeff();
// checking that client data is still actual
Double[] repeatedCalculation = countOrderCost(dto.getGeo(), dto.getProductAmountPairs(), dto.getWarehouseId());
Double countedCost = repeatedCalculation[0];
Double countedDiscount = repeatedCalculation[1];
Double countedHighDemandCoeff = repeatedCalculation[2];
if (!clientCost.equals(countedCost) || !clientHighDemandCoeff.equals(countedHighDemandCoeff) || !clientDiscount.equals(countedDiscount))
throw new OrderCostChangedEx(countedCost, countedDiscount, countedHighDemandCoeff);
}
Aggregations