Subversion Repositories SmartDukaan

Rev

Rev 30322 | Rev 30827 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30322 Rev 30426
Line 140... Line 140...
140
	@Autowired
140
	@Autowired
141
	private ResponseSender<?> responseSender;
141
	private ResponseSender<?> responseSender;
142
 
142
 
143
	@Autowired
143
	@Autowired
144
	private PendingOrderRepository pendingOrderRepository;
144
	private PendingOrderRepository pendingOrderRepository;
145
	
145
 
146
	@Autowired
146
	@Autowired
147
	private OrderRepository orderRepository;
147
	private OrderRepository orderRepository;
148
	
148
 
149
	@Autowired
149
	@Autowired
150
	private PendingOrderItemRepository pendingOrderItemRepository;
150
	private PendingOrderItemRepository pendingOrderItemRepository;
151
 
151
 
152
	@Autowired
152
	@Autowired
153
	private FofoStoreRepository fofoStoreRepository;
153
	private FofoStoreRepository fofoStoreRepository;
Line 534... Line 534...
534
					paymentOptionTransaction);
534
					paymentOptionTransaction);
535
		}
535
		}
536
		return paymentOptionIdPaymentOptionTransactionMap;
536
		return paymentOptionIdPaymentOptionTransactionMap;
537
	}
537
	}
538
 
538
 
539
 
-
 
540
	@RequestMapping(value = "/create-order", method = RequestMethod.POST)
539
	@RequestMapping(value = "/create-order", method = RequestMethod.POST)
541
	public String createOrder(HttpServletRequest request, @RequestBody CreateOrderRequest createOrderRequest,
540
	public String createOrder(HttpServletRequest request, @RequestBody CreateOrderRequest createOrderRequest,
542
			Model model) throws ProfitMandiBusinessException {
541
			Model model) throws ProfitMandiBusinessException {
543
		// throw new ProfitMandiBusinessException("Billing is on hold temporarily",
542
		// throw new ProfitMandiBusinessException("Billing is on hold temporarily",
544
		// "Billing is on hold temporarily", "Billing is on hold temporarily");
543
		// "Billing is on hold temporarily", "Billing is on hold temporarily");
Line 1001... Line 1000...
1001
		List<PendingOrderItem> pendingOrderItem = null;
1000
		List<PendingOrderItem> pendingOrderItem = null;
1002
 
1001
 
1003
		if (isAdmin) {
1002
		if (isAdmin) {
1004
 
1003
 
1005
			pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatus(OrderStatus.CLAIMED);
1004
			pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatus(OrderStatus.CLAIMED);
1006
			Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
1005
			Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
-
 
1006
 
-
 
1007
			Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x))
-
 
1008
					.filter(x -> x != null).collect(Collectors.toList()).stream()
-
 
1009
					.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
1007
			model.addAttribute("customRetailersMap", customRetailersMap);
1010
			model.addAttribute("customRetailersMap", customRetailersMap);
1008
 
1011
 
1009
		} else {
1012
		} else {
1010
			pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatusAndFofoId(OrderStatus.CLAIMED,
1013
			pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatusAndFofoId(OrderStatus.CLAIMED,
1011
					loginDetails.getFofoId());
1014
					loginDetails.getFofoId());
Line 1255... Line 1258...
1255
		LOGGER.info("endTime" + endTime);
1258
		LOGGER.info("endTime" + endTime);
1256
 
1259
 
1257
		List<Integer> fofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId())
1260
		List<Integer> fofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId())
1258
				.collect(Collectors.toList());
1261
				.collect(Collectors.toList());
1259
 
1262
 
1260
		Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
1263
		Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
-
 
1264
 
-
 
1265
		Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x))
-
 
1266
				.filter(x -> x != null).collect(Collectors.toList()).stream()
-
 
1267
				.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
1261
		model.addAttribute("customRetailersMap", customRetailersMap);
1268
		model.addAttribute("customRetailersMap", customRetailersMap);
1262
 
1269
 
1263
		List<PendingOrderItem> pendingOrderItem = null;
1270
		List<PendingOrderItem> pendingOrderItem = null;
1264
		if (startTime == null) {
1271
		if (startTime == null) {
1265
			pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatus(status);
1272
			pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatus(status);
Line 1280... Line 1287...
1280
		model.addAttribute("partnerInventoryMap", map.get("partnerInventoryMap"));
1287
		model.addAttribute("partnerInventoryMap", map.get("partnerInventoryMap"));
1281
 
1288
 
1282
		model.addAttribute("isAdmin", isAdmin);
1289
		model.addAttribute("isAdmin", isAdmin);
1283
		return "online-order-item";
1290
		return "online-order-item";
1284
	}
1291
	}
1285
	
1292
 
1286
	@RequestMapping(value = "/franchiseeSalesReport", method = RequestMethod.GET)
