Subversion Repositories SmartDukaan

Rev

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

Rev 25363 Rev 25371
Line 22... Line 22...
22
import javax.servlet.http.HttpServletRequest;
22
import javax.servlet.http.HttpServletRequest;
23
import javax.servlet.http.HttpServletResponse;
23
import javax.servlet.http.HttpServletResponse;
24
 
24
 
25
import org.apache.logging.log4j.LogManager;
25
import org.apache.logging.log4j.LogManager;
26
import org.apache.logging.log4j.Logger;
26
import org.apache.logging.log4j.Logger;
-
 
27
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
-
 
28
import org.apache.poi.xssf.usermodel.XSSFRow;
-
 
29
import org.apache.poi.xssf.usermodel.XSSFSheet;
-
 
30
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
27
import org.apache.thrift.TException;
31
import org.apache.thrift.TException;
28
import org.json.JSONObject;
32
import org.json.JSONObject;
29
import org.springframework.beans.factory.annotation.Autowired;
33
import org.springframework.beans.factory.annotation.Autowired;
30
import org.springframework.beans.factory.annotation.Qualifier;
34
import org.springframework.beans.factory.annotation.Qualifier;
31
import org.springframework.beans.factory.annotation.Value;
35
import org.springframework.beans.factory.annotation.Value;
Line 41... Line 45...
41
import org.springframework.ui.Model;
45
import org.springframework.ui.Model;
42
import org.springframework.web.bind.annotation.RequestBody;
46
import org.springframework.web.bind.annotation.RequestBody;
43
import org.springframework.web.bind.annotation.RequestMapping;
47
import org.springframework.web.bind.annotation.RequestMapping;
44
import org.springframework.web.bind.annotation.RequestMethod;
48
import org.springframework.web.bind.annotation.RequestMethod;
45
import org.springframework.web.bind.annotation.RequestParam;
49
import org.springframework.web.bind.annotation.RequestParam;
-
 
50
import org.springframework.web.bind.annotation.RequestPart;
-
 
51
import org.springframework.web.multipart.MultipartFile;
46
 
52
 
47
import com.google.gson.Gson;
53
import com.google.gson.Gson;
48
import com.spice.profitmandi.common.enumuration.SearchType;
54
import com.spice.profitmandi.common.enumuration.SearchType;
49
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
55
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
50
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
56
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
Line 60... Line 66...
60
import com.spice.profitmandi.common.util.PdfUtils;
66
import com.spice.profitmandi.common.util.PdfUtils;
61
import com.spice.profitmandi.common.util.Utils;
67
import com.spice.profitmandi.common.util.Utils;
62
import com.spice.profitmandi.dao.entity.catalog.Item;
68
import com.spice.profitmandi.dao.entity.catalog.Item;
63
import com.spice.profitmandi.dao.entity.catalog.TagListing;
69
import com.spice.profitmandi.dao.entity.catalog.TagListing;
64
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
70
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
-
 
71
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
65
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaigns;
72
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaigns;
-
 
73
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
-
 
74
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
66
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
75
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
67
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
76
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
68
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
77
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
69
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
78
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
70
import com.spice.profitmandi.dao.entity.transaction.NotifyColorChange;
79
import com.spice.profitmandi.dao.entity.transaction.NotifyColorChange;
71
import com.spice.profitmandi.dao.entity.transaction.NotifyItem;
80
import com.spice.profitmandi.dao.entity.transaction.NotifyItem;
72
import com.spice.profitmandi.dao.entity.transaction.NotifyMessage;
81
import com.spice.profitmandi.dao.entity.transaction.NotifyMessage;
73
import com.spice.profitmandi.dao.entity.transaction.NotifyOrder;
82
import com.spice.profitmandi.dao.entity.transaction.NotifyOrder;
74
import com.spice.profitmandi.dao.entity.transaction.Order;
83
import com.spice.profitmandi.dao.entity.transaction.Order;
-
 
