Subversion Repositories SmartDukaan

Rev

Rev 25418 | Rev 25445 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23724 amit.gupta 1
package com.smartdukaan.cron.scheduled;
23723 amit.gupta 2
 
24121 govind 3
import java.io.IOException;
24807 amit.gupta 4
import java.io.Serializable;
23739 amit.gupta 5
import java.sql.Timestamp;
23724 amit.gupta 6
import java.time.LocalDate;
7
import java.time.LocalDateTime;
24256 amit.gupta 8
import java.time.LocalTime;
24653 govind 9
import java.time.ZoneOffset;
10
import java.time.format.DateTimeFormatter;
23724 amit.gupta 11
import java.time.temporal.ChronoUnit;
12
import java.util.ArrayList;
13
import java.util.Arrays;
24627 amit.gupta 14
import java.util.Collections;
23723 amit.gupta 15
import java.util.HashMap;
24241 amit.gupta 16
import java.util.HashSet;
23724 amit.gupta 17
import java.util.List;
23723 amit.gupta 18
import java.util.Map;
24242 amit.gupta 19
import java.util.Optional;
24542 amit.gupta 20
import java.util.Set;
23724 amit.gupta 21
import java.util.stream.Collectors;
23723 amit.gupta 22
 
24121 govind 23
import javax.mail.MessagingException;
24
import javax.mail.internet.InternetAddress;
25
import javax.mail.internet.MimeMessage;
26
 
23929 amit.gupta 27
import org.apache.commons.io.output.ByteArrayOutputStream;
25418 amit.gupta 28
import org.apache.commons.lang3.ArrayUtils;
25300 tejbeer 29
import org.apache.http.client.methods.CloseableHttpResponse;
30
import org.apache.http.client.methods.HttpPost;
31
import org.apache.http.entity.StringEntity;
32
import org.apache.http.impl.client.CloseableHttpClient;
33
import org.apache.http.impl.client.HttpClients;
23755 amit.gupta 34
import org.apache.logging.log4j.LogManager;
35
import org.apache.logging.log4j.Logger;
25300 tejbeer 36
import org.json.JSONObject;
23723 amit.gupta 37
import org.springframework.beans.factory.annotation.Autowired;
23933 amit.gupta 38
import org.springframework.beans.factory.annotation.Qualifier;
23724 amit.gupta 39
import org.springframework.beans.factory.annotation.Value;
23929 amit.gupta 40
import org.springframework.core.io.ByteArrayResource;
24692 amit.gupta 41
import org.springframework.core.io.InputStreamSource;
23929 amit.gupta 42
import org.springframework.mail.javamail.JavaMailSender;
24121 govind 43
import org.springframework.mail.javamail.MimeMessageHelper;
23723 amit.gupta 44
import org.springframework.stereotype.Component;
23724 amit.gupta 45
import org.springframework.transaction.annotation.Transactional;
23723 amit.gupta 46
 
24542 amit.gupta 47
import com.google.common.collect.Lists;
25300 tejbeer 48
import com.google.gson.Gson;
49
import com.google.gson.GsonBuilder;
23724 amit.gupta 50
import com.spice.profitmandi.common.enumuration.RechargeStatus;
24681 amit.gupta 51
import com.spice.profitmandi.common.enumuration.ReporticoProject;
24121 govind 52
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
23929 amit.gupta 53
import com.spice.profitmandi.common.model.CustomRetailer;
24542 amit.gupta 54
import com.spice.profitmandi.common.model.GstRate;
23724 amit.gupta 55
import com.spice.profitmandi.common.model.RechargeCredential;
24681 amit.gupta 56
import com.spice.profitmandi.common.services.ReporticoService;
24002 amit.gupta 57
import com.spice.profitmandi.common.util.FileUtil;
23929 amit.gupta 58
import com.spice.profitmandi.common.util.FormattingUtils;
59
import com.spice.profitmandi.common.util.Utils;
24592 amit.gupta 60
import com.spice.profitmandi.common.util.Utils.Attachment;
25300 tejbeer 61
import com.spice.profitmandi.dao.Interface.Campaign;
62
import com.spice.profitmandi.dao.convertor.LocalDateTimeJsonConverter;
24590 amit.gupta 63
import com.spice.profitmandi.dao.entity.catalog.Scheme;
23724 amit.gupta 64
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
25300 tejbeer 65
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
24653 govind 66
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaigns;
25300 tejbeer 67
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
23724 amit.gupta 68
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
69
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
70
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
24542 amit.gupta 71
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
24590 amit.gupta 72
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
23724 amit.gupta 73
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
24542 amit.gupta 74
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
23929 amit.gupta 75
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
24249 amit.gupta 76
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
24277 amit.gupta 77
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
24174 govind 78
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
23724 amit.gupta 79
import com.spice.profitmandi.dao.entity.fofo.Purchase;
24242 amit.gupta 80
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
24241 amit.gupta 81
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
24431 amit.gupta 82
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
24587 amit.gupta 83
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
24580 amit.gupta 84
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
24542 amit.gupta 85
import com.spice.profitmandi.dao.entity.user.Address;
25300 tejbeer 86
import com.spice.profitmandi.dao.entity.user.Device;
24250 amit.gupta 87
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
24242 amit.gupta 88
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
25300 tejbeer 89
import com.spice.profitmandi.dao.model.SimpleCampaign;
90
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
91
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
24249 amit.gupta 92
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
24241 amit.gupta 93
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
23724 amit.gupta 94
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
23929 amit.gupta 95
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
24653 govind 96
import com.spice.profitmandi.dao.repository.dtr.Mongo;
25300 tejbeer 97
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
98
import com.spice.profitmandi.dao.repository.dtr.PushNotificationRepository;
23724 amit.gupta 99
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
100
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
101
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
24542 amit.gupta 102
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
24669 govind 103
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
24542 amit.gupta 104
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
24590 amit.gupta 105
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
24542 amit.gupta 106
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
23724 amit.gupta 107
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
24249 amit.gupta 108
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
24277 amit.gupta 109
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
24174 govind 110
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
23724 amit.gupta 111
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
24242 amit.gupta 112
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
24241 amit.gupta 113
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
23929 amit.gupta 114
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
24431 amit.gupta 115
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
24580 amit.gupta 116
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
24587 amit.gupta 117
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
24542 amit.gupta 118
import com.spice.profitmandi.dao.repository.user.AddressRepository;
24337 amit.gupta 119
import com.spice.profitmandi.service.PartnerInvestmentService;
23929 amit.gupta 120
import com.spice.profitmandi.service.inventory.InventoryService;
25335 amit.gupta 121
import com.spice.profitmandi.service.order.OrderService;
24431 amit.gupta 122
import com.spice.profitmandi.service.pricing.PriceDropService;
23724 amit.gupta 123
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
124
import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;
125
import com.spice.profitmandi.service.scheme.SchemeService;
24121 govind 126
import com.spice.profitmandi.service.slab.TargetSlabService;
23929 amit.gupta 127
import com.spice.profitmandi.service.transaction.TransactionService;
128
import com.spice.profitmandi.service.user.RetailerService;
23739 amit.gupta 129
import com.spice.profitmandi.service.wallet.WalletService;
23723 amit.gupta 130
 
24197 amit.gupta 131
import in.shop2020.model.v1.order.WalletReferenceType;;
23739 amit.gupta 132
 