1293
	@RequestMapping(value = "/franchiseeSalesReport", method = RequestMethod.GET)
1287
	public String getFranchiseeSalesReport(HttpServletRequest request,
1294
	public String getFranchiseeSalesReport(HttpServletRequest request, Model model)
1288
			Model model) throws ProfitMandiBusinessException {
1295
			throws ProfitMandiBusinessException {
1289
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1296
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1290
		
1297
 
1291
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1298
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1292
		LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
1299
		LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
1293
		FofoStore fs =fofoStoreRepository.selectByRetailerId(fofoDetails.getFofoId());
1300
		FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoDetails.getFofoId());
-
 
1301
 
-
 
1302
		List<FocoSaleReportModel> focoSaleReportList = fofoOrderRepository.selectFocoSaleReport(fofoDetails.getFofoId(),
-
 
1303
				fs.getCode(), currentStartMonth, currentDate);
1294
 
1304
 
1295
	    List<FocoSaleReportModel> focoSaleReportList =fofoOrderRepository.selectFocoSaleReport(fofoDetails.getFofoId(),fs.getCode(),currentStartMonth, currentDate);
-
 
1296
		
-
 
1297
		LOGGER.info("focoSaleReportList {}", focoSaleReportList);
1305
		LOGGER.info("focoSaleReportList {}", focoSaleReportList);
1298
		
-
 
1299
		
1306
 
1300
		model.addAttribute("startDate",currentDate.minusDays(30).toLocalDate());
1307
		model.addAttribute("startDate", currentDate.minusDays(30).toLocalDate());
1301
		model.addAttribute("endDate", LocalDate.now());
1308
		model.addAttribute("endDate", LocalDate.now());
1302
		model.addAttribute("focoSaleReportList", focoSaleReportList);
1309
		model.addAttribute("focoSaleReportList", focoSaleReportList);
1303
		return "foco-sale-report";
1310
		return "foco-sale-report";
1304
	}
1311
	}
1305
	
1312
 
1306
	@RequestMapping(value = "/downloadFranchiseeSales", method = RequestMethod.GET)
1313
	@RequestMapping(value = "/downloadFranchiseeSales", method = RequestMethod.GET)