84
import com.spice.profitmandi.dao.entity.user.Device;
75
import com.spice.profitmandi.dao.entity.user.User;
85
import com.spice.profitmandi.dao.entity.user.User;
-
 
86
import com.spice.profitmandi.dao.model.SimpleCampaign;
-
 
87
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
-
 
88
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
76
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
89
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
77
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
90
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
78
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
91
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
79
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
92
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
80
import com.spice.profitmandi.dao.repository.dtr.Mongo;
93
import com.spice.profitmandi.dao.repository.dtr.Mongo;
-
 
94
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
-
 
95
import com.spice.profitmandi.dao.repository.dtr.PushNotificationRepository;
81
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
96
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
-
 
97
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
82
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
98
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
83
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
99
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
84
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
100
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
85
import com.spice.profitmandi.dao.repository.inventory.NotifyStatus;
101
import com.spice.profitmandi.dao.repository.inventory.NotifyStatus;
86
import com.spice.profitmandi.dao.repository.transaction.NotifyColorChangeRepository;
102
import com.spice.profitmandi.dao.repository.transaction.NotifyColorChangeRepository;
Line 172... Line 188...
172
 
188
 
173
	@Autowired
189
	@Autowired
174
	JavaMailSender mailSender;
190
	JavaMailSender mailSender;
175
 
191
 
176
	@Autowired
192
	@Autowired
-
 
193
	private NotificationCampaignRepository notificationCampaignRepository;
-
 
194
 
-
 
195
	@Autowired
-
 
196
	private DeviceRepository deviceRepository;
-
 
197
 
-
 
198
	@Autowired
177
	private Mongo mongoClient;
199
	private Mongo mongoClient;
178
 
200
 
-
 
201
	@Autowired
-
 
202
	private PushNotificationRepository pushNotificationRepository;
-
 
203
 
-
 
204
	@Autowired
-
 
205
	private UserCampaignRepository userCampaignRepository;
-
 
206
 
-
 
207
	@Autowired
-
 
208
	private Gson gson;
-
 
209
 
179
	@RequestMapping(value = "/getCurrentInventorySnapshot")
210
	@RequestMapping(value = "/getCurrentInventorySnapshot")
180
	public String getCurrentAvailability(HttpServletRequest request,
211
	public String getCurrentAvailability(HttpServletRequest request,
181
			@RequestParam(name = "offset", defaultValue = "0") int offset,
212
			@RequestParam(name = "offset", defaultValue = "0") int offset,
182
			@RequestParam(name = "limit", defaultValue = "10") int limit,
213
			@RequestParam(name = "limit", defaultValue = "10") int limit,
183
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
214
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
Line 335... Line 366...
335
		final HttpHeaders headers = new HttpHeaders();
366
		final HttpHeaders headers = new HttpHeaders();
336
		headers.setContentType(MediaType.APPLICATION_PDF);
367
		headers.setContentType(MediaType.APPLICATION_PDF);
337
		headers.set("Content-disposition", "inline; filename=invoices.pdf");
368
		headers.set("Content-disposition", "inline; filename=invoices.pdf");
338
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
369
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
339
		List<PdfModel> pdfModels = new ArrayList<>();
370
		List<PdfModel> pdfModels = new ArrayList<>();
-
 
371
		/*
340
		/*for (FofoOrder fofoOrder : fofoOrders) {
372
		 * for (FofoOrder fofoOrder : fofoOrders) { try {
341
			try {
-
 
342
				pdfModels.add(orderService.getInvoicePdfModel(fofoOrder.getId()));
373
		 * pdfModels.add(orderService.getInvoicePdfModel(fofoOrder.getId())); } catch
343
			} catch (Exception e) {
374
		 * (Exception e) {
344
				LOGGER.info("could not create invoice for {}, invoice number {}", fofoOrder.getId(),
375
		 * LOGGER.info("could not create invoice for {}, invoice number {}",
345
						fofoOrder.getInvoiceNumber());
376
		 * fofoOrder.getId(), fofoOrder.getInvoiceNumber()); } }
346
			}
-
 
347
		}*/
377
		 */
348
		PdfUtils.generateAndWrite(pdfModels, byteArrayOutputStream);
378
		PdfUtils.generateAndWrite(pdfModels, byteArrayOutputStream);
349
		headers.setContentLength(byteArrayOutputStream.toByteArray().length);
379
		headers.setContentLength(byteArrayOutputStream.toByteArray().length);
350
		final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
380
		final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
351
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
381
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
352
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
382
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
Line 428... Line 458...
428
		// return
458
		// return
429
		// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
459
		// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
430
	}
460
	}