23723 amit.gupta 133
@Component
23724 amit.gupta 134
@Transactional(rollbackFor = Throwable.class)
23723 amit.gupta 135
public class ScheduledTasks {
136
 
23724 amit.gupta 137
	@Value("${oxigen.recharge.transaction.url}")
138
	private String oxigenRechargeTransactionUrl;
23723 amit.gupta 139
 
23724 amit.gupta 140
	@Value("${oxigen.recharge.enquiry.url}")
141
	private String oxigenRechargeEnquiryUrl;
24533 govind 142
 
24431 amit.gupta 143
	@Autowired
144
	private PriceDropService priceDropService;
23723 amit.gupta 145
 
23724 amit.gupta 146
	@Value("${oxigen.recharge.auth.key}")
147
	private String oxigenRechargeAuthKey;
148
 
149
	@Value("${oxigen.recharge.validation.url}")
150
	private String oxigenRechargeValidationUrl;
151
 
152
	@Value("${oxigen.recharge.validation.auth.key}")
153
	private String oxigenRechargeValidationAuthKey;
154
 
155
	@Value("${think.walnut.digital.recharge.transaction.mobile.url}")
156
	private String thinkWalnutDigitalRechargeTransactionMobileUrl;
157
 
158
	@Value("${think.walnut.digital.recharge.transaction.dth.url}")
159
	private String thinkWalnutDigitalRechargeTransactionDthUrl;
160
 
161
	@Value("${think.walnut.digital.recharge.enquiry.url}")
162
	private String thinkWalnutDigitalRechargeEnquiryUrl;
163
 
164
	@Value("${think.walnut.digital.recharge.balance.url}")
165
	private String thinkWalnutDigitalRechargeBalanceUrl;
166
 
167
	@Value("${think.walnut.digital.recharge.username}")
168
	private String thinkWalnutDigitalRechargeUserName;
169
 
170
	@Value("${think.walnut.digital.recharge.password}")
171
	private String thinkWalnutDigitalRechargePassword;
172
 
173
	@Value("${think.walnut.digital.recharge.auth.key}")
174
	private String thinkWalnutDigitalRechargeAuthKey;
175
 
23723 amit.gupta 176
	@Autowired
23724 amit.gupta 177
	private PurchaseRepository purchaseRepository;
178
 
179
	@Autowired
180
	private SchemeService schemeService;
24683 amit.gupta 181
 
24681 amit.gupta 182
	@Autowired
183
	private ReporticoService reporticoService;
23724 amit.gupta 184
 
185
	@Autowired
24337 amit.gupta 186
	private PartnerInvestmentService partnerInvestmentService;
187
 
188
	@Autowired
24542 amit.gupta 189
	private FofoOrderItemRepository fofoOrderItemRepository;
190
 
191
	@Autowired
24277 amit.gupta 192
	private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
193
 
194
	@Autowired
24241 amit.gupta 195
	private SchemeInOutRepository schemeInOutRepository;
196
 
197
	@Autowired
23724 amit.gupta 198
	private RechargeTransactionRepository rechargeTransactionRepository;
199
 
200
	@Autowired
24542 amit.gupta 201
	private CustomerAddressRepository customerAddressRepository;
202
 
203
	@Autowired
23724 amit.gupta 204
	private RechargeProviderCreditWalletHistoryRepository rechargeProviderCreditWalletHistoryRepository;
205
 
206
	@Autowired
24590 amit.gupta 207
	private FofoLineItemRepository fofoLineItemRepository;
208
 
209
	@Autowired
23724 amit.gupta 210
	private FofoOrderRepository fofoOrderRepository;
24587 amit.gupta 211
 
24580 amit.gupta 212
	@Autowired
213
	private UserWalletHistoryRepository userWalletHistoryRepository;
24250 amit.gupta 214
 
24249 amit.gupta 215
	@Autowired
24587 amit.gupta 216
	private UserWalletRepository userWalletRepository;
217
 
218
	@Autowired
24249 amit.gupta 219
	private InventoryItemRepository inventoryItemRepository;
23929 amit.gupta 220
 
23739 amit.gupta 221
	@Autowired
222
	private WalletService walletService;
23724 amit.gupta 223
 
224
	@Autowired
225
	private ThinkWalnutDigitalRechargeProviderService thinkWalnutDigitalRechargeProviderService;
226
 
227
	@Autowired
228
	private OxigenRechargeProviderService oxigenRechargeProviderService;
229
 
230
	@Autowired
231
	private RechargeProviderRepository rechargeProviderRepository;
232
 
233
	@Autowired
24242 amit.gupta 234
	private ScanRecordRepository scanRecordRepository;
235
 
236
	@Autowired
23724 amit.gupta 237
	private DailyRechargeRepository dailyRechargeRepository;
238
 
23929 amit.gupta 239
	@Autowired
240
	private FofoStoreRepository fofoStoreRepository;
24177 govind 241
 
24121 govind 242
	@Autowired
243
	private TargetSlabService targetService;
23929 amit.gupta 244
 
23724 amit.gupta 245
	@Value("${prod}")
246
	private boolean prod;
247
 
23929 amit.gupta 248
	@Autowired
249
	private RetailerService retailerService;
250
 
251
	@Autowired
252
	private TransactionService transactionService;
24250 amit.gupta 253
 
24249 amit.gupta 254
	@Autowired
255
	private ItemRepository itemRepository;
23929 amit.gupta 256
 
257
	@Autowired
258
	private OrderRepository orderRepository;
25351 tejbeer 259
 
25335 amit.gupta 260
	@Autowired
261
	private OrderService orderService;
23929 amit.gupta 262
 
263
	@Autowired
24241 amit.gupta 264
	private SchemeRepository schemeRepository;
265
 
266
	@Autowired
23929 amit.gupta 267
	private JavaMailSender mailSender;
24177 govind 268
 
24174 govind 269
	@Autowired
24431 amit.gupta 270
	private PriceDropRepository priceDropRepository;
271
 
272
	@Autowired
24174 govind 273
	private PartnerTargetRepository partnerTargetRepository;
24002 amit.gupta 274
 
275
	@Autowired
276
	@Qualifier(value = "googleMailSender")
23932 amit.gupta 277
	private JavaMailSender googleMailSender;
23929 amit.gupta 278
 
279
	@Autowired
280
	private InventoryService inventoryService;
281
 
24533 govind 282
	@Autowired
24542 amit.gupta 283
	private AddressRepository addressRepository;
284
 
285
	@Autowired
286
	private RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
287
 
24653 govind 288
	@Autowired
289
	private Mongo mongoClient;
24683 amit.gupta 290
 
24669 govind 291
	@Autowired
25300 tejbeer 292
	private DeviceRepository deviceRepository;
293
 
294
	@Autowired
295
	private PushNotificationRepository pushNotificationRepository;
296
 
297
	@Autowired
298
	private NotificationCampaignRepository notificationCampaignRepository;
299
 
300
	@Autowired
24669 govind 301
	private UserAccountRepository userAccountRepository;
24653 govind 302
 
23755 amit.gupta 303
	private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
23724 amit.gupta 304
 
25300 tejbeer 305
	private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
306
	private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
307
 
23724 amit.gupta 308
	public void generateDailyRecharge() {
309
		List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
310
				.selectAll(0, 2000);
311
		List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
312
		rechargeProviders.stream().forEach(x -> x.setAmount(0));
313
 
314
		rechargeProviders.stream().forEach(x -> {
315
			Map<LocalDate, List<RechargeProviderCreditWalletHistory>> dateWiseProviderCreditsMap = allCreditHistory
316
					.stream().filter(z -> z.getProviderId() == x.getId())
317
					.collect(Collectors.groupingBy(x1 -> x1.getReceiveTimestamp().toLocalDate()));
318
 
319
			LOGGER.info("dateWiseProviderCreditsMap -- {}", dateWiseProviderCreditsMap);
320
			LocalDate endDate = LocalDate.now().plusDays(1);
321
			float previousDayClosing = 0;
322
			LocalDate date = LocalDate.of(2018, 4, 6);
323
			while (date.isBefore(endDate)) {
324
				List<RechargeTransaction> dateWiseRechargeTransactions = rechargeTransactionRepository
325
						.selectAllBetweenTimestamp(Arrays.asList(RechargeStatus.values()), date.atStartOfDay(),
326
								date.plusDays(1).atStartOfDay());
327
 
328
				List<RechargeTransaction> successfulTransactions = dateWiseRechargeTransactions.stream()
329
						.filter(y -> y.getStatus().equals(RechargeStatus.SUCCESS)).collect(Collectors.toList());
330
 
331
				float dailyAmount = 0;
332
				float totalCommission = 0;
333
				for (RechargeTransaction rechargeTransaction : successfulTransactions) {
334
					if (rechargeTransaction.getProviderId() == x.getId()) {
335
						dailyAmount += rechargeTransaction.getAmount();
336
						totalCommission += rechargeTransaction.getCommission();
337
					}
338
				}
339
 
340
				List<RechargeProviderCreditWalletHistory> rechargeHistoryList = dateWiseProviderCreditsMap.get(date);
341
				float dailyWalletRecharge = 0;
342
				if (rechargeHistoryList != null) {
343
					for (RechargeProviderCreditWalletHistory rechargeProviderCreditWalletHistory : rechargeHistoryList) {
344
						if (rechargeProviderCreditWalletHistory.getProviderId() == x.getId()) {
345
							dailyWalletRecharge += rechargeProviderCreditWalletHistory.getAmount();
346
						}
347
					}
348
				}
349
				if (dailyAmount > 0 || dailyWalletRecharge > 0) {
350
					DailyRecharge dailyRecharge = null;
351
					try {
352
						dailyRecharge = dailyRechargeRepository.selectByProviderIdAndCreateDate(x.getId(), date);
353
					} catch (Exception e) {
354
						LOGGER.info("Could not find Recharge entry");
355
					}
356
					if (dailyRecharge == null) {
357
						dailyRecharge = new DailyRecharge();
358
						dailyRecharge.setCreateDate(date);
359
					}
360
					dailyRecharge.setOpeningBalance(previousDayClosing);
361
					dailyRecharge.setProviderId(x.getId());
362
					dailyRecharge.setWalletRechargeAmount(dailyWalletRecharge);
363
					dailyRecharge.setTotalAmount(dailyAmount);
364
					dailyRecharge.setTotalCommission(totalCommission);
365
					float closingBalance = dailyRecharge.getOpeningBalance() + dailyWalletRecharge - dailyAmount;
366
					dailyRecharge.setClosingBalance(closingBalance);
367
					dailyRechargeRepository.persist(dailyRecharge);
368
					x.setAmount(x.getAmount() + dailyRecharge.getClosingBalance() - dailyRecharge.getOpeningBalance());
369
					previousDayClosing = dailyRecharge.getClosingBalance();
370
				}
371
				date = date.plusDays(1);
372
			}
373
			rechargeProviderRepository.persist(x);
374
		});
23761 amit.gupta 375
		LOGGER.info("finished generating daily recharge");
23724 amit.gupta 376
	}
377
 
23738 amit.gupta 378
	public void reconcileRecharge() throws Exception {
23724 amit.gupta 379
		LocalDateTime fromDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(30);
380
		LocalDateTime toDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
381
		List<RechargeStatus> nonSuccessRechargeStatuses = new ArrayList<>(Arrays.asList(RechargeStatus.values()));
382
		LOGGER.info("nonSuccessRechargeStatuses {} ", nonSuccessRechargeStatuses);
383
		nonSuccessRechargeStatuses.remove(RechargeStatus.SUCCESS);
384
		nonSuccessRechargeStatuses.remove(RechargeStatus.FAILED);
385
		RechargeCredential thinkWalnutDigitalRechargeEnquiryCredential = new RechargeCredential();
386
		thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUrl(thinkWalnutDigitalRechargeEnquiryUrl);
387
		thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
388
		thinkWalnutDigitalRechargeEnquiryCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
389
		thinkWalnutDigitalRechargeEnquiryCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
390
		Map<String, RechargeStatus> requestRechargeStatusChanged = new HashMap<>();
391
		List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
392
				.selectAllBetweenTimestamp(nonSuccessRechargeStatuses, fromDate, toDate);
393
		for (RechargeTransaction rechargeTransaction : rechargeTransactions) {
394
			try {
395
				int providerId = rechargeTransaction.getProviderId();
396
				if (providerId == 1) {
397
					oxigenRechargeProviderService.doCheckStatusRequest(oxigenRechargeEnquiryUrl, oxigenRechargeAuthKey,
398
							rechargeTransaction);
399
				} else if (providerId == 2) {
400
					thinkWalnutDigitalRechargeProviderService
401
							.doCheckStatusRequest(thinkWalnutDigitalRechargeEnquiryCredential, rechargeTransaction);
402
				}
403
				if (rechargeTransaction.getStatus().equals(RechargeStatus.SUCCESS)
404
						|| rechargeTransaction.getStatus().equals(RechargeStatus.FAILED)) {
405
					requestRechargeStatusChanged.put(rechargeTransaction.getRequestId(),
406
							rechargeTransaction.getStatus());
407
				}
408
			} catch (Exception e) {
409
				LOGGER.info("Could not check status for Request {}", rechargeTransaction.getRequestId());
410
			}
411
		}
23738 amit.gupta 412
		LOGGER.info("Reconcile recharge ran successfully");
23724 amit.gupta 413
	}
24240 amit.gupta 414
 
415
	// TemporaryMethod
24237 amit.gupta 416
	public void migrateInvoice() {
417
		List<FofoOrder> fofoOrders = fofoOrderRepository.selectFromSaleDate(LocalDateTime.now().minusDays(3));
418
		Map<Integer, List<FofoOrder>> partnerOrdersMap = new HashMap<>();
24241 amit.gupta 419
		partnerOrdersMap = fofoOrders.stream()
420
				.collect(Collectors.groupingBy(FofoOrder::getFofoId, Collectors.toList()));
24237 amit.gupta 421
		for (List<FofoOrder> orderList : partnerOrdersMap.values()) {
24240 amit.gupta 422
			int sequence = 0;
423
			String prefix = "";
24241 amit.gupta 424
			List<FofoOrder> sortedList = orderList.stream().sorted((x1, x2) -> x1.getId() - x2.getId())
425
					.collect(Collectors.toList());
426
			for (FofoOrder order : sortedList) {
427
 
24240 amit.gupta 428
				LOGGER.info("Order Id is {}, partner Id is {}", order.getId(), order.getFofoId());
24241 amit.gupta 429
				if (!order.getInvoiceNumber().contains("SEC")) {
24240 amit.gupta 430
					sequence = Integer.parseInt(order.getInvoiceNumber().split("/")[1]);
431
					prefix = order.getInvoiceNumber().split("/")[0];
432
				} else {
433
					sequence += 1;
24241 amit.gupta 434
					String invoiceNumber = prefix + "/" + sequence;
24240 amit.gupta 435
					order.setInvoiceNumber(invoiceNumber);
436
					fofoOrderRepository.persist(order);
437
				}
438
			}
24241 amit.gupta 439
 
24237 amit.gupta 440
		}
441
	}
23724 amit.gupta 442
 
24241 amit.gupta 443
	// Temporary Method
24252 amit.gupta 444
	public void evaluateExcessSchemeOut() throws Exception {
24244 amit.gupta 445
		Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
446
		Map<Integer, Float> userAmountMap = new HashMap<>();
24252 amit.gupta 447
 
24807 amit.gupta 448
		List<List<? extends Serializable>> rows = new ArrayList<>();
24271 amit.gupta 449
		List<String> headers = Arrays.asList("Scheme", "Item", "Partner", "Amount", "Credited On", "Invoice Number",
450
				"Sale On", "Scheme Start", "Scheme End", "Active On", "Expired On");
24241 amit.gupta 451
		schemeRepository.selectAll().stream().forEach(x -> {
24250 amit.gupta 452
			if (x.getType().equals(SchemeType.OUT)) {
453
				List<SchemeInOut> sioList = schemeInOutRepository
454
						.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
455
				if (x.getActiveTimestamp() != null) {
456
					LocalDateTime endDateTime = x.getEndDateTime();
457
					if (x.getExpireTimestamp() != null && x.getExpireTimestamp().isBefore(x.getEndDateTime())) {
458
						endDateTime = x.getExpireTimestamp();
24249 amit.gupta 459
					}
24250 amit.gupta 460
					for (SchemeInOut sio : sioList) {
461
						InventoryItem inventoryItem = null;
24266 amit.gupta 462
						inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
24271 amit.gupta 463
						FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndSerialNumber(
464
								inventoryItem.getFofoId(), inventoryItem.getSerialNumber(), null, null, 0, 1).get(0);
24250 amit.gupta 465
						Optional<ScanRecord> record = scanRecordRepository
466
								.selectByInventoryItemId(sio.getInventoryItemId()).stream()
467
								.filter(y -> y.getType().equals(ScanType.SALE)).findFirst();
468
						if (record.isPresent()) {
469
							int fofoId = record.get().getFofoId();
470
							if (record.get().getCreateTimestamp().isAfter(endDateTime)
471
									|| record.get().getCreateTimestamp().isBefore(x.getStartDateTime())) {
472
								if (!userAmountMap.containsKey(fofoId)) {
473
									userAmountMap.put(fofoId, 0f);
474
								}
475
								userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
476
								try {
24252 amit.gupta 477
									rows.add(Arrays.asList(x.getDescription(),
24250 amit.gupta 478
											itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(),
24252 amit.gupta 479
											userNameMap.get(fofoId), sio.getAmount(),
24253 amit.gupta 480
											FormattingUtils.formatDate(sio.getCreateTimestamp()),
481
											fofoOrder.getInvoiceNumber(),
482
											FormattingUtils.formatDate(record.get().getCreateTimestamp()),
483
											FormattingUtils.formatDate(x.getStartDateTime()),
484
											FormattingUtils.formatDate(x.getEndDateTime()),
485
											FormattingUtils.formatDate(x.getActiveTimestamp()),
486
											FormattingUtils.formatDate(x.getExpireTimestamp())));
24250 amit.gupta 487
								} catch (Exception e) {
488
									e.printStackTrace();
489
								}
24242 amit.gupta 490
							}
24241 amit.gupta 491
						}
492
					}
493
				}
494
			}
495
		});
24246 amit.gupta 496
		userAmountMap.entrySet().stream()
497
				.forEach(x -> LOGGER.info("{} to be deducted from {}({}) for wrongly disbursed due to technical error.",
498
						x.getValue(), userNameMap.get(x.getKey())));
24241 amit.gupta 499
 
24252 amit.gupta 500
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
24271 amit.gupta 501
		Utils.sendMailWithAttachment(googleMailSender,
502
				new String[] { "amit.gupta@shop2020.in", "adeel.yazdani@smartdukaan.com" }, null,
503
				"Partner Excess Amount", "PFA", "ListofSchemes.csv", new ByteArrayResource(baos.toByteArray()));
24252 amit.gupta 504
 
24241 amit.gupta 505
	}
24271 amit.gupta 506
 
24256 amit.gupta 507
	public void processScheme(int offset) throws Exception {
24462 amit.gupta 508
		LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
24259 amit.gupta 509
		LocalDateTime endDate = startDate.plusDays(30);
24258 amit.gupta 510
		processScheme(startDate, endDate);
24256 amit.gupta 511
	}
24533 govind 512
 
24461 amit.gupta 513
	public void processScheme(int offset, int durationDays) throws Exception {
24462 amit.gupta 514
		LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
24461 amit.gupta 515
		LocalDateTime endDate = startDate.plusDays(durationDays);
516
		processScheme(startDate, endDate);
517
	}
24271 amit.gupta 518
 
23738 amit.gupta 519
	public void processScheme() throws Exception {
24256 amit.gupta 520
		LocalDateTime fromDate = LocalDateTime.now().minusDays(30);
521
		processScheme(fromDate, LocalDateTime.now());
522
	}
24271 amit.gupta 523
 
24256 amit.gupta 524
	public void processScheme(LocalDateTime startDate, LocalDateTime endDate) throws Exception {
23724 amit.gupta 525
		LOGGER.info("Started execution at {}", LocalDateTime.now());
25312 amit.gupta 526
		System.out.println(
527
				"InventoryId\tSerialNumber\tItem Id\tScheme Id\tScheme Name\tScheme Type\tAmount Type\tDP\tTaxable\tScheme Amount\tAmount Paid");
24561 amit.gupta 528
		try {
24587 amit.gupta 529
			List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
530
			for (Purchase purchase : purchases) {
531
				schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
532
			}
24271 amit.gupta 533
 
24587 amit.gupta 534
			List<FofoOrder> fofoOrders = fofoOrderRepository.selectBetweenSaleDate(startDate, endDate);
535
			for (FofoOrder fofoOrder : fofoOrders) {
536
				schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
537
			}
538
		} catch (Exception e) {
24561 amit.gupta 539
			e.printStackTrace();
24565 amit.gupta 540
			throw e;
24561 amit.gupta 541
		}
25312 amit.gupta 542
		List<UserWalletHistory> uwhs = userWalletHistoryRepository.selectAllByDateType(startDate, endDate,
543
				Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
25043 amit.gupta 544
		System.out.println("Amount\tReference\tReferenceType\tTimestamp\tDescription");
25312 amit.gupta 545
		for (UserWalletHistory uwh : uwhs) {
546
			System.out.println(String.format("%d\t%d\t%s\t%s\t%s", uwh.getAmount(), uwh.getReference(),
547
					uwh.getReferenceType(), uwh.getTimestamp().toString(), uwh.getDescription()));
25043 amit.gupta 548
		}
23724 amit.gupta 549
		LOGGER.info("Schemes process successfully.");
25312 amit.gupta 550
		// throw new Exception();
23724 amit.gupta 551
	}
23929 amit.gupta 552
 
23739 amit.gupta 553
	public void processRechargeCashback() throws Throwable {
23761 amit.gupta 554
		LocalDateTime cashbackTime = LocalDateTime.now();
23929 amit.gupta 555
		int referenceId = (int) Timestamp.valueOf(cashbackTime).getTime() / 1000;
556
		List<RechargeTransaction> pendingTransactions = rechargeTransactionRepository
557
				.getPendingCashBackRehargeTransactions();
558
		Map<Object, Double> totalRetailerCashbacks = pendingTransactions.stream().collect(
559
				Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingDouble(x -> x.getCommission())));
560
		for (Map.Entry<Object, Double> totalRetailerCashback : totalRetailerCashbacks.entrySet()) {
561
			int retailerId = (Integer) totalRetailerCashback.getKey();
23739 amit.gupta 562
			float amount = totalRetailerCashback.getValue().floatValue();
23929 amit.gupta 563
			if (Math.round(amount) > 0) {
564
				walletService.addAmountToWallet(retailerId, referenceId, WalletReferenceType.CASHBACK,
565
						"Recharge Cashback", Math.round(amount));
23762 amit.gupta 566
			}
23739 amit.gupta 567
		}
23929 amit.gupta 568
		for (RechargeTransaction rt : pendingTransactions) {
23761 amit.gupta 569
			rt.setCashbackTimestamp(cashbackTime);
570
			rt.setCashbackReference(referenceId);
571
			rechargeTransactionRepository.persist(rt);
572
		}
23739 amit.gupta 573
		LOGGER.info("Cashbacks for Recharge processed Successfully");
574
	}
23724 amit.gupta 575
 
24271 amit.gupta 576
	public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
25312 amit.gupta 577
		if (sendTo == null) {
25341 amit.gupta 578
			sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
25312 amit.gupta 579
					"amit.gupta@shop2020.in");
580
		}