1307
	public ResponseEntity<?> getdownloadFranchiseeSales(HttpServletRequest request,
1314
	public ResponseEntity<?> getdownloadFranchiseeSales(HttpServletRequest request,
1308
			@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
1315
			@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
1309
			@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
1316
			@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
1310
			throws Exception {
1317
			throws Exception {
Line 1342... Line 1349...
1342
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Franchisee Sales Report");
1349
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Franchisee Sales Report");
1343
 
1350
 
1344
		return responseEntity;
1351
		return responseEntity;
1345
 
1352
 
1346
	}
1353
	}
1347
	
1354
 
1348
	@RequestMapping(value = "/downloadWalletSummaryReport", method = RequestMethod.GET)
1355
	@RequestMapping(value = "/downloadWalletSummaryReport", method = RequestMethod.GET)
1349
	public ResponseEntity<?> getDownloadWalletSummaryReport(HttpServletRequest request,
1356
	public ResponseEntity<?> getDownloadWalletSummaryReport(HttpServletRequest request,
1350
			@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
1357
			@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
1351
			@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
1358
			@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
1352
			throws Exception {
1359
			throws Exception {
Line 1377... Line 1384...
1377
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Wallet Statement Report");
1384
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Wallet Statement Report");
1378
 
1385
 
1379
		return responseEntity;
1386
		return responseEntity;
1380
 
1387
 
1381
	}
1388
	}
1382
	
1389
 
1383
	@RequestMapping(value = "/walletSummaryReport", method = RequestMethod.GET)
1390
	@RequestMapping(value = "/walletSummaryReport", method = RequestMethod.GET)
1384
	public String getWalletSummaryReport(HttpServletRequest request,
1391
	public String getWalletSummaryReport(HttpServletRequest request, Model model) throws Exception {
1385
			Model model) throws Exception {
-
 
1386
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1392
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1387
	
-
 
1388
 
1393
 
1389
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1394
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1390
		LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
1395
		LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
1391
		
1396
 
-
 
1397
		List<WalletSummaryReportModel> walletSummartList = fofoOrderRepository
1392
		List<WalletSummaryReportModel> walletSummartList =fofoOrderRepository.selectWalletSummaryReport(fofoDetails.getFofoId(),currentStartMonth, currentDate);
1398
				.selectWalletSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1393
		LOGGER.info("walletSummartList {}", walletSummartList);
1399
		LOGGER.info("walletSummartList {}", walletSummartList);
1394
		
1400
 
1395
		model.addAttribute("startDate",currentDate.minusDays(30).toLocalDate());
1401
		model.addAttribute("startDate", currentDate.minusDays(30).toLocalDate());
1396
		model.addAttribute("endDate", LocalDate.now());
1402
		model.addAttribute("endDate", LocalDate.now());
1397
		model.addAttribute("walletSummartList", walletSummartList);
1403
		model.addAttribute("walletSummartList", walletSummartList);
1398
	
1404
 
1399
		return "wallet-summary-report";
1405
		return "wallet-summary-report";
1400
	}
1406
	}
1401
	
1407
 
1402
	@RequestMapping(value = "/pendingIndentReport", method = RequestMethod.GET)
1408
	@RequestMapping(value = "/pendingIndentReport", method = RequestMethod.GET)
1403
	public String getPendingIndentReport(HttpServletRequest request,
1409
	public String getPendingIndentReport(HttpServletRequest request, Model model) throws Exception {
1404
			Model model) throws Exception {
-
 
1405
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1410
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1406
	
-
 
1407
 
1411
 
1408
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1412
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1409
		LocalDateTime currentStartMonth = currentDate.minusMonths(2).toLocalDate().atStartOfDay();
1413
		LocalDateTime currentStartMonth = currentDate.minusMonths(2).toLocalDate().atStartOfDay();
1410
		
1414
 
-
 
1415
		List<PendingIndentReportModel> pendingIndentReports = fofoOrderRepository
1411
		List<PendingIndentReportModel> pendingIndentReports =fofoOrderRepository.selectPendingIndentReport(fofoDetails.getFofoId(),currentStartMonth, currentDate);
1416
				.selectPendingIndentReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1412
		LOGGER.info("pendingIndentReports {}", pendingIndentReports);
1417
		LOGGER.info("pendingIndentReports {}", pendingIndentReports);
1413
		
1418
 
1414
		model.addAttribute("startDate",currentDate.minusMonths(2).toLocalDate());
1419
		model.addAttribute("startDate", currentDate.minusMonths(2).toLocalDate());
1415
		model.addAttribute("endDate", LocalDate.now());
1420
		model.addAttribute("endDate", LocalDate.now());
1416
		model.addAttribute("pendingIndentReports", pendingIndentReports);
1421
		model.addAttribute("pendingIndentReports", pendingIndentReports);
1417
	
1422
 
1418
		return "pending-indent-report";
1423
		return "pending-indent-report";
1419
	}
1424
	}
1420
	
-
 
1421
	
1425
 
1422
	@RequestMapping(value = "/pendingIndentReportDownload", method = RequestMethod.GET)
1426
	@RequestMapping(value = "/pendingIndentReportDownload", method = RequestMethod.GET)
1423
	public ResponseEntity<?> getPendingIndentReportDownload(HttpServletRequest request,
1427
	public ResponseEntity<?> getPendingIndentReportDownload(HttpServletRequest request, Model model) throws Exception {
1424
			Model model) throws Exception {
-
 
1425
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1428
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1426
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1429
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1427
		LocalDateTime currentStartMonth = currentDate.minusMonths(2).toLocalDate().atStartOfDay();
1430
		LocalDateTime currentStartMonth = currentDate.minusMonths(2).toLocalDate().atStartOfDay();
1428
		List<List<?>> rows = new ArrayList<>();
1431
		List<List<?>> rows = new ArrayList<>();
-
 
1432
		List<PendingIndentReportModel> pendingIndentReports = fofoOrderRepository
1429
		List<PendingIndentReportModel> pendingIndentReports =fofoOrderRepository.selectPendingIndentReport(fofoDetails.getFofoId(),currentStartMonth, currentDate);
1433
				.selectPendingIndentReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1430
		LOGGER.info("pendingIndentReports {}", pendingIndentReports);
1434
		LOGGER.info("pendingIndentReports {}", pendingIndentReports);
1431
		
-
 
1432
      for( PendingIndentReportModel pir : pendingIndentReports) {
-
 
1433
 
1435
 
-
 
1436
		for (PendingIndentReportModel pir : pendingIndentReports) {
1434
     
1437
 
1435
			rows.add(Arrays.asList(pir.getTransactionId(),pir.getOrderId(),pir.getCreatTimestamp(),pir.getItemId()
1438
			rows.add(Arrays.asList(pir.getTransactionId(), pir.getOrderId(), pir.getCreatTimestamp(), pir.getItemId(),
1436
					,pir.getBrand(),pir.getModelName(),pir.getModelNumber(),pir.getColor(),pir.getQuantity()
1439
					pir.getBrand(), pir.getModelName(), pir.getModelNumber(), pir.getColor(), pir.getQuantity(),
1437
					,pir.getUnitPrice(),pir.getWalletAmount(),pir.getStatus(),pir.getInvoiceNumber(),
1440
					pir.getUnitPrice(), pir.getWalletAmount(), pir.getStatus(), pir.getInvoiceNumber(),
1438
					pir.getBillingTimestamp()));
1441
					pir.getBillingTimestamp()));
1439
			
1442
 
1440
		}
1443
		}
1441
      
-
 
1442
    
-
 
1443
		org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
-
 
1444
				.getCSVByteStream(Arrays.asList("Transaction Id", "Order Id","Created_At", "Item_Id", "Brand", "Model Name",
-
 
1445
						"Model Number", "Color"  ,"Quantity", "Unit Price", "Wallet Deduction", "Status", "Invoice Number", "Billing Timestamp"),rows);
-
 
1446
						
-
 
1447
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows,"Order Status Summary Report");
-
 
1448
 
1444
 
-
 
1445
		org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(Arrays.asList(
-
 
1446
				"Transaction Id", "Order Id", "Created_At", "Item_Id", "Brand", "Model Name", "Model Number", "Color",
-
 
1447
				"Quantity", "Unit Price", "Wallet Deduction", "Status", "Invoice Number", "Billing Timestamp"), rows);
1449
		
1448
 
-
 
1449
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Order Status Summary Report");
-
 
1450
 
1450
		return responseEntity;
1451
		return responseEntity;
1451
	}
1452
	}
1452
	
1453
 
1453
	@RequestMapping(value = "/schemePayoutReport", method = RequestMethod.GET)
1454
	@RequestMapping(value = "/schemePayoutReport", method = RequestMethod.GET)
1454
	public String getSchemePayoutReport(HttpServletRequest request,
1455
	public String getSchemePayoutReport(HttpServletRequest request, Model model) throws Exception {
1455
			Model model) throws Exception {
-
 
1456
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1456
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1457
	
-
 
1458
 
1457
 
1459
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1458
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1460
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1459
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1461
		
1460
 
-
 
1461
		List<SchemePayoutReportModel> schemePayoutReports = fofoOrderRepository
1462
		List<SchemePayoutReportModel> schemePayoutReports =fofoOrderRepository.selectSchemePayoutReport(fofoDetails.getFofoId(),currentStartMonth, currentDate);
1462
				.selectSchemePayoutReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1463
		LOGGER.info("schemePayoutReports {}", schemePayoutReports);
1463
		LOGGER.info("schemePayoutReports {}", schemePayoutReports);
1464
		
-
 
1465
		
-
 
1466
		
1464
 
1467
		model.addAttribute("startDate",currentDate.minusMonths(3).toLocalDate());
1465
		model.addAttribute("startDate", currentDate.minusMonths(3).toLocalDate());
1468
		model.addAttribute("endDate", LocalDate.now());
1466
		model.addAttribute("endDate", LocalDate.now());
1469
		model.addAttribute("schemePayoutReports", schemePayoutReports);
1467
		model.addAttribute("schemePayoutReports", schemePayoutReports);
1470
	
1468
 
1471
		return "scheme-payout-report";
1469
		return "scheme-payout-report";
1472
	}
1470
	}
-
 
1471
 
1473
	@RequestMapping(value = "/selectPartnerBillingSummaryReport", method = RequestMethod.GET)
1472
	@RequestMapping(value = "/selectPartnerBillingSummaryReport", method = RequestMethod.GET)
1474
	public String getselectPartnerBillingSummaryReport(HttpServletRequest request,
1473
	public String getselectPartnerBillingSummaryReport(HttpServletRequest request, Model model) throws Exception {
1475
			Model model) throws Exception {
-
 
1476
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1474
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1477
	
1475
 
1478
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1476
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1479
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1477
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1480
		
1478
 
-
 
1479
		List<PartnerBillingSummaryModel> partnerBillingSummaryReports = fofoOrderRepository
1481
		List<PartnerBillingSummaryModel> partnerBillingSummaryReports = fofoOrderRepository.selectPartnerBillingSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1480
				.selectPartnerBillingSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1482
		
1481
 
1483
		
-
 
1484
		model.addAttribute("startDate",currentDate.minusMonths(3).toLocalDate());
1482
		model.addAttribute("startDate", currentDate.minusMonths(3).toLocalDate());
1485
		model.addAttribute("endDate", LocalDate.now());
1483
		model.addAttribute("endDate", LocalDate.now());
1486
		model.addAttribute("partnerBillingSummaryReports", partnerBillingSummaryReports);
1484
		model.addAttribute("partnerBillingSummaryReports", partnerBillingSummaryReports);
1487
		
1485
 
1488
		return "partner-billing-summary-report";
1486
		return "partner-billing-summary-report";
1489
	}
1487
	}
1490
	
1488
 
1491
	@RequestMapping(value = "/priceDropReport", method = RequestMethod.GET)
1489
	@RequestMapping(value = "/priceDropReport", method = RequestMethod.GET)
1492
	public String getSelectPriceDropReport(HttpServletRequest request,
1490
	public String getSelectPriceDropReport(HttpServletRequest request, Model model) throws Exception {
1493
			Model model) throws Exception {
-
 
1494
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1491
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1495
	
1492
 
1496
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1493
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1497
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1494
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1498
		
1495
 
1499
		List<PriceDropReportModel> priceDropReports = orderRepository.selectPriceDropReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1496
		List<PriceDropReportModel> priceDropReports = orderRepository.selectPriceDropReport(fofoDetails.getFofoId(),
-
 
1497
				currentStartMonth, currentDate);
1500
		
1498
 
1501
		model.addAttribute("startDate",currentDate.minusMonths(3).toLocalDate());
1499
		model.addAttribute("startDate", currentDate.minusMonths(3).toLocalDate());
1502
		model.addAttribute("endDate", LocalDate.now());
1500
		model.addAttribute("endDate", LocalDate.now());
1503
		model.addAttribute("priceDropReports", priceDropReports);
1501
		model.addAttribute("priceDropReports", priceDropReports);
1504
		
1502
 
1505
		return "price-drop-report";
1503
		return "price-drop-report";
1506
	}
1504
	}
1507
	
1505
 
1508
	@RequestMapping(value = "/downloadPriceDropReport", method = RequestMethod.GET)
1506
	@RequestMapping(value = "/downloadPriceDropReport", method = RequestMethod.GET)
1509
	public  ResponseEntity<?> getSelectDownloadPriceDropReport(HttpServletRequest request,
1507
	public ResponseEntity<?> getSelectDownloadPriceDropReport(HttpServletRequest request, Model model)
1510
			Model model) throws Exception {
1508
			throws Exception {
1511
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1509
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1512
	
1510
 
1513
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1511
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1514
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1512
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1515
		List<List<?>> rows = new ArrayList<>();
1513
		List<List<?>> rows = new ArrayList<>();
1516
		List<PriceDropReportModel> priceDropReports = orderRepository.selectPriceDropReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1514
		List<PriceDropReportModel> priceDropReports = orderRepository.selectPriceDropReport(fofoDetails.getFofoId(),
-
 
1515
				currentStartMonth, currentDate);
1517
		
1516
 
1518
     for (PriceDropReportModel pdr : priceDropReports) {
1517
		for (PriceDropReportModel pdr : priceDropReports) {
1519
			
1518
 
1520
			rows.add(Arrays.asList(pdr.getCode(), pdr.getId(), pdr.getBrand(),pdr.getModelName(),
1519
			rows.add(Arrays.asList(pdr.getCode(), pdr.getId(), pdr.getBrand(), pdr.getModelName(), pdr.getModelNumber(),
1521
					pdr.getModelNumber(), pdr.getAffectedOn() ,pdr.getAmount(), pdr.getPartnerPayout(),
1520
					pdr.getAffectedOn(), pdr.getAmount(), pdr.getPartnerPayout(), pdr.getImei(), pdr.getStatus(),
1522
					pdr.getImei(), pdr.getStatus(),pdr.getUpdateTimestamp(),pdr.getRejectionReason()));
1521
					pdr.getUpdateTimestamp(), pdr.getRejectionReason()));
1523
 
1522
 
1524
		}
1523
		}
1525
		org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
1524
		org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
1526
				.getCSVByteStream(Arrays.asList("code","Price_Drop_Id","brand","model_name","model_number"
1525
				.getCSVByteStream(Arrays.asList("code", "Price_Drop_Id", "brand", "model_name", "model_number",
1527
						,"affected_on","amount", "partner_payout", "Imei", "status","processed_on"
1526
						"affected_on", "amount", "partner_payout", "Imei", "status", "processed_on", "Reason"), rows);
1528
						  ,  "Reason"), rows);
-
 
1529
 
1527
 
1530
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "price drop report");
1528
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "price drop report");
1531
 
1529
 
1532
		return responseEntity;
1530
		return responseEntity;
1533
		
1531
 
1534
	}
1532
	}
1535
	
-
 
1536
	
1533
 
1537
	@RequestMapping(value = "/downloadPartnerBillingSummaryReport", method = RequestMethod.GET)
1534
	@RequestMapping(value = "/downloadPartnerBillingSummaryReport", method = RequestMethod.GET)
1538
	public ResponseEntity<?> getdownloadPartnerBillingSummaryReport(HttpServletRequest request,
1535
	public ResponseEntity<?> getdownloadPartnerBillingSummaryReport(HttpServletRequest request,
1539
			@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
1536
			@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
1540
			@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
1537
			@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
1541
			throws Exception {
1538
			throws Exception {
1542
 
1539
 
1543
		List<List<?>> rows = new ArrayList<>();
1540
		List<List<?>> rows = new ArrayList<>();
1544
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1541
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1545
		
1542
 
1546
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1543
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1547
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1544
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1548
		
1545
 
-
 
1546
		List<PartnerBillingSummaryModel> partnerBillingSummaryReports = fofoOrderRepository
1549
		List<PartnerBillingSummaryModel> partnerBillingSummaryReports = fofoOrderRepository.selectPartnerBillingSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1547
				.selectPartnerBillingSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1550
	
1548
 
1551
		for (PartnerBillingSummaryModel pbsr : partnerBillingSummaryReports) {
1549
		for (PartnerBillingSummaryModel pbsr : partnerBillingSummaryReports) {
1552
			
1550
 
1553
			rows.add(Arrays.asList(pbsr.getId(), pbsr.getCreateTimestamp(), pbsr.getBillingTimestamp(),pbsr.getDeliveryTimestamp(),
1551
			rows.add(Arrays.asList(pbsr.getId(), pbsr.getCreateTimestamp(), pbsr.getBillingTimestamp(),
1554
					pbsr.getDeliveryTimestamp(), pbsr.getPartnerGrnTimestamp() ,pbsr.getTransactionId(), pbsr.getLogisticsTransactionId(),
1552
					pbsr.getDeliveryTimestamp(), pbsr.getDeliveryTimestamp(), pbsr.getPartnerGrnTimestamp(),
-
 
1553
					pbsr.getTransactionId(), pbsr.getLogisticsTransactionId(), pbsr.getAirwayBillNumber(),
1555
					pbsr.getAirwayBillNumber(), pbsr.getStatusSubGroup(), pbsr.getStatusName(),pbsr.getRetailerId(), pbsr.getRetailerName(),pbsr.getItemId(), pbsr.getBrand()
1554
					pbsr.getStatusSubGroup(), pbsr.getStatusName(), pbsr.getRetailerId(), pbsr.getRetailerName(),
1556
					         , pbsr.getModelName(),  pbsr.getModelNumber(),pbsr.getColor(),pbsr.getUnitPrice(), pbsr.getQuantity(),
1555
					pbsr.getItemId(), pbsr.getBrand(), pbsr.getModelName(), pbsr.getModelNumber(), pbsr.getColor(),
-
 
1556
					pbsr.getUnitPrice(), pbsr.getQuantity(), pbsr.getTotalPrice(), pbsr.getInvoiceNumber(),
1557
					          pbsr.getTotalPrice(),pbsr.getInvoiceNumber(), pbsr.getIgstRate(),pbsr.getCgstRate(),pbsr.getSgstRate()));
1557
					pbsr.getIgstRate(), pbsr.getCgstRate(), pbsr.getSgstRate()));
1558
 
1558
 
1559
		}
1559
		}
1560
 
1560
 
1561
		org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
1561
		org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(Arrays.asList("OrderId",
1562
				.getCSVByteStream(Arrays.asList("OrderId","CREATION_DATE","BILLING_DATE","DELIVERED_ON","SCANNED_IN_ON"
1562
				"CREATION_DATE", "BILLING_DATE", "DELIVERED_ON", "SCANNED_IN_ON", "Transaction_id", "master_order_id",
1563
						,"Transaction_id","master_order_id", "airwaybill_no", "statusSubGroupp", "statusName","customer_id"
1563
				"airwaybill_no", "statusSubGroupp", "statusName", "customer_id", "customer_name", "Item_Id", "brand",
1564
						  ,  "customer_name","Item_Id", "brand", "model_name",  "model_number" ,"color", "selling_price"
1564
				"model_name", "model_number", "color", "selling_price", "Quantity", "total_price", "invoice_number",
1565
						                 ,"Quantity","total_price","invoice_number","igstrate","cgstrate","sgstrate"), rows);
1565
				"igstrate", "cgstrate", "sgstrate"), rows);
1566
 
1566
 
1567
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Billing Statement Report");
1567
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Billing Statement Report");
1568
 
1568
 
1569
		return responseEntity;
1569
		return responseEntity;
1570
 
1570
 
1571
	}
1571
	}
1572
	
1572
 
1573
	@RequestMapping(value = "/invoiceSchemeOutSummaryReport", method = RequestMethod.GET)
1573
	@RequestMapping(value = "/invoiceSchemeOutSummaryReport", method = RequestMethod.GET)
1574
	public String getInvoiceSchemeOutSummaryReport(HttpServletRequest request,
1574
	public String getInvoiceSchemeOutSummaryReport(HttpServletRequest request, Model model) throws Exception {
1575
			Model model) throws Exception {
-
 
1576
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1575
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1577
	
-
 
1578
 
1576
 
1579
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1577
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1580
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1578
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1581
		
1579
 
-
 
1580
		List<FocoSchemeOutReportModel> focoSchemeOutReports = fofoOrderRepository
1582
		List<FocoSchemeOutReportModel> focoSchemeOutReports =fofoOrderRepository.selectInvoiceSchemeOutSummaryReport(fofoDetails.getFofoId(),currentStartMonth, currentDate);
1581
				.selectInvoiceSchemeOutSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1583
		LOGGER.info("focoSchemeOutReportModel {}", focoSchemeOutReports);
1582
		LOGGER.info("focoSchemeOutReportModel {}", focoSchemeOutReports);
1584
		
-
 
1585
		
-
 
1586
		
1583
 
1587
		model.addAttribute("startDate",currentDate.minusMonths(3).toLocalDate());
1584
		model.addAttribute("startDate", currentDate.minusMonths(3).toLocalDate());
1588
		model.addAttribute("endDate", LocalDate.now());
1585
		model.addAttribute("endDate", LocalDate.now());
1589
		model.addAttribute("focoSchemeOutReports", focoSchemeOutReports);
1586
		model.addAttribute("focoSchemeOutReports", focoSchemeOutReports);
1590
	
1587
 
1591
		return "invoicewise-scheme-out-report";
1588
		return "invoicewise-scheme-out-report";
1592
	}
1589
	}
1593
	
1590
 
1594
	@RequestMapping(value = "/downloadInvoiceSchemeOutSummaryReport", method = RequestMethod.GET)
1591
	@RequestMapping(value = "/downloadInvoiceSchemeOutSummaryReport", method = RequestMethod.GET)
1595
	public ResponseEntity<?> getDownloadInvoiceSchemeOutSummaryReport(HttpServletRequest request,
1592
	public ResponseEntity<?> getDownloadInvoiceSchemeOutSummaryReport(HttpServletRequest request, Model model)
1596
			Model model) throws Exception {
1593
			throws Exception {
1597
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1594
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1598
	
1595
 
1599
		List<List<?>> rows = new ArrayList<>();
1596
		List<List<?>> rows = new ArrayList<>();
1600
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1597
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1601
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1598
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1602
		
1599
 
-
 
1600
		List<FocoSchemeOutReportModel> focoSchemeOutReports = fofoOrderRepository
1603
		List<FocoSchemeOutReportModel> focoSchemeOutReports =fofoOrderRepository.selectInvoiceSchemeOutSummaryReport(fofoDetails.getFofoId(),currentStartMonth, currentDate);
1601
				.selectInvoiceSchemeOutSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1604
		LOGGER.info("focoSchemeOutReportModel {}", focoSchemeOutReports);
1602
		LOGGER.info("focoSchemeOutReportModel {}", focoSchemeOutReports);
1605
		
1603
 
1606
		for( FocoSchemeOutReportModel  fsor : focoSchemeOutReports) {
1604
		for (FocoSchemeOutReportModel fsor : focoSchemeOutReports) {
1607
			rows.add(Arrays.asList(fsor.getInvoiceNumber(),fsor.getQuantity(),fsor.getBrand(),fsor.getModelName()
1605
			rows.add(Arrays.asList(fsor.getInvoiceNumber(), fsor.getQuantity(), fsor.getBrand(), fsor.getModelName(),
1608
					,fsor.getModelNumber(),fsor.getColor(),fsor.getAmount()));
1606
					fsor.getModelNumber(), fsor.getColor(), fsor.getAmount()));
1609
			
1607
 
1610
		}
1608
		}
1611
	
1609
 
1612
		org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
1610
		org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
1613
				.getCSVByteStream(Arrays.asList("InvoiceNumber", "Quantity","Brand", "Model Name", "Model Number", 
1611
				Arrays.asList("InvoiceNumber", "Quantity", "Brand", "Model Name", "Model Number", "Color", "Amount"),
1614
						 "Color"  ,"Amount"),rows);
1612
				rows);
1615
						
1613
 
1616
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "invoice wise scheme out Summary Report");
1614
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows,
-
 
1615
				"invoice wise scheme out Summary Report");
1617
 
1616
 
1618
		return responseEntity;
1617
		return responseEntity;
1619
	}
1618
	}
