Subversion Repositories SmartDukaan

Rev

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