24277 amit.gupta 581
		LocalDate yesterDay = LocalDate.now().minusDays(1);
25267 amit.gupta 582
		List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
23929 amit.gupta 583
		Map<Integer, CustomRetailer> customRetailerMap = retailerService
584
				.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
25351 tejbeer 585
 
25345 amit.gupta 586
		List<String> headers = Arrays.asList("Code", "Firm Name", "Store Name", "State Manager", "Teritory Manager",
25312 amit.gupta 587
				"Team Leader", "Wallet Amount", "In Stock Amount", "Return In Transit Stock", "Unbilled Amount",
25342 amit.gupta 588
				"Grn Pending Amount", "Min Investment", "Investment Amount", "Investment Short", "Unbilled Qty");
24807 amit.gupta 589
		List<List<? extends Serializable>> rows = new ArrayList<>();
25312 amit.gupta 590
		Map<String, List<? extends Serializable>> partnerRow = new HashMap<>();
24002 amit.gupta 591
		for (FofoStore fofoStore : fofoStores) {
25314 amit.gupta 592
			if (!fofoStore.isActive())
593
				continue;
24002 amit.gupta 594
			CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
25314 amit.gupta 595
			if (retailer == null || storeManagerMap.get(retailer.getEmail()) == null) {
24002 amit.gupta 596
				LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
597
				continue;
598
			}
24533 govind 599
			PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoStore.getId(),
600
					1);
24337 amit.gupta 601
			partnerDailyInvestment.setDate(yesterDay);
602
			partnerDailyInvestmentRepository.persist(partnerDailyInvestment);
24533 govind 603
 