431
 
461
 
432
	@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
462
	@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
433
	public String FeaturePanel(HttpServletRequest request,Model model) throws Exception {
463
	public String FeaturePanel(HttpServletRequest request, Model model) throws Exception {
434
 
464
 
435
		List<TagRanking> tagRanking = null;
465
		List<TagRanking> tagRanking = null;
436
		tagRanking = tagRankingRepository.getAllTagRanking();
466
		tagRanking = tagRankingRepository.getAllTagRanking();
437
		LOGGER.info("tagRanking" + tagRanking);
467
		LOGGER.info("tagRanking" + tagRanking);
438
		if (!tagRanking.isEmpty()) {
468
		if (!tagRanking.isEmpty()) {
439
            Set<Integer> catalogIds = tagRanking.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
469
			Set<Integer> catalogIds = tagRanking.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
440
			List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
470
			List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
441
			Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
471
			Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
442
					x -> x.getItemDescription(), (description1, description2) -> description1));
472
					x -> x.getItemDescription(), (description1, description2) -> description1));
443
 
473
 
444
			LOGGER.info("catalogDescription" + catalogDescription);
474
			LOGGER.info("catalogDescription" + catalogDescription);
Line 477... Line 507...
477
	 * "feature-paginated"; }
507
	 * "feature-paginated"; }
478
	 */
508
	 */
479
	@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
509
	@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
480
	public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel,
510
	public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel,
481
			Model model) throws Exception {
511
			Model model) throws Exception {
482
        TagRanking tagRanking = tagRankingRepository.selectBycatalogItemId(itemFeatureDatatModel.getCatalogItemId());
512
		TagRanking tagRanking = tagRankingRepository.selectBycatalogItemId(itemFeatureDatatModel.getCatalogItemId());
483
        LOGGER.info("tagRanking" + tagRanking);
513
		LOGGER.info("tagRanking" + tagRanking);
484
        if(tagRanking == null) {
514
		if (tagRanking == null) {
485
		tagRanking = new TagRanking();
515
			tagRanking = new TagRanking();
486
		tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
516
			tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
487
		}
517
		}
488
		tagRanking.setFeature(itemFeatureDatatModel.getFeature());
518
		tagRanking.setFeature(itemFeatureDatatModel.getFeature());
489
		tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
519
		tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
490
		
520
 
491
		tagRankingRepository.persist(tagRanking);
521
		tagRankingRepository.persist(tagRanking);
492
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
522
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
493
		return "response";
523
		return "response";
494
	}
524
	}
495
 
525
 
Line 524... Line 554...
524
 
554
 
525
			Set<String> serial = new HashSet<>();
555
			Set<String> serial = new HashSet<>();
526
			for (InventoryItem invItem : inventoryItem) {
556
			for (InventoryItem invItem : inventoryItem) {
527
				if (!serailNumberList.contains(invItem.getSerialNumber())) {
557
				if (!serailNumberList.contains(invItem.getSerialNumber())) {
528
					inventoryItem1.add(invItem);
558
					inventoryItem1.add(invItem);
-
 
559
 
529
				}
560
				}
530
 
561
 
531
			}
562
			}
532
 
563
 
533
			LOGGER.info("inventoyItem" + inventoryItem1);