1620
	
1619
 
1621
	@RequestMapping(value = "/schemePayoutReportDownload", method = RequestMethod.GET)
1620
	@RequestMapping(value = "/schemePayoutReportDownload", method = RequestMethod.GET)
1622
	public ResponseEntity<?> getSchemePayoutReportDownload(HttpServletRequest request,
1621
	public ResponseEntity<?> getSchemePayoutReportDownload(HttpServletRequest request, Model model) throws Exception {
1623
			Model model) throws Exception {
-
 
1624
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1622
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
1625
	
1623
 
1626
		List<List<?>> rows = new ArrayList<>();
1624
		List<List<?>> rows = new ArrayList<>();
1627
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1625
		LocalDateTime currentDate = LocalDate.now().atStartOfDay();
1628
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1626
		LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
1629
		
1627
 
-
 
1628
		List<SchemePayoutReportModel> schemePayoutReports = fofoOrderRepository
1630
		List<SchemePayoutReportModel> schemePayoutReports =fofoOrderRepository.selectSchemePayoutReport(fofoDetails.getFofoId(),currentStartMonth, currentDate);
1629
				.selectSchemePayoutReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
1631
		LOGGER.info("schemePayoutReports {}", schemePayoutReports);
1630
		LOGGER.info("schemePayoutReports {}", schemePayoutReports);
1632
	
-
 
1633
	
-
 
1634
		 for( SchemePayoutReportModel spr : schemePayoutReports) {
-
 
1635
			
-
 
1636
				rows.add(Arrays.asList(spr.getId(),spr.getSerialNumber(),spr.getBrand(),spr.getModelName()
-
 
1637
						,spr.getModelNumber(),spr.getColor(),spr.getSchemeInDp(),spr.getSchemeOutDp(),
-
 
1638
						spr.getSchemeId(),spr.getName(),spr.getType(),spr.getAmountType(),spr.getPurchaseReference()
-
 
1639
						,spr.getInvoiceNumber(),spr.getSioAmount(),spr.getStatus(),spr.getStatusDescription()
-
 
1640
						,spr.getCreateTimestamp(),spr.getRolledBackTimestamp()));
-
 
1641
				
-
 
1642
			}
-
 
1643
			org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
-
 
1644
					.getCSVByteStream(Arrays.asList("Item_Id", "serial_number","Brand", "Model Name", "Model Number", 
-
 
1645
							 "Color"  ,"Scheme_IN_DP", "Scheme_out_dp", "Scheme_Id", "Name", "Type", "amount", "Purchase_Invoice",
-
 
1646
							 "SALE_INOVOICE","Amount","status","description","create_timestamp","rolled_back_timestamp"),rows);
-
 
1647
							
-
 
1648
			ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Scheme Payout Summary Report");
-
 
1649
 
1631
 
-
 
1632
		for (SchemePayoutReportModel spr : schemePayoutReports) {
-
 
1633
 
-
 
1634
			rows.add(Arrays.asList(spr.getId(), spr.getSerialNumber(), spr.getBrand(), spr.getModelName(),
-
 
1635
					spr.getModelNumber(), spr.getColor(), spr.getSchemeInDp(), spr.getSchemeOutDp(), spr.getSchemeId(),
-
 
1636
					spr.getName(), spr.getType(), spr.getAmountType(), spr.getPurchaseReference(),
-
 
1637
					spr.getInvoiceNumber(), spr.getSioAmount(), spr.getStatus(), spr.getStatusDescription(),
-
 
1638
					spr.getCreateTimestamp(), spr.getRolledBackTimestamp()));
-
 
1639
 
1650
			
1640
		}
-
 
1641
		org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(Arrays.asList("Item_Id",
-
 
1642
				"serial_number", "Brand", "Model Name", "Model Number", "Color", "Scheme_IN_DP", "Scheme_out_dp",
-
 
1643
				"Scheme_Id", "Name", "Type", "amount", "Purchase_Invoice", "SALE_INOVOICE", "Amount", "status",
-
 
1644
				"description", "create_timestamp", "rolled_back_timestamp"), rows);
-
 
1645
 
-
 
1646
		ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Scheme Payout Summary Report");
-
 
1647
 
1651
			return responseEntity;
1648
		return responseEntity;
1652
	}
1649
	}