25351 tejbeer 604
			List<? extends Serializable> row = Arrays.asList(fofoStore.getCode(), retailer.getBusinessName(),
605
					"SmartDukaan-" + fofoStore.getCode().replaceAll("[a-zA-Z]+", ""),
25312 amit.gupta 606
					storeManagerMap.get(retailer.getEmail()).get(2), storeManagerMap.get(retailer.getEmail()).get(1),
25351 tejbeer 607
					storeManagerMap.get(retailer.getEmail()).get(0), partnerDailyInvestment.getWalletAmount(),
608
					partnerDailyInvestment.getInStockAmount(), 0, partnerDailyInvestment.getUnbilledAmount(),
609
					partnerDailyInvestment.getGrnPendingAmount(), partnerDailyInvestment.getMinInvestment(),
610
					partnerDailyInvestment.getTotalInvestment(), partnerDailyInvestment.getShortInvestment(),
25335 amit.gupta 611
					partnerDailyInvestment.getUnbilledQty());
25312 amit.gupta 612
			partnerRow.put(retailer.getEmail(), row);
24002 amit.gupta 613
			rows.add(row);
614
 
23929 amit.gupta 615
		}
25312 amit.gupta 616
		Map<String, Set<String>> storeGuyMap = new HashMap<>();
617
		for (Map.Entry<String, List<String>> entry : storeManagerMap.entrySet()) {
618
			String storeEmail = entry.getKey();
619
			List<String> storeGuys = entry.getValue();
620
			for (String storeGuy : storeGuys) {
621
				if (!storeGuyMap.containsKey(storeGuy)) {
622
					storeGuyMap.put(storeGuy, new HashSet<>());
623
				}
624
				storeGuyMap.get(storeGuy).add(storeEmail);
625
			}
626
		}
25322 amit.gupta 627
		storeGuyMap.remove("");
25312 amit.gupta 628
 
24271 amit.gupta 629
		String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
25341 amit.gupta 630
		for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuyMap.entrySet()) {
25312 amit.gupta 631
			List<List<? extends Serializable>> filteredRows = storeGuyEntry.getValue().stream()
25351 tejbeer 632
					.map(x -> partnerRow.get(x)).filter(x -> x != null).collect(Collectors.toList());
25312 amit.gupta 633
			ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
25321 amit.gupta 634
			String[] sendToArray = new String[] { nameEmail.get(storeGuyEntry.getKey()) };
25312 amit.gupta 635
			Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Partner Investment Summary", "PFA",
636
					fileName, new ByteArrayResource(baos.toByteArray()));
25341 amit.gupta 637
		}
25312 amit.gupta 638
 
24002 amit.gupta 639
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
24271 amit.gupta 640
		String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
641
		Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Partner Investment Summary", "PFA", fileName,
642
				new ByteArrayResource(baos.toByteArray()));
643
 
23929 amit.gupta 644
	}
24177 govind 645
 
24271 amit.gupta 646
	public void sendPartnerInvestmentDetails() throws Exception {
25312 amit.gupta 647
		this.sendPartnerInvestmentDetails(null);
24271 amit.gupta 648
 
649
	}
650
 
25312 amit.gupta 651
	public void sendTargetVsSalesReport(List<String> sendTo) throws Exception {
24177 govind 652
 
25312 amit.gupta 653
		if (sendTo == null) {
25341 amit.gupta 654
			sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
25312 amit.gupta 655
					"amit.gupta@shop2020.in");
656
		}
24177 govind 657
		List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
25373 amit.gupta 658
				.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now().minusDays(1));
25312 amit.gupta 659
		Map<String, List<? extends Serializable>> partnerSalesTargetRowsMap = new HashMap<>();
24177 govind 660
		for (PartnerTargetDetails partnerTargetDetail : partnerTargetDetails) {
25312 amit.gupta 661
			partnerSalesTargetRowsMap.putAll(targetService.getDailySaleReportVsTarget(partnerTargetDetail));
24174 govind 662
		}
25315 amit.gupta 663
		Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream()
664
				.collect(Collectors.toMap(x -> x.getId(), x -> x));
665
 
25312 amit.gupta 666
		Map<Integer, CustomRetailer> customRetailerMap = retailerService
25315 amit.gupta 667
				.getFofoRetailers(new ArrayList<>(fofoStoresMap.keySet()));
24177 govind 668
 
25315 amit.gupta 669
		Map<String, CustomRetailer> customRetailerEmailMap = customRetailerMap.values().stream()
670
				.collect(Collectors.toMap(x -> x.getEmail(), x -> x));
671
 
25345 amit.gupta 672
		List<String> headers = Arrays.asList("Code", "Firm Name", "Store Name", "State Manager", "Teritory Manager",
25327 amit.gupta 673
				"Team Leader", "Target Name", "Target Value", "Target Achieved", "Achived Percentage",
674
				"Remaining Target", "Today's Target", "Today's achievement");
24177 govind 675
 
25312 amit.gupta 676
		List<List<? extends Serializable>> rows = new ArrayList<>();
677
		Map<String, List<Serializable>> partnerRowMap = new HashMap<>();
25315 amit.gupta 678
		for (Map.Entry<String, List<? extends Serializable>> partnerSalesTargetRowEntry : partnerSalesTargetRowsMap
679
				.entrySet()) {
680
			CustomRetailer retailer = customRetailerEmailMap.get(partnerSalesTargetRowEntry.getKey());
681
			FofoStore fofoStore = fofoStoresMap.get(retailer.getPartnerId());
25312 amit.gupta 682
			Serializable code = fofoStore.getCode();
25345 amit.gupta 683
			Serializable storeName = "SmartDukaan-" + fofoStore.getCode().replaceAll("[a-zA-Z]", "");
25314 amit.gupta 684
			Serializable businessName = retailer.getBusinessName();
25317 amit.gupta 685
			try {
686
				Serializable stateManager = storeManagerMap.get(retailer.getEmail()).get(2);
687
				Serializable territoryManager = storeManagerMap.get(retailer.getEmail()).get(1);
688
				Serializable teamLeader = storeManagerMap.get(retailer.getEmail()).get(0);
689
				List<Serializable> row = new ArrayList<>(
25345 amit.gupta 690
						Arrays.asList(code, businessName, storeName, stateManager, territoryManager, teamLeader));
25317 amit.gupta 691
				if (partnerSalesTargetRowsMap.get(retailer.getEmail()) != null) {
25323 amit.gupta 692
					row.addAll(partnerSalesTargetRowsMap.get(retailer.getEmail()));
25317 amit.gupta 693
					partnerRowMap.put(retailer.getEmail(), row);
694
					rows.add(row);
695
				}
25351 tejbeer 696
			} catch (Exception e) {
25317 amit.gupta 697
				LOGGER.warn("Could not find partner with email - {}", retailer.getEmail());
25315 amit.gupta 698
			}
25312 amit.gupta 699
 
24177 govind 700
		}
25407 amit.gupta 701
 
25318 amit.gupta 702
		String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
25407 amit.gupta 703
		for (Map.Entry<String, Set<String>> storeGuyEntry : getStoreGuyMap().entrySet()) {
25312 amit.gupta 704
			List<List<? extends Serializable>> filteredRows = storeGuyEntry.getValue().stream()
25351 tejbeer 705
					.map(x -> partnerRowMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
25312 amit.gupta 706
			ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
25320 amit.gupta 707
			String[] sendToArray = new String[] { nameEmail.get(storeGuyEntry.getKey()) };
25312 amit.gupta 708
			Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA",
709
					fileName, new ByteArrayResource(baos.toByteArray()));
25341 amit.gupta 710
		}
24240 amit.gupta 711
 
25312 amit.gupta 712
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
713
		String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
714
		Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA", fileName,
715
				new ByteArrayResource(baos.toByteArray()));
24174 govind 716
	}
24683 amit.gupta 717
 
25407 amit.gupta 718
	private Map<String, Set<String>> getStoreGuyMap() {
719
		Map<String, Set<String>> storeGuyMap = new HashMap<>();
720
		for (Map.Entry<String, List<String>> entry : storeManagerMap.entrySet()) {
721
			String storeEmail = entry.getKey();
722
			List<String> storeGuys = entry.getValue();
723
			for (String storeGuy : storeGuys) {
724
				if (!storeGuyMap.containsKey(storeGuy)) {
725
					storeGuyMap.put(storeGuy, new HashSet<>());
726
				}
727
				storeGuyMap.get(storeGuy).add(storeEmail);
728
			}
729
		}
730
		storeGuyMap.remove("");
731
		return storeGuyMap;
732
	}
733
 
24697 amit.gupta 734
	public void sendAgeingReport(String... sendTo) throws Exception {
24692 amit.gupta 735
 
736
		InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.WAREHOUSENEW,
737
				"itemstockageing.xml");
24708 amit.gupta 738
		InputStreamSource isr1 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
24754 amit.gupta 739
				"ItemwiseOverallPendingIndent.xml");
