| Line 45... |
Line 45... |
| 45 |
import com.spice.profitmandi.common.model.PdfModel;
|
45 |
import com.spice.profitmandi.common.model.PdfModel;
|
| 46 |
import com.spice.profitmandi.common.model.PriceModel;
|
46 |
import com.spice.profitmandi.common.model.PriceModel;
|
| 47 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
47 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 48 |
import com.spice.profitmandi.common.util.PdfUtils;
|
48 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 49 |
import com.spice.profitmandi.common.util.StringUtils;
|
49 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 50 |
import com.spice.profitmandi.common.util.Utils;
|
- |
|
| 51 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
50 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 52 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
51 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 53 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
52 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| 54 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
53 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
| 55 |
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
|
54 |
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
|
| Line 73... |
Line 72... |
| 73 |
import com.spice.profitmandi.dao.repository.fofo.CustomerReturnItemRepository;
|
72 |
import com.spice.profitmandi.dao.repository.fofo.CustomerReturnItemRepository;
|
| 74 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
73 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 75 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
74 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 76 |
import com.spice.profitmandi.dao.repository.fofo.FofoPartnerPaymentOptionRepository;
|
75 |
import com.spice.profitmandi.dao.repository.fofo.FofoPartnerPaymentOptionRepository;
|
| 77 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
76 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
| - |
|
77 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
78 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 79 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
79 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| - |
|
80 |
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
|
| - |
|
81 |
import com.spice.profitmandi.service.integrations.zest.ZestService;
|
| 80 |
import com.spice.profitmandi.service.order.OrderService;
|
82 |
import com.spice.profitmandi.service.order.OrderService;
|
| 81 |
import com.spice.profitmandi.service.pricing.PricingService;
|
83 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 82 |
import com.spice.profitmandi.web.model.LoginDetails;
|
84 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 83 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
85 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 84 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
86 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| Line 103... |
Line 105... |
| 103 |
@Autowired
|
105 |
@Autowired
|
| 104 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
106 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 105 |
|
107 |
|
| 106 |
@Autowired
|
108 |
@Autowired
|
| 107 |
private PaymentOptionRepository paymentOptionRepository;
|
109 |
private PaymentOptionRepository paymentOptionRepository;
|
| - |
|
110 |
|
| - |
|
111 |
@Autowired
|
| - |
|
112 |
private StateRepository stateRepository;
|
| 108 |
|
113 |
|
| 109 |
@Autowired
|
114 |
@Autowired
|
| 110 |
private ItemRepository itemRepository;
|
115 |
private ItemRepository itemRepository;
|
| 111 |
|
116 |
|
| 112 |
@Autowired
|
117 |
@Autowired
|
| 113 |
private MVCResponseSender mvcResponseSender;
|
118 |
private MVCResponseSender mvcResponseSender;
|
| - |
|
119 |
|
| - |
|
120 |
@Autowired
|
| - |
|
121 |
private ZestService zestService;
|
| 114 |
|
122 |
|
| 115 |
@Autowired
|
123 |
@Autowired
|
| 116 |
private FofoOrderRepository fofoOrderRepository;
|
124 |
private FofoOrderRepository fofoOrderRepository;
|
| 117 |
|
125 |
|
| 118 |
@Autowired
|
126 |
@Autowired
|
| Line 166... |
Line 174... |
| 166 |
loginDetails.getFofoId());
|
174 |
loginDetails.getFofoId());
|
| 167 |
List<Integer> paymentOptionIds = fofoPartnerPaymentOptionRepository
|
175 |
List<Integer> paymentOptionIds = fofoPartnerPaymentOptionRepository
|
| 168 |
.selectPaymentOptionIdsByFofoId(loginDetails.getFofoId());
|
176 |
.selectPaymentOptionIdsByFofoId(loginDetails.getFofoId());
|
| 169 |
List<PaymentOption> paymentOptions = paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds));
|
177 |
List<PaymentOption> paymentOptions = paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds));
|
| 170 |
LOGGER.info("mopPriceMap {}", mopPriceMap);
|
178 |
LOGGER.info("mopPriceMap {}", mopPriceMap);
|
| 171 |
model.addAttribute("stateNames", Utils.getAllStateNames());
|
179 |
model.addAttribute("stateNames", stateRepository.selectAll().stream().map(x->x.getName()).collect(Collectors.toList()));
|
| 172 |
model.addAttribute("retailerStateName", address.getState());
|
180 |
model.addAttribute("retailerStateName", address.getState());
|
| 173 |
model.addAttribute("cartObj", cartItems);
|
181 |
model.addAttribute("cartItems", cartItems);
|
| 174 |
model.addAttribute("mopPriceMap", mopPriceMap);
|
182 |
model.addAttribute("mopPriceMap", mopPriceMap);
|
| 175 |
model.addAttribute("paymentOptions", paymentOptions);
|
183 |
model.addAttribute("paymentOptions", paymentOptions);
|
| 176 |
model.addAttribute("accessoriesDeals", accessoriesDeals);
|
184 |
model.addAttribute("accessoriesDeals", accessoriesDeals);
|
| 177 |
return "order-index";
|
185 |
return "order-index";
|
| 178 |
}
|
186 |
}
|
| 179 |
|
187 |
|
| 180 |
@RequestMapping(value = "/insurancePrices", method = RequestMethod.GET)
|
188 |
@RequestMapping(value = "/checkplans", method = RequestMethod.GET)
|
| 181 |
public ResponseEntity<?> getInsurancePrices(HttpServletRequest request,
|
189 |
public String getInsurancePrices(HttpServletRequest request,
|
| 182 |
@RequestParam(name = ProfitMandiConstants.PRICE) float price) throws ProfitMandiBusinessException {
|
190 |
@RequestParam float price, Model model) throws ProfitMandiBusinessException {
|
| 183 |
LOGGER.info("Request received at url : {}", request.getRequestURI());
|
191 |
LOGGER.info("Request received at url : {}", request.getRequestURI());
|
| - |
|
192 |
|
| - |
|
193 |
try {
|
| - |
|
194 |
String response = mvcResponseSender.createResponseString(this.getPlans(price));
|
| 184 |
Set<Float> prices = new HashSet<>();
|
195 |
model.addAttribute("response", response);
|
| - |
|
196 |
} catch (Exception e) {
|
| - |
|
197 |
// TODO Auto-generated catch block
|
| 185 |
prices.add(price);
|
198 |
e.printStackTrace();
|
| 186 |
return responseSender.ok(pricingService.getInsurancePrices(prices, ProfitMandiConstants.GADGET_COPS));
|
199 |
throw new ProfitMandiBusinessException("Plans", "Plans API", "Error formatting insurance plans");
|
| - |
|
200 |
}
|
| - |
|
201 |
|
| - |
|
202 |
return "response";
|
| 187 |
}
|
203 |
}
|
| 188 |
|
204 |
|
| 189 |
@RequestMapping(value = "/get-order", method = RequestMethod.GET)
|
205 |
@RequestMapping(value = "/get-order", method = RequestMethod.GET)
|
| 190 |
public String getOrder(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId,
|
206 |
public String getOrder(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId,
|
| 191 |
Model model) throws ProfitMandiBusinessException {
|
207 |
Model model) throws ProfitMandiBusinessException {
|
| Line 418... |
Line 434... |
| 418 |
model.addAttribute("paymentOptionIdPaymentOptionMap", paymentOptionIdPaymentOptionMap);
|
434 |
model.addAttribute("paymentOptionIdPaymentOptionMap", paymentOptionIdPaymentOptionMap);
|
| 419 |
model.addAttribute("paymentOptionIdPaymentOptionTransactionMap", paymentOptionIdPaymentOptionTransactionMap);
|
435 |
model.addAttribute("paymentOptionIdPaymentOptionTransactionMap", paymentOptionIdPaymentOptionTransactionMap);
|
| 420 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
436 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
| 421 |
model.addAttribute("fofoPartnerPaymentOptions", fofoPartnerPaymentOptions);
|
437 |
model.addAttribute("fofoPartnerPaymentOptions", fofoPartnerPaymentOptions);
|
| 422 |
model.addAttribute("totalNumberOfPaymentOptionId", fofoPartnerPaymentOptions.size());
|
438 |
model.addAttribute("totalNumberOfPaymentOptionId", fofoPartnerPaymentOptions.size());
|
| 423 |
model.addAttribute("stateNames", Utils.getAllStateNames());
|
439 |
model.addAttribute("stateNames", stateRepository.selectAll().stream().map(x->x.getName()).collect(Collectors.toList()));
|
| 424 |
return "search-order-details";
|
440 |
return "search-order-details";
|
| 425 |
}
|
441 |
}
|
| 426 |
|
442 |
|
| 427 |
private Map<Integer, PaymentOption> paymentOptionIdPaymentOptionMap(
|
443 |
private Map<Integer, PaymentOption> paymentOptionIdPaymentOptionMap(
|
| 428 |
List<PaymentOptionTransaction> paymentOptionTransactions) {
|
444 |
List<PaymentOptionTransaction> paymentOptionTransactions) {
|
| Line 625... |
Line 641... |
| 625 |
throw new ProfitMandiBusinessException("Amount", amount, "Sum of amount is not equal to total amount");
|
641 |
throw new ProfitMandiBusinessException("Amount", amount, "Sum of amount is not equal to total amount");
|
| 626 |
}
|
642 |
}
|
| 627 |
|
643 |
|
| 628 |
return "response";
|
644 |
return "response";
|
| 629 |
}
|
645 |
}
|
| - |
|
646 |
|
| - |
|
647 |
|
| - |
|
648 |
|
| - |
|
649 |
private Map<String, List<MobileInsurancePlan>> getPlans(float sellingPrice) throws ProfitMandiBusinessException {
|
| - |
|
650 |
Map<String, List<MobileInsurancePlan>> productDurationPlans = zestService.getAllPlansByProductAndDuration();
|
| - |
|
651 |
Map<String, List<MobileInsurancePlan>> returnPlans = new HashMap<>();
|
| - |
|
652 |
productDurationPlans.entrySet().stream().forEach(m -> {
|
| - |
|
653 |
returnPlans.put(m.getKey(), m.getValue().stream().filter(x -> {
|
| - |
|
654 |
return Float.parseFloat(x.getMaxPrice()) >= sellingPrice
|
| - |
|
655 |
&& Float.parseFloat(x.getMinPrice()) <= sellingPrice;
|
| - |
|
656 |
}).collect(Collectors.toList()));
|
| - |
|
657 |
});
|
| - |
|
658 |
return returnPlans;
|
| - |
|
659 |
}
|
| 630 |
}
|
660 |
}
|