1653
	
-
 
1654
	
1650
 
1655
	@GetMapping("/getAllOnlineOrder")
1651
	@GetMapping("/getAllOnlineOrder")
1656
	public String getAllOrders(HttpServletRequest request, @RequestParam(required = false) LocalDate date, Model model)
1652
	public String getAllOrders(HttpServletRequest request, @RequestParam(required = false) LocalDate date, Model model)
1657
			throws ProfitMandiBusinessException {
1653
			throws ProfitMandiBusinessException {
1658
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1654
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1659
		boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
1655
		boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
Line 1663... Line 1659...
1663
 
1659
 
1664
		LOGGER.info("date" + date);
1660
		LOGGER.info("date" + date);
1665
		List<Integer> fofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId())
1661
		List<Integer> fofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId())
1666
				.collect(Collectors.toList());
1662
				.collect(Collectors.toList());
1667
 
1663
 
1668
		Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
1664
		Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
-
 
1665
 
-
 
1666
		Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x))
-
 
1667
				.filter(x -> x != null).collect(Collectors.toList()).stream()
-
 
1668
				.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
1669
 
1669
		model.addAttribute("customRetailersMap", customRetailersMap);
1670
		model.addAttribute("customRetailersMap", customRetailersMap);
1670
 
1671
 
1671
		List<PendingOrderItem> pendingOrderItem = null;
1672
		List<PendingOrderItem> pendingOrderItem = null;
1672
 
1673
 
1673
		pendingOrderItem = pendingOrderItemRepository.selectAll(date.atStartOfDay(), LocalDateTime.now());
1674
		pendingOrderItem = pendingOrderItemRepository.selectAll(date.atStartOfDay(), LocalDateTime.now());