| Line 76... |
Line 76... |
| 76 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
76 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
| 77 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
77 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
78 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
| 79 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
79 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 80 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
80 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| - |
|
81 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 81 |
import com.spice.profitmandi.web.model.FofoDetails;
|
82 |
import com.spice.profitmandi.web.model.FofoDetails;
|
| 82 |
import com.spice.profitmandi.web.request.CreateOrderRequest;
|
83 |
import com.spice.profitmandi.web.request.CreateOrderRequest;
|
| 83 |
import com.spice.profitmandi.web.request.CustomPaymentOption;
|
84 |
import com.spice.profitmandi.web.request.CustomPaymentOption;
|
| 84 |
import com.spice.profitmandi.web.response.ItemIdQuantityAvailability;
|
85 |
import com.spice.profitmandi.web.response.ItemIdQuantityAvailability;
|
| 85 |
import com.spice.profitmandi.web.response.Quantity;
|
86 |
import com.spice.profitmandi.web.response.Quantity;
|
| 86 |
import com.spice.profitmandi.web.util.CookiesFetcher;
|
87 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 87 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
88 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 88 |
|
89 |
|
| 89 |
import in.shop2020.model.v1.catalog.ItemType;
|
90 |
import in.shop2020.model.v1.catalog.ItemType;
|
| 90 |
|
91 |
|
| 91 |
@Controller
|
92 |
@Controller
|
| Line 147... |
Line 148... |
| 147 |
|
148 |
|
| 148 |
@Autowired
|
149 |
@Autowired
|
| 149 |
MVCResponseSender mvcResponseSender;
|
150 |
MVCResponseSender mvcResponseSender;
|
| 150 |
|
151 |
|
| 151 |
@Autowired
|
152 |
@Autowired
|
| 152 |
CookiesFetcher cookiesFetcher;
|
153 |
CookiesProcessor cookiesProcessor;
|
| - |
|
154 |
|
| - |
|
155 |
@Autowired
|
| - |
|
156 |
PricingService pricingService;
|
| 153 |
|
157 |
|
| 154 |
@RequestMapping(value = "/order")
|
158 |
@RequestMapping(value = "/order")
|
| 155 |
public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model) throws Exception{
|
159 |
public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model) throws Exception{
|
| 156 |
try {
|
160 |
try {
|
| 157 |
cookiesFetcher.getCookiesObject(request);
|
161 |
cookiesProcessor.getCookiesObject(request);
|
| 158 |
} catch (ProfitMandiBusinessException e) {
|
162 |
} catch (ProfitMandiBusinessException e) {
|
| 159 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
163 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| 160 |
return "response";
|
164 |
return "response";
|
| 161 |
}
|
165 |
}
|
| 162 |
JSONObject cartObject = new JSONObject(cartData);
|
166 |
JSONObject cartObject = new JSONObject(cartData);
|
| Line 204... |
Line 208... |
| 204 |
|
208 |
|
| 205 |
@RequestMapping(value = "/get-order", method = RequestMethod.GET)
|
209 |
@RequestMapping(value = "/get-order", method = RequestMethod.GET)
|
| 206 |
public String getOrder(HttpServletRequest request, @RequestParam(name = "orderId") int orderId, Model model) throws ProfitMandiBusinessException, Exception{
|
210 |
public String getOrder(HttpServletRequest request, @RequestParam(name = "orderId") int orderId, Model model) throws ProfitMandiBusinessException, Exception{
|
| 207 |
FofoDetails fofoDetails;
|
211 |
FofoDetails fofoDetails;
|
| 208 |
try {
|
212 |
try {
|
| 209 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
213 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 210 |
} catch (ProfitMandiBusinessException e) {
|
214 |
} catch (ProfitMandiBusinessException e) {
|
| 211 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
215 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| 212 |
return "response";
|
216 |
return "response";
|
| 213 |
}
|
217 |
}
|
| 214 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
218 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
| Line 224... |
Line 228... |
| 224 |
@RequestMapping(value = "/create-order", method = RequestMethod.POST)
|
228 |
@RequestMapping(value = "/create-order", method = RequestMethod.POST)
|
| 225 |
public String createOrder(HttpServletRequest request, @RequestBody CreateOrderRequest createOrderRequest, Model model) throws Throwable{
|
229 |
public String createOrder(HttpServletRequest request, @RequestBody CreateOrderRequest createOrderRequest, Model model) throws Throwable{
|
| 226 |
LOGGER.info("request at uri {} body {}", request.getRequestURI(), createOrderRequest);
|
230 |
LOGGER.info("request at uri {} body {}", request.getRequestURI(), createOrderRequest);
|
| 227 |
FofoDetails fofoDetails;
|
231 |
FofoDetails fofoDetails;
|
| 228 |
try {
|
232 |
try {
|
| 229 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
233 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 230 |
} catch (ProfitMandiBusinessException e) {
|
234 |
} catch (ProfitMandiBusinessException e) {
|
| 231 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
235 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| 232 |
return "response";
|
236 |
return "response";
|
| 233 |
}
|
237 |
}
|
| 234 |
Set<Integer> itemIds = new HashSet<>();
|
238 |
Set<Integer> itemIds = new HashSet<>();
|
| Line 465... |
Line 469... |
| 465 |
return "error";
|
469 |
return "error";
|
| 466 |
}
|
470 |
}
|
| 467 |
inventoryItemsToBill.put(i.getId(), inventoryItemsNonSerializedUsed);
|
471 |
inventoryItemsToBill.put(i.getId(), inventoryItemsNonSerializedUsed);
|
| 468 |
}
|
472 |
}
|
| 469 |
}
|
473 |
}
|
| - |
|
474 |
|
| - |
|
475 |
// mop price validation
|
| - |
|
476 |
Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
|
| - |
|
477 |
Map<Integer, Float> itemIdPrinceMap = pricingService.getPrice(itemIds, fofoDetails.getFofoId());
|
| - |
|
478 |
for(Map.Entry<Integer, Float> entry : itemIdPrinceMap.entrySet()){
|
| - |
|
479 |
CustomFofoLineItem customFofoLineItem = customFofoLineItemMap.get(entry.getKey());
|
| - |
|
480 |
if(customFofoLineItem.getSellingPrice() < entry.getValue()){
|
| - |
|
481 |
invalidMopItemIdPriceMap.put(entry.getKey(), customFofoLineItem.getSellingPrice());
|
| - |
|
482 |
}
|
| - |
|
483 |
}
|
| - |
|
484 |
|
| - |
|
485 |
if(invalidMopItemIdPriceMap.isEmpty()){
|
| - |
|
486 |
LOGGER.error("Invalid itemIds mop prices should be greater than mop prices {}", invalidMopItemIdPriceMap);
|
| - |
|
487 |
return "error";
|
| - |
|
488 |
}
|
| 470 |
|
489 |
|
| 471 |
InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
|
490 |
InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
|
| 472 |
try{
|
491 |
try{
|
| 473 |
invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(fofoDetails.getFofoId());
|
492 |
invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(fofoDetails.getFofoId());
|
| 474 |
invoiceNumberGenerationSequence.setSequence(invoiceNumberGenerationSequence.getSequence() + 1);
|
493 |
invoiceNumberGenerationSequence.setSequence(invoiceNumberGenerationSequence.getSequence() + 1);
|
| Line 658... |
Line 677... |
| 658 |
|
677 |
|
| 659 |
|
678 |
|
| 660 |
@RequestMapping(value = "/generateInvoice")
|
679 |
@RequestMapping(value = "/generateInvoice")
|
| 661 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws Throwable{
|
680 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws Throwable{
|
| 662 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(), ProfitMandiConstants.ORDER_ID, orderId);
|
681 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(), ProfitMandiConstants.ORDER_ID, orderId);
|
| 663 |
FofoDetails fofoDetails = cookiesFetcher.getCookiesObject(request);
|
682 |
FofoDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 664 |
|
683 |
|
| 665 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
684 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
| 666 |
PdfModel pdfModel = new PdfModel();
|
685 |
PdfModel pdfModel = new PdfModel();
|
| 667 |
pdfModel.setAuther("profitmandi");
|
686 |
pdfModel.setAuther("profitmandi");
|
| 668 |
pdfModel.setTitle("Retailer Invoice");
|
687 |
pdfModel.setTitle("Retailer Invoice");
|