564
			LOGGER.info("inventoyItem" + inventoryItem1);
534
			model.addAttribute("customRetailers", customRetailers);
565
			model.addAttribute("customRetailers", customRetailers);
535
			model.addAttribute("liveDemo", inventoryItem1);
-
 
536
 
566
 
-
 
567
			model.addAttribute("liveDemo", inventoryItem1);
537
			CustomRetailer fofoIdsAndRetailerName = retailerService.getFofoRetailer(fofoId);
568
			CustomRetailer fofoIdsAndRetailerName = retailerService.getFofoRetailer(fofoId);
538
 
569
 
539
			model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
570
			model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
540
 
571
 
541
		}
572
		}
Line 652... Line 683...
652
		// User userInfo = saholicUserRepository.selectById(loginDetails.getFofoId());
683
		// User userInfo = saholicUserRepository.selectById(loginDetails.getFofoId());
653
		LOGGER.info("status" + orderStatus);
684
		LOGGER.info("status" + orderStatus);
654
		try {
685
		try {
655
			Order order = orderRepository.selectById(orderId);
686
			Order order = orderRepository.selectById(orderId);
656
			orderRepository.refundOrder(orderId, loginDetails.getEmailId(), reason, orderStatus);
687
			orderRepository.refundOrder(orderId, loginDetails.getEmailId(), reason, orderStatus);
657
			
688
 
658
			sendCancellationNotificationToPartner(order, reason);
689
			sendCancellationNotificationToPartner(order, reason);
659
			model.addAttribute("response", mvcResponseSender.createResponseString(true));
690
			model.addAttribute("response", mvcResponseSender.createResponseString(true));
660
 
691
 
661
		} catch (TransactionServiceException | TException e) {
692
		} catch (TransactionServiceException | TException e) {
662
			model.addAttribute("response", mvcResponseSender.createResponseString(false));
693
			model.addAttribute("response", mvcResponseSender.createResponseString(false));
Line 665... Line 696...
665
		return "response";
696
		return "response";
666
	}
697
	}
667
 
698
 
668
	private void sendCancellationNotificationToPartner(Order order, String reason) throws Exception {
699
	private void sendCancellationNotificationToPartner(Order order, String reason) throws Exception {
669
		Item item = itemRepository.selectById(order.getLineItem().getItemId());
700
		Item item = itemRepository.selectById(order.getLineItem().getItemId());
-
 
701
		
670
		NotificationCampaigns notification = new NotificationCampaigns();
702
		SimpleCampaignParams scp = new SimpleCampaignParams();
671
		notification.setName("Order Cancellation");
-
 
672
 
-
 
673
		notification.setTitle(String.format("Order %s %d(Pcs) cancelled", item.getItemDescription(),
703
		scp.setTitle(String.format("Order %s %d(Pcs) cancelled", item.getItemDescription(),
674
				order.getLineItem().getQuantity()));
704
				order.getLineItem().getQuantity()));
675
 
-
 
676
		notification.setMessage(reason);
705
		scp.setMessage(reason);
677
		notification.setType("url");
706
		scp.setType("url");
678
		notification.setUrl("http://app.profitmandi.com/pages/home/notifications");
707
		scp.setUrl("http://app.profitmandi.com/pages/home/notifyOrder");
-
 
708
		scp.setExpireTimestamp(LocalDateTime.now().plusDays(2));
-
 
709
		SimpleCampaign sc = new SimpleCampaign(scp);
-
 
710
		sc.setSimpleCampaignParams(scp);
679
 
711
 
680
		notification.setSql("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
712
		NotificationCampaign nc = new NotificationCampaign();
-
 
713
		nc.setName("Order Cancellation");
-
 
714
		nc.setImplementationType("SimpleCampaign");
-
 
715
		nc.setImplementationParams(gson.toJson(scp));
681
				+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
716
		nc.setCreatedTimestamp(LocalDateTime.now());
682
				+ " where d2.id is null and d1.user_id = "
717
		notificationCampaignRepository.persist(nc);
-
 
718
 
683
				+ userAccountRepository.selectUserIdByRetailerId(order.getRetailerId()));
719
		int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
684
		notification.setExpiresat(LocalDateTime.now().plusDays(2).toEpochSecond(ZoneOffset.UTC) * 1000);
720
		UserCampaign uc = new UserCampaign();
685
		notification.setStatus("active");
721
		uc.setCampaignId(nc.getId());
686
		notification.setSmsprocessed(0);
722
		uc.setUserId(userId);
-
 
723
		uc.setPushTimestamp(LocalDateTime.now());
687
		notification.setNotification_processed(0);
724
		userCampaignRepository.persist(uc);
-
 
725
		List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(userId,
688
		notification.setNotification_type("GENERAL_NOTIFICATION");
726
				LocalDateTime.now().minusMonths(3), LocalDateTime.now());
689
		mongoClient.persistNotificationCmpInfo(notification);
727
		pushNotification(nc.getId(), devices);
690
 
728
 
691
	}
729
	}
