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