24683 amit.gupta 740
		Attachment attachment = new Attachment(
24692 amit.gupta 741
				"aeging-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr);
24707 amit.gupta 742
		Attachment attachment1 = new Attachment(
743
				"aeging-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr1);
24841 govind 744
		Utils.sendMailWithAttachments(googleMailSender, sendTo, null, "Stock Aeging Report", "PFA", attachment,
745
				attachment1);
25418 amit.gupta 746
 
747
		//Reports to be sent to mapped partners
748
		Map<String, Set<String>> storeGuysMap = getStoreGuyMap();
25407 amit.gupta 749
 
25418 amit.gupta 750
		String[] sendToArray = new String[storeGuysMap.size()];
751
		int i=0;
752
		for(String storeGuyName : storeGuysMap.keySet()) {
753
			sendToArray[i]= nameEmail.get(storeGuyName);
754
			i++;
755
		}
25407 amit.gupta 756
		Utils.sendMailWithAttachments(googleMailSender, sendToArray, null, "Stock Aeging Report", "PFA", attachment);
757
 
25418 amit.gupta 758
 
759
		for(Map.Entry<String, Set<String>> storeGuyEntry: storeGuysMap.entrySet()) {
760
			Map<String, String> params = new HashMap<>();
761
			params.put("MANUAL_email", String.join(",", storeGuyEntry.getValue()));
762
			InputStreamSource isr3 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
763
					"focostockreport.xml", params);
764
			Attachment attache = new Attachment(
765
					"aeging-report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr3);
766
			Utils.sendMailWithAttachments(googleMailSender, new String[] {}, null, "Partner Stock Report", "PFA", attache);
767
		}
768
 
24681 amit.gupta 769
	}
24533 govind 770
 
24697 amit.gupta 771
	public void sendAgeingReport() throws Exception {
25418 amit.gupta 772
		sendAgeingReport("kamini.sharma@smartdukaan.com",
773
				"tarun.verma@smartdukaan.com", "chaitnaya.vats@smartdukaan.com");
24697 amit.gupta 774
	}
775
 
24533 govind 776
	public void moveImeisToPriceDropImeis() throws Exception {
24431 amit.gupta 777
		List<PriceDrop> priceDrops = priceDropRepository.selectAll();
24533 govind 778
		for (PriceDrop priceDrop : priceDrops) {
24431 amit.gupta 779
			priceDropService.priceDropStatus(priceDrop.getId());
780
		}
781
	}
23929 amit.gupta 782
 
24542 amit.gupta 783
	public void walletmismatch() throws Exception {
784
		LocalDate curDate = LocalDate.now();
24553 amit.gupta 785
		List<PartnerDailyInvestment> pdis = partnerDailyInvestmentRepository.selectAll(curDate.minusDays(2));
24552 amit.gupta 786
		System.out.println(pdis.size());
24542 amit.gupta 787
		for (PartnerDailyInvestment pdi : pdis) {
24549 amit.gupta 788
			int fofoId = pdi.getFofoId();
24542 amit.gupta 789
			for (PartnerDailyInvestment investment : Lists
790
					.reverse(partnerDailyInvestmentRepository.selectAll(fofoId, null, null))) {
24552 amit.gupta 791
				float statementAmount = walletService.getOpeningTill(fofoId,
24555 amit.gupta 792
						investment.getDate().plusDays(1).atTime(LocalTime.of(4, 0)));
24552 amit.gupta 793
				CustomRetailer retailer = retailerService.getFofoRetailer(fofoId);
24841 govind 794
				LOGGER.info("{}\t{}\t{}\t{}\t{}", fofoId, retailer.getBusinessName(), retailer.getMobileNumber(),
795
						investment.getDate().toString(), investment.getWalletAmount(), statementAmount);
24551 amit.gupta 796
 
24542 amit.gupta 797
			}
24549 amit.gupta 798
		}
24542 amit.gupta 799
 
800
	}
801
 
802
	public void gst() throws Exception {
24548 amit.gupta 803
		List<FofoOrder> fofoOrders = fofoOrderRepository.selectBetweenSaleDate(LocalDate.of(2019, 1, 26).atStartOfDay(),
804
				LocalDate.of(2019, 1, 27).atTime(LocalTime.MAX));
805
		for (FofoOrder fofoOrder : fofoOrders) {
806
			int retailerAddressId = retailerRegisteredAddressRepository
807
					.selectAddressIdByRetailerId(fofoOrder.getFofoId());
24542 amit.gupta 808
 
809
			Address retailerAddress = addressRepository.selectById(retailerAddressId);
810
			CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
811
			Integer stateId = null;
812
			if (customerAddress.getState().equals(retailerAddress.getState())) {
813
				try {
814
					stateId = Long.valueOf(Utils.getStateInfo(customerAddress.getState()).getId()).intValue();
815
				} catch (Exception e) {
816
					LOGGER.error("Unable to get state rates");
817
				}
818
			}
819
			Map<Integer, GstRate> itemIdStateTaxRateMap = null;
820
			Map<Integer, Float> itemIdIgstTaxRateMap = null;
24548 amit.gupta 821
 
822
			List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
823
			Set<Integer> itemIds = fofoOrderItems.stream().map(x -> x.getItemId()).collect(Collectors.toSet());
24542 amit.gupta 824
			if (stateId != null) {
825
				itemIdStateTaxRateMap = Utils.getStateTaxRate(new ArrayList<>(itemIds), stateId);
826
			} else {
827
				itemIdIgstTaxRateMap = Utils.getIgstTaxRate(new ArrayList<>(itemIds));
828
			}
829
 
24548 amit.gupta 830
			for (FofoOrderItem foi : fofoOrderItems) {
24542 amit.gupta 831
				if (stateId == null) {
832
					foi.setIgstRate(itemIdIgstTaxRateMap.get(foi.getItemId()));
833
				} else {
834
					foi.setCgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getCgstRate());
835
					foi.setSgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getSgstRate());
836
				}
837
				fofoOrderItemRepository.persist(foi);
838
			}
839
		}
24548 amit.gupta 840
 
24542 amit.gupta 841
	}
842
 
24580 amit.gupta 843
	public void schemewalletmismatch() {
844
		LocalDate dateToReconcile = LocalDate.of(2018, 4, 1);
24587 amit.gupta 845
		while (dateToReconcile.isBefore(LocalDate.now())) {
24580 amit.gupta 846
			reconcileSchemes(dateToReconcile);
24587 amit.gupta 847
			// reconcileOrders(dateTime);
848
			// reconcileRecharges(dateTime);
24580 amit.gupta 849
			dateToReconcile = dateToReconcile.plusDays(1);
850
		}
851
	}
852
 
853
	private void reconcileSchemes(LocalDate date) {
854
		LocalDateTime startDate = date.atStartOfDay();
855
		LocalDateTime endDate = startDate.plusDays(1);
856
		List<SchemeInOut> siosCreated = schemeInOutRepository.selectAllByCreateDate(startDate, endDate);
857
		List<SchemeInOut> siosRefunded = schemeInOutRepository.selectAllByRefundDate(startDate, endDate);
24587 amit.gupta 858
		double totalSchemeDisbursed = siosCreated.stream().mapToDouble(x -> x.getAmount()).sum();
859
		double totalSchemeRolledback = siosRefunded.stream().mapToDouble(x -> x.getAmount()).sum();
24580 amit.gupta 860
		double netSchemeDisbursed = totalSchemeDisbursed - totalSchemeRolledback;
24587 amit.gupta 861
		List<WalletReferenceType> walletReferenceTypes = Arrays.asList(WalletReferenceType.SCHEME_IN,
862
				WalletReferenceType.SCHEME_OUT);
863
		List<UserWalletHistory> history = userWalletHistoryRepository.selectAllByDateType(startDate, endDate,
864
				walletReferenceTypes);
865
		double schemeAmountWalletTotal = history.stream().mapToDouble(x -> x.getAmount()).sum();
866
		if (Math.abs(netSchemeDisbursed - schemeAmountWalletTotal) > 10d) {
24580 amit.gupta 867
			LOGGER.info("Scheme Amount mismatched for Date {}", date);
24587 amit.gupta 868
 
869
			Map<Integer, Double> inventoryItemSchemeIO = siosCreated.stream().collect(Collectors
870
					.groupingBy(x -> x.getInventoryItemId(), Collectors.summingDouble(SchemeInOut::getAmount)));
871
 
872
			Map<Integer, Double> userSchemeMap = inventoryItemRepository.selectByIds(inventoryItemSchemeIO.keySet())
873
					.stream().collect(Collectors.groupingBy(x -> x.getFofoId(),
874
							Collectors.summingDouble(x -> inventoryItemSchemeIO.get(x.getId()))));
875
 
876
			Map<Integer, Double> inventoryItemSchemeIORefunded = siosRefunded.stream().collect(Collectors
877
					.groupingBy(x -> x.getInventoryItemId(), Collectors.summingDouble(SchemeInOut::getAmount)));
878
 
879
			Map<Integer, Double> userSchemeRefundedMap = inventoryItemRepository
880
					.selectByIds(inventoryItemSchemeIORefunded.keySet()).stream()
881
					.collect(Collectors.groupingBy(x -> x.getFofoId(),
882
							Collectors.summingDouble(x -> inventoryItemSchemeIORefunded.get(x.getId()))));
883
 
884
			Map<Integer, Double> finalUserSchemeAmountMap = new HashMap<>();
885
			for (Map.Entry<Integer, Double> schemeAmount : userSchemeMap.entrySet()) {
886
			}
887
			for (Map.Entry<Integer, Double> schemeAmount : userSchemeRefundedMap.entrySet()) {
888
				if (!finalUserSchemeAmountMap.containsKey(schemeAmount.getKey())) {
889
					finalUserSchemeAmountMap.put(schemeAmount.getKey(), schemeAmount.getValue());
890
				} else {
891
					finalUserSchemeAmountMap.put(schemeAmount.getKey(),
892
							finalUserSchemeAmountMap.get(schemeAmount.getKey()) + schemeAmount.getValue());
893
				}
894
			}
24590 amit.gupta 895
			Map<Integer, Integer> userWalletMap = userWalletRepository
896
					.selectByRetailerIds(finalUserSchemeAmountMap.keySet()).stream()
897
					.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
898
 
24587 amit.gupta 899
			Map<Integer, Double> walletAmountMap = history.stream().collect(Collectors.groupingBy(
900
					UserWalletHistory::getWalletId, Collectors.summingDouble((UserWalletHistory::getAmount))));
901
			for (Map.Entry<Integer, Double> userAmount : walletAmountMap.entrySet()) {
902
				double diff = Math.abs(finalUserSchemeAmountMap.get(userAmount.getKey()) - userAmount.getValue());
903
				if (diff > 5) {
904
					LOGGER.info("Partner scheme mismatched for Userid {}", userWalletMap.get(userAmount.getKey()));
905
				}
906
			}
24580 amit.gupta 907
		}
24587 amit.gupta 908
 
24580 amit.gupta 909
	}
24590 amit.gupta 910
 
