| Line 1... |
Line 1... |
| 1 |
package com.smartdukaan.cron.scheduled;
|
1 |
package com.smartdukaan.cron.scheduled;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.io.FileOutputStream;
|
| - |
|
4 |
import java.io.IOException;
|
| - |
|
5 |
import java.io.ObjectOutputStream;
|
| - |
|
6 |
import java.io.Serializable;
|
| - |
|
7 |
import java.io.UnsupportedEncodingException;
|
| - |
|
8 |
import java.math.BigDecimal;
|
| - |
|
9 |
import java.math.RoundingMode;
|
| - |
|
10 |
import java.nio.file.Files;
|
| - |
|
11 |
import java.nio.file.Paths;
|
| - |
|
12 |
import java.sql.Timestamp;
|
| - |
|
13 |
import java.text.DecimalFormat;
|
| - |
|
14 |
import java.time.Duration;
|
| - |
|
15 |
import java.time.LocalDate;
|
| - |
|
16 |
import java.time.LocalDateTime;
|
| - |
|
17 |
import java.time.LocalTime;
|
| - |
|
18 |
import java.time.Month;
|
| - |
|
19 |
import java.time.YearMonth;
|
| - |
|
20 |
import java.time.format.DateTimeFormatter;
|
| - |
|
21 |
import java.time.temporal.ChronoField;
|
| - |
|
22 |
import java.time.temporal.ChronoUnit;
|
| - |
|
23 |
import java.util.ArrayList;
|
| - |
|
24 |
import java.util.Arrays;
|
| - |
|
25 |
import java.util.Base64;
|
| - |
|
26 |
import java.util.Collections;
|
| - |
|
27 |
import java.util.Comparator;
|
| - |
|
28 |
import java.util.HashMap;
|
| - |
|
29 |
import java.util.HashSet;
|
| - |
|
30 |
import java.util.LinkedHashMap;
|
| - |
|
31 |
import java.util.List;
|
| - |
|
32 |
import java.util.Map;
|
| - |
|
33 |
import java.util.Map.Entry;
|
| - |
|
34 |
import java.util.Optional;
|
| - |
|
35 |
import java.util.Set;
|
| - |
|
36 |
import java.util.stream.Collectors;
|
| - |
|
37 |
|
| - |
|
38 |
import javax.mail.MessagingException;
|
| - |
|
39 |
import javax.mail.internet.InternetAddress;
|
| - |
|
40 |
import javax.mail.internet.MimeMessage;
|
| - |
|
41 |
|
| - |
|
42 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| - |
|
43 |
import org.apache.commons.lang.StringUtils;
|
| - |
|
44 |
import org.apache.http.client.methods.CloseableHttpResponse;
|
| - |
|
45 |
import org.apache.http.client.methods.HttpPost;
|
| - |
|
46 |
import org.apache.http.conn.HttpHostConnectException;
|
| - |
|
47 |
import org.apache.http.entity.StringEntity;
|
| - |
|
48 |
import org.apache.http.impl.client.CloseableHttpClient;
|
| - |
|
49 |
import org.apache.http.impl.client.HttpClients;
|
| - |
|
50 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
51 |
import org.apache.logging.log4j.Logger;
|
| - |
|
52 |
import org.json.JSONArray;
|
| - |
|
53 |
import org.json.JSONObject;
|
| - |
|
54 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
55 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| - |
|
56 |
import org.springframework.beans.factory.annotation.Value;
|
| - |
|
57 |
import org.springframework.core.io.ByteArrayResource;
|
| - |
|
58 |
import org.springframework.core.io.InputStreamSource;
|
| - |
|
59 |
import org.springframework.mail.javamail.JavaMailSender;
|
| - |
|
60 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
| - |
|
61 |
import org.springframework.stereotype.Component;
|
| - |
|
62 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
63 |
|
| 3 |
import com.google.common.collect.Lists;
|
64 |
import com.google.common.collect.Lists;
|
| 4 |
import com.google.gson.Gson;
|
65 |
import com.google.gson.Gson;
|
| 5 |
import com.razorpay.Payment;
|
66 |
import com.razorpay.Payment;
|
| 6 |
import com.smartdukaan.cron.itelImeiActivation.ItelImeiActivationService;
|
67 |
import com.smartdukaan.cron.itelImeiActivation.ItelImeiActivationService;
|
| 7 |
import com.smartdukaan.cron.itelImeiActivation.TecnoImeiActivation;
|
68 |
import com.smartdukaan.cron.itelImeiActivation.TecnoImeiActivation;
|
| 8 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
69 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 9 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
70 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
| 10 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
71 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
| 11 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
72 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
73 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| - |
|
74 |
import com.spice.profitmandi.common.model.FocusedModelShortageModel;
|
| 12 |
import com.spice.profitmandi.common.model.*;
|
75 |
import com.spice.profitmandi.common.model.GstRate;
|
| - |
|
76 |
import com.spice.profitmandi.common.model.InvoicePdfModel;
|
| - |
|
77 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
78 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| - |
|
79 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 13 |
import com.spice.profitmandi.common.services.ReporticoService;
|
80 |
import com.spice.profitmandi.common.services.ReporticoService;
|
| 14 |
import com.spice.profitmandi.common.services.mandii.AccountStatusResponseOut;
|
81 |
import com.spice.profitmandi.common.services.mandii.AccountStatusResponseOut;
|
| 15 |
import com.spice.profitmandi.common.services.mandii.EligibilityStatusEnum;
|
82 |
import com.spice.profitmandi.common.services.mandii.EligibilityStatusEnum;
|
| 16 |
import com.spice.profitmandi.common.services.mandii.MandiiService;
|
83 |
import com.spice.profitmandi.common.services.mandii.MandiiService;
|
| 17 |
import com.spice.profitmandi.common.util.FileUtil;
|
84 |
import com.spice.profitmandi.common.util.FileUtil;
|
| Line 26... |
Line 93... |
| 26 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
|
93 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
|
| 27 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
94 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 28 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
95 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 29 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
96 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 30 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
97 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
| - |
|
98 |
import com.spice.profitmandi.dao.entity.dtr.CreditAccount;
|
| - |
|
99 |
import com.spice.profitmandi.dao.entity.dtr.CreditStatus;
|
| - |
|
100 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
| - |
|
101 |
import com.spice.profitmandi.dao.entity.dtr.EmployeeAttendance;
|
| - |
|
102 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| - |
|
103 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
| - |
|
104 |
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
|
| - |
|
105 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
| - |
|
106 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
| - |
|
107 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
| 31 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
108 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| - |
|
109 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
| - |
|
110 |
import com.spice.profitmandi.dao.entity.fofo.CurrentPartnerDailyInvestment;
|
| 32 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
111 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
| - |
|
112 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
| - |
|
113 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
| - |
|
114 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| - |
|
115 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| - |
|
116 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| - |
|
117 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| - |
|
118 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| - |
|
119 |
import com.spice.profitmandi.dao.entity.fofo.PartnerProblem;
|
| - |
|
120 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| - |
|
121 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
|
| - |
|
122 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
|
| - |
|
123 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 33 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
124 |
import com.spice.profitmandi.dao.entity.fofo.RazorPay;
|
| - |
|
125 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| - |
|
126 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 34 |
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
|
127 |
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
|
| 35 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
128 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
| 36 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
129 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| 37 |
import com.spice.profitmandi.dao.entity.transaction.*;
|
130 |
import com.spice.profitmandi.dao.entity.transaction.Loan;
|
| - |
|
131 |
import com.spice.profitmandi.dao.entity.transaction.LoanStatement;
|
| - |
|
132 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| - |
|
133 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| - |
|
134 |
import com.spice.profitmandi.dao.entity.transaction.PriceDropIMEI;
|
| - |
|
135 |
import com.spice.profitmandi.dao.entity.transaction.SDCreditRequirement;
|
| - |
|
136 |
import com.spice.profitmandi.dao.entity.transaction.SanctionRequest;
|
| - |
|
137 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| - |
|
138 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| - |
|
139 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| - |
|
140 |
import com.spice.profitmandi.dao.entity.user.Device;
|
| - |
|
141 |
import com.spice.profitmandi.dao.entity.user.FranchiseeVisit;
|
| 38 |
import com.spice.profitmandi.dao.entity.user.*;
|
142 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
| - |
|
143 |
import com.spice.profitmandi.dao.entity.user.Refferal;
|
| 39 |
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
|
144 |
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
|
| 40 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
145 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 41 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
146 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 42 |
import com.spice.profitmandi.dao.enumuration.dtr.RefferalStatus;
|
147 |
import com.spice.profitmandi.dao.enumuration.dtr.RefferalStatus;
|
| 43 |
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
|
148 |
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
|
| Line 48... |
Line 153... |
| 48 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
153 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
| 49 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
154 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
| 50 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
155 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 51 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
156 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 52 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
|
157 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
|
| - |
|
158 |
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
|
| - |
|
159 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
| 53 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
160 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| - |
|
161 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| - |
|
162 |
import com.spice.profitmandi.dao.repository.catalog.StateGstRateRepository;
|
| 54 |
import com.spice.profitmandi.dao.repository.cs.*;
|
163 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| - |
|
164 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
| - |
|
165 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| - |
|
166 |
import com.spice.profitmandi.dao.repository.cs.RegionRepository;
|
| - |
|
167 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| - |
|
168 |
import com.spice.profitmandi.dao.repository.dtr.CreditAccountRepository;
|
| - |
|
169 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
| - |
|
170 |
import com.spice.profitmandi.dao.repository.dtr.EmployeeAttendanceRepository;
|
| - |
|
171 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
172 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeActivityRepository;
|
| - |
|
173 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeVisitRepository;
|
| - |
|
174 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
| - |
|
175 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 55 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
176 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| - |
|
177 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
| - |
|
178 |
import com.spice.profitmandi.dao.repository.dtr.PartnerProblemRepository;
|
| - |
|
179 |
import com.spice.profitmandi.dao.repository.dtr.PushNotificationRepository;
|
| - |
|
180 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
|
| - |
|
181 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
| - |
|
182 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| - |
|
183 |
import com.spice.profitmandi.dao.repository.dtr.RefferalRepository;
|
| - |
|
184 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
| - |
|
185 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| - |
|
186 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
| - |
|
187 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
| - |
|
188 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| - |
|
189 |
import com.spice.profitmandi.dao.repository.fofo.CurrentPartnerDailyInvestmentRepository;
|
| - |
|
190 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
| - |
|
191 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
| - |
|
192 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
| - |
|
193 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| - |
|
194 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| - |
|
195 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| - |
|
196 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| - |
|
197 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| - |
|
198 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
| - |
|
199 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| - |
|
200 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
|
| - |
|
201 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderRepository;
|
| - |
|
202 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
|
| - |
|
203 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 56 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
204 |
import com.spice.profitmandi.dao.repository.fofo.RazorPayRepository;
|
| - |
|
205 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
| - |
|
206 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
| - |
|
207 |
import com.spice.profitmandi.dao.repository.fofo.ServiceConfigRepository;
|
| 57 |
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
|
208 |
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
|
| 58 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
209 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 59 |
import com.spice.profitmandi.dao.repository.inventory.WarehouseRepository;
|
210 |
import com.spice.profitmandi.dao.repository.inventory.WarehouseRepository;
|
| - |
|
211 |
import com.spice.profitmandi.dao.repository.transaction.HdfcPaymentRepository;
|
| - |
|
212 |
import com.spice.profitmandi.dao.repository.transaction.LineItemRepository;
|
| 60 |
import com.spice.profitmandi.dao.repository.transaction.*;
|
213 |
import com.spice.profitmandi.dao.repository.transaction.LoanRepository;
|
| - |
|
214 |
import com.spice.profitmandi.dao.repository.transaction.LoanStatementRepository;
|
| - |
|
215 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| - |
|
216 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropIMEIRepository;
|
| - |
|
217 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| - |
|
218 |
import com.spice.profitmandi.dao.repository.transaction.SDCreditRequirementRepository;
|
| - |
|
219 |
import com.spice.profitmandi.dao.repository.transaction.SanctionRequestRepository;
|
| - |
|
220 |
import com.spice.profitmandi.dao.repository.transaction.TransactionRepository;
|
| - |
|
221 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| - |
|
222 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
223 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
224 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 63 |
import com.spice.profitmandi.service.NotificationService;
|
225 |
import com.spice.profitmandi.service.NotificationService;
|
| 64 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
226 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 65 |
import com.spice.profitmandi.service.PartnerStatsService;
|
227 |
import com.spice.profitmandi.service.PartnerStatsService;
|
| Line 77... |
Line 239... |
| 77 |
import com.spice.profitmandi.service.transaction.CreditNoteService;
|
239 |
import com.spice.profitmandi.service.transaction.CreditNoteService;
|
| 78 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
240 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
| 79 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
241 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 80 |
import com.spice.profitmandi.service.user.RetailerService;
|
242 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 81 |
import com.spice.profitmandi.service.wallet.WalletService;
|
243 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| - |
|
244 |
|
| 82 |
import in.shop2020.model.v1.order.OrderStatus;
|
245 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 83 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
246 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| 84 |
import okhttp3.OkHttpClient;
|
247 |
import okhttp3.OkHttpClient;
|
| 85 |
import okhttp3.Request;
|
248 |
import okhttp3.Request;
|
| 86 |
import okhttp3.Response;
|
249 |
import okhttp3.Response;
|
| 87 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
- |
|
| 88 |
import org.apache.commons.lang.StringUtils;
|
- |
|
| 89 |
import org.apache.http.client.methods.CloseableHttpResponse;
|
- |
|
| 90 |
import org.apache.http.client.methods.HttpPost;
|
- |
|
| 91 |
import org.apache.http.conn.HttpHostConnectException;
|
- |
|
| 92 |
import org.apache.http.entity.StringEntity;
|
- |
|
| 93 |
import org.apache.http.impl.client.CloseableHttpClient;
|
- |
|
| 94 |
import org.apache.http.impl.client.HttpClients;
|
- |
|
| 95 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 96 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 97 |
import org.json.JSONArray;
|
- |
|
| 98 |
import org.json.JSONObject;
|
- |
|
| 99 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 100 |
import org.springframework.beans.factory.annotation.Qualifier;
|
- |
|
| 101 |
import org.springframework.beans.factory.annotation.Value;
|
- |
|
| 102 |
import org.springframework.core.io.ByteArrayResource;
|
- |
|
| 103 |
import org.springframework.core.io.InputStreamSource;
|
- |
|
| 104 |
import org.springframework.mail.javamail.JavaMailSender;
|
- |
|
| 105 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
- |
|
| 106 |
import org.springframework.stereotype.Component;
|
- |
|
| 107 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 108 |
|
- |
|
| 109 |
import javax.mail.MessagingException;
|
- |
|
| 110 |
import javax.mail.internet.InternetAddress;
|
- |
|
| 111 |
import javax.mail.internet.MimeMessage;
|
- |
|
| 112 |
import java.io.*;
|
- |
|
| 113 |
import java.math.BigDecimal;
|
- |
|
| 114 |
import java.math.RoundingMode;
|
- |
|
| 115 |
import java.nio.file.Files;
|
- |
|
| 116 |
import java.nio.file.Paths;
|
- |
|
| 117 |
import java.sql.Timestamp;
|
- |
|
| 118 |
import java.text.DecimalFormat;
|
- |
|
| 119 |
import java.time.*;
|
- |
|
| 120 |
import java.time.format.DateTimeFormatter;
|
- |
|
| 121 |
import java.time.temporal.ChronoField;
|
- |
|
| 122 |
import java.time.temporal.ChronoUnit;
|
- |
|
| 123 |
import java.util.*;
|
- |
|
| 124 |
import java.util.Map.Entry;
|
- |
|
| 125 |
import java.util.stream.Collectors;
|
- |
|
| 126 |
|
250 |
|
| 127 |
@Component
|
251 |
@Component
|
| 128 |
@Transactional(rollbackFor = Throwable.class)
|
252 |
@Transactional(rollbackFor = Throwable.class)
|
| 129 |
public class ScheduledTasks {
|
253 |
public class ScheduledTasks {
|
| 130 |
|
254 |
|
| Line 3402... |
Line 3526... |
| 3402 |
private TransactionRepository transactionRepository;
|
3526 |
private TransactionRepository transactionRepository;
|
| 3403 |
|
3527 |
|
| 3404 |
@Autowired
|
3528 |
@Autowired
|
| 3405 |
private CreditAccountRepository crediRepository;
|
3529 |
private CreditAccountRepository crediRepository;
|
| 3406 |
|
3530 |
|
| - |
|
3531 |
@Autowired
|
| - |
|
3532 |
private SanctionRequestRepository sanctionRequestRepository;
|
| - |
|
3533 |
|
| 3407 |
public void calculateInterestAccured() throws ProfitMandiBusinessException {
|
3534 |
public void calculateInterestAccured() throws ProfitMandiBusinessException {
|
| 3408 |
|
3535 |
|
| 3409 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
3536 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
| 3410 |
|
3537 |
|
| 3411 |
if (!loans.isEmpty()) {
|
3538 |
if (!loans.isEmpty()) {
|
| Line 3463... |
Line 3590... |
| 3463 |
} else {
|
3590 |
} else {
|
| 3464 |
throw new ProfitMandiBusinessException("loanstament", loanStatement.getLoanId(), "Invalid LoanId");
|
3591 |
throw new ProfitMandiBusinessException("loanstament", loanStatement.getLoanId(), "Invalid LoanId");
|
| 3465 |
}
|
3592 |
}
|
| 3466 |
}
|
3593 |
}
|
| 3467 |
|
3594 |
|
| 3468 |
public void loanSettlement() throws ProfitMandiBusinessException {
|
3595 |
public void loanSettlement() throws Exception {
|
| 3469 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
3596 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
| 3470 |
|
3597 |
|
| 3471 |
if (!loans.isEmpty()) {
|
3598 |
if (!loans.isEmpty()) {
|
| 3472 |
|
3599 |
|
| 3473 |
for (Loan loan : loans) {
|
3600 |
for (Loan loan : loans) {
|
| Line 3482... |
Line 3609... |
| 3482 |
Map<LoanReferenceType, Double> loanStatusAmount = loanStatements.stream()
|
3609 |
Map<LoanReferenceType, Double> loanStatusAmount = loanStatements.stream()
|
| 3483 |
.collect(Collectors.groupingBy(x -> x.getLoanReferenceType(),
|
3610 |
.collect(Collectors.groupingBy(x -> x.getLoanReferenceType(),
|
| 3484 |
Collectors.summingDouble(x -> x.getAmount().doubleValue())));
|
3611 |
Collectors.summingDouble(x -> x.getAmount().doubleValue())));
|
| 3485 |
|
3612 |
|
| 3486 |
LOGGER.info("loanStatusAmount {}", loanStatusAmount);
|
3613 |
LOGGER.info("loanStatusAmount {}", loanStatusAmount);
|
| 3487 |
double interestAmount = loanStatusAmount.get(LoanReferenceType.INTEREST);
|
3614 |
Double interestAmount = loanStatusAmount.get(LoanReferenceType.INTEREST);
|
| - |
|
3615 |
|
| - |
|
3616 |
if (interestAmount == null) {
|
| - |
|
3617 |
interestAmount = (double) 0;
|
| - |
|
3618 |
}
|
| 3488 |
|
3619 |
|
| 3489 |
double principalAmount = loanStatusAmount.get(LoanReferenceType.PRINCIPAL);
|
3620 |
double principalAmount = loanStatusAmount.get(LoanReferenceType.PRINCIPAL);
|
| 3490 |
double paidAmount = 0;
|
3621 |
double paidAmount = 0;
|
| 3491 |
if (userWallet.getAmount() > Math.abs(interestAmount)) {
|
3622 |
if (userWallet.getAmount() > Math.abs(interestAmount)) {
|
| 3492 |
|
3623 |
|
| Line 3511... |
Line 3642... |
| 3511 |
|
3642 |
|
| 3512 |
paidAmount += Math.abs(principalAmount);
|
3643 |
paidAmount += Math.abs(principalAmount);
|
| 3513 |
|
3644 |
|
| 3514 |
userWallet.setAmount((int) amount);
|
3645 |
userWallet.setAmount((int) amount);
|
| 3515 |
|
3646 |
|
| 3516 |
sdCreditRequirement.setAvailableLimit(sdCreditRequirement.getAvailableLimit()
|
3647 |
BigDecimal availableLimit = sdCreditRequirement.getAvailableLimit()
|
| 3517 |
.add(BigDecimal.valueOf(principalAmount).abs()));
|
3648 |
.add(BigDecimal.valueOf(principalAmount).abs());
|
| - |
|
3649 |
|
| 3518 |
sdCreditRequirement.setUtilizedAmount(sdCreditRequirement.getUtilizedAmount()
|
3650 |
BigDecimal utilizationAmount = sdCreditRequirement.getUtilizedAmount()
|
| 3519 |
.subtract(BigDecimal.valueOf(principalAmount).abs()));
|
3651 |
.subtract(BigDecimal.valueOf(principalAmount).abs());
|
| 3520 |
|
3652 |
|
| - |
|
3653 |
sdCreditService.setLimit(loan.getFofoId(), availableLimit, utilizationAmount);
|
| 3521 |
loan.setPendingAmount(BigDecimal.ZERO);
|
3654 |
loan.setPendingAmount(BigDecimal.ZERO);
|
| 3522 |
|
3655 |
|
| 3523 |
} else if (principalAmount != 0) {
|
3656 |
} else if (principalAmount != 0) {
|
| 3524 |
|
3657 |
|
| 3525 |
settledLoanStatement(LoanReferenceType.PRINCIPAL, BigDecimal.valueOf(userWalletAmount),
|
3658 |
settledLoanStatement(LoanReferenceType.PRINCIPAL, BigDecimal.valueOf(userWalletAmount),
|
| 3526 |
loan.getFofoId(), loan.getId(), "Amount adjusted against loan",
|
3659 |
loan.getFofoId(), loan.getId(), "Amount adjusted against loan",
|
| 3527 |
LocalDateTime.now());
|
3660 |
LocalDateTime.now());
|
| 3528 |
|
3661 |
|
| 3529 |
paidAmount += Math.abs(userWalletAmount);
|
3662 |
paidAmount += Math.abs(userWalletAmount);
|
| 3530 |
|
3663 |
|
| 3531 |
sdCreditRequirement.setAvailableLimit(sdCreditRequirement.getAvailableLimit()
|
3664 |
BigDecimal availableLimit = sdCreditRequirement.getAvailableLimit()
|
| 3532 |
.add(BigDecimal.valueOf(userWalletAmount)).abs());
|
3665 |
.add(BigDecimal.valueOf(userWalletAmount)).abs();
|
| - |
|
3666 |
|
| 3533 |
sdCreditRequirement.setUtilizedAmount(sdCreditRequirement.getUtilizedAmount()
|
3667 |
BigDecimal utilizationAmount = sdCreditRequirement.getUtilizedAmount()
|
| 3534 |
.subtract(BigDecimal.valueOf(userWalletAmount)).abs());
|
3668 |
.subtract(BigDecimal.valueOf(userWalletAmount)).abs();
|
| - |
|
3669 |
|
| - |
|
3670 |
sdCreditService.setLimit(loan.getFofoId(), availableLimit, utilizationAmount);
|
| - |
|
3671 |
|
| 3535 |
userWallet.setAmount(0);
|
3672 |
userWallet.setAmount(0);
|
| 3536 |
|
3673 |
|
| 3537 |
loan.setPendingAmount(
|
3674 |
loan.setPendingAmount(
|
| 3538 |
loan.getPendingAmount().subtract(BigDecimal.valueOf(userWalletAmount)));
|
3675 |
loan.getPendingAmount().subtract(BigDecimal.valueOf(userWalletAmount)));
|
| 3539 |
|
3676 |
|
| Line 3559... |
Line 3696... |
| 3559 |
}
|
3696 |
}
|
| 3560 |
|
3697 |
|
| 3561 |
}
|
3698 |
}
|
| 3562 |
}
|
3699 |
}
|
| 3563 |
|
3700 |
|
| - |
|
3701 |
List<Order> allOrders = orderRepository.selectHoldOrder();
|
| - |
|
3702 |
|
| - |
|
3703 |
LOGGER.info("allOrders {}", allOrders);
|
| - |
|
3704 |
|
| - |
|
3705 |
if (!allOrders.isEmpty()) {
|
| - |
|
3706 |
Map<Integer, List<Order>> transactionOrdersMap = allOrders.stream()
|
| - |
|
3707 |
.collect(Collectors.groupingBy(Order::getTransactionId, Collectors.toList()));
|
| - |
|
3708 |
LinkedHashMap<Integer, List<Order>> sortedTransactionOrdersMap = new LinkedHashMap<>();
|
| - |
|
3709 |
transactionOrdersMap.entrySet().stream().sorted(Map.Entry.comparingByKey())
|
| - |
|
3710 |
.forEachOrdered(x -> sortedTransactionOrdersMap.put(x.getKey(), x.getValue()));
|
| - |
|
3711 |
LOGGER.info("sortedTransactionOrdersMap {}", sortedTransactionOrdersMap);
|
| - |
|
3712 |
|
| - |
|
3713 |
for (Entry<Integer, List<Order>> transactionOrdersEntry : sortedTransactionOrdersMap.entrySet()) {
|
| - |
|
3714 |
|
| - |
|
3715 |
List<Order> orders = transactionOrdersEntry.getValue();
|
| - |
|
3716 |
|
| - |
|
3717 |
double totalAmount = orders.stream().collect(Collectors.summingDouble(x -> x.getTotalAmount()));
|
| - |
|
3718 |
|
| - |
|
3719 |
LocalDateTime createDate = orders.get(0).getCreateTimestamp();
|
| - |
|
3720 |
|
| - |
|
3721 |
int fofoId = orders.get(0).getRetailerId();
|
| - |
|
3722 |
|
| - |
|
3723 |
int transactionId = transactionOrdersEntry.getKey();
|
| - |
|
3724 |
|
| - |
|
3725 |
SanctionRequest sanctionRequest = sanctionRequestRepository.selectByTransactionId(transactionId);
|
| - |
|
3726 |
|
| - |
|
3727 |
double loanSettleAmount = loanStatementRepository.selectByDateAndFofoId(createDate, fofoId).stream()
|
| - |
|
3728 |
.filter(x -> x.getAmount().doubleValue() > 0)
|
| - |
|
3729 |
.collect(Collectors.summingDouble(x -> x.getAmount().doubleValue()));
|
| - |
|
3730 |
|
| - |
|
3731 |
LOGGER.info("loanSettleAmount {}", loanSettleAmount);
|
| - |
|
3732 |
|
| - |
|
3733 |
LOGGER.info("totalAmount {}", totalAmount);
|
| - |
|
3734 |
if (loanSettleAmount >= sanctionRequest.getUtilizationAmount().doubleValue()) {
|
| - |
|
3735 |
|
| - |
|
3736 |
LOGGER.info("totalAmount {}", totalAmount);
|
| - |
|
3737 |
|
| - |
|
3738 |
orders.forEach(x -> x.setShipmentHold(false));
|
| - |
|
3739 |
|
| - |
|
3740 |
List<String> authUserEmail = csService.getAuthUserIdByPartnerId(orders.get(0).getRetailerId())
|
| - |
|
3741 |
.stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
| - |
|
3742 |
authUserEmail.add("vinay.p@smartdukaan.com");
|
| - |
|
3743 |
authUserEmail.add("shivam.gupta@smartdukaan.com");
|
| - |
|
3744 |
|
| - |
|
3745 |
String[] emailTo = authUserEmail.toArray(new String[authUserEmail.size()]);
|
| - |
|
3746 |
|
| - |
|
3747 |
String[] ccTo = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com" };
|
| - |
|
3748 |
|
| - |
|
3749 |
String subject = "Dispatched " + (orders.get(0).getRetailerName());
|
| - |
|
3750 |
String message = String.format("Dear Team, \n" + "kindly note the meterial for the "
|
| - |
|
3751 |
+ orders.get(0).getRetailerName() + "of Rs." + totalAmount + "is dispatched.");
|
| - |
|
3752 |
|
| - |
|
3753 |
Utils.sendMailWithAttachments(mailSender, emailTo, ccTo, subject, message);
|
| - |
|
3754 |
|
| - |
|
3755 |
}
|
| - |
|
3756 |
|
| - |
|
3757 |
}
|
| - |
|
3758 |
}
|
| - |
|
3759 |
|
| 3564 |
}
|
3760 |
}
|
| 3565 |
|
3761 |
|
| 3566 |
}
|
3762 |
}
|
| 3567 |
|
3763 |
|
| 3568 |
private void settledLoanStatement(LoanReferenceType loanReferneceType, BigDecimal amount, int fofoId, int loanId,
|
3764 |
private void settledLoanStatement(LoanReferenceType loanReferneceType, BigDecimal amount, int fofoId, int loanId,
|