| Line 77... |
Line 77... |
| 77 |
import com.spice.profitmandi.dao.repository.fofo.FofoPartnerPaymentOptionRepository;
|
77 |
import com.spice.profitmandi.dao.repository.fofo.FofoPartnerPaymentOptionRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
78 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
| 79 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
79 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 80 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
80 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 81 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
81 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| - |
|
82 |
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
|
| 82 |
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
|
83 |
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
|
| 83 |
import com.spice.profitmandi.service.integrations.zest.ZestService;
|
- |
|
| 84 |
import com.spice.profitmandi.service.order.OrderService;
|
84 |
import com.spice.profitmandi.service.order.OrderService;
|
| 85 |
import com.spice.profitmandi.service.pricing.PricingService;
|
85 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 86 |
import com.spice.profitmandi.web.model.LoginDetails;
|
86 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 87 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
87 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 88 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
88 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| Line 118... |
Line 118... |
| 118 |
|
118 |
|
| 119 |
@Autowired
|
119 |
@Autowired
|
| 120 |
private MVCResponseSender mvcResponseSender;
|
120 |
private MVCResponseSender mvcResponseSender;
|
| 121 |
|
121 |
|
| 122 |
@Autowired
|
122 |
@Autowired
|
| 123 |
private ZestService zestService;
|
123 |
private InsuranceService insuranceService;
|
| 124 |
|
124 |
|
| 125 |
@Autowired
|
125 |
@Autowired
|
| 126 |
private FofoOrderRepository fofoOrderRepository;
|
126 |
private FofoOrderRepository fofoOrderRepository;
|
| 127 |
|
127 |
|
| 128 |
@Autowired
|
128 |
@Autowired
|
| Line 187... |
Line 187... |
| 187 |
model.addAttribute("accessoriesDeals", accessoriesDeals);
|
187 |
model.addAttribute("accessoriesDeals", accessoriesDeals);
|
| 188 |
return "order-index";
|
188 |
return "order-index";
|
| 189 |
}
|
189 |
}
|
| 190 |
|
190 |
|
| 191 |
@RequestMapping(value = "/checkplans", method = RequestMethod.GET)
|
191 |
@RequestMapping(value = "/checkplans", method = RequestMethod.GET)
|
| 192 |
public String getInsurancePrices(HttpServletRequest request, @RequestParam float price, Model model)
|
192 |
public String getInsurancePrices(HttpServletRequest request, @RequestParam float price, Model model,
|
| 193 |
throws ProfitMandiBusinessException {
|
193 |
@RequestParam int itemId) throws ProfitMandiBusinessException {
|
| 194 |
LOGGER.info("Request received at url : {}", request.getRequestURI());
|
194 |
LOGGER.info("Request received at url : {}", request.getRequestURI());
|
| 195 |
|
195 |
|
| 196 |
try {
|
196 |
try {
|
| 197 |
String response = mvcResponseSender.createResponseString(this.getPlans(price));
|
197 |
String response = mvcResponseSender.createResponseString(this.getPlans(price, itemId));
|
| 198 |
model.addAttribute("response", response);
|
198 |
model.addAttribute("response", response);
|
| 199 |
} catch (Exception e) {
|
199 |
} catch (Exception e) {
|
| 200 |
// TODO Auto-generated catch block
|
200 |
// TODO Auto-generated catch block
|
| 201 |
e.printStackTrace();
|
201 |
e.printStackTrace();
|
| 202 |
throw new ProfitMandiBusinessException("Plans", "Plans API", "Error formatting insurance plans");
|
202 |
throw new ProfitMandiBusinessException("Plans", "Plans API", "Error formatting insurance plans");
|
| Line 709... |
Line 709... |
| 709 |
}
|
709 |
}
|
| 710 |
|
710 |
|
| 711 |
return "response";
|
711 |
return "response";
|
| 712 |
}
|
712 |
}
|
| 713 |
|
713 |
|
| 714 |
private Map<String, List<MobileInsurancePlan>> getPlans(float sellingPrice) throws ProfitMandiBusinessException {
|
714 |
private Map<String, List<MobileInsurancePlan>> getPlans(float sellingPrice, int itemId)
|
| - |
|
715 |
throws ProfitMandiBusinessException {
|
| - |
|
716 |
try {
|
| 715 |
Map<String, List<MobileInsurancePlan>> productDurationPlans = zestService.getAllPlansByProductAndDuration();
|
717 |
Map<String, List<MobileInsurancePlan>> productDurationPlans = insuranceService.getAllPlans(itemId,
|
| 716 |
Map<String, List<MobileInsurancePlan>> returnPlans = new HashMap<>();
|
718 |
sellingPrice);
|
| 717 |
productDurationPlans.entrySet().stream().forEach(m -> {
|
719 |
return productDurationPlans;
|
| 718 |
returnPlans.put(m.getKey(), m.getValue().stream().filter(x -> {
|
720 |
} catch (Exception e) {
|
| 719 |
return Float.parseFloat(x.getMaxPrice()) >= sellingPrice
|
721 |
e.printStackTrace();
|
| 720 |
&& Float.parseFloat(x.getMinPrice()) <= sellingPrice;
|
722 |
throw new ProfitMandiBusinessException("Fetch Insurance Plans", "Insurance",
|
| 721 |
}).collect(Collectors.toList()));
|
723 |
"Could not fetch insurance Plans");
|
| 722 |
});
|
724 |
}
|
| 723 |
return returnPlans;
|
- |
|
| - |
|
725 |
|
| 724 |
}
|
726 |
}
|
| 725 |
|
727 |
|
| 726 |
@GetMapping("/insuranceDetails")
|
728 |
@GetMapping("/insuranceDetails")
|
| 727 |
public String getInsuranceDetails(HttpServletRequest request,
|
729 |
public String getInsuranceDetails(HttpServletRequest request,
|
| 728 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
730 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|