24592 amit.gupta 911
	public void dryRunSchemeReco() throws Exception {
24635 amit.gupta 912
		Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream()
913
				.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
914
 
24592 amit.gupta 915
		List<UserWalletHistory> userWalletHistory = new ArrayList<>();
916
		List<SchemeInOut> rolledbackSios = new ArrayList<>();
24635 amit.gupta 917
		Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream()
918
				.collect(Collectors.toMap(Scheme::getId, Scheme::getType));
919
		Set<String> serialNumbersConsidered = new HashSet<>();
920
 
25096 amit.gupta 921
		LocalDateTime startDate = LocalDate.of(2018, 3, 1).atStartOfDay();
24635 amit.gupta 922
		LocalDateTime endDate = LocalDate.now().atStartOfDay();
923
		List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
924
 
24683 amit.gupta 925
		Map<Integer, String> storeNameMap = fofoStoreRepository.getStoresMap();
24635 amit.gupta 926
		purchases.stream().forEach(purchase -> {
927
			float amountToRollback = 0;
928
			String description = "Adjustment of Duplicate Scheme for Purchase Invoice "
929
					+ purchase.getPurchaseReference();
930
			Map<Integer, String> inventorySerialNumberMap = inventoryItemRepository.selectByPurchaseId(purchase.getId())
931
					.stream().filter(ii -> ii.getSerialNumber() != null)
932
					.collect(Collectors.toMap(InventoryItem::getId, InventoryItem::getSerialNumber));
933
			if (inventorySerialNumberMap.size() > 0) {
934
				for (Map.Entry<Integer, String> inventorySerialNumberEntry : inventorySerialNumberMap.entrySet()) {
935
					String serialNumber = inventorySerialNumberEntry.getValue();
936
					int inventoryItemId = inventorySerialNumberEntry.getKey();
937
					if (serialNumbersConsidered.contains(serialNumber)) {
938
						// This will rollback scheme for differenct orders for same serial
939
						List<SchemeInOut> sios = schemeInOutRepository
940
								.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
941
								.filter(x -> x.getRolledBackTimestamp() == null
942
										&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.IN))
943
								.collect(Collectors.toList());
944
						Collections.reverse(sios);
945
						for (SchemeInOut sio : sios) {
946
							sio.setRolledBackTimestamp(LocalDateTime.now());
947
							amountToRollback += sio.getAmount();
948
							// sio.setSchemeType(SchemeType.OUT);
949
							sio.setSerialNumber(serialNumber);
950
							rolledbackSios.add(sio);
951
						}
952
						description = description.concat(" " + serialNumber + " ");
953
					} else {
954
						serialNumbersConsidered.add(serialNumber);
955
						List<Integer> schemesConsidered = new ArrayList<>();
956
						List<SchemeInOut> sios = schemeInOutRepository
957
								.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
958
								.filter(x -> x.getRolledBackTimestamp() == null
959
										&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.IN))
960
								.collect(Collectors.toList());
961
						Collections.reverse(sios);
962
						for (SchemeInOut sio : sios) {
963
							if (!schemesConsidered.contains(sio.getSchemeId())) {
964
								schemesConsidered.add(sio.getSchemeId());
965
								continue;
966
							}
967
							sio.setRolledBackTimestamp(LocalDateTime.now());
968
							amountToRollback += sio.getAmount();
969
							// sio.setSchemeType(SchemeType.OUT);
970
							sio.setSerialNumber(serialNumber);
24681 amit.gupta 971
							sio.setStoreCode(storeNameMap.get(purchase.getFofoId()));
972
							sio.setReference(purchase.getId());
24635 amit.gupta 973
							rolledbackSios.add(sio);
974
						}
975
					}
976
 
977
				}
978
			}
979
			if (amountToRollback > 0) {
24683 amit.gupta 980
				// Address address =
981
				// addressRepository.selectAllByRetailerId(purchase.getFofoId(), 0, 10).get(0);
24635 amit.gupta 982
				UserWalletHistory uwh = new UserWalletHistory();
983
				uwh.setAmount(Math.round(amountToRollback));
984
				uwh.setDescription(description);
985
				uwh.setTimestamp(LocalDateTime.now());
24681 amit.gupta 986
				uwh.setReferenceType(WalletReferenceType.SCHEME_IN);
24635 amit.gupta 987
				uwh.setReference(purchase.getId());
988
				uwh.setWalletId(userWalletMap.get(purchase.getFofoId()));
989
				uwh.setFofoId(purchase.getFofoId());
24681 amit.gupta 990
				uwh.setStoreCode(storeNameMap.get(purchase.getFofoId()));
24635 amit.gupta 991
				userWalletHistory.add(uwh);
992
			}
993
		});
994
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
995
				Arrays.asList("User Id", "Store Code", "Reference Type", "Reference", "Amount", "Description",
996
						"Timestamp"),
997
				userWalletHistory.stream()
998
						.map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(),
999
								x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
1000
						.collect(Collectors.toList()));
1001
 
1002
		ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
24683 amit.gupta 1003
				Arrays.asList("Scheme ID", "SchemeType", "Reference", "Store Code", "Serial Number", "Amount",
1004
						"Created", "Rolledback"),
24635 amit.gupta 1005
				rolledbackSios.stream()
24681 amit.gupta 1006
						.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getReference(), x.getStoreCode(),
24635 amit.gupta 1007
								x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
1008
						.collect(Collectors.toList()));
1009
 
25043 amit.gupta 1010
		Utils.sendMailWithAttachments(googleMailSender, new String[] { "amit.gupta@shop2020.in" }, null,
24636 amit.gupta 1011
				"Partner Excess Amount Scheme In", "PFA",
24635 amit.gupta 1012
				new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
24636 amit.gupta 1013
						new Attachment("SchemeInRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
24635 amit.gupta 1014
 
25096 amit.gupta 1015
		throw new Exception();
24635 amit.gupta 1016
 
1017
	}
1018
 
1019
	public void dryRunOutSchemeReco() throws Exception {
1020
		List<UserWalletHistory> userWalletHistory = new ArrayList<>();
1021
		List<SchemeInOut> rolledbackSios = new ArrayList<>();
24606 amit.gupta 1022
		Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream()
1023
				.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
24590 amit.gupta 1024
		Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream()
1025
				.collect(Collectors.toMap(Scheme::getId, Scheme::getType));
25028 amit.gupta 1026
		LocalDateTime startDate = LocalDate.of(2019, 5, 1).atStartOfDay();
24632 amit.gupta 1027
		LocalDateTime endDate = LocalDate.now().atStartOfDay();
24631 amit.gupta 1028
		List<FofoOrder> allOrders = fofoOrderRepository.selectBetweenSaleDate(startDate, endDate);
1029
		// Collections.reverse(allOrders);
1030
		// List<FofoOrder> allOrders =
24653 govind 1031
		// List<FofoOrder> allOrders =
24631 amit.gupta 1032
		// Arrays.asList(fofoOrderRepository.selectByInvoiceNumber("UPGZ019/25"));
24625 amit.gupta 1033
		Set<String> serialNumbersConsidered = new HashSet<>();
24590 amit.gupta 1034
		allOrders.stream().forEach(fofoOrder -> {
24592 amit.gupta 1035
			String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
24598 amit.gupta 1036
			Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
24592 amit.gupta 1037
			float amountToRollback = 0;
24590 amit.gupta 1038
			List<FofoOrderItem> orderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
1039
			orderItems.forEach(x -> {
24606 amit.gupta 1040
				inventorySerialNumberMap.putAll(x.getFofoLineItems().stream().filter(li -> li.getSerialNumber() != null)
24598 amit.gupta 1041
						.collect(Collectors.toMap(FofoLineItem::getInventoryItemId, FofoLineItem::getSerialNumber)));
24590 amit.gupta 1042
			});
24606 amit.gupta 1043
			if (inventorySerialNumberMap.size() > 0) {
24631 amit.gupta 1044
				for (Map.Entry<Integer, String> inventorySerialNumberEntry : inventorySerialNumberMap.entrySet()) {
1045
					String serialNumber = inventorySerialNumberEntry.getValue();
1046
					int inventoryItemId = inventorySerialNumberEntry.getKey();
1047
					if (serialNumbersConsidered.contains(serialNumber)) {
1048
						// This will rollback scheme for differenct orders for same serial
1049
						List<SchemeInOut> sios = schemeInOutRepository
24633 amit.gupta 1050
								.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
24635 amit.gupta 1051
								.filter(x -> x.getRolledBackTimestamp() == null
1052
										&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT))
24631 amit.gupta 1053
								.collect(Collectors.toList());
1054
						Collections.reverse(sios);
1055
						for (SchemeInOut sio : sios) {
1056
							sio.setRolledBackTimestamp(LocalDateTime.now());
1057
							amountToRollback += sio.getAmount();
1058
							// sio.setSchemeType(SchemeType.OUT);
1059
							sio.setSerialNumber(serialNumber);
1060
							sio.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
24681 amit.gupta 1061
							sio.setReference(fofoOrder.getId());
24631 amit.gupta 1062
							rolledbackSios.add(sio);
24623 amit.gupta 1063
						}
24635 amit.gupta 1064
						description = description.concat(" " + serialNumber + " ");
24631 amit.gupta 1065
					} else {
1066
						serialNumbersConsidered.add(serialNumber);
1067
						List<Integer> schemesConsidered = new ArrayList<>();
1068
						List<SchemeInOut> sios = schemeInOutRepository
24633 amit.gupta 1069
								.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
24635 amit.gupta 1070
								.filter(x -> x.getRolledBackTimestamp() == null
1071
										&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT))
24631 amit.gupta 1072
								.collect(Collectors.toList());
1073
						Collections.reverse(sios);
1074
						for (SchemeInOut sio : sios) {
1075
							if (!schemesConsidered.contains(sio.getSchemeId())) {
1076
								schemesConsidered.add(sio.getSchemeId());
1077
								continue;
1078
							}
1079
							sio.setRolledBackTimestamp(LocalDateTime.now());
1080
							amountToRollback += sio.getAmount();
1081
							// sio.setSchemeType(SchemeType.OUT);
24681 amit.gupta 1082
							sio.setReference(fofoOrder.getId());
24631 amit.gupta 1083
							sio.setSerialNumber(serialNumber);
1084
							sio.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
1085
							rolledbackSios.add(sio);
1086
						}
24615 amit.gupta 1087
					}
24631 amit.gupta 1088
 
24604 amit.gupta 1089
				}
24590 amit.gupta 1090
			}
24631 amit.gupta 1091
			if (amountToRollback > 0) {
1092
				UserWalletHistory uwh = new UserWalletHistory();
1093
				uwh.setAmount(Math.round(amountToRollback));
1094
				uwh.setDescription(description);
1095
				uwh.setTimestamp(LocalDateTime.now());
1096
				uwh.setReferenceType(WalletReferenceType.SCHEME_OUT);
1097
				uwh.setReference(fofoOrder.getId());
1098
				uwh.setWalletId(userWalletMap.get(fofoOrder.getFofoId()));
1099
				uwh.setFofoId(fofoOrder.getFofoId());
1100
				uwh.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
1101
				userWalletHistory.add(uwh);
1102
			}
24590 amit.gupta 1103
		});
24598 amit.gupta 1104
 
24592 amit.gupta 1105
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
24681 amit.gupta 1106
				Arrays.asList("Wallet Id", "Store Code", "Reference Type", "Reference", "Amount", "Description",
24615 amit.gupta 1107
						"Timestamp"),
1108
				userWalletHistory.stream()
1109
						.map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(),
1110
								x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
24592 amit.gupta 1111
						.collect(Collectors.toList()));
1112
 
1113
		ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
1114
				Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created",
1115
						"Rolledback"),
1116
				rolledbackSios.stream()
1117
						.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
1118
								x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
1119
						.collect(Collectors.toList()));
1120
 
25043 amit.gupta 1121
		Utils.sendMailWithAttachments(googleMailSender, new String[] { "amit.gupta@shop2020.in" }, null,
24681 amit.gupta 1122
				"Partner Excess Amount Scheme Out", "PFA",
24598 amit.gupta 1123
				new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
1124
						new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
24631 amit.gupta 1125
 
25267 amit.gupta 1126
		throw new Exception();
24590 amit.gupta 1127
	}
24615 amit.gupta 1128
 