692
 
730
 
693
	@RequestMapping(value = "/getNotifyItemColor", method = RequestMethod.GET)
731
	@RequestMapping(value = "/getNotifyItemColor", method = RequestMethod.GET)
694
	public String getNotifyItemColor(HttpServletRequest request, @RequestParam int catalogItemId,
732
	public String getNotifyItemColor(HttpServletRequest request, @RequestParam int catalogItemId,
Line 783... Line 821...
783
		for (Order order : orders) {
821
		for (Order order : orders) {
784
			LOGGER.info("order" + order.getId());
822
			LOGGER.info("order" + order.getId());
785
 
823
 
786
			NotifyMessage message = notifyMessageRepository.selectByNotifyId(notifytimestamp.getId());
824
			NotifyMessage message = notifyMessageRepository.selectByNotifyId(notifytimestamp.getId());
787
 
825
 
-
 
826
			SimpleCampaignParams scp = new SimpleCampaignParams();
788
			// LOGGER.info("message112" + message.getNotifyMessages());
827
			scp.setMessage(message.getNotifyMessages());
-
 
828
			scp.setTitle("Notify Partner");
-
 
829
			scp.setType("url");
-
 
830
			scp.setUrl("http://app.profitmandi.com/pages/home/notifyOrder");
-
 
831
			scp.setExpireTimestamp(LocalDateTime.now().plusDays(2));
-
 
832
			SimpleCampaign sc = new SimpleCampaign(scp);
-
 
833
			sc.setSimpleCampaignParams(scp);
789
 
834
 
790
			NotificationCampaigns notification = new NotificationCampaigns();
835
			NotificationCampaign nc = new NotificationCampaign();
791
			notification.setName("Notify Partner");
836
			nc.setName("Notify Partner");
792
 
-
 
793
			notification.setTitle("Notify Partner");
837
			nc.setImplementationType("SimpleCampaign");
794
 
-
 
795
			notification.setMessage(message.getNotifyMessages());
838
			nc.setImplementationParams(gson.toJson(scp));
796
			notification.setType("url");
839
			nc.setCreatedTimestamp(LocalDateTime.now());
797
			notification.setUrl("http://app.profitmandi.com/pages/home/notifyOrder");
840
			notificationCampaignRepository.persist(nc);
798
 
841
 
799
			notification.setSql("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
842
			int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
800
					+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
843
			UserCampaign uc = new UserCampaign();
801
					+ " where d2.id is null and d1.user_id = "
844
			uc.setCampaignId(nc.getId());
802
					+ userAccountRepository.selectUserIdByRetailerId(order.getRetailerId()));
845
			uc.setUserId(userId);
803
			notification.setExpiresat(LocalDateTime.now().plusDays(2).toEpochSecond(ZoneOffset.UTC) * 1000);
-
 
804
			notification.setStatus("active");
846
			uc.setPushTimestamp(LocalDateTime.now());
805
			notification.setSmsprocessed(0);
847
			userCampaignRepository.persist(uc);
806
			notification.setNotification_processed(0);
848
			List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(userId,
807
			notification.setNotification_type("GENERAL_NOTIFICATION");
849
					LocalDateTime.now().minusMonths(3), LocalDateTime.now());
808
			mongoClient.persistNotificationCmpInfo(notification);
850
			pushNotification(nc.getId(), devices);
809
 
851
			
810
		}
852
		}
811
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
853
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
812
		return "response";
854
		return "response";
813
	}
855
	}
