Subversion Repositories SmartDukaan

Rev

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

Rev 31612 Rev 31618
Line 60... Line 60...
60
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
60
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
61
import com.spice.profitmandi.dao.repository.inventory.WarehouseRepository;
61
import com.spice.profitmandi.dao.repository.inventory.WarehouseRepository;
62
import com.spice.profitmandi.dao.repository.transaction.*;
62
import com.spice.profitmandi.dao.repository.transaction.*;
63
import com.spice.profitmandi.dao.repository.user.AddressRepository;
63
import com.spice.profitmandi.dao.repository.user.AddressRepository;
64
import com.spice.profitmandi.dao.repository.user.UserRepository;
64
import com.spice.profitmandi.dao.repository.user.UserRepository;
-
 
65
import com.spice.profitmandi.dao.repository.warehouse.BilledImeiModel;
-
 
66
import com.spice.profitmandi.dao.repository.warehouse.WarehouseInventoryItemRepository;
65
import com.spice.profitmandi.dao.service.solr.FofoSolr;
67
import com.spice.profitmandi.dao.service.solr.FofoSolr;
66
import com.spice.profitmandi.service.NotificationService;
68
import com.spice.profitmandi.service.NotificationService;
67
import com.spice.profitmandi.service.PartnerInvestmentService;
69
import com.spice.profitmandi.service.PartnerInvestmentService;
68
import com.spice.profitmandi.service.PartnerStatsService;
70
import com.spice.profitmandi.service.PartnerStatsService;
69
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
71
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
Line 462... Line 464...
462
 
464
 
463
	@Autowired
465
	@Autowired
464
	CustomerOfferItemRepository customerOfferItemRepository;
466
	CustomerOfferItemRepository customerOfferItemRepository;
465
	@Autowired
467
	@Autowired
466
	private FofoSolr fofoSolr;
468
	private FofoSolr fofoSolr;
-
 
469
 
-
 
470
 
467
	private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
471
	private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
468
 
472
 
469
	private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
473
	private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
470
	private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
474
	private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
471
 
475
 
Line 1008... Line 1012...
1008
			this.fofoId = fofoId;
1012
			this.fofoId = fofoId;
1009
		}
1013
		}
1010
 
1014
 
1011
	}
1015
	}
1012
 
1016
 
-
 
1017
	@Autowired
-
 
1018
	WarehouseInventoryItemRepository warehouseInventoryItemRepository;
-
 
1019
	public void test() throws Exception {
-
 
1020
		//this.sendMailForSamsungRebilling();
-
 
1021
	}
-
 
1022
 
-
 
1023
	public void sendMailForSamsungRebilling() throws Exception {
-
 
1024
		List<BilledImeiModel> samsungModels = warehouseInventoryItemRepository.findByBillingDateBrand(LocalDate.now(), "Samsung");
-
 
1025
		LOGGER.info("SamsungModels {}", samsungModels);
-
 
1026
		samsungModels = samsungModels.stream().sorted(Comparator.comparing(x-> x.getPcmDate()==null ? -1:1)).collect(Collectors.toList());
-
 
1027
		if(samsungModels.size() > 0) {
-
 
1028
			List<String> headers = Arrays.asList("Partner Id", "Code", "Name", "City", "Brand", "Model Name", "Model Number", "Color", "Serial Number", "Remarks");
-
 
1029
			List<List<?>> rows = new ArrayList<>();
-
 
1030
			for(BilledImeiModel billedImeiModel : samsungModels) {
-
 
1031
				List<Serializable> row = Arrays.asList(billedImeiModel.getFofoId(), billedImeiModel.getStoreCode(), billedImeiModel.getStoreName(),
-
 
1032
						billedImeiModel.getStoreCity(), billedImeiModel.getBrand(), billedImeiModel.getModelName(), billedImeiModel.getModelNumber(),
-
 
1033
						billedImeiModel.getColor(), billedImeiModel.getSerialNumber(), billedImeiModel.getPcmDate()==null ? "PCM date Missing" : "Rebill Imeis");
-
 
1034
				rows.add(row);
-
 
1035
			}
-
 
1036
			ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
-
 
1037
			String[] sendToArray = new String[]{"kamini.sharma@smartdukaan.com", "praveen.sharma@smartdukaan.com"};
-
 
1038
			String fileName = "Imeis need Rebilling -" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
-
 
1039
			Utils.sendMailWithAttachment(googleMailSender, sendToArray, new String[]{"tarun.verma@smartdukaan.com"}, "Samsung Rebilling IMEI Summary", "PFA",
-
 
1040
					fileName, new ByteArrayResource(baos.toByteArray()));
-
 
1041
		}
-
 
1042
	}
-
 
1043
 
1013
	public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
1044
	public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
1014
		LocalDate yesterDay = LocalDate.now().minusDays(1);
1045
		LocalDate yesterDay = LocalDate.now().minusDays(1);
1015
		List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
1046
		List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
1016
		Map<Integer, CustomRetailer> customRetailerMap = retailerService
1047
		Map<Integer, CustomRetailer> customRetailerMap = retailerService
1017
				.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
1048
				.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));