24611 amit.gupta 1129
	public void dryRunSchemeOutReco1() throws Exception {
24615 amit.gupta 1130
		List<Integer> references = Arrays.asList(6744, 7347, 8320, 8891, 9124, 9217, 9263, 9379);
24611 amit.gupta 1131
		List<UserWalletHistory> userWalletHistory = new ArrayList<>();
1132
		List<SchemeInOut> rolledbackSios = new ArrayList<>();
1133
		Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream()
1134
				.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
1135
		Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream()
1136
				.collect(Collectors.toMap(Scheme::getId, Scheme::getType));
1137
		references.stream().forEach(reference -> {
1138
			FofoOrder fofoOrder = null;
1139
			try {
1140
				fofoOrder = fofoOrderRepository.selectByOrderId(reference);
24615 amit.gupta 1141
			} catch (Exception e) {
1142
 
24611 amit.gupta 1143
			}
1144
			String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
1145
			Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
1146
			float amountToRollback = 0;
1147
			List<FofoOrderItem> orderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
1148
			orderItems.forEach(x -> {
1149
				inventorySerialNumberMap.putAll(x.getFofoLineItems().stream().filter(li -> li.getSerialNumber() != null)
1150
						.collect(Collectors.toMap(FofoLineItem::getInventoryItemId, FofoLineItem::getSerialNumber)));
1151
			});
1152
			if (inventorySerialNumberMap.size() > 0) {
24615 amit.gupta 1153
				List<SchemeInOut> sios = schemeInOutRepository
1154
						.selectByInventoryItemIds(inventorySerialNumberMap.keySet()).stream()
1155
						.filter(x -> schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT))
24611 amit.gupta 1156
						.collect(Collectors.toList());
1157
				LOGGER.info("Found {} duplicate schemeouts for Orderid {}", sios.size(), fofoOrder.getId());
1158
				UserWalletHistory uwh = new UserWalletHistory();
24615 amit.gupta 1159
				Map<Integer, List<SchemeInOut>> inventoryIdSouts = sios.stream()
1160
						.collect(Collectors.groupingBy(SchemeInOut::getInventoryItemId, Collectors.toList()));
24611 amit.gupta 1161
				for (Map.Entry<Integer, List<SchemeInOut>> inventorySioEntry : inventoryIdSouts.entrySet()) {
1162
					List<SchemeInOut> outList = inventorySioEntry.getValue();
24615 amit.gupta 1163
					if (outList.size() > 1) {
1164
 
24611 amit.gupta 1165
					}
1166
				}
1167
				uwh.setAmount(Math.round(amountToRollback));
1168
				uwh.setDescription(description);
1169
				uwh.setTimestamp(LocalDateTime.now());
1170
				uwh.setReferenceType(WalletReferenceType.SCHEME_OUT);
1171
				uwh.setReference(fofoOrder.getId());
1172
				uwh.setWalletId(userWalletMap.get(fofoOrder.getFofoId()));
1173
				uwh.setFofoId(fofoOrder.getFofoId());
1174
				uwh.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
1175
				userWalletHistory.add(uwh);
1176
			}
1177
		});
24615 amit.gupta 1178
 
24611 amit.gupta 1179
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
1180
				Arrays.asList("User Id", "Reference Type", "Reference", "Amount", "Description", "Timestamp"),
1181
				userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getReferenceType(),
1182
						x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
24615 amit.gupta 1183
						.collect(Collectors.toList()));
1184
 
24611 amit.gupta 1185
		ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
1186
				Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created",
1187
						"Rolledback"),
1188
				rolledbackSios.stream()
24615 amit.gupta 1189
						.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
1190
								x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
1191
						.collect(Collectors.toList()));
1192
 
24623 amit.gupta 1193
		Utils.sendMailWithAttachments(googleMailSender,
1194
				new String[] { "amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com" }, null,
24611 amit.gupta 1195
				"Partner Excess Amount", "PFA",
1196
				new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
1197
						new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
24631 amit.gupta 1198
 
24628 amit.gupta 1199
		throw new Exception();
24615 amit.gupta 1200
 
24611 amit.gupta 1201
	}
24615 amit.gupta 1202
 
24855 amit.gupta 1203
	public void sendDailySalesReportNotificationToPartner(Integer fofoIdInt)
24653 govind 1204
			throws ProfitMandiBusinessException, MessagingException, IOException {
1205
		LocalDateTime now = LocalDateTime.now();
1206
		LocalDateTime from = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 00, 00);
1207
		Map<Integer, Double> salesByFofoIdMap = new HashMap<>();
24855 amit.gupta 1208
		List<Integer> fofoIds = null;
25043 amit.gupta 1209
		if (fofoIdInt == null) {
1210
			fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
1211
					.collect(Collectors.toList());
24856 amit.gupta 1212
		} else {
24855 amit.gupta 1213
			fofoIds = Arrays.asList(fofoIdInt);
1214
		}
24653 govind 1215
		List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
1216
				.selectAllGeEqAndLeEqStartDateAndEndDate(now);
24683 amit.gupta 1217
		DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h a");
1218
 
1219
		Map<Integer, Float> dailyTarget = new HashMap<>();
24653 govind 1220
		for (Integer fofoId : fofoIds) {
24683 amit.gupta 1221
			Map<Integer, Float> dailyAverageSale = null;
24653 govind 1222
			double sale = fofoOrderRepository.selectTotalSaleSumByFofoIdBrtweenDate(fofoId, from, now);
1223
			for (PartnerTargetDetails partnerTargetDetail : partnerTargetDetails) {
1224
				Map<Integer, Float> targetValues = targetService.getTargetValueByFofoIdAndTargetId(fofoId,
1225
						partnerTargetDetail.getId());
1226
				if (targetValues.size() == 0) {
1227
					continue;
1228
				} else {
1229
					List<Integer> partnerIds = new ArrayList<>();
1230
					partnerIds.add(fofoId);
1231
					dailyAverageSale = targetService.getDailyAverageSaleForCurrentForSingleFofoIdAndBrand(partnerIds,
1232
							targetValues, partnerTargetDetail.getStartDate(), partnerTargetDetail.getEndDate(),
1233
							partnerTargetDetail.getBrandName());
1234
					dailyTarget.put(fofoId, dailyAverageSale.get(fofoId));
1235
					break;
1236
				}
1237
			}
1238
			NotificationCampaigns notification = new NotificationCampaigns();
24847 amit.gupta 1239
			notification.setName("Daily Sales");
1240
			notification.setTitle("Daily Sale Update");
24683 amit.gupta 1241
			if (dailyAverageSale != null && dailyAverageSale.get(fofoId) != null) {
24864 amit.gupta 1242
				notification.setMessage(String.format("Rs.%.0f till %s. Today's Target is Rs.%.0f", sale,
24847 amit.gupta 1243
						now.format(timeFormatter), dailyAverageSale.get(fofoId)));
24683 amit.gupta 1244
			} else {
25043 amit.gupta 1245
				notification.setMessage(String.format("Rs.%.0f till %s", sale, now.format(timeFormatter)));
24653 govind 1246
			}
24683 amit.gupta 1247
			// notification.setMessage("Your sale is "+salesbyfofoId.get(fofoId));
24989 tejbeer 1248
			notification.setType("url");
24863 govind 1249
			notification.setUrl("http://app.profitmandi.com/pages/home/notifications");
24683 amit.gupta 1250
			LOGGER.info("UserID" + userAccountRepository.selectUserIdByRetailerId(fofoId));
1251
			notification.setSql("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
1252
					+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
1253
					+ " where d2.id is null and d1.user_id = "
1254
					+ userAccountRepository.selectUserIdByRetailerId(fofoId));
24676 govind 1255
			LOGGER.info("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
24683 amit.gupta 1256
					+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
1257
					+ " where d2.id is null and d1.user_id = "
1258
					+ userAccountRepository.selectUserIdByRetailerId(fofoId));
24667 govind 1259
			notification.setExpiresat(LocalDateTime.now().plusDays(1).toEpochSecond(ZoneOffset.UTC) * 1000);
24653 govind 1260
			notification.setStatus("active");
1261
			notification.setSmsprocessed(0);
1262
			notification.setNotification_processed(0);
1263
			notification.setNotification_type("GENERAL_NOTIFICATION");
24657 govind 1264
			mongoClient.persistNotificationCmpInfo(notification);
24653 govind 1265
			salesByFofoIdMap.put(fofoId, sale);
1266
			LOGGER.info(sale);
1267
		}
24683 amit.gupta 1268
		String saleReport = this.getDailySalesReportByPartnerId(salesByFofoIdMap, dailyTarget);
24653 govind 1269
		LOGGER.info(saleReport);
1270
		String cc[] = { "Tarun.verma@smartdukaan.com", "Kamini.sharma@smartdukaan.com",
24697 amit.gupta 1271
				"chaitnaya.vats@smartdukaan.com", "adeel.yazdani@smartdukaan.com", "mohinder.mutreja@smartdukaan.com" };
24653 govind 1272
		String subject = "sale report till" + " " + now.format(timeFormatter);
24677 govind 1273
		this.sendMailOfHtmlFomat("amod.sen@smartdukaan.com", saleReport, cc, subject);
24653 govind 1274
	}
1275
 
24683 amit.gupta 1276
	public String getDailySalesReportByPartnerId(Map<Integer, Double> salesByFofoIdMap, Map<Integer, Float> dailyTarget)
24653 govind 1277
			throws ProfitMandiBusinessException {
1278
		StringBuilder sb = new StringBuilder();
1279
		sb.append("<html><body><p>Sale Report:</p><br/><table style='border:1px solid black ;padding: 5px';>");
1280
		sb.append("<tbody>\n" + "	    				<tr>\n"
1281
				+ "	    					<th style='border:1px solid black;padding: 5px'>Partner</th>\n"
1282
				+ "	    					<th style='border:1px solid black;padding: 5px'>Daily Target</th>\n"
1283
				+ "	    					<th style='border:1px solid black;padding: 5px'>Sale</th>\n"
1284
				+ "	    				</tr>");
1285
		for (Integer fofoId : salesByFofoIdMap.keySet()) {
25043 amit.gupta 1286
			try {
1287
				String PartnerName = retailerService.getFofoRetailer(fofoId).getBusinessName();
1288
				sb.append("<tr>");
1289
				sb.append("<td style='border:1px solid black;padding: 5px'>" + PartnerName + "</td>");
1290
				if (dailyTarget != null && dailyTarget.get(fofoId) != null) {
1291
					sb.append("<td style='border:1px solid black;padding: 5px'>" + dailyTarget.get(fofoId) + "</td>");
1292
				} else {
1293
					sb.append("<td style='border:1px solid black;padding: 5px'>" + 0.0 + "</td>");
1294
				}
1295
				sb.append("<td style='border:1px solid black;padding: 5px'>" + salesByFofoIdMap.get(fofoId) + "</td>");
24653 govind 1296
 
25043 amit.gupta 1297
				sb.append("</tr>");
1298
			} catch (Exception e) {
24842 govind 1299
				e.printStackTrace();
1300
			}
25043 amit.gupta 1301
 
24653 govind 1302
		}
24683 amit.gupta 1303
 
24653 govind 1304
		sb.append("</tbody></table></body></html>");
1305
		return sb.toString();
1306
	}
24841 govind 1307
 
1308
	private void sendMailOfHtmlFomat(String email, String body, String cc[], String subject)
1309
			throws MessagingException, ProfitMandiBusinessException, IOException {
1310
		MimeMessage message = mailSender.createMimeMessage();
1311
		MimeMessageHelper helper = new MimeMessageHelper(message);
1312
		helper.setSubject(subject);
1313
		helper.setText(body, true);
1314
		helper.setTo(email);
1315
		if (cc != null) {
1316
			helper.setCc(cc);
1317
		}
1318
		InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smart Dukaan");
1319
		helper.setFrom(senderAddress);
1320
		mailSender.send(message);
1321
	}