814
 
856
 
-
 
857
	public void pushNotification(int cid, List<Device> devices) {
-
 
858
		for (Device device : devices) {
-
 
859
			PushNotifications pn = new PushNotifications();
-
 
860
			pn.setNotificationCampaignid(cid);
-
 
861
			pn.setDeviceId(device.getId());
-
 
862
			pn.setUserId(device.getUser_id());
-
 
863
			pushNotificationRepository.persist(pn);
-
 
864
		}
-
 
865
 
-
 
866
	}
-
 
867
 
815
	private void sendMailOfHtmlFomat(String email, String messageText, String subject)
868
	private void sendMailOfHtmlFomat(String email, String messageText, String subject)
816
			throws MessagingException, ProfitMandiBusinessException, IOException {
869
			throws MessagingException, ProfitMandiBusinessException, IOException {
817
		MimeMessage message = mailSender.createMimeMessage();
870
		MimeMessage message = mailSender.createMimeMessage();
818
		MimeMessageHelper helper = new MimeMessageHelper(message);
871
		MimeMessageHelper helper = new MimeMessageHelper(message);
819
		helper.setSubject(subject);
872
		helper.setSubject(subject);
Line 921... Line 974...
921
			notifyIdNotifyColorMap.put(notifyColorChange.getId(), notifyColorChange);
974
			notifyIdNotifyColorMap.put(notifyColorChange.getId(), notifyColorChange);
922
		}
975
		}
923
		return notifyIdNotifyColorMap;
976
		return notifyIdNotifyColorMap;
924
	}
977
	}
925
 
978
 
926
	/*@RequestMapping(value = "/getContentUploader", method = RequestMethod.GET)
979
	@RequestMapping(value = "/getContentUploader", method = RequestMethod.GET)
927
	public String contentUploader(HttpServletRequest request) throws Exception {
980
	public String contentUploader(HttpServletRequest request) throws Exception {
928
		return "content-upload";
981
		return "content-upload";
-
 
982
	}
-
 
983
 
-
 
984
	/*@RequestMapping(value = "/fileUpload", method = RequestMethod.POST)
-
 
985
	public String updateContents(HttpServletRequest request, @RequestParam("file") MultipartFile multipartFile)
-
 
986
			throws Throwable {
-
 
987
 
-
 
988
		try (XSSFWorkbook myWorkBook = new XSSFWorkbook(multipartFile.getInputStream())) {
-
 
989
 
-
 
990
			myWorkBook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
-
 
991
			// Return first sheet from the XLSX workbook
-
 
992
			XSSFSheet mySheet = myWorkBook.getSheetAt(0);
-
 
993
			LOGGER.info("row" + mySheet.getLastRowNum());
-
 
994
 
-
 
995
			for (int rowNumber = 0; rowNumber <= mySheet.getLastRowNum(); rowNumber++) {
-
 
996
				XSSFRow row = mySheet.getRow(rowNumber);
-
 
997
				LOGGER.info("row1" + row.getCell(0).getStringCellValue());
-
 
998
			}
-
 
999
		} catch (Exception e) {
-
 
1000
			e.printStackTrace();
-
 
1001
		}
-
 
1002
		LOGGER.info("multipart" + multipartFile);
-
 
1003
		return "response";
929
	}*/
1004
	}*/
930
}
1005
}
931
1006