25300 tejbeer 1322
 
25351 tejbeer 1323
	public void sendNotification() throws Exception {
25300 tejbeer 1324
		List<PushNotifications> pushNotifications = pushNotificationRepository.selectAllByTimestamp();
1325
		if (!pushNotifications.isEmpty()) {
1326
			for (PushNotifications pushNotification : pushNotifications) {
25351 tejbeer 1327
				Device device = deviceRepository.selectById(pushNotification.getDeviceId());
25300 tejbeer 1328
				NotificationCampaign notificationCampaign = notificationCampaignRepository
1329
						.selectById(pushNotification.getNotificationCampaignid());
1330
				Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls()
1331
						.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeJsonConverter()).create();
1332
 
1333
				SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
1334
						SimpleCampaignParams.class);
1335
				Campaign campaign = new SimpleCampaign(scp);
25351 tejbeer 1336
				String result_url = campaign.getUrl() + "&user_id=" + device.getUser_id();
25300 tejbeer 1337
				JSONObject json = new JSONObject();
25351 tejbeer 1338
				json.put("to", device.getFcmId());
25300 tejbeer 1339
				JSONObject jsonObj = new JSONObject();
1340
				jsonObj.put("message", campaign.getMessage());
1341
				jsonObj.put("title", campaign.getTitle());
1342
				jsonObj.put("type", campaign.getType());
1343
				jsonObj.put("url", result_url);
1344
				jsonObj.put("time_to_live", campaign.getExpireTimestamp());
1345
				jsonObj.put("image", campaign.getImageUrl());
1346
				jsonObj.put("largeIcon", "large_icon");
1347
				jsonObj.put("smallIcon", "small_icon");
1348
				jsonObj.put("vibrate", 1);
1349
				jsonObj.put("pid", pushNotification.getId());
1350
				jsonObj.put("sound", 1);
1351
				jsonObj.put("priority", "high");
1352
				json.put("data", jsonObj);
25351 tejbeer 1353
				try {
1354
					CloseableHttpClient client = HttpClients.createDefault();
1355
					HttpPost httpPost = new HttpPost(FCM_URL);
25300 tejbeer 1356
 
25351 tejbeer 1357
					httpPost.setHeader("Content-Type", "application/json; utf-8");
1358
					httpPost.setHeader("authorization", "key=" + FCM_API_KEY);
1359
					StringEntity entity = new StringEntity(json.toString());
1360
					httpPost.setEntity(entity);
1361
					CloseableHttpResponse response = client.execute(httpPost);
1362
					LOGGER.info("response" + response);
25300 tejbeer 1363
 
25351 tejbeer 1364
					if (response.getStatusLine().getStatusCode() == 200) {
1365
						pushNotification.setSentTimestamp(LocalDateTime.now());
1366
					} else {
25356 tejbeer 1367
						pushNotification.setSentTimestamp(LocalDateTime.of(1970, 1, 1, 00, 00));
25351 tejbeer 1368
						LOGGER.info("message" + "not sent");
1369
					}
25300 tejbeer 1370
 
25351 tejbeer 1371
				} catch (Exception e) {
1372
					e.printStackTrace();
25300 tejbeer 1373
					LOGGER.info("message" + "not sent");
1374
				}
1375
			}
1376
		}
1377
	}
1378
 
25312 amit.gupta 1379
	public static final Map<String, String> nameEmail = new HashMap<>();
1380
 
1381
	public static final Map<String, List<String>> storeManagerMap = new HashMap<>();
1382
 
1383
	static {
1384
		nameEmail.put("Amod", "amod.sen@smartdukaan.com");
25350 amit.gupta 1385
		nameEmail.put("Parmod", "parmod.kumar@smartdukaan.com");
25312 amit.gupta 1386
		nameEmail.put("Anis", "md.anis@smartdukaan.com");
25348 amit.gupta 1387
		nameEmail.put("Manoj", "manoj.singh@smartdukaan.com");
25312 amit.gupta 1388
		nameEmail.put("Adeel", "adeel.yazdani@smartdukaan.com");
25346 amit.gupta 1389
		nameEmail.put("Mohinder", "mohinder.mutreja@smartdukaan.com");
25312 amit.gupta 1390
		nameEmail.put("Dharmendar", "dharmender.verma@smartdukaan.com");
1391
		nameEmail.put("Rajat", "rajat.gupta@smartdukaan.com");
1392
		nameEmail.put("Ankit", "ankit.bhatia@smartdukaan.com");
1393
		nameEmail.put("Rajit", "rajit.alag@smartdukaan.com");
25348 amit.gupta 1394
		nameEmail.put("Gulshan", "gulshan.kumar@smartdukaan.com");
1395
		nameEmail.put("PramodSharma", "parmod.sharma@smartdukaan.com");
25312 amit.gupta 1396
		// nameEmail.put("Gulshan","");
1397
		storeManagerMap.put("themobileplanet03@gmail.com", Arrays.asList("Amod", "", "Adeel"));
25349 amit.gupta 1398
		storeManagerMap.put("mobileplanet7599@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
1399
		storeManagerMap.put("robintelecom.snp@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
25312 amit.gupta 1400
		storeManagerMap.put("smartconnect4141@gmail.com", Arrays.asList("Amod", "", "Adeel"));
25349 amit.gupta 1401
		storeManagerMap.put("bhimsain919@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
1402
		storeManagerMap.put("babitaranirk@gmail.com", Arrays.asList("PramodSharma", "", "Mohinder"));
25312 amit.gupta 1403
		storeManagerMap.put("dharmendery079@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
25349 amit.gupta 1404
		storeManagerMap.put("kkv.enterprises1@gmail.com", Arrays.asList("PramodSharma", "", "Mohinder"));
25312 amit.gupta 1405
		storeManagerMap.put("gulshersaifi74226@gmail.com", Arrays.asList("Amod", "", "Adeel"));
1406
		storeManagerMap.put("deepak.lalwani1985@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
1407
		storeManagerMap.put("gupta.smartdukaan@gmail.com", Arrays.asList("Amod", "", "Adeel"));
25349 amit.gupta 1408
		storeManagerMap.put("sachinindri2006@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
1409
		storeManagerMap.put("kambojanil83@gmail.com", Arrays.asList("PramodSharma", "", "Mohinder"));
25312 amit.gupta 1410
		storeManagerMap.put("uppal.neeraj82@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
25349 amit.gupta 1411
		storeManagerMap.put("thefonehousekarnal@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
25312 amit.gupta 1412
		storeManagerMap.put("richa9910763006@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
1413
		storeManagerMap.put("smartdukangzb@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
1414
		storeManagerMap.put("lovelymobile183@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
25355 amit.gupta 1415
		storeManagerMap.put("smartdukaan.sonepat@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
25349 amit.gupta 1416
		storeManagerMap.put("arunmittal299@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
1417
		storeManagerMap.put("gtc01100@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
25312 amit.gupta 1418
		storeManagerMap.put("sumittyagi1975@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
25349 amit.gupta 1419
		storeManagerMap.put("metrofurniture342@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
25355 amit.gupta 1420
		storeManagerMap.put("suryaelectronicskaithal@gmail.com", Arrays.asList("PramodSharma", "", "Mohinder"));
25312 amit.gupta 1421
		storeManagerMap.put("mmtelecomsec16@gmail.com", Arrays.asList("Amod", "", "Adeel"));
25349 amit.gupta 1422
		storeManagerMap.put("omsonsindia08@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
25312 amit.gupta 1423
		storeManagerMap.put("smartenterprisespv@gmail.com", Arrays.asList("Amod", "", "Adeel"));
1424
		storeManagerMap.put("cachaitnya@gmail.com", Arrays.asList("Amod", "", "Adeel"));
1425
		storeManagerMap.put("ajaykumarkansal03@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
25434 amit.gupta 1426
		storeManagerMap.put("spurwar73@gmail.com", Arrays.asList("", "Rajat", "Adeel"));
1427
		storeManagerMap.put("Shreemobile.ind@gmail.com", Arrays.asList("", "Rajat", "Adeel"));
25312 amit.gupta 1428
		storeManagerMap.put("felixenterprises2017@rediffmail.com", Arrays.asList("", "Dharmendar", "Mohinder"));
1429
		storeManagerMap.put("nareandergupta@gmail.com", Arrays.asList("", "Dharmendar", "Mohinder"));
1430
		storeManagerMap.put("shreebalajielectronic2019@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
1431
		storeManagerMap.put("saranshary@gmail.com", Arrays.asList("", "Dharmendar", "Mohinder"));
1432
		storeManagerMap.put("gambhirsmartphone@gmail.com", Arrays.asList("", "Gulshan", "Adeel"));
1433
		storeManagerMap.put("Priyankaenterprises9910@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
1434
		storeManagerMap.put("pawan.dhimaan@gmail.com", Arrays.asList("", "Dharmendar", "Mohinder"));
25349 amit.gupta 1435
		storeManagerMap.put("lakshaydhulla62@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
25434 amit.gupta 1436
		storeManagerMap.put("parastelecom.stp@gmail.com", Arrays.asList("", "Rajat", "Adeel"));
25349 amit.gupta 1437
		storeManagerMap.put("talwarmukesh298@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
1438
		storeManagerMap.put("sahilnarang0009@gmail.com", Arrays.asList("PramodSharma", "", "Mohinder"));
25312 amit.gupta 1439
		storeManagerMap.put("supertelecomjind@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
1440
		storeManagerMap.put("saketnagpal@gmail.com", Arrays.asList("", "Rajit", "Mohinder"));
1441
		storeManagerMap.put("DEEPAKGOYAL702.DG@GMAIL.COM", Arrays.asList("", "Ankit", "Mohinder"));
25349 amit.gupta 1442
		storeManagerMap.put("sambhav350@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
25312 amit.gupta 1443
		storeManagerMap.put("mayankarora98133@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
1444
		storeManagerMap.put("vijaymobilityandmoew@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
1445
		storeManagerMap.put("amitv70003@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
25434 amit.gupta 1446
		storeManagerMap.put("newagelucknow.123@gmail.com", Arrays.asList("", "Rajat", "Adeel"));
1447
		storeManagerMap.put("Newagetechnologygomtinagar@gmail.com", Arrays.asList("", "Rajat", "Adeel"));
25349 amit.gupta 1448
		storeManagerMap.put("rohitbatra106@gmail.com", Arrays.asList("PramodSharma", "Dharmendar", "Mohinder"));
25312 amit.gupta 1449
		storeManagerMap.put("sonisunil9050873061@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
1450
		storeManagerMap.put("moderncohsr@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
1451
		storeManagerMap.put("raghubir.ngh@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
1452
		storeManagerMap.put("aman007singla@gmail.com", Arrays.asList("", "Rajit", "Mohinder"));
1453
	}
24587 amit.gupta 1454
}