| 28217 |
tejbeer |
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;
|
| 27271 |
amit.gupta |
9 |
import java.time.Month;
|
| 24653 |
govind |
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;
|
| 27683 |
amit.gupta |
14 |
import java.util.Base64;
|
| 24627 |
amit.gupta |
15 |
import java.util.Collections;
|
| 26945 |
amit.gupta |
16 |
import java.util.Comparator;
|
| 23723 |
amit.gupta |
17 |
import java.util.HashMap;
|
| 24241 |
amit.gupta |
18 |
import java.util.HashSet;
|
| 23724 |
amit.gupta |
19 |
import java.util.List;
|
| 23723 |
amit.gupta |
20 |
import java.util.Map;
|
| 28205 |
tejbeer |
21 |
import java.util.Map.Entry;
|
| 24242 |
amit.gupta |
22 |
import java.util.Optional;
|
| 24542 |
amit.gupta |
23 |
import java.util.Set;
|
| 23724 |
amit.gupta |
24 |
import java.util.stream.Collectors;
|
| 23723 |
amit.gupta |
25 |
|
| 24121 |
govind |
26 |
import javax.mail.MessagingException;
|
|
|
27 |
import javax.mail.internet.InternetAddress;
|
|
|
28 |
import javax.mail.internet.MimeMessage;
|
|
|
29 |
|
| 23929 |
amit.gupta |
30 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 25598 |
amit.gupta |
31 |
import org.apache.commons.lang.StringUtils;
|
| 25300 |
tejbeer |
32 |
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
33 |
import org.apache.http.client.methods.HttpPost;
|
|
|
34 |
import org.apache.http.entity.StringEntity;
|
|
|
35 |
import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
36 |
import org.apache.http.impl.client.HttpClients;
|
| 23755 |
amit.gupta |
37 |
import org.apache.logging.log4j.LogManager;
|
|
|
38 |
import org.apache.logging.log4j.Logger;
|
| 25300 |
tejbeer |
39 |
import org.json.JSONObject;
|
| 23723 |
amit.gupta |
40 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23933 |
amit.gupta |
41 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 23724 |
amit.gupta |
42 |
import org.springframework.beans.factory.annotation.Value;
|
| 23929 |
amit.gupta |
43 |
import org.springframework.core.io.ByteArrayResource;
|
| 24692 |
amit.gupta |
44 |
import org.springframework.core.io.InputStreamSource;
|
| 23929 |
amit.gupta |
45 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 24121 |
govind |
46 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
| 23723 |
amit.gupta |
47 |
import org.springframework.stereotype.Component;
|
| 23724 |
amit.gupta |
48 |
import org.springframework.transaction.annotation.Transactional;
|
| 23723 |
amit.gupta |
49 |
|
| 24542 |
amit.gupta |
50 |
import com.google.common.collect.Lists;
|
| 25300 |
tejbeer |
51 |
import com.google.gson.Gson;
|
| 28369 |
tejbeer |
52 |
import com.razorpay.Payment;
|
| 25721 |
tejbeer |
53 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 23724 |
amit.gupta |
54 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
| 24681 |
amit.gupta |
55 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
| 24121 |
govind |
56 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 23929 |
amit.gupta |
57 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 25721 |
tejbeer |
58 |
import com.spice.profitmandi.common.model.FocusedModelShortageModel;
|
| 24542 |
amit.gupta |
59 |
import com.spice.profitmandi.common.model.GstRate;
|
| 27678 |
amit.gupta |
60 |
import com.spice.profitmandi.common.model.PdfModel;
|
| 25590 |
amit.gupta |
61 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 23724 |
amit.gupta |
62 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| 25821 |
amit.gupta |
63 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 24681 |
amit.gupta |
64 |
import com.spice.profitmandi.common.services.ReporticoService;
|
| 24002 |
amit.gupta |
65 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 23929 |
amit.gupta |
66 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 27678 |
amit.gupta |
67 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 23929 |
amit.gupta |
68 |
import com.spice.profitmandi.common.util.Utils;
|
| 24592 |
amit.gupta |
69 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
| 25300 |
tejbeer |
70 |
import com.spice.profitmandi.dao.Interface.Campaign;
|
| 25590 |
amit.gupta |
71 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 25800 |
tejbeer |
72 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
|
| 25609 |
amit.gupta |
73 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 24590 |
amit.gupta |
74 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 25590 |
amit.gupta |
75 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 26283 |
tejbeer |
76 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
| 23724 |
amit.gupta |
77 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
| 27678 |
amit.gupta |
78 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| 25300 |
tejbeer |
79 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
|
|
80 |
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
|
| 23724 |
amit.gupta |
81 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
|
|
82 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
|
|
83 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
| 26283 |
tejbeer |
84 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
| 28368 |
tejbeer |
85 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
| 24542 |
amit.gupta |
86 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
| 24590 |
amit.gupta |
87 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
| 23724 |
amit.gupta |
88 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 24542 |
amit.gupta |
89 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 23929 |
amit.gupta |
90 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 24249 |
amit.gupta |
91 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 24277 |
amit.gupta |
92 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 28205 |
tejbeer |
93 |
import com.spice.profitmandi.dao.entity.fofo.PartnerProblem;
|
| 28368 |
tejbeer |
94 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
|
|
|
95 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
|
| 23724 |
amit.gupta |
96 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 28368 |
tejbeer |
97 |
import com.spice.profitmandi.dao.entity.fofo.RazorPay;
|
| 24242 |
amit.gupta |
98 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 24241 |
amit.gupta |
99 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 27208 |
tejbeer |
100 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
|
|
101 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| 24431 |
amit.gupta |
102 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| 25609 |
amit.gupta |
103 |
import com.spice.profitmandi.dao.entity.transaction.PriceDropIMEI;
|
| 24587 |
amit.gupta |
104 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 24580 |
amit.gupta |
105 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 24542 |
amit.gupta |
106 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 25300 |
tejbeer |
107 |
import com.spice.profitmandi.dao.entity.user.Device;
|
| 25927 |
amit.gupta |
108 |
import com.spice.profitmandi.dao.entity.user.FranchiseeVisit;
|
| 25910 |
amit.gupta |
109 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
| 26790 |
tejbeer |
110 |
import com.spice.profitmandi.dao.entity.user.Refferal;
|
| 24250 |
amit.gupta |
111 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 25598 |
amit.gupta |
112 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 26790 |
tejbeer |
113 |
import com.spice.profitmandi.dao.enumuration.dtr.RefferalStatus;
|
| 24242 |
amit.gupta |
114 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 25609 |
amit.gupta |
115 |
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
|
| 25300 |
tejbeer |
116 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
|
|
117 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 25590 |
amit.gupta |
118 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 25300 |
tejbeer |
119 |
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
|
| 25721 |
tejbeer |
120 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
| 24249 |
amit.gupta |
121 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 24241 |
amit.gupta |
122 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 26929 |
amit.gupta |
123 |
import com.spice.profitmandi.dao.repository.catalog.StateGstRateRepository;
|
| 25590 |
amit.gupta |
124 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 27088 |
tejbeer |
125 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
| 25590 |
amit.gupta |
126 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 27088 |
tejbeer |
127 |
import com.spice.profitmandi.dao.repository.cs.RegionRepository;
|
| 26283 |
tejbeer |
128 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| 23724 |
amit.gupta |
129 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
| 23929 |
amit.gupta |
130 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 25927 |
amit.gupta |
131 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeActivityRepository;
|
|
|
132 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeVisitRepository;
|
| 25837 |
amit.gupta |
133 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
| 25910 |
amit.gupta |
134 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 24653 |
govind |
135 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 25300 |
tejbeer |
136 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
| 28205 |
tejbeer |
137 |
import com.spice.profitmandi.dao.repository.dtr.PartnerProblemRepository;
|
| 25300 |
tejbeer |
138 |
import com.spice.profitmandi.dao.repository.dtr.PushNotificationRepository;
|
| 23724 |
amit.gupta |
139 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
|
|
|
140 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
|
|
141 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| 26790 |
tejbeer |
142 |
import com.spice.profitmandi.dao.repository.dtr.RefferalRepository;
|
| 24542 |
amit.gupta |
143 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
| 24669 |
govind |
144 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 25721 |
tejbeer |
145 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
| 26408 |
amit.gupta |
146 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
| 25721 |
tejbeer |
147 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24542 |
amit.gupta |
148 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
| 28377 |
tejbeer |
149 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
| 24590 |
amit.gupta |
150 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
| 24542 |
amit.gupta |
151 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 23724 |
amit.gupta |
152 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 24249 |
amit.gupta |
153 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 24277 |
amit.gupta |
154 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 24174 |
govind |
155 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| 27086 |
tejbeer |
156 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
| 25503 |
amit.gupta |
157 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 28368 |
tejbeer |
158 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
|
|
|
159 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderRepository;
|
| 28377 |
tejbeer |
160 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
|
| 23724 |
amit.gupta |
161 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 28368 |
tejbeer |
162 |
import com.spice.profitmandi.dao.repository.fofo.RazorPayRepository;
|
| 24242 |
amit.gupta |
163 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
| 24241 |
amit.gupta |
164 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
| 25982 |
amit.gupta |
165 |
import com.spice.profitmandi.dao.repository.transaction.HdfcPaymentRepository;
|
| 23929 |
amit.gupta |
166 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 25609 |
amit.gupta |
167 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropIMEIRepository;
|
| 24431 |
amit.gupta |
168 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| 24580 |
amit.gupta |
169 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| 24587 |
amit.gupta |
170 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 24542 |
amit.gupta |
171 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 25721 |
tejbeer |
172 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 25854 |
amit.gupta |
173 |
import com.spice.profitmandi.service.NotificationService;
|
| 24337 |
amit.gupta |
174 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 28368 |
tejbeer |
175 |
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
|
| 25694 |
amit.gupta |
176 |
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
|
| 23929 |
amit.gupta |
177 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 27208 |
tejbeer |
178 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
| 25335 |
amit.gupta |
179 |
import com.spice.profitmandi.service.order.OrderService;
|
| 24431 |
amit.gupta |
180 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
| 23724 |
amit.gupta |
181 |
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
|
|
|
182 |
import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;
|
|
|
183 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 23929 |
amit.gupta |
184 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
|
|
185 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 23739 |
amit.gupta |
186 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 23723 |
amit.gupta |
187 |
|
| 25721 |
tejbeer |
188 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 28388 |
amit.gupta |
189 |
import in.shop2020.model.v1.order.WalletReferenceType;;
|
| 23739 |
amit.gupta |
190 |
|
| 23723 |
amit.gupta |
191 |
@Component
|
| 23724 |
amit.gupta |
192 |
@Transactional(rollbackFor = Throwable.class)
|
| 23723 |
amit.gupta |
193 |
public class ScheduledTasks {
|
|
|
194 |
|
| 23724 |
amit.gupta |
195 |
@Value("${oxigen.recharge.transaction.url}")
|
|
|
196 |
private String oxigenRechargeTransactionUrl;
|
| 23723 |
amit.gupta |
197 |
|
| 23724 |
amit.gupta |
198 |
@Value("${oxigen.recharge.enquiry.url}")
|
|
|
199 |
private String oxigenRechargeEnquiryUrl;
|
| 24533 |
govind |
200 |
|
| 24431 |
amit.gupta |
201 |
@Autowired
|
| 27088 |
tejbeer |
202 |
private RegionRepository regionRepository;
|
| 28205 |
tejbeer |
203 |
|
| 27795 |
amit.gupta |
204 |
private static final DateTimeFormatter leadTimeFormatter = DateTimeFormatter.ofPattern("d LLL, hh:mm a");
|
| 27088 |
tejbeer |
205 |
|
|
|
206 |
@Autowired
|
|
|
207 |
private PartnerRegionRepository partnerRegionRepository;
|
|
|
208 |
|
|
|
209 |
@Autowired
|
| 25503 |
amit.gupta |
210 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 25598 |
amit.gupta |
211 |
|
| 25590 |
amit.gupta |
212 |
@Autowired
|
| 26408 |
amit.gupta |
213 |
private ActivatedImeiRepository activatedImeiRepository;
|
|
|
214 |
|
|
|
215 |
@Autowired
|
| 25910 |
amit.gupta |
216 |
private LeadRepository leadRepository;
|
| 25927 |
amit.gupta |
217 |
|
| 25910 |
amit.gupta |
218 |
@Autowired
|
| 25590 |
amit.gupta |
219 |
private AuthRepository authRepository;
|
| 25503 |
amit.gupta |
220 |
|
|
|
221 |
@Autowired
|
| 24431 |
amit.gupta |
222 |
private PriceDropService priceDropService;
|
| 26283 |
tejbeer |
223 |
|
| 25590 |
amit.gupta |
224 |
@Autowired
|
| 25927 |
amit.gupta |
225 |
private FranchiseeVisitRepository franchiseeVisitRepository;
|
| 26790 |
tejbeer |
226 |
|
| 25927 |
amit.gupta |
227 |
@Autowired
|
|
|
228 |
private FranchiseeActivityRepository franchiseeActivityRepository;
|
| 26790 |
tejbeer |
229 |
|
| 25927 |
amit.gupta |
230 |
@Autowired
|
| 25982 |
amit.gupta |
231 |
private HdfcPaymentRepository hdfcPaymentRepository;
|
| 26790 |
tejbeer |
232 |
|
| 25982 |
amit.gupta |
233 |
@Autowired
|
| 25590 |
amit.gupta |
234 |
private CsService csService;
|
| 25846 |
amit.gupta |
235 |
|
| 25837 |
amit.gupta |
236 |
@Autowired
|
| 27208 |
tejbeer |
237 |
private SaholicInventoryService saholicInventoryService;
|
|
|
238 |
|
|
|
239 |
@Autowired
|
| 25837 |
amit.gupta |
240 |
private InsurancePolicyRepository insurancePolicyRepository;
|
| 23723 |
amit.gupta |
241 |
|
| 25694 |
amit.gupta |
242 |
@Autowired
|
|
|
243 |
private ToffeeService toffeeService;
|
|
|
244 |
|
| 23724 |
amit.gupta |
245 |
@Value("${oxigen.recharge.auth.key}")
|
|
|
246 |
private String oxigenRechargeAuthKey;
|
|
|
247 |
|
|
|
248 |
@Value("${oxigen.recharge.validation.url}")
|
|
|
249 |
private String oxigenRechargeValidationUrl;
|
|
|
250 |
|
|
|
251 |
@Value("${oxigen.recharge.validation.auth.key}")
|
|
|
252 |
private String oxigenRechargeValidationAuthKey;
|
|
|
253 |
|
|
|
254 |
@Value("${think.walnut.digital.recharge.transaction.mobile.url}")
|
|
|
255 |
private String thinkWalnutDigitalRechargeTransactionMobileUrl;
|
|
|
256 |
|
|
|
257 |
@Value("${think.walnut.digital.recharge.transaction.dth.url}")
|
|
|
258 |
private String thinkWalnutDigitalRechargeTransactionDthUrl;
|
|
|
259 |
|
|
|
260 |
@Value("${think.walnut.digital.recharge.enquiry.url}")
|
|
|
261 |
private String thinkWalnutDigitalRechargeEnquiryUrl;
|
|
|
262 |
|
|
|
263 |
@Value("${think.walnut.digital.recharge.balance.url}")
|
|
|
264 |
private String thinkWalnutDigitalRechargeBalanceUrl;
|
|
|
265 |
|
|
|
266 |
@Value("${think.walnut.digital.recharge.username}")
|
|
|
267 |
private String thinkWalnutDigitalRechargeUserName;
|
|
|
268 |
|
|
|
269 |
@Value("${think.walnut.digital.recharge.password}")
|
|
|
270 |
private String thinkWalnutDigitalRechargePassword;
|
|
|
271 |
|
|
|
272 |
@Value("${think.walnut.digital.recharge.auth.key}")
|
|
|
273 |
private String thinkWalnutDigitalRechargeAuthKey;
|
|
|
274 |
|
| 23723 |
amit.gupta |
275 |
@Autowired
|
| 23724 |
amit.gupta |
276 |
private PurchaseRepository purchaseRepository;
|
|
|
277 |
|
|
|
278 |
@Autowired
|
| 25609 |
amit.gupta |
279 |
private PriceDropIMEIRepository priceDropIMEIRepository;
|
|
|
280 |
|
|
|
281 |
@Autowired
|
|
|
282 |
PriceDropRepository priceDropRepository;
|
|
|
283 |
|
|
|
284 |
@Autowired
|
| 27086 |
tejbeer |
285 |
private PartnerTypeChangeRepository partnerTypeChangeRepository;
|
| 28368 |
tejbeer |
286 |
|
| 27086 |
tejbeer |
287 |
@Autowired
|
| 23724 |
amit.gupta |
288 |
private SchemeService schemeService;
|
| 24683 |
amit.gupta |
289 |
|
| 26945 |
amit.gupta |
290 |
private static final String[] STOCK_AGEING_MAIL_LIST = new String[] { "uday.singh@smartudkaan.com",
|
| 27102 |
amit.gupta |
291 |
"adeel.yazdani@smartdukaan.com", "kamini.sharma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com",
|
| 28467 |
tejbeer |
292 |
"ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com", "rajat.gupta@smartdukaan.com",
|
|
|
293 |
"kuldeep.kumar@smartdukaan.com", "manish.gupta@smartdukaan.com" };
|
| 25609 |
amit.gupta |
294 |
|
|
|
295 |
private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[] { "kamini.sharma@smartdukaan.com",
|
| 28205 |
tejbeer |
296 |
"tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com",
|
|
|
297 |
"niranjan.kala@smartdukaan.com" };
|
| 28632 |
amit.gupta |
298 |
|
|
|
299 |
private static final String[] INDENT_TERTIARY_MAIL_LIST = new String[] { "uday.singh@smartdukaan.com","kuldeep.kumar@smartdukaan.com"};
|
| 25609 |
amit.gupta |
300 |
|
| 25721 |
tejbeer |
301 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
302 |
|
| 24681 |
amit.gupta |
303 |
@Autowired
|
|
|
304 |
private ReporticoService reporticoService;
|
| 23724 |
amit.gupta |
305 |
|
|
|
306 |
@Autowired
|
| 24337 |
amit.gupta |
307 |
private PartnerInvestmentService partnerInvestmentService;
|
| 25598 |
amit.gupta |
308 |
|
| 25590 |
amit.gupta |
309 |
@Autowired
|
|
|
310 |
private PositionRepository positionRepository;
|
| 24337 |
amit.gupta |
311 |
|
|
|
312 |
@Autowired
|
| 24542 |
amit.gupta |
313 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 25865 |
amit.gupta |
314 |
|
| 25854 |
amit.gupta |
315 |
@Autowired
|
|
|
316 |
private NotificationService notificationService;
|
| 24542 |
amit.gupta |
317 |
|
|
|
318 |
@Autowired
|
| 24277 |
amit.gupta |
319 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
|
|
320 |
|
|
|
321 |
@Autowired
|
| 24241 |
amit.gupta |
322 |
private SchemeInOutRepository schemeInOutRepository;
|
|
|
323 |
|
|
|
324 |
@Autowired
|
| 23724 |
amit.gupta |
325 |
private RechargeTransactionRepository rechargeTransactionRepository;
|
|
|
326 |
|
|
|
327 |
@Autowired
|
| 24542 |
amit.gupta |
328 |
private CustomerAddressRepository customerAddressRepository;
|
|
|
329 |
|
|
|
330 |
@Autowired
|
| 23724 |
amit.gupta |
331 |
private RechargeProviderCreditWalletHistoryRepository rechargeProviderCreditWalletHistoryRepository;
|
|
|
332 |
|
|
|
333 |
@Autowired
|
| 24590 |
amit.gupta |
334 |
private FofoLineItemRepository fofoLineItemRepository;
|
|
|
335 |
|
|
|
336 |
@Autowired
|
| 23724 |
amit.gupta |
337 |
private FofoOrderRepository fofoOrderRepository;
|
| 24587 |
amit.gupta |
338 |
|
| 24580 |
amit.gupta |
339 |
@Autowired
|
|
|
340 |
private UserWalletHistoryRepository userWalletHistoryRepository;
|
| 24250 |
amit.gupta |
341 |
|
| 24249 |
amit.gupta |
342 |
@Autowired
|
| 24587 |
amit.gupta |
343 |
private UserWalletRepository userWalletRepository;
|
|
|
344 |
|
|
|
345 |
@Autowired
|
| 24249 |
amit.gupta |
346 |
private InventoryItemRepository inventoryItemRepository;
|
| 23929 |
amit.gupta |
347 |
|
| 23739 |
amit.gupta |
348 |
@Autowired
|
|
|
349 |
private WalletService walletService;
|
| 23724 |
amit.gupta |
350 |
|
|
|
351 |
@Autowired
|
|
|
352 |
private ThinkWalnutDigitalRechargeProviderService thinkWalnutDigitalRechargeProviderService;
|
|
|
353 |
|
|
|
354 |
@Autowired
|
|
|
355 |
private OxigenRechargeProviderService oxigenRechargeProviderService;
|
|
|
356 |
|
|
|
357 |
@Autowired
|
|
|
358 |
private RechargeProviderRepository rechargeProviderRepository;
|
|
|
359 |
|
|
|
360 |
@Autowired
|
| 24242 |
amit.gupta |
361 |
private ScanRecordRepository scanRecordRepository;
|
|
|
362 |
|
|
|
363 |
@Autowired
|
| 23724 |
amit.gupta |
364 |
private DailyRechargeRepository dailyRechargeRepository;
|
|
|
365 |
|
| 23929 |
amit.gupta |
366 |
@Autowired
|
|
|
367 |
private FofoStoreRepository fofoStoreRepository;
|
| 24177 |
govind |
368 |
|
| 23724 |
amit.gupta |
369 |
@Value("${prod}")
|
|
|
370 |
private boolean prod;
|
| 26945 |
amit.gupta |
371 |
|
| 26929 |
amit.gupta |
372 |
@Autowired
|
|
|
373 |
private StateGstRateRepository stateGstRateRepository;
|
| 23724 |
amit.gupta |
374 |
|
| 23929 |
amit.gupta |
375 |
@Autowired
|
|
|
376 |
private RetailerService retailerService;
|
|
|
377 |
|
|
|
378 |
@Autowired
|
|
|
379 |
private TransactionService transactionService;
|
| 24250 |
amit.gupta |
380 |
|
| 24249 |
amit.gupta |
381 |
@Autowired
|
|
|
382 |
private ItemRepository itemRepository;
|
| 23929 |
amit.gupta |
383 |
|
|
|
384 |
@Autowired
|
|
|
385 |
private OrderRepository orderRepository;
|
| 25351 |
tejbeer |
386 |
|
| 25335 |
amit.gupta |
387 |
@Autowired
|
|
|
388 |
private OrderService orderService;
|
| 23929 |
amit.gupta |
389 |
|
|
|
390 |
@Autowired
|
| 24241 |
amit.gupta |
391 |
private SchemeRepository schemeRepository;
|
|
|
392 |
|
|
|
393 |
@Autowired
|
| 23929 |
amit.gupta |
394 |
private JavaMailSender mailSender;
|
| 24177 |
govind |
395 |
|
| 24174 |
govind |
396 |
@Autowired
|
|
|
397 |
private PartnerTargetRepository partnerTargetRepository;
|
| 24002 |
amit.gupta |
398 |
|
|
|
399 |
@Autowired
|
|
|
400 |
@Qualifier(value = "googleMailSender")
|
| 23932 |
amit.gupta |
401 |
private JavaMailSender googleMailSender;
|
| 23929 |
amit.gupta |
402 |
|
|
|
403 |
@Autowired
|
|
|
404 |
private InventoryService inventoryService;
|
|
|
405 |
|
| 24533 |
govind |
406 |
@Autowired
|
| 24542 |
amit.gupta |
407 |
private AddressRepository addressRepository;
|
|
|
408 |
|
|
|
409 |
@Autowired
|
|
|
410 |
private RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
|
|
411 |
|
| 24653 |
govind |
412 |
@Autowired
|
|
|
413 |
private Mongo mongoClient;
|
| 24683 |
amit.gupta |
414 |
|
| 24669 |
govind |
415 |
@Autowired
|
| 25300 |
tejbeer |
416 |
private DeviceRepository deviceRepository;
|
|
|
417 |
|
|
|
418 |
@Autowired
|
|
|
419 |
private PushNotificationRepository pushNotificationRepository;
|
|
|
420 |
|
|
|
421 |
@Autowired
|
|
|
422 |
private NotificationCampaignRepository notificationCampaignRepository;
|
|
|
423 |
|
|
|
424 |
@Autowired
|
| 25721 |
tejbeer |
425 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
426 |
|
|
|
427 |
@Autowired
|
|
|
428 |
private FocusedModelRepository focusedModelRepository;
|
|
|
429 |
|
|
|
430 |
@Autowired
|
| 24669 |
govind |
431 |
private UserAccountRepository userAccountRepository;
|
| 24653 |
govind |
432 |
|
| 25721 |
tejbeer |
433 |
@Autowired
|
| 25927 |
amit.gupta |
434 |
private UserRepository userUserRepository;
|
| 25721 |
tejbeer |
435 |
|
|
|
436 |
@Autowired
|
| 25927 |
amit.gupta |
437 |
private com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
|
|
|
438 |
|
|
|
439 |
@Autowired
|
| 25721 |
tejbeer |
440 |
private UserCampaignRepository userCampaignRepository;
|
|
|
441 |
|
|
|
442 |
@Autowired
|
|
|
443 |
private Gson gson;
|
|
|
444 |
|
| 26283 |
tejbeer |
445 |
@Autowired
|
|
|
446 |
private TicketRepository ticketRepository;
|
|
|
447 |
|
| 26790 |
tejbeer |
448 |
@Autowired
|
|
|
449 |
private RefferalRepository refferalRepository;
|
|
|
450 |
|
| 28205 |
tejbeer |
451 |
@Autowired
|
|
|
452 |
private PartnerProblemRepository partnerProblemRepository;
|
|
|
453 |
|
| 28368 |
tejbeer |
454 |
@Autowired
|
|
|
455 |
private PendingOrderRepository pendingOrderRepository;
|
|
|
456 |
|
|
|
457 |
@Autowired
|
|
|
458 |
private PendingOrderItemRepository pendingOrderItemRepository;
|
|
|
459 |
|
|
|
460 |
@Value("${razorpay.account.keyId}")
|
|
|
461 |
private String keyId;
|
|
|
462 |
|
|
|
463 |
@Value("${razorpay.account.keySecret}")
|
|
|
464 |
private String keySecret;
|
|
|
465 |
|
| 28369 |
tejbeer |
466 |
@Autowired
|
|
|
467 |
private RazorpayPaymentService razorPaymentService;
|
|
|
468 |
|
|
|
469 |
@Autowired
|
|
|
470 |
private RazorPayRepository razorPayRepository;
|
|
|
471 |
|
| 28377 |
tejbeer |
472 |
@Autowired
|
|
|
473 |
private PendingOrderService pendingOrderService;
|
|
|
474 |
|
|
|
475 |
@Autowired
|
|
|
476 |
private CustomerRepository customerRepository;
|
|
|
477 |
|
| 23755 |
amit.gupta |
478 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
| 23724 |
amit.gupta |
479 |
|
| 25300 |
tejbeer |
480 |
private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
|
|
|
481 |
private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
|
|
|
482 |
|
| 23724 |
amit.gupta |
483 |
public void generateDailyRecharge() {
|
|
|
484 |
List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
|
|
|
485 |
.selectAll(0, 2000);
|
|
|
486 |
List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
|
|
|
487 |
rechargeProviders.stream().forEach(x -> x.setAmount(0));
|
|
|
488 |
|
|
|
489 |
rechargeProviders.stream().forEach(x -> {
|
|
|
490 |
Map<LocalDate, List<RechargeProviderCreditWalletHistory>> dateWiseProviderCreditsMap = allCreditHistory
|
|
|
491 |
.stream().filter(z -> z.getProviderId() == x.getId())
|
|
|
492 |
.collect(Collectors.groupingBy(x1 -> x1.getReceiveTimestamp().toLocalDate()));
|
|
|
493 |
|
|
|
494 |
LOGGER.info("dateWiseProviderCreditsMap -- {}", dateWiseProviderCreditsMap);
|
|
|
495 |
LocalDate endDate = LocalDate.now().plusDays(1);
|
|
|
496 |
float previousDayClosing = 0;
|
|
|
497 |
LocalDate date = LocalDate.of(2018, 4, 6);
|
|
|
498 |
while (date.isBefore(endDate)) {
|
|
|
499 |
List<RechargeTransaction> dateWiseRechargeTransactions = rechargeTransactionRepository
|
|
|
500 |
.selectAllBetweenTimestamp(Arrays.asList(RechargeStatus.values()), date.atStartOfDay(),
|
|
|
501 |
date.plusDays(1).atStartOfDay());
|
|
|
502 |
|
|
|
503 |
List<RechargeTransaction> successfulTransactions = dateWiseRechargeTransactions.stream()
|
|
|
504 |
.filter(y -> y.getStatus().equals(RechargeStatus.SUCCESS)).collect(Collectors.toList());
|
|
|
505 |
|
|
|
506 |
float dailyAmount = 0;
|
|
|
507 |
float totalCommission = 0;
|
|
|
508 |
for (RechargeTransaction rechargeTransaction : successfulTransactions) {
|
|
|
509 |
if (rechargeTransaction.getProviderId() == x.getId()) {
|
|
|
510 |
dailyAmount += rechargeTransaction.getAmount();
|
|
|
511 |
totalCommission += rechargeTransaction.getCommission();
|
|
|
512 |
}
|
|
|
513 |
}
|
|
|
514 |
|
|
|
515 |
List<RechargeProviderCreditWalletHistory> rechargeHistoryList = dateWiseProviderCreditsMap.get(date);
|
|
|
516 |
float dailyWalletRecharge = 0;
|
|
|
517 |
if (rechargeHistoryList != null) {
|
|
|
518 |
for (RechargeProviderCreditWalletHistory rechargeProviderCreditWalletHistory : rechargeHistoryList) {
|
|
|
519 |
if (rechargeProviderCreditWalletHistory.getProviderId() == x.getId()) {
|
|
|
520 |
dailyWalletRecharge += rechargeProviderCreditWalletHistory.getAmount();
|
|
|
521 |
}
|
|
|
522 |
}
|
|
|
523 |
}
|
|
|
524 |
if (dailyAmount > 0 || dailyWalletRecharge > 0) {
|
|
|
525 |
DailyRecharge dailyRecharge = null;
|
|
|
526 |
try {
|
|
|
527 |
dailyRecharge = dailyRechargeRepository.selectByProviderIdAndCreateDate(x.getId(), date);
|
|
|
528 |
} catch (Exception e) {
|
|
|
529 |
LOGGER.info("Could not find Recharge entry");
|
|
|
530 |
}
|
|
|
531 |
if (dailyRecharge == null) {
|
|
|
532 |
dailyRecharge = new DailyRecharge();
|
|
|
533 |
dailyRecharge.setCreateDate(date);
|
|
|
534 |
}
|
|
|
535 |
dailyRecharge.setOpeningBalance(previousDayClosing);
|
|
|
536 |
dailyRecharge.setProviderId(x.getId());
|
|
|
537 |
dailyRecharge.setWalletRechargeAmount(dailyWalletRecharge);
|
|
|
538 |
dailyRecharge.setTotalAmount(dailyAmount);
|
|
|
539 |
dailyRecharge.setTotalCommission(totalCommission);
|
|
|
540 |
float closingBalance = dailyRecharge.getOpeningBalance() + dailyWalletRecharge - dailyAmount;
|
|
|
541 |
dailyRecharge.setClosingBalance(closingBalance);
|
|
|
542 |
dailyRechargeRepository.persist(dailyRecharge);
|
|
|
543 |
x.setAmount(x.getAmount() + dailyRecharge.getClosingBalance() - dailyRecharge.getOpeningBalance());
|
|
|
544 |
previousDayClosing = dailyRecharge.getClosingBalance();
|
|
|
545 |
}
|
|
|
546 |
date = date.plusDays(1);
|
|
|
547 |
}
|
|
|
548 |
rechargeProviderRepository.persist(x);
|
|
|
549 |
});
|
| 23761 |
amit.gupta |
550 |
LOGGER.info("finished generating daily recharge");
|
| 23724 |
amit.gupta |
551 |
}
|
|
|
552 |
|
| 23738 |
amit.gupta |
553 |
public void reconcileRecharge() throws Exception {
|
| 23724 |
amit.gupta |
554 |
LocalDateTime fromDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(30);
|
|
|
555 |
LocalDateTime toDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
|
|
|
556 |
List<RechargeStatus> nonSuccessRechargeStatuses = new ArrayList<>(Arrays.asList(RechargeStatus.values()));
|
|
|
557 |
LOGGER.info("nonSuccessRechargeStatuses {} ", nonSuccessRechargeStatuses);
|
|
|
558 |
nonSuccessRechargeStatuses.remove(RechargeStatus.SUCCESS);
|
|
|
559 |
nonSuccessRechargeStatuses.remove(RechargeStatus.FAILED);
|
|
|
560 |
RechargeCredential thinkWalnutDigitalRechargeEnquiryCredential = new RechargeCredential();
|
|
|
561 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUrl(thinkWalnutDigitalRechargeEnquiryUrl);
|
|
|
562 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
563 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
|
|
564 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
|
|
565 |
Map<String, RechargeStatus> requestRechargeStatusChanged = new HashMap<>();
|
|
|
566 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
567 |
.selectAllBetweenTimestamp(nonSuccessRechargeStatuses, fromDate, toDate);
|
|
|
568 |
for (RechargeTransaction rechargeTransaction : rechargeTransactions) {
|
|
|
569 |
try {
|
|
|
570 |
int providerId = rechargeTransaction.getProviderId();
|
|
|
571 |
if (providerId == 1) {
|
|
|
572 |
oxigenRechargeProviderService.doCheckStatusRequest(oxigenRechargeEnquiryUrl, oxigenRechargeAuthKey,
|
|
|
573 |
rechargeTransaction);
|
|
|
574 |
} else if (providerId == 2) {
|
|
|
575 |
thinkWalnutDigitalRechargeProviderService
|
|
|
576 |
.doCheckStatusRequest(thinkWalnutDigitalRechargeEnquiryCredential, rechargeTransaction);
|
|
|
577 |
}
|
|
|
578 |
if (rechargeTransaction.getStatus().equals(RechargeStatus.SUCCESS)
|
|
|
579 |
|| rechargeTransaction.getStatus().equals(RechargeStatus.FAILED)) {
|
|
|
580 |
requestRechargeStatusChanged.put(rechargeTransaction.getRequestId(),
|
|
|
581 |
rechargeTransaction.getStatus());
|
|
|
582 |
}
|
|
|
583 |
} catch (Exception e) {
|
|
|
584 |
LOGGER.info("Could not check status for Request {}", rechargeTransaction.getRequestId());
|
|
|
585 |
}
|
|
|
586 |
}
|
| 23738 |
amit.gupta |
587 |
LOGGER.info("Reconcile recharge ran successfully");
|
| 23724 |
amit.gupta |
588 |
}
|
| 28205 |
tejbeer |
589 |
|
| 27438 |
amit.gupta |
590 |
public void processActivation() throws Exception {
|
|
|
591 |
schemeService.processActivation();
|
|
|
592 |
}
|
| 24240 |
amit.gupta |
593 |
|
|
|
594 |
// TemporaryMethod
|
| 24237 |
amit.gupta |
595 |
public void migrateInvoice() {
|
|
|
596 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectFromSaleDate(LocalDateTime.now().minusDays(3));
|
|
|
597 |
Map<Integer, List<FofoOrder>> partnerOrdersMap = new HashMap<>();
|
| 24241 |
amit.gupta |
598 |
partnerOrdersMap = fofoOrders.stream()
|
|
|
599 |
.collect(Collectors.groupingBy(FofoOrder::getFofoId, Collectors.toList()));
|
| 24237 |
amit.gupta |
600 |
for (List<FofoOrder> orderList : partnerOrdersMap.values()) {
|
| 24240 |
amit.gupta |
601 |
int sequence = 0;
|
|
|
602 |
String prefix = "";
|
| 24241 |
amit.gupta |
603 |
List<FofoOrder> sortedList = orderList.stream().sorted((x1, x2) -> x1.getId() - x2.getId())
|
|
|
604 |
.collect(Collectors.toList());
|
|
|
605 |
for (FofoOrder order : sortedList) {
|
|
|
606 |
|
| 24240 |
amit.gupta |
607 |
LOGGER.info("Order Id is {}, partner Id is {}", order.getId(), order.getFofoId());
|
| 24241 |
amit.gupta |
608 |
if (!order.getInvoiceNumber().contains("SEC")) {
|
| 24240 |
amit.gupta |
609 |
sequence = Integer.parseInt(order.getInvoiceNumber().split("/")[1]);
|
|
|
610 |
prefix = order.getInvoiceNumber().split("/")[0];
|
|
|
611 |
} else {
|
|
|
612 |
sequence += 1;
|
| 24241 |
amit.gupta |
613 |
String invoiceNumber = prefix + "/" + sequence;
|
| 24240 |
amit.gupta |
614 |
order.setInvoiceNumber(invoiceNumber);
|
|
|
615 |
fofoOrderRepository.persist(order);
|
|
|
616 |
}
|
|
|
617 |
}
|
| 24241 |
amit.gupta |
618 |
|
| 24237 |
amit.gupta |
619 |
}
|
|
|
620 |
}
|
| 23724 |
amit.gupta |
621 |
|
| 24241 |
amit.gupta |
622 |
// Temporary Method
|
| 24252 |
amit.gupta |
623 |
public void evaluateExcessSchemeOut() throws Exception {
|
| 24244 |
amit.gupta |
624 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
|
|
625 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
| 24252 |
amit.gupta |
626 |
|
| 25837 |
amit.gupta |
627 |
List<List<?>> rows = new ArrayList<>();
|
| 24271 |
amit.gupta |
628 |
List<String> headers = Arrays.asList("Scheme", "Item", "Partner", "Amount", "Credited On", "Invoice Number",
|
|
|
629 |
"Sale On", "Scheme Start", "Scheme End", "Active On", "Expired On");
|
| 24241 |
amit.gupta |
630 |
schemeRepository.selectAll().stream().forEach(x -> {
|
| 24250 |
amit.gupta |
631 |
if (x.getType().equals(SchemeType.OUT)) {
|
|
|
632 |
List<SchemeInOut> sioList = schemeInOutRepository
|
|
|
633 |
.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
|
|
|
634 |
if (x.getActiveTimestamp() != null) {
|
|
|
635 |
LocalDateTime endDateTime = x.getEndDateTime();
|
|
|
636 |
if (x.getExpireTimestamp() != null && x.getExpireTimestamp().isBefore(x.getEndDateTime())) {
|
|
|
637 |
endDateTime = x.getExpireTimestamp();
|
| 24249 |
amit.gupta |
638 |
}
|
| 24250 |
amit.gupta |
639 |
for (SchemeInOut sio : sioList) {
|
|
|
640 |
InventoryItem inventoryItem = null;
|
| 24266 |
amit.gupta |
641 |
inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
| 24271 |
amit.gupta |
642 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndSerialNumber(
|
|
|
643 |
inventoryItem.getFofoId(), inventoryItem.getSerialNumber(), null, null, 0, 1).get(0);
|
| 24250 |
amit.gupta |
644 |
Optional<ScanRecord> record = scanRecordRepository
|
|
|
645 |
.selectByInventoryItemId(sio.getInventoryItemId()).stream()
|
|
|
646 |
.filter(y -> y.getType().equals(ScanType.SALE)).findFirst();
|
|
|
647 |
if (record.isPresent()) {
|
|
|
648 |
int fofoId = record.get().getFofoId();
|
|
|
649 |
if (record.get().getCreateTimestamp().isAfter(endDateTime)
|
|
|
650 |
|| record.get().getCreateTimestamp().isBefore(x.getStartDateTime())) {
|
|
|
651 |
if (!userAmountMap.containsKey(fofoId)) {
|
|
|
652 |
userAmountMap.put(fofoId, 0f);
|
|
|
653 |
}
|
|
|
654 |
userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
|
|
|
655 |
try {
|
| 24252 |
amit.gupta |
656 |
rows.add(Arrays.asList(x.getDescription(),
|
| 24250 |
amit.gupta |
657 |
itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(),
|
| 24252 |
amit.gupta |
658 |
userNameMap.get(fofoId), sio.getAmount(),
|
| 24253 |
amit.gupta |
659 |
FormattingUtils.formatDate(sio.getCreateTimestamp()),
|
|
|
660 |
fofoOrder.getInvoiceNumber(),
|
|
|
661 |
FormattingUtils.formatDate(record.get().getCreateTimestamp()),
|
|
|
662 |
FormattingUtils.formatDate(x.getStartDateTime()),
|
|
|
663 |
FormattingUtils.formatDate(x.getEndDateTime()),
|
|
|
664 |
FormattingUtils.formatDate(x.getActiveTimestamp()),
|
|
|
665 |
FormattingUtils.formatDate(x.getExpireTimestamp())));
|
| 24250 |
amit.gupta |
666 |
} catch (Exception e) {
|
|
|
667 |
e.printStackTrace();
|
|
|
668 |
}
|
| 24242 |
amit.gupta |
669 |
}
|
| 24241 |
amit.gupta |
670 |
}
|
|
|
671 |
}
|
|
|
672 |
}
|
|
|
673 |
}
|
|
|
674 |
});
|
| 24246 |
amit.gupta |
675 |
userAmountMap.entrySet().stream()
|
|
|
676 |
.forEach(x -> LOGGER.info("{} to be deducted from {}({}) for wrongly disbursed due to technical error.",
|
|
|
677 |
x.getValue(), userNameMap.get(x.getKey())));
|
| 24241 |
amit.gupta |
678 |
|
| 24252 |
amit.gupta |
679 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| 24271 |
amit.gupta |
680 |
Utils.sendMailWithAttachment(googleMailSender,
|
|
|
681 |
new String[] { "amit.gupta@shop2020.in", "adeel.yazdani@smartdukaan.com" }, null,
|
|
|
682 |
"Partner Excess Amount", "PFA", "ListofSchemes.csv", new ByteArrayResource(baos.toByteArray()));
|
| 24252 |
amit.gupta |
683 |
|
| 24241 |
amit.gupta |
684 |
}
|
| 24271 |
amit.gupta |
685 |
|
| 25584 |
amit.gupta |
686 |
public void processScheme(int offset, boolean dryRun) throws Exception {
|
| 24462 |
amit.gupta |
687 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
|
| 24259 |
amit.gupta |
688 |
LocalDateTime endDate = startDate.plusDays(30);
|
| 25584 |
amit.gupta |
689 |
processScheme(startDate, endDate, dryRun);
|
| 24256 |
amit.gupta |
690 |
}
|
| 28205 |
tejbeer |
691 |
|
| 27892 |
amit.gupta |
692 |
public void processSchemeOut(List<String> invoiceNumbers) throws Exception {
|
| 28205 |
tejbeer |
693 |
for (String invoiceNumber : invoiceNumbers) {
|
|
|
694 |
System.out.println("Invoice Number - " + invoiceNumber);
|
| 27892 |
amit.gupta |
695 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
|
|
696 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
|
|
|
697 |
}
|
|
|
698 |
}
|
| 28205 |
tejbeer |
699 |
|
| 27987 |
amit.gupta |
700 |
public void processSchemeIn(List<String> invoiceNumbers) throws Exception {
|
| 28205 |
tejbeer |
701 |
for (String invoiceNumber : invoiceNumbers) {
|
|
|
702 |
System.out.println("Invoice Number - " + invoiceNumber);
|
| 27987 |
amit.gupta |
703 |
Purchase purchase = purchaseRepository.selectByPurchaseReference(invoiceNumber);
|
|
|
704 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
|
|
705 |
}
|
|
|
706 |
}
|
| 24533 |
govind |
707 |
|
| 25584 |
amit.gupta |
708 |
public void processScheme(int offset, int durationDays, boolean dryRun) throws Exception {
|
| 24462 |
amit.gupta |
709 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
|
| 24461 |
amit.gupta |
710 |
LocalDateTime endDate = startDate.plusDays(durationDays);
|
| 25584 |
amit.gupta |
711 |
processScheme(startDate, endDate, dryRun);
|
| 24461 |
amit.gupta |
712 |
}
|
| 24271 |
amit.gupta |
713 |
|
| 25584 |
amit.gupta |
714 |
public void processScheme(boolean dryRun) throws Exception {
|
| 24256 |
amit.gupta |
715 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(30);
|
| 25584 |
amit.gupta |
716 |
processScheme(fromDate, LocalDateTime.now(), dryRun);
|
| 24256 |
amit.gupta |
717 |
}
|
| 24271 |
amit.gupta |
718 |
|
| 25584 |
amit.gupta |
719 |
public void processScheme(LocalDateTime startDate, LocalDateTime endDate, boolean dryRun) throws Exception {
|
| 23724 |
amit.gupta |
720 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
| 25312 |
amit.gupta |
721 |
System.out.println(
|
|
|
722 |
"InventoryId\tSerialNumber\tItem Id\tScheme Id\tScheme Name\tScheme Type\tAmount Type\tDP\tTaxable\tScheme Amount\tAmount Paid");
|
| 24561 |
amit.gupta |
723 |
try {
|
| 24587 |
amit.gupta |
724 |
List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
|
|
|
725 |
for (Purchase purchase : purchases) {
|
|
|
726 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
|
|
727 |
}
|
| 24271 |
amit.gupta |
728 |
|
| 24587 |
amit.gupta |
729 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectBetweenSaleDate(startDate, endDate);
|
|
|
730 |
for (FofoOrder fofoOrder : fofoOrders) {
|
|
|
731 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
|
|
|
732 |
}
|
|
|
733 |
} catch (Exception e) {
|
| 24561 |
amit.gupta |
734 |
e.printStackTrace();
|
| 24565 |
amit.gupta |
735 |
throw e;
|
| 24561 |
amit.gupta |
736 |
}
|
| 28205 |
tejbeer |
737 |
List<UserWalletHistory> uwhs = userWalletHistoryRepository.selectAllByDateType(LocalDate.now().atStartOfDay(),
|
|
|
738 |
endDate, Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
| 25043 |
amit.gupta |
739 |
System.out.println("Amount\tReference\tReferenceType\tTimestamp\tDescription");
|
| 25312 |
amit.gupta |
740 |
for (UserWalletHistory uwh : uwhs) {
|
|
|
741 |
System.out.println(String.format("%d\t%d\t%s\t%s\t%s", uwh.getAmount(), uwh.getReference(),
|
|
|
742 |
uwh.getReferenceType(), uwh.getTimestamp().toString(), uwh.getDescription()));
|
| 25043 |
amit.gupta |
743 |
}
|
| 23724 |
amit.gupta |
744 |
LOGGER.info("Schemes process successfully.");
|
| 25598 |
amit.gupta |
745 |
if (dryRun) {
|
| 25584 |
amit.gupta |
746 |
throw new Exception();
|
|
|
747 |
}
|
| 23724 |
amit.gupta |
748 |
}
|
| 23929 |
amit.gupta |
749 |
|
| 23739 |
amit.gupta |
750 |
public void processRechargeCashback() throws Throwable {
|
| 23761 |
amit.gupta |
751 |
LocalDateTime cashbackTime = LocalDateTime.now();
|
| 23929 |
amit.gupta |
752 |
int referenceId = (int) Timestamp.valueOf(cashbackTime).getTime() / 1000;
|
|
|
753 |
List<RechargeTransaction> pendingTransactions = rechargeTransactionRepository
|
|
|
754 |
.getPendingCashBackRehargeTransactions();
|
|
|
755 |
Map<Object, Double> totalRetailerCashbacks = pendingTransactions.stream().collect(
|
|
|
756 |
Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingDouble(x -> x.getCommission())));
|
|
|
757 |
for (Map.Entry<Object, Double> totalRetailerCashback : totalRetailerCashbacks.entrySet()) {
|
|
|
758 |
int retailerId = (Integer) totalRetailerCashback.getKey();
|
| 23739 |
amit.gupta |
759 |
float amount = totalRetailerCashback.getValue().floatValue();
|
| 23929 |
amit.gupta |
760 |
if (Math.round(amount) > 0) {
|
|
|
761 |
walletService.addAmountToWallet(retailerId, referenceId, WalletReferenceType.CASHBACK,
|
| 26565 |
amit.gupta |
762 |
"Recharge Cashback", Math.round(amount), LocalDateTime.now());
|
| 23762 |
amit.gupta |
763 |
}
|
| 23739 |
amit.gupta |
764 |
}
|
| 23929 |
amit.gupta |
765 |
for (RechargeTransaction rt : pendingTransactions) {
|
| 23761 |
amit.gupta |
766 |
rt.setCashbackTimestamp(cashbackTime);
|
|
|
767 |
rt.setCashbackReference(referenceId);
|
|
|
768 |
rechargeTransactionRepository.persist(rt);
|
|
|
769 |
}
|
| 23739 |
amit.gupta |
770 |
LOGGER.info("Cashbacks for Recharge processed Successfully");
|
|
|
771 |
}
|
| 23724 |
amit.gupta |
772 |
|
| 25598 |
amit.gupta |
773 |
private class SaleRoles {
|
|
|
774 |
|
|
|
775 |
private List<String> l1;
|
|
|
776 |
private List<String> l2;
|
|
|
777 |
|
|
|
778 |
public SaleRoles() {
|
|
|
779 |
l1 = new ArrayList<>();
|
|
|
780 |
l2 = new ArrayList<>();
|
|
|
781 |
}
|
|
|
782 |
|
|
|
783 |
public List<String> getL1() {
|
|
|
784 |
return l1;
|
|
|
785 |
}
|
|
|
786 |
|
|
|
787 |
public List<String> getL2() {
|
|
|
788 |
return l2;
|
|
|
789 |
}
|
|
|
790 |
|
|
|
791 |
}
|
|
|
792 |
|
| 26945 |
amit.gupta |
793 |
private class FofoReportingModel {
|
|
|
794 |
private String code;
|
|
|
795 |
private int fofoId;
|
|
|
796 |
private String businessName;
|
|
|
797 |
private String territoryManager;
|
|
|
798 |
private String regionalManager;
|
|
|
799 |
|
|
|
800 |
@Override
|
|
|
801 |
public String toString() {
|
|
|
802 |
return "FofoReportingModel [code=" + code + ", fofoId=" + fofoId + ", businessName=" + businessName
|
|
|
803 |
+ ", territoryManager=" + territoryManager + ", regionalManager=" + regionalManager + "]";
|
|
|
804 |
}
|
|
|
805 |
|
|
|
806 |
public String getCode() {
|
|
|
807 |
return code;
|
|
|
808 |
}
|
|
|
809 |
|
|
|
810 |
public void setCode(String code) {
|
|
|
811 |
this.code = code;
|
|
|
812 |
}
|
|
|
813 |
|
|
|
814 |
public String getBusinessName() {
|
|
|
815 |
return businessName;
|
|
|
816 |
}
|
|
|
817 |
|
|
|
818 |
public void setBusinessName(String businessName) {
|
|
|
819 |
this.businessName = businessName;
|
|
|
820 |
}
|
|
|
821 |
|
|
|
822 |
public String getTerritoryManager() {
|
|
|
823 |
return territoryManager;
|
|
|
824 |
}
|
|
|
825 |
|
|
|
826 |
public void setTerritoryManager(String territoryManager) {
|
|
|
827 |
this.territoryManager = territoryManager;
|
|
|
828 |
}
|
|
|
829 |
|
|
|
830 |
public String getRegionalManager() {
|
|
|
831 |
return regionalManager;
|
|
|
832 |
}
|
|
|
833 |
|
|
|
834 |
public void setRegionalManager(String regionalManager) {
|
|
|
835 |
this.regionalManager = regionalManager;
|
|
|
836 |
}
|
|
|
837 |
|
|
|
838 |
private ScheduledTasks getOuterType() {
|
|
|
839 |
return ScheduledTasks.this;
|
|
|
840 |
}
|
|
|
841 |
|
|
|
842 |
@Override
|
|
|
843 |
public int hashCode() {
|
|
|
844 |
final int prime = 31;
|
|
|
845 |
int result = 1;
|
|
|
846 |
result = prime * result + getOuterType().hashCode();
|
|
|
847 |
result = prime * result + ((businessName == null) ? 0 : businessName.hashCode());
|
|
|
848 |
result = prime * result + ((code == null) ? 0 : code.hashCode());
|
|
|
849 |
result = prime * result + fofoId;
|
|
|
850 |
result = prime * result + ((regionalManager == null) ? 0 : regionalManager.hashCode());
|
|
|
851 |
result = prime * result + ((territoryManager == null) ? 0 : territoryManager.hashCode());
|
|
|
852 |
return result;
|
|
|
853 |
}
|
|
|
854 |
|
|
|
855 |
@Override
|
|
|
856 |
public boolean equals(Object obj) {
|
|
|
857 |
if (this == obj)
|
|
|
858 |
return true;
|
|
|
859 |
if (obj == null)
|
|
|
860 |
return false;
|
|
|
861 |
if (getClass() != obj.getClass())
|
|
|
862 |
return false;
|
|
|
863 |
FofoReportingModel other = (FofoReportingModel) obj;
|
|
|
864 |
if (!getOuterType().equals(other.getOuterType()))
|
|
|
865 |
return false;
|
|
|
866 |
if (businessName == null) {
|
|
|
867 |
if (other.businessName != null)
|
|
|
868 |
return false;
|
|
|
869 |
} else if (!businessName.equals(other.businessName))
|
|
|
870 |
return false;
|
|
|
871 |
if (code == null) {
|
|
|
872 |
if (other.code != null)
|
|
|
873 |
return false;
|
|
|
874 |
} else if (!code.equals(other.code))
|
|
|
875 |
return false;
|
|
|
876 |
if (fofoId != other.fofoId)
|
|
|
877 |
return false;
|
|
|
878 |
if (regionalManager == null) {
|
|
|
879 |
if (other.regionalManager != null)
|
|
|
880 |
return false;
|
|
|
881 |
} else if (!regionalManager.equals(other.regionalManager))
|
|
|
882 |
return false;
|
|
|
883 |
if (territoryManager == null) {
|
|
|
884 |
if (other.territoryManager != null)
|
|
|
885 |
return false;
|
|
|
886 |
} else if (!territoryManager.equals(other.territoryManager))
|
|
|
887 |
return false;
|
|
|
888 |
return true;
|
|
|
889 |
}
|
|
|
890 |
|
|
|
891 |
public int getFofoId() {
|
|
|
892 |
return fofoId;
|
|
|
893 |
}
|
|
|
894 |
|
|
|
895 |
public void setFofoId(int fofoId) {
|
|
|
896 |
this.fofoId = fofoId;
|
|
|
897 |
}
|
|
|
898 |
|
|
|
899 |
}
|
|
|
900 |
|
| 24271 |
amit.gupta |
901 |
public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
|
| 24277 |
amit.gupta |
902 |
LocalDate yesterDay = LocalDate.now().minusDays(1);
|
| 25267 |
amit.gupta |
903 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
| 23929 |
amit.gupta |
904 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService
|
|
|
905 |
.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| 25351 |
tejbeer |
906 |
|
| 26957 |
amit.gupta |
907 |
List<String> headers = Arrays.asList("Code", "Outlet name", "State Manager", "Teritory/Team Lead",
|
| 26945 |
amit.gupta |
908 |
"Wallet Amount", "In Stock Amount", "Activated Stock", "Return In Transit Stock", "Unbilled Amount",
|
|
|
909 |
"Grn Pending Amount", "Min Investment", "Investment Amount", "Investment Short", "Unbilled Qty",
|
|
|
910 |
"Short Days");
|
| 25837 |
amit.gupta |
911 |
List<List<?>> rows = new ArrayList<>();
|
| 25895 |
amit.gupta |
912 |
Map<Integer, List<?>> partnerRowsMap = new HashMap<>();
|
| 25598 |
amit.gupta |
913 |
|
| 26945 |
amit.gupta |
914 |
Map<Integer, FofoReportingModel> partnerIdSalesHeaderMap = this.getPartnerIdSalesHeaders();
|
| 25598 |
amit.gupta |
915 |
|
| 26945 |
amit.gupta |
916 |
Map<Integer, Integer> shortDaysMap = partnerDailyInvestmentRepository
|
|
|
917 |
.selectAll(LocalDate.now().withDayOfMonth(1), LocalDate.now()).stream().collect(Collectors.groupingBy(
|
|
|
918 |
x -> x.getFofoId(), Collectors.summingInt(x -> x.getShortPercentage() > 10 ? 1 : 0)));
|
|
|
919 |
|
| 24002 |
amit.gupta |
920 |
for (FofoStore fofoStore : fofoStores) {
|
| 27750 |
amit.gupta |
921 |
LOGGER.info("Fofo Store {}, {}", fofoStore.getId(), fofoStore.getCode());
|
| 26376 |
amit.gupta |
922 |
int fofoId = fofoStore.getId();
|
| 26945 |
amit.gupta |
923 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoId, 1);
|
| 25598 |
amit.gupta |
924 |
partnerDailyInvestment.setDate(yesterDay);
|
| 26945 |
amit.gupta |
925 |
|
| 25598 |
amit.gupta |
926 |
try {
|
|
|
927 |
partnerDailyInvestmentRepository.persist(partnerDailyInvestment);
|
| 26945 |
amit.gupta |
928 |
shortDaysMap.put(fofoId,
|
|
|
929 |
shortDaysMap.get(fofoId) + (partnerDailyInvestment.getShortPercentage() > 10 ? 1 : 0));
|
| 25598 |
amit.gupta |
930 |
} catch (Exception e) {
|
|
|
931 |
// ignore the exceptions during persist
|
|
|
932 |
}
|
|
|
933 |
|
| 24002 |
amit.gupta |
934 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
| 25837 |
amit.gupta |
935 |
if (retailer == null || partnerIdSalesHeaderMap.get(fofoStore.getId()) == null) {
|
| 24002 |
amit.gupta |
936 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
|
|
937 |
continue;
|
|
|
938 |
}
|
| 26945 |
amit.gupta |
939 |
FofoReportingModel reportingModel = partnerIdSalesHeaderMap.get(fofoStore.getId());
|
|
|
940 |
List<Serializable> row = new ArrayList<>();
|
|
|
941 |
row.addAll(Arrays.asList(reportingModel.getCode(), reportingModel.getBusinessName(),
|
|
|
942 |
reportingModel.getRegionalManager(), reportingModel.getTerritoryManager()));
|
| 25927 |
amit.gupta |
943 |
row.addAll(
|
|
|
944 |
Arrays.asList(partnerDailyInvestment.getWalletAmount(), partnerDailyInvestment.getInStockAmount(),
|
| 26945 |
amit.gupta |
945 |
partnerDailyInvestment.getActivatedStockAmount() == 0 ? "-"
|
|
|
946 |
: "(" + partnerDailyInvestment.getActivatedStockAmount() + ")",
|
| 25927 |
amit.gupta |
947 |
0, partnerDailyInvestment.getUnbilledAmount(), partnerDailyInvestment.getGrnPendingAmount(),
|
|
|
948 |
partnerDailyInvestment.getMinInvestment(), partnerDailyInvestment.getTotalInvestment(),
|
| 26945 |
amit.gupta |
949 |
partnerDailyInvestment.getShortInvestment(), partnerDailyInvestment.getUnbilledQty(),
|
|
|
950 |
shortDaysMap.get(fofoId)));
|
| 25837 |
amit.gupta |
951 |
partnerRowsMap.put(fofoStore.getId(), row);
|
| 24002 |
amit.gupta |
952 |
rows.add(row);
|
|
|
953 |
|
| 23929 |
amit.gupta |
954 |
}
|
| 25312 |
amit.gupta |
955 |
|
| 24271 |
amit.gupta |
956 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 25598 |
amit.gupta |
957 |
|
| 25927 |
amit.gupta |
958 |
if (sendTo == null) {
|
| 25895 |
amit.gupta |
959 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
|
|
960 |
List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x))
|
|
|
961 |
.filter(x -> x != null).collect(Collectors.toList());
|
|
|
962 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
|
|
963 |
String[] sendToArray = new String[] { storeGuyEntry.getKey() };
|
|
|
964 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
|
|
965 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
|
|
966 |
}
|
| 27210 |
tejbeer |
967 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| 28467 |
tejbeer |
968 |
"neeraj.gupta@smartdukaan.com", "amit.gupta@shop2020.in", "manish.gupta@smartdukaan.com",
|
|
|
969 |
"niranjan.kala@smartdukaan.com");
|
| 25341 |
amit.gupta |
970 |
}
|
| 25312 |
amit.gupta |
971 |
|
| 25604 |
amit.gupta |
972 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
|
|
973 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
| 25609 |
amit.gupta |
974 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
|
|
975 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
| 24271 |
amit.gupta |
976 |
|
| 23929 |
amit.gupta |
977 |
}
|
| 24177 |
govind |
978 |
|
| 26945 |
amit.gupta |
979 |
private Map<Integer, FofoReportingModel> getPartnerIdSalesHeaders() {
|
| 25598 |
amit.gupta |
980 |
Map<String, SaleRoles> partnerEmailSalesMap = new HashMap<>();
|
|
|
981 |
|
|
|
982 |
List<Position> positions = positionRepository
|
|
|
983 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
|
|
984 |
Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream()
|
|
|
985 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
986 |
Map<Integer, List<CustomRetailer>> positionIdRetailerMap = csService.getPositionCustomRetailerMap(positions);
|
|
|
987 |
for (Position position : positions) {
|
|
|
988 |
List<CustomRetailer> crList = positionIdRetailerMap.get(position.getId());
|
| 25609 |
amit.gupta |
989 |
if (crList == null)
|
|
|
990 |
continue;
|
| 25598 |
amit.gupta |
991 |
for (CustomRetailer cr : crList) {
|
|
|
992 |
if (!partnerEmailSalesMap.containsKey(cr.getEmail())) {
|
|
|
993 |
partnerEmailSalesMap.put(cr.getEmail(), new SaleRoles());
|
|
|
994 |
}
|
|
|
995 |
SaleRoles saleRoles = partnerEmailSalesMap.get(cr.getEmail());
|
|
|
996 |
AuthUser authUser = authUsersMap.get(position.getAuthUserId());
|
| 26945 |
amit.gupta |
997 |
if (authUser == null) {
|
| 26059 |
amit.gupta |
998 |
continue;
|
|
|
999 |
}
|
| 25598 |
amit.gupta |
1000 |
String name = authUser.getFirstName() + " " + authUser.getLastName();
|
|
|
1001 |
if (position.getEscalationType().equals(EscalationType.L1)) {
|
|
|
1002 |
saleRoles.getL1().add(name);
|
|
|
1003 |
} else if (position.getEscalationType().equals(EscalationType.L2)) {
|
|
|
1004 |
saleRoles.getL2().add(name);
|
|
|
1005 |
}
|
|
|
1006 |
}
|
|
|
1007 |
}
|
| 25837 |
amit.gupta |
1008 |
|
|
|
1009 |
Set<CustomRetailer> allCrList = new HashSet<>();
|
|
|
1010 |
for (List<CustomRetailer> cr : positionIdRetailerMap.values()) {
|
|
|
1011 |
allCrList.addAll(cr);
|
|
|
1012 |
}
|
|
|
1013 |
|
|
|
1014 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream()
|
|
|
1015 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
1016 |
|
| 26945 |
amit.gupta |
1017 |
Map<Integer, FofoReportingModel> partnerIdSalesHeadersMap = new HashMap<>();
|
| 25837 |
amit.gupta |
1018 |
|
|
|
1019 |
for (CustomRetailer cr : allCrList) {
|
|
|
1020 |
FofoStore fofoStore = fofoStoresMap.get(cr.getPartnerId());
|
| 25927 |
amit.gupta |
1021 |
if (fofoStore == null) {
|
| 25870 |
amit.gupta |
1022 |
LOGGER.info("Could not find Store {} in active Store", cr.getBusinessName());
|
|
|
1023 |
continue;
|
|
|
1024 |
}
|
| 26945 |
amit.gupta |
1025 |
String code = fofoStore.getCode();
|
|
|
1026 |
// String storeName = "SmartDukaan-" +
|
|
|
1027 |
// fofoStore.getCode().replaceAll("[a-zA-Z]", "");
|
| 25837 |
amit.gupta |
1028 |
String businessName = cr.getBusinessName();
|
|
|
1029 |
try {
|
|
|
1030 |
String stateManager = StringUtils.join(partnerEmailSalesMap.get(cr.getEmail()).getL2(), ", ");
|
|
|
1031 |
String territoryManager = StringUtils.join(partnerEmailSalesMap.get(cr.getEmail()).getL1(), ", ");
|
| 26945 |
amit.gupta |
1032 |
FofoReportingModel reportingModel = new FofoReportingModel();
|
|
|
1033 |
reportingModel.setBusinessName(businessName);
|
|
|
1034 |
reportingModel.setCode(code);
|
|
|
1035 |
reportingModel.setFofoId(fofoStore.getId());
|
|
|
1036 |
reportingModel.setRegionalManager(stateManager);
|
|
|
1037 |
reportingModel.setTerritoryManager(territoryManager);
|
|
|
1038 |
partnerIdSalesHeadersMap.put(fofoStore.getId(), reportingModel);
|
| 25837 |
amit.gupta |
1039 |
} catch (Exception e) {
|
|
|
1040 |
LOGGER.warn("Could not find partner with email - {}", cr.getEmail());
|
|
|
1041 |
}
|
|
|
1042 |
}
|
|
|
1043 |
return partnerIdSalesHeadersMap;
|
|
|
1044 |
|
| 25598 |
amit.gupta |
1045 |
}
|
|
|
1046 |
|
| 24271 |
amit.gupta |
1047 |
public void sendPartnerInvestmentDetails() throws Exception {
|
| 25565 |
amit.gupta |
1048 |
this.sendPartnerInvestmentDetails(null);
|
| 24271 |
amit.gupta |
1049 |
}
|
|
|
1050 |
|
| 24697 |
amit.gupta |
1051 |
public void sendAgeingReport(String... sendTo) throws Exception {
|
| 24692 |
amit.gupta |
1052 |
|
|
|
1053 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.WAREHOUSENEW,
|
|
|
1054 |
"itemstockageing.xml");
|
| 24708 |
amit.gupta |
1055 |
InputStreamSource isr1 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
|
| 24754 |
amit.gupta |
1056 |
"ItemwiseOverallPendingIndent.xml");
|
| 24683 |
amit.gupta |
1057 |
Attachment attachment = new Attachment(
|
| 25445 |
amit.gupta |
1058 |
"ageing-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr);
|
| 24707 |
amit.gupta |
1059 |
Attachment attachment1 = new Attachment(
|
| 25445 |
amit.gupta |
1060 |
"pending-indent-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr1);
|
| 25418 |
amit.gupta |
1061 |
|
| 25609 |
amit.gupta |
1062 |
Utils.sendMailWithAttachments(googleMailSender, STOCK_AGEING_MAIL_LIST, null, "Stock Ageing Report", "PFA",
|
|
|
1063 |
attachment);
|
|
|
1064 |
Utils.sendMailWithAttachments(googleMailSender, ITEMWISE_PENDING_INDENT_MAIL_LIST, null,
|
|
|
1065 |
"Itemwise Pending indent", "PFA", attachment1);
|
|
|
1066 |
|
| 25598 |
amit.gupta |
1067 |
// Reports to be sent to mapped partners
|
| 25597 |
amit.gupta |
1068 |
Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
|
| 25503 |
amit.gupta |
1069 |
|
|
|
1070 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
|
| 25418 |
amit.gupta |
1071 |
Map<String, String> params = new HashMap<>();
|
| 25503 |
amit.gupta |
1072 |
if (storeGuyEntry.getValue().size() == 0)
|
|
|
1073 |
continue;
|
| 25418 |
amit.gupta |
1074 |
params.put("MANUAL_email", String.join(",", storeGuyEntry.getValue()));
|
|
|
1075 |
InputStreamSource isr3 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
|
|
|
1076 |
"focostockreport.xml", params);
|
|
|
1077 |
Attachment attache = new Attachment(
|
| 25609 |
amit.gupta |
1078 |
"Franchise-stock-report" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr3);
|
| 25584 |
amit.gupta |
1079 |
System.out.println(storeGuyEntry.getValue());
|
| 25609 |
amit.gupta |
1080 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { storeGuyEntry.getKey() }, null,
|
|
|
1081 |
"Franchise Stock Report", "PFA", attache);
|
| 25418 |
amit.gupta |
1082 |
}
|
| 25503 |
amit.gupta |
1083 |
|
| 24681 |
amit.gupta |
1084 |
}
|
| 24533 |
govind |
1085 |
|
| 28632 |
amit.gupta |
1086 |
|
|
|
1087 |
public void sendIndentTertiary() throws Exception {
|
|
|
1088 |
|
|
|
1089 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
|
|
|
1090 |
"indentandtertiary.xml");
|
|
|
1091 |
Attachment attachment = new Attachment(
|
|
|
1092 |
"indentandtertiary-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr);
|
|
|
1093 |
Utils.sendMailWithAttachments(googleMailSender, INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report", "PFA",
|
|
|
1094 |
attachment);
|
|
|
1095 |
|
|
|
1096 |
}
|
|
|
1097 |
|
| 24697 |
amit.gupta |
1098 |
public void sendAgeingReport() throws Exception {
|
| 27210 |
tejbeer |
1099 |
sendAgeingReport("kamini.sharma@smartdukaan.com", "amit.babu@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
| 28467 |
tejbeer |
1100 |
"niranjan.kala@smartdukaan.com", "manish.gupta@smartdukaan.com", "kuldeep.kumar@smartdukaan.com");
|
| 24697 |
amit.gupta |
1101 |
}
|
|
|
1102 |
|
| 24533 |
govind |
1103 |
public void moveImeisToPriceDropImeis() throws Exception {
|
| 24431 |
amit.gupta |
1104 |
List<PriceDrop> priceDrops = priceDropRepository.selectAll();
|
| 24533 |
govind |
1105 |
for (PriceDrop priceDrop : priceDrops) {
|
| 24431 |
amit.gupta |
1106 |
priceDropService.priceDropStatus(priceDrop.getId());
|
|
|
1107 |
}
|
|
|
1108 |
}
|
| 23929 |
amit.gupta |
1109 |
|
| 24542 |
amit.gupta |
1110 |
public void walletmismatch() throws Exception {
|
|
|
1111 |
LocalDate curDate = LocalDate.now();
|
| 24553 |
amit.gupta |
1112 |
List<PartnerDailyInvestment> pdis = partnerDailyInvestmentRepository.selectAll(curDate.minusDays(2));
|
| 24552 |
amit.gupta |
1113 |
System.out.println(pdis.size());
|
| 24542 |
amit.gupta |
1114 |
for (PartnerDailyInvestment pdi : pdis) {
|
| 24549 |
amit.gupta |
1115 |
int fofoId = pdi.getFofoId();
|
| 24542 |
amit.gupta |
1116 |
for (PartnerDailyInvestment investment : Lists
|
|
|
1117 |
.reverse(partnerDailyInvestmentRepository.selectAll(fofoId, null, null))) {
|
| 24552 |
amit.gupta |
1118 |
float statementAmount = walletService.getOpeningTill(fofoId,
|
| 24555 |
amit.gupta |
1119 |
investment.getDate().plusDays(1).atTime(LocalTime.of(4, 0)));
|
| 24552 |
amit.gupta |
1120 |
CustomRetailer retailer = retailerService.getFofoRetailer(fofoId);
|
| 24841 |
govind |
1121 |
LOGGER.info("{}\t{}\t{}\t{}\t{}", fofoId, retailer.getBusinessName(), retailer.getMobileNumber(),
|
|
|
1122 |
investment.getDate().toString(), investment.getWalletAmount(), statementAmount);
|
| 24551 |
amit.gupta |
1123 |
|
| 24542 |
amit.gupta |
1124 |
}
|
| 24549 |
amit.gupta |
1125 |
}
|
| 24542 |
amit.gupta |
1126 |
|
|
|
1127 |
}
|
|
|
1128 |
|
|
|
1129 |
public void gst() throws Exception {
|
| 24548 |
amit.gupta |
1130 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectBetweenSaleDate(LocalDate.of(2019, 1, 26).atStartOfDay(),
|
|
|
1131 |
LocalDate.of(2019, 1, 27).atTime(LocalTime.MAX));
|
|
|
1132 |
for (FofoOrder fofoOrder : fofoOrders) {
|
|
|
1133 |
int retailerAddressId = retailerRegisteredAddressRepository
|
|
|
1134 |
.selectAddressIdByRetailerId(fofoOrder.getFofoId());
|
| 24542 |
amit.gupta |
1135 |
|
|
|
1136 |
Address retailerAddress = addressRepository.selectById(retailerAddressId);
|
|
|
1137 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
|
|
1138 |
Integer stateId = null;
|
|
|
1139 |
if (customerAddress.getState().equals(retailerAddress.getState())) {
|
|
|
1140 |
try {
|
|
|
1141 |
stateId = Long.valueOf(Utils.getStateInfo(customerAddress.getState()).getId()).intValue();
|
|
|
1142 |
} catch (Exception e) {
|
|
|
1143 |
LOGGER.error("Unable to get state rates");
|
|
|
1144 |
}
|
|
|
1145 |
}
|
|
|
1146 |
Map<Integer, GstRate> itemIdStateTaxRateMap = null;
|
|
|
1147 |
Map<Integer, Float> itemIdIgstTaxRateMap = null;
|
| 24548 |
amit.gupta |
1148 |
|
|
|
1149 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 26929 |
amit.gupta |
1150 |
List<Integer> itemIds = fofoOrderItems.stream().map(x -> x.getItemId()).collect(Collectors.toList());
|
| 24542 |
amit.gupta |
1151 |
if (stateId != null) {
|
| 26929 |
amit.gupta |
1152 |
itemIdStateTaxRateMap = stateGstRateRepository.getStateTaxRate(itemIds, stateId);
|
| 24542 |
amit.gupta |
1153 |
} else {
|
| 26929 |
amit.gupta |
1154 |
itemIdIgstTaxRateMap = stateGstRateRepository.getIgstTaxRate(itemIds);
|
| 24542 |
amit.gupta |
1155 |
}
|
|
|
1156 |
|
| 24548 |
amit.gupta |
1157 |
for (FofoOrderItem foi : fofoOrderItems) {
|
| 24542 |
amit.gupta |
1158 |
if (stateId == null) {
|
|
|
1159 |
foi.setIgstRate(itemIdIgstTaxRateMap.get(foi.getItemId()));
|
|
|
1160 |
} else {
|
|
|
1161 |
foi.setCgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getCgstRate());
|
|
|
1162 |
foi.setSgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getSgstRate());
|
|
|
1163 |
}
|
|
|
1164 |
fofoOrderItemRepository.persist(foi);
|
|
|
1165 |
}
|
|
|
1166 |
}
|
| 24548 |
amit.gupta |
1167 |
|
| 24542 |
amit.gupta |
1168 |
}
|
|
|
1169 |
|
| 24580 |
amit.gupta |
1170 |
public void schemewalletmismatch() {
|
|
|
1171 |
LocalDate dateToReconcile = LocalDate.of(2018, 4, 1);
|
| 24587 |
amit.gupta |
1172 |
while (dateToReconcile.isBefore(LocalDate.now())) {
|
| 24580 |
amit.gupta |
1173 |
reconcileSchemes(dateToReconcile);
|
| 24587 |
amit.gupta |
1174 |
// reconcileOrders(dateTime);
|
|
|
1175 |
// reconcileRecharges(dateTime);
|
| 24580 |
amit.gupta |
1176 |
dateToReconcile = dateToReconcile.plusDays(1);
|
|
|
1177 |
}
|
|
|
1178 |
}
|
|
|
1179 |
|
|
|
1180 |
private void reconcileSchemes(LocalDate date) {
|
|
|
1181 |
LocalDateTime startDate = date.atStartOfDay();
|
|
|
1182 |
LocalDateTime endDate = startDate.plusDays(1);
|
|
|
1183 |
List<SchemeInOut> siosCreated = schemeInOutRepository.selectAllByCreateDate(startDate, endDate);
|
|
|
1184 |
List<SchemeInOut> siosRefunded = schemeInOutRepository.selectAllByRefundDate(startDate, endDate);
|
| 24587 |
amit.gupta |
1185 |
double totalSchemeDisbursed = siosCreated.stream().mapToDouble(x -> x.getAmount()).sum();
|
|
|
1186 |
double totalSchemeRolledback = siosRefunded.stream().mapToDouble(x -> x.getAmount()).sum();
|
| 24580 |
amit.gupta |
1187 |
double netSchemeDisbursed = totalSchemeDisbursed - totalSchemeRolledback;
|
| 24587 |
amit.gupta |
1188 |
List<WalletReferenceType> walletReferenceTypes = Arrays.asList(WalletReferenceType.SCHEME_IN,
|
|
|
1189 |
WalletReferenceType.SCHEME_OUT);
|
|
|
1190 |
List<UserWalletHistory> history = userWalletHistoryRepository.selectAllByDateType(startDate, endDate,
|
|
|
1191 |
walletReferenceTypes);
|
|
|
1192 |
double schemeAmountWalletTotal = history.stream().mapToDouble(x -> x.getAmount()).sum();
|
|
|
1193 |
if (Math.abs(netSchemeDisbursed - schemeAmountWalletTotal) > 10d) {
|
| 24580 |
amit.gupta |
1194 |
LOGGER.info("Scheme Amount mismatched for Date {}", date);
|
| 24587 |
amit.gupta |
1195 |
|
|
|
1196 |
Map<Integer, Double> inventoryItemSchemeIO = siosCreated.stream().collect(Collectors
|
|
|
1197 |
.groupingBy(x -> x.getInventoryItemId(), Collectors.summingDouble(SchemeInOut::getAmount)));
|
|
|
1198 |
|
|
|
1199 |
Map<Integer, Double> userSchemeMap = inventoryItemRepository.selectByIds(inventoryItemSchemeIO.keySet())
|
|
|
1200 |
.stream().collect(Collectors.groupingBy(x -> x.getFofoId(),
|
|
|
1201 |
Collectors.summingDouble(x -> inventoryItemSchemeIO.get(x.getId()))));
|
|
|
1202 |
|
|
|
1203 |
Map<Integer, Double> inventoryItemSchemeIORefunded = siosRefunded.stream().collect(Collectors
|
|
|
1204 |
.groupingBy(x -> x.getInventoryItemId(), Collectors.summingDouble(SchemeInOut::getAmount)));
|
|
|
1205 |
|
|
|
1206 |
Map<Integer, Double> userSchemeRefundedMap = inventoryItemRepository
|
|
|
1207 |
.selectByIds(inventoryItemSchemeIORefunded.keySet()).stream()
|
|
|
1208 |
.collect(Collectors.groupingBy(x -> x.getFofoId(),
|
|
|
1209 |
Collectors.summingDouble(x -> inventoryItemSchemeIORefunded.get(x.getId()))));
|
|
|
1210 |
|
|
|
1211 |
Map<Integer, Double> finalUserSchemeAmountMap = new HashMap<>();
|
| 26092 |
amit.gupta |
1212 |
|
| 24587 |
amit.gupta |
1213 |
for (Map.Entry<Integer, Double> schemeAmount : userSchemeRefundedMap.entrySet()) {
|
|
|
1214 |
if (!finalUserSchemeAmountMap.containsKey(schemeAmount.getKey())) {
|
|
|
1215 |
finalUserSchemeAmountMap.put(schemeAmount.getKey(), schemeAmount.getValue());
|
|
|
1216 |
} else {
|
|
|
1217 |
finalUserSchemeAmountMap.put(schemeAmount.getKey(),
|
|
|
1218 |
finalUserSchemeAmountMap.get(schemeAmount.getKey()) + schemeAmount.getValue());
|
|
|
1219 |
}
|
|
|
1220 |
}
|
| 24590 |
amit.gupta |
1221 |
Map<Integer, Integer> userWalletMap = userWalletRepository
|
|
|
1222 |
.selectByRetailerIds(finalUserSchemeAmountMap.keySet()).stream()
|
|
|
1223 |
.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
|
|
1224 |
|
| 24587 |
amit.gupta |
1225 |
Map<Integer, Double> walletAmountMap = history.stream().collect(Collectors.groupingBy(
|
|
|
1226 |
UserWalletHistory::getWalletId, Collectors.summingDouble((UserWalletHistory::getAmount))));
|
|
|
1227 |
for (Map.Entry<Integer, Double> userAmount : walletAmountMap.entrySet()) {
|
|
|
1228 |
double diff = Math.abs(finalUserSchemeAmountMap.get(userAmount.getKey()) - userAmount.getValue());
|
|
|
1229 |
if (diff > 5) {
|
|
|
1230 |
LOGGER.info("Partner scheme mismatched for Userid {}", userWalletMap.get(userAmount.getKey()));
|
|
|
1231 |
}
|
|
|
1232 |
}
|
| 24580 |
amit.gupta |
1233 |
}
|
| 24587 |
amit.gupta |
1234 |
|
| 24580 |
amit.gupta |
1235 |
}
|
| 24590 |
amit.gupta |
1236 |
|
| 24592 |
amit.gupta |
1237 |
public void dryRunSchemeReco() throws Exception {
|
| 24635 |
amit.gupta |
1238 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream()
|
|
|
1239 |
.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
|
|
1240 |
|
| 24592 |
amit.gupta |
1241 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
|
|
1242 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
| 24635 |
amit.gupta |
1243 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream()
|
|
|
1244 |
.collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
|
|
1245 |
Set<String> serialNumbersConsidered = new HashSet<>();
|
|
|
1246 |
|
| 25096 |
amit.gupta |
1247 |
LocalDateTime startDate = LocalDate.of(2018, 3, 1).atStartOfDay();
|
| 24635 |
amit.gupta |
1248 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
|
|
1249 |
List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
|
|
|
1250 |
|
| 24683 |
amit.gupta |
1251 |
Map<Integer, String> storeNameMap = fofoStoreRepository.getStoresMap();
|
| 24635 |
amit.gupta |
1252 |
purchases.stream().forEach(purchase -> {
|
|
|
1253 |
float amountToRollback = 0;
|
|
|
1254 |
String description = "Adjustment of Duplicate Scheme for Purchase Invoice "
|
|
|
1255 |
+ purchase.getPurchaseReference();
|
|
|
1256 |
Map<Integer, String> inventorySerialNumberMap = inventoryItemRepository.selectByPurchaseId(purchase.getId())
|
|
|
1257 |
.stream().filter(ii -> ii.getSerialNumber() != null)
|
|
|
1258 |
.collect(Collectors.toMap(InventoryItem::getId, InventoryItem::getSerialNumber));
|
|
|
1259 |
if (inventorySerialNumberMap.size() > 0) {
|
|
|
1260 |
for (Map.Entry<Integer, String> inventorySerialNumberEntry : inventorySerialNumberMap.entrySet()) {
|
|
|
1261 |
String serialNumber = inventorySerialNumberEntry.getValue();
|
|
|
1262 |
int inventoryItemId = inventorySerialNumberEntry.getKey();
|
|
|
1263 |
if (serialNumbersConsidered.contains(serialNumber)) {
|
|
|
1264 |
// This will rollback scheme for differenct orders for same serial
|
|
|
1265 |
List<SchemeInOut> sios = schemeInOutRepository
|
|
|
1266 |
.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
|
|
|
1267 |
.filter(x -> x.getRolledBackTimestamp() == null
|
|
|
1268 |
&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.IN))
|
|
|
1269 |
.collect(Collectors.toList());
|
|
|
1270 |
Collections.reverse(sios);
|
|
|
1271 |
for (SchemeInOut sio : sios) {
|
|
|
1272 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
|
|
1273 |
amountToRollback += sio.getAmount();
|
|
|
1274 |
// sio.setSchemeType(SchemeType.OUT);
|
|
|
1275 |
sio.setSerialNumber(serialNumber);
|
|
|
1276 |
rolledbackSios.add(sio);
|
|
|
1277 |
}
|
|
|
1278 |
description = description.concat(" " + serialNumber + " ");
|
|
|
1279 |
} else {
|
|
|
1280 |
serialNumbersConsidered.add(serialNumber);
|
|
|
1281 |
List<Integer> schemesConsidered = new ArrayList<>();
|
|
|
1282 |
List<SchemeInOut> sios = schemeInOutRepository
|
|
|
1283 |
.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
|
|
|
1284 |
.filter(x -> x.getRolledBackTimestamp() == null
|
|
|
1285 |
&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.IN))
|
|
|
1286 |
.collect(Collectors.toList());
|
|
|
1287 |
Collections.reverse(sios);
|
|
|
1288 |
for (SchemeInOut sio : sios) {
|
|
|
1289 |
if (!schemesConsidered.contains(sio.getSchemeId())) {
|
|
|
1290 |
schemesConsidered.add(sio.getSchemeId());
|
|
|
1291 |
continue;
|
|
|
1292 |
}
|
|
|
1293 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
|
|
1294 |
amountToRollback += sio.getAmount();
|
|
|
1295 |
// sio.setSchemeType(SchemeType.OUT);
|
|
|
1296 |
sio.setSerialNumber(serialNumber);
|
| 24681 |
amit.gupta |
1297 |
sio.setStoreCode(storeNameMap.get(purchase.getFofoId()));
|
|
|
1298 |
sio.setReference(purchase.getId());
|
| 24635 |
amit.gupta |
1299 |
rolledbackSios.add(sio);
|
|
|
1300 |
}
|
|
|
1301 |
}
|
|
|
1302 |
|
|
|
1303 |
}
|
|
|
1304 |
}
|
|
|
1305 |
if (amountToRollback > 0) {
|
| 24683 |
amit.gupta |
1306 |
// Address address =
|
|
|
1307 |
// addressRepository.selectAllByRetailerId(purchase.getFofoId(), 0, 10).get(0);
|
| 24635 |
amit.gupta |
1308 |
UserWalletHistory uwh = new UserWalletHistory();
|
|
|
1309 |
uwh.setAmount(Math.round(amountToRollback));
|
|
|
1310 |
uwh.setDescription(description);
|
|
|
1311 |
uwh.setTimestamp(LocalDateTime.now());
|
| 24681 |
amit.gupta |
1312 |
uwh.setReferenceType(WalletReferenceType.SCHEME_IN);
|
| 24635 |
amit.gupta |
1313 |
uwh.setReference(purchase.getId());
|
|
|
1314 |
uwh.setWalletId(userWalletMap.get(purchase.getFofoId()));
|
|
|
1315 |
uwh.setFofoId(purchase.getFofoId());
|
| 24681 |
amit.gupta |
1316 |
uwh.setStoreCode(storeNameMap.get(purchase.getFofoId()));
|
| 24635 |
amit.gupta |
1317 |
userWalletHistory.add(uwh);
|
|
|
1318 |
}
|
|
|
1319 |
});
|
|
|
1320 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
|
|
1321 |
Arrays.asList("User Id", "Store Code", "Reference Type", "Reference", "Amount", "Description",
|
|
|
1322 |
"Timestamp"),
|
|
|
1323 |
userWalletHistory.stream()
|
|
|
1324 |
.map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(),
|
|
|
1325 |
x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
|
|
|
1326 |
.collect(Collectors.toList()));
|
|
|
1327 |
|
|
|
1328 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
| 24683 |
amit.gupta |
1329 |
Arrays.asList("Scheme ID", "SchemeType", "Reference", "Store Code", "Serial Number", "Amount",
|
|
|
1330 |
"Created", "Rolledback"),
|
| 24635 |
amit.gupta |
1331 |
rolledbackSios.stream()
|
| 24681 |
amit.gupta |
1332 |
.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getReference(), x.getStoreCode(),
|
| 24635 |
amit.gupta |
1333 |
x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
|
|
|
1334 |
.collect(Collectors.toList()));
|
|
|
1335 |
|
| 25043 |
amit.gupta |
1336 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { "amit.gupta@shop2020.in" }, null,
|
| 24636 |
amit.gupta |
1337 |
"Partner Excess Amount Scheme In", "PFA",
|
| 24635 |
amit.gupta |
1338 |
new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
|
| 24636 |
amit.gupta |
1339 |
new Attachment("SchemeInRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
|
| 24635 |
amit.gupta |
1340 |
|
| 25096 |
amit.gupta |
1341 |
throw new Exception();
|
| 24635 |
amit.gupta |
1342 |
|
|
|
1343 |
}
|
|
|
1344 |
|
|
|
1345 |
public void dryRunOutSchemeReco() throws Exception {
|
|
|
1346 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
|
|
1347 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
| 24606 |
amit.gupta |
1348 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream()
|
|
|
1349 |
.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
| 24590 |
amit.gupta |
1350 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream()
|
|
|
1351 |
.collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
| 25028 |
amit.gupta |
1352 |
LocalDateTime startDate = LocalDate.of(2019, 5, 1).atStartOfDay();
|
| 24632 |
amit.gupta |
1353 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
| 24631 |
amit.gupta |
1354 |
List<FofoOrder> allOrders = fofoOrderRepository.selectBetweenSaleDate(startDate, endDate);
|
|
|
1355 |
// Collections.reverse(allOrders);
|
|
|
1356 |
// List<FofoOrder> allOrders =
|
| 24653 |
govind |
1357 |
// List<FofoOrder> allOrders =
|
| 24631 |
amit.gupta |
1358 |
// Arrays.asList(fofoOrderRepository.selectByInvoiceNumber("UPGZ019/25"));
|
| 24625 |
amit.gupta |
1359 |
Set<String> serialNumbersConsidered = new HashSet<>();
|
| 24590 |
amit.gupta |
1360 |
allOrders.stream().forEach(fofoOrder -> {
|
| 24592 |
amit.gupta |
1361 |
String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
|
| 24598 |
amit.gupta |
1362 |
Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
|
| 24592 |
amit.gupta |
1363 |
float amountToRollback = 0;
|
| 24590 |
amit.gupta |
1364 |
List<FofoOrderItem> orderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
|
|
1365 |
orderItems.forEach(x -> {
|
| 24606 |
amit.gupta |
1366 |
inventorySerialNumberMap.putAll(x.getFofoLineItems().stream().filter(li -> li.getSerialNumber() != null)
|
| 24598 |
amit.gupta |
1367 |
.collect(Collectors.toMap(FofoLineItem::getInventoryItemId, FofoLineItem::getSerialNumber)));
|
| 24590 |
amit.gupta |
1368 |
});
|
| 24606 |
amit.gupta |
1369 |
if (inventorySerialNumberMap.size() > 0) {
|
| 24631 |
amit.gupta |
1370 |
for (Map.Entry<Integer, String> inventorySerialNumberEntry : inventorySerialNumberMap.entrySet()) {
|
|
|
1371 |
String serialNumber = inventorySerialNumberEntry.getValue();
|
|
|
1372 |
int inventoryItemId = inventorySerialNumberEntry.getKey();
|
|
|
1373 |
if (serialNumbersConsidered.contains(serialNumber)) {
|
|
|
1374 |
// This will rollback scheme for differenct orders for same serial
|
|
|
1375 |
List<SchemeInOut> sios = schemeInOutRepository
|
| 24633 |
amit.gupta |
1376 |
.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
|
| 24635 |
amit.gupta |
1377 |
.filter(x -> x.getRolledBackTimestamp() == null
|
|
|
1378 |
&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT))
|
| 24631 |
amit.gupta |
1379 |
.collect(Collectors.toList());
|
|
|
1380 |
Collections.reverse(sios);
|
|
|
1381 |
for (SchemeInOut sio : sios) {
|
|
|
1382 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
|
|
1383 |
amountToRollback += sio.getAmount();
|
|
|
1384 |
// sio.setSchemeType(SchemeType.OUT);
|
|
|
1385 |
sio.setSerialNumber(serialNumber);
|
|
|
1386 |
sio.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
| 24681 |
amit.gupta |
1387 |
sio.setReference(fofoOrder.getId());
|
| 24631 |
amit.gupta |
1388 |
rolledbackSios.add(sio);
|
| 24623 |
amit.gupta |
1389 |
}
|
| 24635 |
amit.gupta |
1390 |
description = description.concat(" " + serialNumber + " ");
|
| 24631 |
amit.gupta |
1391 |
} else {
|
|
|
1392 |
serialNumbersConsidered.add(serialNumber);
|
|
|
1393 |
List<Integer> schemesConsidered = new ArrayList<>();
|
|
|
1394 |
List<SchemeInOut> sios = schemeInOutRepository
|
| 24633 |
amit.gupta |
1395 |
.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
|
| 24635 |
amit.gupta |
1396 |
.filter(x -> x.getRolledBackTimestamp() == null
|
|
|
1397 |
&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT))
|
| 24631 |
amit.gupta |
1398 |
.collect(Collectors.toList());
|
|
|
1399 |
Collections.reverse(sios);
|
|
|
1400 |
for (SchemeInOut sio : sios) {
|
|
|
1401 |
if (!schemesConsidered.contains(sio.getSchemeId())) {
|
|
|
1402 |
schemesConsidered.add(sio.getSchemeId());
|
|
|
1403 |
continue;
|
|
|
1404 |
}
|
|
|
1405 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
|
|
1406 |
amountToRollback += sio.getAmount();
|
|
|
1407 |
// sio.setSchemeType(SchemeType.OUT);
|
| 24681 |
amit.gupta |
1408 |
sio.setReference(fofoOrder.getId());
|
| 24631 |
amit.gupta |
1409 |
sio.setSerialNumber(serialNumber);
|
|
|
1410 |
sio.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
|
|
1411 |
rolledbackSios.add(sio);
|
|
|
1412 |
}
|
| 24615 |
amit.gupta |
1413 |
}
|
| 24631 |
amit.gupta |
1414 |
|
| 24604 |
amit.gupta |
1415 |
}
|
| 24590 |
amit.gupta |
1416 |
}
|
| 24631 |
amit.gupta |
1417 |
if (amountToRollback > 0) {
|
|
|
1418 |
UserWalletHistory uwh = new UserWalletHistory();
|
|
|
1419 |
uwh.setAmount(Math.round(amountToRollback));
|
|
|
1420 |
uwh.setDescription(description);
|
|
|
1421 |
uwh.setTimestamp(LocalDateTime.now());
|
|
|
1422 |
uwh.setReferenceType(WalletReferenceType.SCHEME_OUT);
|
|
|
1423 |
uwh.setReference(fofoOrder.getId());
|
|
|
1424 |
uwh.setWalletId(userWalletMap.get(fofoOrder.getFofoId()));
|
|
|
1425 |
uwh.setFofoId(fofoOrder.getFofoId());
|
|
|
1426 |
uwh.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
|
|
1427 |
userWalletHistory.add(uwh);
|
|
|
1428 |
}
|
| 24590 |
amit.gupta |
1429 |
});
|
| 24598 |
amit.gupta |
1430 |
|
| 24592 |
amit.gupta |
1431 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| 24681 |
amit.gupta |
1432 |
Arrays.asList("Wallet Id", "Store Code", "Reference Type", "Reference", "Amount", "Description",
|
| 24615 |
amit.gupta |
1433 |
"Timestamp"),
|
|
|
1434 |
userWalletHistory.stream()
|
|
|
1435 |
.map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(),
|
|
|
1436 |
x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
|
| 24592 |
amit.gupta |
1437 |
.collect(Collectors.toList()));
|
|
|
1438 |
|
|
|
1439 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
|
|
1440 |
Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created",
|
|
|
1441 |
"Rolledback"),
|
|
|
1442 |
rolledbackSios.stream()
|
|
|
1443 |
.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
|
|
|
1444 |
x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
|
|
|
1445 |
.collect(Collectors.toList()));
|
|
|
1446 |
|
| 25043 |
amit.gupta |
1447 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { "amit.gupta@shop2020.in" }, null,
|
| 24681 |
amit.gupta |
1448 |
"Partner Excess Amount Scheme Out", "PFA",
|
| 24598 |
amit.gupta |
1449 |
new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
|
|
|
1450 |
new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
|
| 24631 |
amit.gupta |
1451 |
|
| 25267 |
amit.gupta |
1452 |
throw new Exception();
|
| 24590 |
amit.gupta |
1453 |
}
|
| 24615 |
amit.gupta |
1454 |
|
| 24611 |
amit.gupta |
1455 |
public void dryRunSchemeOutReco1() throws Exception {
|
| 24615 |
amit.gupta |
1456 |
List<Integer> references = Arrays.asList(6744, 7347, 8320, 8891, 9124, 9217, 9263, 9379);
|
| 24611 |
amit.gupta |
1457 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
|
|
1458 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
|
|
1459 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream()
|
|
|
1460 |
.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
|
|
1461 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream()
|
|
|
1462 |
.collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
|
|
1463 |
references.stream().forEach(reference -> {
|
|
|
1464 |
FofoOrder fofoOrder = null;
|
|
|
1465 |
try {
|
|
|
1466 |
fofoOrder = fofoOrderRepository.selectByOrderId(reference);
|
| 24615 |
amit.gupta |
1467 |
} catch (Exception e) {
|
|
|
1468 |
|
| 24611 |
amit.gupta |
1469 |
}
|
|
|
1470 |
String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
|
|
|
1471 |
Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
|
|
|
1472 |
float amountToRollback = 0;
|
|
|
1473 |
List<FofoOrderItem> orderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
|
|
1474 |
orderItems.forEach(x -> {
|
|
|
1475 |
inventorySerialNumberMap.putAll(x.getFofoLineItems().stream().filter(li -> li.getSerialNumber() != null)
|
|
|
1476 |
.collect(Collectors.toMap(FofoLineItem::getInventoryItemId, FofoLineItem::getSerialNumber)));
|
|
|
1477 |
});
|
|
|
1478 |
if (inventorySerialNumberMap.size() > 0) {
|
| 24615 |
amit.gupta |
1479 |
List<SchemeInOut> sios = schemeInOutRepository
|
|
|
1480 |
.selectByInventoryItemIds(inventorySerialNumberMap.keySet()).stream()
|
|
|
1481 |
.filter(x -> schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT))
|
| 24611 |
amit.gupta |
1482 |
.collect(Collectors.toList());
|
|
|
1483 |
LOGGER.info("Found {} duplicate schemeouts for Orderid {}", sios.size(), fofoOrder.getId());
|
|
|
1484 |
UserWalletHistory uwh = new UserWalletHistory();
|
| 24615 |
amit.gupta |
1485 |
Map<Integer, List<SchemeInOut>> inventoryIdSouts = sios.stream()
|
|
|
1486 |
.collect(Collectors.groupingBy(SchemeInOut::getInventoryItemId, Collectors.toList()));
|
| 24611 |
amit.gupta |
1487 |
for (Map.Entry<Integer, List<SchemeInOut>> inventorySioEntry : inventoryIdSouts.entrySet()) {
|
|
|
1488 |
List<SchemeInOut> outList = inventorySioEntry.getValue();
|
| 24615 |
amit.gupta |
1489 |
if (outList.size() > 1) {
|
|
|
1490 |
|
| 24611 |
amit.gupta |
1491 |
}
|
|
|
1492 |
}
|
|
|
1493 |
uwh.setAmount(Math.round(amountToRollback));
|
|
|
1494 |
uwh.setDescription(description);
|
|
|
1495 |
uwh.setTimestamp(LocalDateTime.now());
|
|
|
1496 |
uwh.setReferenceType(WalletReferenceType.SCHEME_OUT);
|
|
|
1497 |
uwh.setReference(fofoOrder.getId());
|
|
|
1498 |
uwh.setWalletId(userWalletMap.get(fofoOrder.getFofoId()));
|
|
|
1499 |
uwh.setFofoId(fofoOrder.getFofoId());
|
|
|
1500 |
uwh.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
|
|
1501 |
userWalletHistory.add(uwh);
|
|
|
1502 |
}
|
|
|
1503 |
});
|
| 24615 |
amit.gupta |
1504 |
|
| 24611 |
amit.gupta |
1505 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
|
|
1506 |
Arrays.asList("User Id", "Reference Type", "Reference", "Amount", "Description", "Timestamp"),
|
|
|
1507 |
userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getReferenceType(),
|
|
|
1508 |
x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
|
| 24615 |
amit.gupta |
1509 |
.collect(Collectors.toList()));
|
|
|
1510 |
|
| 24611 |
amit.gupta |
1511 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
|
|
1512 |
Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created",
|
|
|
1513 |
"Rolledback"),
|
|
|
1514 |
rolledbackSios.stream()
|
| 24615 |
amit.gupta |
1515 |
.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
|
|
|
1516 |
x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
|
|
|
1517 |
.collect(Collectors.toList()));
|
|
|
1518 |
|
| 24623 |
amit.gupta |
1519 |
Utils.sendMailWithAttachments(googleMailSender,
|
|
|
1520 |
new String[] { "amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com" }, null,
|
| 24611 |
amit.gupta |
1521 |
"Partner Excess Amount", "PFA",
|
|
|
1522 |
new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
|
|
|
1523 |
new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
|
| 24631 |
amit.gupta |
1524 |
|
| 24628 |
amit.gupta |
1525 |
throw new Exception();
|
| 24615 |
amit.gupta |
1526 |
|
| 24611 |
amit.gupta |
1527 |
}
|
| 24615 |
amit.gupta |
1528 |
|
| 26945 |
amit.gupta |
1529 |
public void sendDailySalesNotificationToPartner(Integer fofoIdInt) throws Exception {
|
| 25927 |
amit.gupta |
1530 |
|
| 24653 |
govind |
1531 |
LocalDateTime now = LocalDateTime.now();
|
| 25837 |
amit.gupta |
1532 |
LocalDateTime from = now.with(LocalTime.MIN);
|
| 25925 |
amit.gupta |
1533 |
String timeString = "Today %s";
|
| 25927 |
amit.gupta |
1534 |
// Send yesterday's report
|
| 27007 |
amit.gupta |
1535 |
/*
|
|
|
1536 |
* if (now.getHour() < 13) { timeString = "Yesterday %s"; from =
|
|
|
1537 |
* now.minusDays(1).; now = from.with(LocalTime.MAX);
|
|
|
1538 |
*
|
|
|
1539 |
* }
|
|
|
1540 |
*/
|
| 24855 |
amit.gupta |
1541 |
List<Integer> fofoIds = null;
|
| 25043 |
amit.gupta |
1542 |
if (fofoIdInt == null) {
|
|
|
1543 |
fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
|
|
|
1544 |
.collect(Collectors.toList());
|
| 24856 |
amit.gupta |
1545 |
} else {
|
| 24855 |
amit.gupta |
1546 |
fofoIds = Arrays.asList(fofoIdInt);
|
|
|
1547 |
}
|
| 25912 |
amit.gupta |
1548 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
|
| 24683 |
amit.gupta |
1549 |
|
| 25865 |
amit.gupta |
1550 |
Map<Integer, Float> partnerPolicyAmountMap = insurancePolicyRepository.selectAmountSumGroupByRetailerId(now,
|
|
|
1551 |
null);
|
|
|
1552 |
Map<Integer, Long> partnerPolicyQtyMap = insurancePolicyRepository.selectQtyGroupByRetailerId(now, null);
|
| 26945 |
amit.gupta |
1553 |
|
|
|
1554 |
Map<Integer, Double> spPartnerOrderValMap = fofoOrderItemRepository.selectSumAmountGroupByRetailer(from, now, 0,
|
|
|
1555 |
true);
|
|
|
1556 |
|
|
|
1557 |
Map<Integer, Double> spPartner3DaysOrderValMap = fofoOrderItemRepository
|
|
|
1558 |
.selectSumAmountGroupByRetailer(from.minusDays(3), now, 0, true);
|
| 26941 |
amit.gupta |
1559 |
Map<Integer, Long> spPartnerOrderQtyMap = fofoOrderItemRepository.selectQtyGroupByRetailer(from, now, 0, true);
|
|
|
1560 |
|
| 26945 |
amit.gupta |
1561 |
Map<Integer, Double> partnerOrderValMap = fofoOrderItemRepository.selectSumAmountGroupByRetailer(from, now, 0,
|
|
|
1562 |
false);
|
| 26941 |
amit.gupta |
1563 |
Map<Integer, Long> partnerOrderQtyMap = fofoOrderItemRepository.selectQtyGroupByRetailer(from, now, 0, false);
|
| 26945 |
amit.gupta |
1564 |
|
| 25865 |
amit.gupta |
1565 |
Map<Integer, SaleTargetReportModel> saleTargetReportModelMap = new HashMap<>();
|
|
|
1566 |
for (int fofoId : fofoIds) {
|
|
|
1567 |
SaleTargetReportModel model = new SaleTargetReportModel();
|
| 25927 |
amit.gupta |
1568 |
model.setInsuranceSale(
|
|
|
1569 |
partnerPolicyAmountMap.containsKey(fofoId) ? partnerPolicyAmountMap.get(fofoId).doubleValue() : 0);
|
| 25865 |
amit.gupta |
1570 |
model.setInsruanceQty(partnerPolicyQtyMap.containsKey(fofoId) ? partnerPolicyQtyMap.get(fofoId) : 0);
|
| 26941 |
amit.gupta |
1571 |
model.setSmartphoneSale(spPartnerOrderValMap.containsKey(fofoId) ? spPartnerOrderValMap.get(fofoId) : 0);
|
|
|
1572 |
model.setSmartphoneQty(spPartnerOrderQtyMap.containsKey(fofoId) ? spPartnerOrderQtyMap.get(fofoId) : 0);
|
|
|
1573 |
model.setTotalSale(partnerOrderValMap.containsKey(fofoId) ? partnerOrderValMap.get(fofoId) : 0);
|
|
|
1574 |
model.setTotalQty(partnerOrderQtyMap.containsKey(fofoId) ? partnerOrderQtyMap.get(fofoId) : 0);
|
| 26945 |
amit.gupta |
1575 |
model.setPast3daysSale(
|
|
|
1576 |
spPartner3DaysOrderValMap.containsKey(fofoId) ? spPartner3DaysOrderValMap.get(fofoId) : 0);
|
| 25880 |
amit.gupta |
1577 |
model.setFofoId(fofoId);
|
| 25865 |
amit.gupta |
1578 |
saleTargetReportModelMap.put(fofoId, model);
|
|
|
1579 |
}
|
| 25880 |
amit.gupta |
1580 |
|
| 26945 |
amit.gupta |
1581 |
Map<Integer, FofoReportingModel> partnerSalesHeadersMap = this.getPartnerIdSalesHeaders();
|
| 24653 |
govind |
1582 |
for (Integer fofoId : fofoIds) {
|
| 25865 |
amit.gupta |
1583 |
SaleTargetReportModel model = saleTargetReportModelMap.get(fofoId);
|
| 25821 |
amit.gupta |
1584 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
1585 |
sendNotificationModel.setCampaignName("Sales update alert");
|
| 25884 |
tejbeer |
1586 |
sendNotificationModel.setTitle("Sale Update");
|
| 25927 |
amit.gupta |
1587 |
sendNotificationModel
|
|
|
1588 |
.setMessage(String.format("Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.",
|
|
|
1589 |
model.getSmartphoneSale(), model.getInsuranceSale(), model.getTotalSale(),
|
|
|
1590 |
String.format(timeString, now.format(timeFormatter))));
|
| 25821 |
amit.gupta |
1591 |
sendNotificationModel.setType("url");
|
| 27206 |
tejbeer |
1592 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 25821 |
amit.gupta |
1593 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
|
|
1594 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 25872 |
tejbeer |
1595 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
|
|
1596 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 25854 |
amit.gupta |
1597 |
notificationService.sendNotification(sendNotificationModel);
|
| 24653 |
govind |
1598 |
}
|
| 26945 |
amit.gupta |
1599 |
// String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap,
|
|
|
1600 |
// saleTargetReportModelMap);
|
|
|
1601 |
String statewiseSaleReport = this.getStateWiseSales(saleTargetReportModelMap, partnerSalesHeadersMap);
|
| 27116 |
amit.gupta |
1602 |
String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "amit.babu@smartdukaan.com",
|
| 26945 |
amit.gupta |
1603 |
"niranjan.kala@smartdukaan.com", "up.singh@smartdukaan.com", "sm@smartdukaan.com" };
|
| 25837 |
amit.gupta |
1604 |
|
| 25912 |
amit.gupta |
1605 |
String subject = String.format("Sale till %s", String.format(timeString, now.format(timeFormatter)));
|
| 26945 |
amit.gupta |
1606 |
// this.sendMailOfHtmlFomat("amit.gupta@smartukaan.com", saleReport, cc,
|
|
|
1607 |
// subject);
|
|
|
1608 |
this.sendMailOfHtmlFormat("amit.gupta@smartdukaan.com", statewiseSaleReport, cc, "Statewise" + subject);
|
| 24653 |
govind |
1609 |
}
|
|
|
1610 |
|
| 28377 |
tejbeer |
1611 |
public void checkRazorPayPaymentStatus() throws Exception {
|
| 28368 |
tejbeer |
1612 |
List<PendingOrder> pendingOrder = pendingOrderRepository
|
|
|
1613 |
.selectAllByStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.PENDING);
|
|
|
1614 |
|
|
|
1615 |
for (PendingOrder po : pendingOrder) {
|
|
|
1616 |
RazorPay razorPay = razorPayRepository.selectByOrdeId(po.getId());
|
| 28377 |
tejbeer |
1617 |
List<PendingOrderItem> poItems = pendingOrderItemRepository.selectByOrderId(po.getId());
|
| 28368 |
tejbeer |
1618 |
|
| 28369 |
tejbeer |
1619 |
LOGGER.info("razorPay" + razorPay);
|
|
|
1620 |
if (razorPay != null) {
|
|
|
1621 |
List<Payment> payments = razorPaymentService.fetchOrderForPayment(razorPay.getRazorOrderId());
|
| 28377 |
tejbeer |
1622 |
|
| 28369 |
tejbeer |
1623 |
if (!payments.isEmpty()) {
|
| 28377 |
tejbeer |
1624 |
List<String> statusList = new ArrayList<>();
|
| 28369 |
tejbeer |
1625 |
for (Payment payment : payments) {
|
| 28368 |
tejbeer |
1626 |
|
| 28377 |
tejbeer |
1627 |
JSONObject jsonObj = new JSONObject(payment.toString());
|
|
|
1628 |
|
|
|
1629 |
String status = jsonObj.getString("status");
|
|
|
1630 |
|
|
|
1631 |
statusList.add(status);
|
|
|
1632 |
|
| 28369 |
tejbeer |
1633 |
}
|
| 28377 |
tejbeer |
1634 |
LOGGER.info("statusList" + statusList);
|
| 28368 |
tejbeer |
1635 |
|
| 28377 |
tejbeer |
1636 |
if (statusList.contains("authorized") || statusList.contains("captured")) {
|
|
|
1637 |
po.setStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.PROCESSING);
|
|
|
1638 |
po.setPaidAmount(po.getTotalAmount());
|
|
|
1639 |
for (PendingOrderItem poi : poItems) {
|
|
|
1640 |
poi.setStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.PROCESSING);
|
|
|
1641 |
}
|
|
|
1642 |
Map<String, Object> emailModel = pendingOrderService.sendCreateOrderMail(po);
|
|
|
1643 |
|
|
|
1644 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(po.getFofoId());
|
|
|
1645 |
Customer customer = customerRepository.selectById(po.getCustomerId());
|
|
|
1646 |
String[] customerEmail = null;
|
|
|
1647 |
if (customer.getEmailId() != null) {
|
|
|
1648 |
customerEmail = new String[] { customer.getEmailId() };
|
|
|
1649 |
}
|
|
|
1650 |
List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com",
|
| 28467 |
tejbeer |
1651 |
"tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "sm@smartdukaan.com",
|
|
|
1652 |
"tejbeer.kaur@shop2020.in", customRetailer.getEmail());
|
| 28377 |
tejbeer |
1653 |
List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
|
|
|
1654 |
if (authUserEmails != null) {
|
|
|
1655 |
authUserEmails = new ArrayList<>();
|
|
|
1656 |
}
|
|
|
1657 |
authUserEmails.addAll(bccTo);
|
|
|
1658 |
|
| 28382 |
tejbeer |
1659 |
// emailService.sendMailWithAttachments("Order Created with SmartDukaan",
|
|
|
1660 |
// "order-confirm.vm",
|
|
|
1661 |
// emailModel, customerEmail, null, authUserEmails.toArray(new String[0]));
|
| 28377 |
tejbeer |
1662 |
|
|
|
1663 |
} else if (statusList.contains("refunded") || statusList.contains("failed")) {
|
|
|
1664 |
for (PendingOrderItem poi : poItems) {
|
|
|
1665 |
poi.setStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.FAILED);
|
|
|
1666 |
}
|
|
|
1667 |
|
|
|
1668 |
po.setStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.FAILED);
|
|
|
1669 |
}
|
|
|
1670 |
|
| 28369 |
tejbeer |
1671 |
}
|
| 28377 |
tejbeer |
1672 |
// LOGGER.info("payment" + payments);
|
| 28369 |
tejbeer |
1673 |
|
|
|
1674 |
}
|
| 28368 |
tejbeer |
1675 |
}
|
|
|
1676 |
}
|
|
|
1677 |
|
| 25865 |
amit.gupta |
1678 |
public static class SaleTargetReportModel {
|
|
|
1679 |
private double totalSale;
|
| 26941 |
amit.gupta |
1680 |
private long totalQty;
|
| 26945 |
amit.gupta |
1681 |
private double past3daysSale;
|
| 25880 |
amit.gupta |
1682 |
private int fofoId;
|
|
|
1683 |
|
|
|
1684 |
public int getFofoId() {
|
|
|
1685 |
return fofoId;
|
|
|
1686 |
}
|
|
|
1687 |
|
|
|
1688 |
public void setFofoId(int fofoId) {
|
|
|
1689 |
this.fofoId = fofoId;
|
|
|
1690 |
}
|
|
|
1691 |
|
| 25865 |
amit.gupta |
1692 |
private double smartphoneSale;
|
|
|
1693 |
private long smartphoneQty;
|
|
|
1694 |
private double insuranceSale;
|
|
|
1695 |
private long insruanceQty;
|
|
|
1696 |
|
| 26941 |
amit.gupta |
1697 |
public long getTotalQty() {
|
|
|
1698 |
return totalQty;
|
|
|
1699 |
}
|
|
|
1700 |
|
|
|
1701 |
public void setTotalQty(long totalQty) {
|
|
|
1702 |
this.totalQty = totalQty;
|
|
|
1703 |
}
|
|
|
1704 |
|
| 26945 |
amit.gupta |
1705 |
public double getPast3daysSale() {
|
|
|
1706 |
return past3daysSale;
|
|
|
1707 |
}
|
|
|
1708 |
|
|
|
1709 |
public void setPast3daysSale(double past3daysSale) {
|
|
|
1710 |
this.past3daysSale = past3daysSale;
|
|
|
1711 |
}
|
|
|
1712 |
|
| 25865 |
amit.gupta |
1713 |
@Override
|
|
|
1714 |
public int hashCode() {
|
|
|
1715 |
final int prime = 31;
|
|
|
1716 |
int result = 1;
|
| 25880 |
amit.gupta |
1717 |
result = prime * result + fofoId;
|
| 25865 |
amit.gupta |
1718 |
result = prime * result + (int) (insruanceQty ^ (insruanceQty >>> 32));
|
|
|
1719 |
long temp;
|
|
|
1720 |
temp = Double.doubleToLongBits(insuranceSale);
|
|
|
1721 |
result = prime * result + (int) (temp ^ (temp >>> 32));
|
|
|
1722 |
result = prime * result + (int) (smartphoneQty ^ (smartphoneQty >>> 32));
|
|
|
1723 |
temp = Double.doubleToLongBits(smartphoneSale);
|
|
|
1724 |
result = prime * result + (int) (temp ^ (temp >>> 32));
|
| 26941 |
amit.gupta |
1725 |
result = prime * result + (int) (totalQty ^ (totalQty >>> 32));
|
| 25865 |
amit.gupta |
1726 |
temp = Double.doubleToLongBits(totalSale);
|
|
|
1727 |
result = prime * result + (int) (temp ^ (temp >>> 32));
|
|
|
1728 |
return result;
|
|
|
1729 |
}
|
|
|
1730 |
|
|
|
1731 |
@Override
|
|
|
1732 |
public boolean equals(Object obj) {
|
|
|
1733 |
if (this == obj)
|
|
|
1734 |
return true;
|
|
|
1735 |
if (obj == null)
|
|
|
1736 |
return false;
|
|
|
1737 |
if (getClass() != obj.getClass())
|
|
|
1738 |
return false;
|
|
|
1739 |
SaleTargetReportModel other = (SaleTargetReportModel) obj;
|
| 25880 |
amit.gupta |
1740 |
if (fofoId != other.fofoId)
|
|
|
1741 |
return false;
|
| 25865 |
amit.gupta |
1742 |
if (insruanceQty != other.insruanceQty)
|
|
|
1743 |
return false;
|
|
|
1744 |
if (Double.doubleToLongBits(insuranceSale) != Double.doubleToLongBits(other.insuranceSale))
|
|
|
1745 |
return false;
|
|
|
1746 |
if (smartphoneQty != other.smartphoneQty)
|
|
|
1747 |
return false;
|
|
|
1748 |
if (Double.doubleToLongBits(smartphoneSale) != Double.doubleToLongBits(other.smartphoneSale))
|
|
|
1749 |
return false;
|
| 26941 |
amit.gupta |
1750 |
if (totalQty != other.totalQty)
|
|
|
1751 |
return false;
|
| 25865 |
amit.gupta |
1752 |
if (Double.doubleToLongBits(totalSale) != Double.doubleToLongBits(other.totalSale))
|
|
|
1753 |
return false;
|
|
|
1754 |
return true;
|
|
|
1755 |
}
|
|
|
1756 |
|
|
|
1757 |
public double getTotalSale() {
|
|
|
1758 |
return totalSale;
|
|
|
1759 |
}
|
|
|
1760 |
|
|
|
1761 |
public void setTotalSale(double totalSale) {
|
|
|
1762 |
this.totalSale = totalSale;
|
|
|
1763 |
}
|
|
|
1764 |
|
|
|
1765 |
public double getSmartphoneSale() {
|
|
|
1766 |
return smartphoneSale;
|
|
|
1767 |
}
|
|
|
1768 |
|
|
|
1769 |
public void setSmartphoneSale(double smartphoneSale) {
|
|
|
1770 |
this.smartphoneSale = smartphoneSale;
|
|
|
1771 |
}
|
|
|
1772 |
|
|
|
1773 |
public long getSmartphoneQty() {
|
|
|
1774 |
return smartphoneQty;
|
|
|
1775 |
}
|
|
|
1776 |
|
|
|
1777 |
public void setSmartphoneQty(long smartphoneQty) {
|
|
|
1778 |
this.smartphoneQty = smartphoneQty;
|
|
|
1779 |
}
|
|
|
1780 |
|
|
|
1781 |
public double getInsuranceSale() {
|
|
|
1782 |
return insuranceSale;
|
|
|
1783 |
}
|
|
|
1784 |
|
|
|
1785 |
public void setInsuranceSale(double insuranceSale) {
|
|
|
1786 |
this.insuranceSale = insuranceSale;
|
|
|
1787 |
}
|
|
|
1788 |
|
|
|
1789 |
public long getInsruanceQty() {
|
|
|
1790 |
return insruanceQty;
|
|
|
1791 |
}
|
|
|
1792 |
|
|
|
1793 |
public void setInsruanceQty(long insruanceQty) {
|
|
|
1794 |
this.insruanceQty = insruanceQty;
|
|
|
1795 |
}
|
|
|
1796 |
|
|
|
1797 |
@Override
|
|
|
1798 |
public String toString() {
|
| 26945 |
amit.gupta |
1799 |
return "SaleTargetReportModel [totalSale=" + totalSale + ", totalQty=" + totalQty + ", past3daysSale="
|
|
|
1800 |
+ past3daysSale + ", fofoId=" + fofoId + ", smartphoneSale=" + smartphoneSale + ", smartphoneQty="
|
|
|
1801 |
+ smartphoneQty + ", insuranceSale=" + insuranceSale + ", insruanceQty=" + insruanceQty + "]";
|
| 25865 |
amit.gupta |
1802 |
}
|
|
|
1803 |
|
|
|
1804 |
}
|
|
|
1805 |
|
| 26945 |
amit.gupta |
1806 |
private String getStateWiseSales(Map<Integer, SaleTargetReportModel> saleTargetReportModelMap,
|
|
|
1807 |
Map<Integer, FofoReportingModel> partnerSalesHeadersMap) throws Exception {
|
| 26940 |
amit.gupta |
1808 |
List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
|
| 26945 |
amit.gupta |
1809 |
Map<String, List<Integer>> stateMap = stores.stream().collect(Collectors
|
|
|
1810 |
.groupingBy(x -> x.getCode().substring(0, 2), Collectors.mapping(x -> x.getId(), Collectors.toList())));
|
| 26940 |
amit.gupta |
1811 |
List<List<Serializable>> stateWiseSales = new ArrayList<>();
|
|
|
1812 |
for (Map.Entry<String, List<Integer>> stateMapEntry : stateMap.entrySet()) {
|
| 26945 |
amit.gupta |
1813 |
long totalQty = stateMapEntry.getValue().stream()
|
|
|
1814 |
.collect(Collectors.summingLong(x -> saleTargetReportModelMap.get(x).getTotalQty()));
|
|
|
1815 |
double totalSale = stateMapEntry.getValue().stream()
|
|
|
1816 |
.collect(Collectors.summingDouble(x -> saleTargetReportModelMap.get(x).getTotalSale()));
|
|
|
1817 |
long smartPhoneQty = stateMapEntry.getValue().stream()
|
|
|
1818 |
.collect(Collectors.summingLong(x -> saleTargetReportModelMap.get(x).getSmartphoneQty()));
|
|
|
1819 |
double smartPhoneSale = stateMapEntry.getValue().stream()
|
|
|
1820 |
.collect(Collectors.summingDouble(x -> saleTargetReportModelMap.get(x).getSmartphoneSale()));
|
|
|
1821 |
stateWiseSales
|
|
|
1822 |
.add(Arrays.asList(stateMapEntry.getKey(), smartPhoneQty, smartPhoneSale, totalQty, totalSale));
|
| 26940 |
amit.gupta |
1823 |
}
|
|
|
1824 |
StringBuilder sb = new StringBuilder();
|
| 26945 |
amit.gupta |
1825 |
sb.append("<html><body>");
|
|
|
1826 |
sb.append("<p>Statewise Sale Report:</p><br/><table style='border:1px solid black';cellspacing=0>");
|
| 26940 |
amit.gupta |
1827 |
sb.append("<tbody>\n" + " <tr>"
|
|
|
1828 |
+ " <th style='border:1px solid black;padding: 5px'>State</th>"
|
| 26941 |
amit.gupta |
1829 |
+ " <th style='border:1px solid black;padding: 5px'>SmartPhone Qty</th>"
|
|
|
1830 |
+ " <th style='border:1px solid black;padding: 5px'>SmartPhone Value</th>"
|
|
|
1831 |
+ " <th style='border:1px solid black;padding: 5px'>Total Qty</th>"
|
|
|
1832 |
+ " <th style='border:1px solid black;padding: 5px'>Total Value</th>"
|
| 26940 |
amit.gupta |
1833 |
+ " </tr>");
|
|
|
1834 |
for (List<Serializable> stateSale : stateWiseSales) {
|
|
|
1835 |
sb.append("<tr>");
|
|
|
1836 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(0) + "</td>");
|
|
|
1837 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(1) + "</td>");
|
|
|
1838 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(2) + "</td>");
|
| 26941 |
amit.gupta |
1839 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(3) + "</td>");
|
|
|
1840 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(4) + "</td>");
|
| 26940 |
amit.gupta |
1841 |
sb.append("</tr>");
|
|
|
1842 |
}
|
| 26945 |
amit.gupta |
1843 |
sb.append("</tbody></table><br><br>");
|
| 25872 |
tejbeer |
1844 |
|
| 26945 |
amit.gupta |
1845 |
sb.append("<p>Sale Report:</p><br/><table style='border:1px solid black';cellspacing=0>");
|
| 24653 |
govind |
1846 |
sb.append("<tbody>\n" + " <tr>\n"
|
| 26945 |
amit.gupta |
1847 |
+ " <th style='border:1px solid black;padding: 5px'>Code</th>"
|
|
|
1848 |
+ " <th style='border:1px solid black;padding: 5px'>Business Name</th>"
|
|
|
1849 |
+ " <th style='border:1px solid black;padding: 5px'>Regional Manager</th>"
|
|
|
1850 |
+ " <th style='border:1px solid black;padding: 5px'>Territory Manager</th>"
|
|
|
1851 |
+ " <th style='border:1px solid black;padding: 5px'>Sale</th>"
|
|
|
1852 |
+ " <th style='border:1px solid black;padding: 5px'>Smartphone Sale</th>"
|
|
|
1853 |
+ " <th style='border:1px solid black;padding: 5px'>SmartPhone Qty</th>"
|
| 24653 |
govind |
1854 |
+ " </tr>");
|
| 26945 |
amit.gupta |
1855 |
|
|
|
1856 |
List<Integer> sortedPartnerSalesHeaders = partnerSalesHeadersMap.values().stream()
|
| 26947 |
amit.gupta |
1857 |
.sorted(Comparator.comparing(FofoReportingModel::getCode)
|
|
|
1858 |
.thenComparing(FofoReportingModel::getRegionalManager)
|
| 26948 |
amit.gupta |
1859 |
.thenComparing(FofoReportingModel::getTerritoryManager))
|
| 26945 |
amit.gupta |
1860 |
.map(FofoReportingModel::getFofoId).collect(Collectors.toList());
|
| 25927 |
amit.gupta |
1861 |
for (Integer fofoId : sortedPartnerSalesHeaders) {
|
| 27007 |
amit.gupta |
1862 |
if (saleTargetReportModelMap.get(fofoId).getPast3daysSale() == 0) {
|
| 26947 |
amit.gupta |
1863 |
sb.append("<tr style='background-color:red'>");
|
|
|
1864 |
} else {
|
| 26945 |
amit.gupta |
1865 |
sb.append("<tr>");
|
|
|
1866 |
}
|
|
|
1867 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + partnerSalesHeadersMap.get(fofoId).getCode()
|
| 25880 |
amit.gupta |
1868 |
+ "</td>");
|
|
|
1869 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| 27007 |
amit.gupta |
1870 |
+ partnerSalesHeadersMap.get(fofoId).getBusinessName() + "</td>");
|
|
|
1871 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
|
|
1872 |
+ partnerSalesHeadersMap.get(fofoId).getRegionalManager() + "</td>");
|
|
|
1873 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
|
|
1874 |
+ partnerSalesHeadersMap.get(fofoId).getTerritoryManager() + "</td>");
|
|
|
1875 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| 26945 |
amit.gupta |
1876 |
+ saleTargetReportModelMap.get(fofoId).getTotalSale() + "</td>");
|
| 25880 |
amit.gupta |
1877 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| 26945 |
amit.gupta |
1878 |
+ saleTargetReportModelMap.get(fofoId).getSmartphoneSale() + "</td>");
|
| 25880 |
amit.gupta |
1879 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| 26945 |
amit.gupta |
1880 |
+ saleTargetReportModelMap.get(fofoId).getSmartphoneQty() + "</td>");
|
| 25865 |
amit.gupta |
1881 |
sb.append("</tr>");
|
| 24653 |
govind |
1882 |
}
|
| 24683 |
amit.gupta |
1883 |
|
| 26945 |
amit.gupta |
1884 |
sb.append("</tr>");
|
|
|
1885 |
|
|
|
1886 |
sb.append("</body></html>");
|
|
|
1887 |
|
|
|
1888 |
return sb.toString();
|
| 24653 |
govind |
1889 |
}
|
| 24841 |
govind |
1890 |
|
| 26945 |
amit.gupta |
1891 |
private void sendMailOfHtmlFormat(String email, String body, String cc[], String subject)
|
| 24841 |
govind |
1892 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
|
|
1893 |
MimeMessage message = mailSender.createMimeMessage();
|
|
|
1894 |
MimeMessageHelper helper = new MimeMessageHelper(message);
|
|
|
1895 |
helper.setSubject(subject);
|
|
|
1896 |
helper.setText(body, true);
|
|
|
1897 |
helper.setTo(email);
|
|
|
1898 |
if (cc != null) {
|
|
|
1899 |
helper.setCc(cc);
|
|
|
1900 |
}
|
|
|
1901 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smart Dukaan");
|
|
|
1902 |
helper.setFrom(senderAddress);
|
|
|
1903 |
mailSender.send(message);
|
|
|
1904 |
}
|
| 25300 |
tejbeer |
1905 |
|
| 25351 |
tejbeer |
1906 |
public void sendNotification() throws Exception {
|
| 25300 |
tejbeer |
1907 |
List<PushNotifications> pushNotifications = pushNotificationRepository.selectAllByTimestamp();
|
|
|
1908 |
if (!pushNotifications.isEmpty()) {
|
|
|
1909 |
for (PushNotifications pushNotification : pushNotifications) {
|
| 25351 |
tejbeer |
1910 |
Device device = deviceRepository.selectById(pushNotification.getDeviceId());
|
| 25300 |
tejbeer |
1911 |
NotificationCampaign notificationCampaign = notificationCampaignRepository
|
|
|
1912 |
.selectById(pushNotification.getNotificationCampaignid());
|
|
|
1913 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
|
|
1914 |
SimpleCampaignParams.class);
|
|
|
1915 |
Campaign campaign = new SimpleCampaign(scp);
|
| 25351 |
tejbeer |
1916 |
String result_url = campaign.getUrl() + "&user_id=" + device.getUser_id();
|
| 25300 |
tejbeer |
1917 |
JSONObject json = new JSONObject();
|
| 25351 |
tejbeer |
1918 |
json.put("to", device.getFcmId());
|
| 25300 |
tejbeer |
1919 |
JSONObject jsonObj = new JSONObject();
|
|
|
1920 |
jsonObj.put("message", campaign.getMessage());
|
|
|
1921 |
jsonObj.put("title", campaign.getTitle());
|
|
|
1922 |
jsonObj.put("type", campaign.getType());
|
|
|
1923 |
jsonObj.put("url", result_url);
|
|
|
1924 |
jsonObj.put("time_to_live", campaign.getExpireTimestamp());
|
|
|
1925 |
jsonObj.put("image", campaign.getImageUrl());
|
|
|
1926 |
jsonObj.put("largeIcon", "large_icon");
|
|
|
1927 |
jsonObj.put("smallIcon", "small_icon");
|
|
|
1928 |
jsonObj.put("vibrate", 1);
|
|
|
1929 |
jsonObj.put("pid", pushNotification.getId());
|
|
|
1930 |
jsonObj.put("sound", 1);
|
|
|
1931 |
jsonObj.put("priority", "high");
|
|
|
1932 |
json.put("data", jsonObj);
|
| 25351 |
tejbeer |
1933 |
try {
|
|
|
1934 |
CloseableHttpClient client = HttpClients.createDefault();
|
|
|
1935 |
HttpPost httpPost = new HttpPost(FCM_URL);
|
| 25300 |
tejbeer |
1936 |
|
| 25351 |
tejbeer |
1937 |
httpPost.setHeader("Content-Type", "application/json; utf-8");
|
|
|
1938 |
httpPost.setHeader("authorization", "key=" + FCM_API_KEY);
|
|
|
1939 |
StringEntity entity = new StringEntity(json.toString());
|
|
|
1940 |
httpPost.setEntity(entity);
|
|
|
1941 |
CloseableHttpResponse response = client.execute(httpPost);
|
| 25300 |
tejbeer |
1942 |
|
| 25351 |
tejbeer |
1943 |
if (response.getStatusLine().getStatusCode() == 200) {
|
|
|
1944 |
pushNotification.setSentTimestamp(LocalDateTime.now());
|
|
|
1945 |
} else {
|
| 25356 |
tejbeer |
1946 |
pushNotification.setSentTimestamp(LocalDateTime.of(1970, 1, 1, 00, 00));
|
| 25778 |
amit.gupta |
1947 |
LOGGER.info("message" + "not sent");
|
| 26945 |
amit.gupta |
1948 |
response.toString();
|
| 25351 |
tejbeer |
1949 |
}
|
| 25300 |
tejbeer |
1950 |
|
| 25351 |
tejbeer |
1951 |
} catch (Exception e) {
|
|
|
1952 |
e.printStackTrace();
|
| 26443 |
amit.gupta |
1953 |
pushNotification.setSentTimestamp(LocalDateTime.of(1970, 1, 1, 00, 00));
|
| 26436 |
amit.gupta |
1954 |
LOGGER.info("message " + "not sent " + e.getMessage());
|
| 25300 |
tejbeer |
1955 |
}
|
|
|
1956 |
}
|
|
|
1957 |
}
|
|
|
1958 |
}
|
|
|
1959 |
|
| 25553 |
amit.gupta |
1960 |
public void grouping() throws Exception {
|
| 25609 |
amit.gupta |
1961 |
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM-dd-yyyy hh:mm");
|
|
|
1962 |
List<PriceDropIMEI> priceDropImeis = priceDropIMEIRepository.selectByStatus(PriceDropImeiStatus.APPROVED);
|
|
|
1963 |
System.out.println(String.join("\t",
|
|
|
1964 |
Arrays.asList("IMEI", "ItemId", "Brand", "Model Name", "Model Number", "Franchise Id", "Franchise Name",
|
| 25694 |
amit.gupta |
1965 |
"Grn On", "Price Dropped On", "Approved On", "Returned On", "Price Drop Paid", "Is Doa")));
|
| 26963 |
amit.gupta |
1966 |
Map<Integer, CustomRetailer> retailersMap = retailerService.getFofoRetailers(false);
|
| 25609 |
amit.gupta |
1967 |
for (PriceDropIMEI priceDropIMEI : priceDropImeis) {
|
| 25694 |
amit.gupta |
1968 |
if (priceDropIMEI.getPartnerId() == 0)
|
|
|
1969 |
continue;
|
| 25609 |
amit.gupta |
1970 |
HashSet<String> imeis = new HashSet<>();
|
|
|
1971 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropIMEI.getPriceDropId());
|
|
|
1972 |
imeis.add(priceDropIMEI.getImei());
|
|
|
1973 |
List<InventoryItem> inventoryItems = inventoryItemRepository
|
|
|
1974 |
.selectByFofoIdSerialNumbers(priceDropIMEI.getPartnerId(), imeis, false);
|
| 25694 |
amit.gupta |
1975 |
if (inventoryItems.size() == 0) {
|
|
|
1976 |
LOGGER.info("Need to investigate partnerId - {} imeis - {}", priceDropIMEI.getPartnerId(), imeis);
|
| 25613 |
amit.gupta |
1977 |
continue;
|
| 25612 |
amit.gupta |
1978 |
}
|
| 25609 |
amit.gupta |
1979 |
InventoryItem inventoryItem = inventoryItems.get(0);
|
|
|
1980 |
CustomRetailer customRetailer = retailersMap.get(inventoryItem.getFofoId());
|
|
|
1981 |
if (inventoryItem.getLastScanType().equals(ScanType.DOA_OUT)
|
|
|
1982 |
|| inventoryItem.getLastScanType().equals(ScanType.PURCHASE_RET)) {
|
|
|
1983 |
// check if pricedrop has been rolled out
|
|
|
1984 |
List<UserWalletHistory> uwh = walletService.getAllByReference(inventoryItem.getFofoId(),
|
|
|
1985 |
priceDropIMEI.getPriceDropId(), WalletReferenceType.PRICE_DROP);
|
|
|
1986 |
if (uwh.size() > 0) {
|
| 25615 |
amit.gupta |
1987 |
Item item = itemRepository.selectById(inventoryItem.getItemId());
|
| 26945 |
amit.gupta |
1988 |
System.out.println(String.join("\t", Arrays.asList(priceDropIMEI.getImei(),
|
|
|
1989 |
inventoryItem.getItemId() + "", item.getBrand(), item.getModelName(), item.getModelNumber(),
|
|
|
1990 |
inventoryItem.getFofoId() + "", customRetailer.getBusinessName(),
|
|
|
1991 |
inventoryItem.getCreateTimestamp().format(dtf), priceDrop.getAffectedOn().format(dtf),
|
|
|
1992 |
priceDropIMEI.getUpdateTimestamp().format(dtf),
|
|
|
1993 |
inventoryItem.getUpdateTimestamp().format(dtf), priceDrop.getAutoPartnerPayout() + "",
|
|
|
1994 |
inventoryItem.getLastScanType().equals(ScanType.DOA_OUT) + "")));
|
| 25609 |
amit.gupta |
1995 |
}
|
|
|
1996 |
}
|
|
|
1997 |
}
|
| 25503 |
amit.gupta |
1998 |
}
|
| 25694 |
amit.gupta |
1999 |
|
| 27686 |
amit.gupta |
2000 |
public void attachToffeeInvoices() throws Exception {
|
| 28205 |
tejbeer |
2001 |
/*
|
|
|
2002 |
* LOGGER.info("Insurance Sum Summary --- {}",
|
|
|
2003 |
* insurancePolicyRepository.selectAmountSumGroupByRetailerId(LocalDateTime.MIN,
|
|
|
2004 |
* LocalDateTime.MAX)); LOGGER.info("Insurance Qty Summary --- {}",
|
|
|
2005 |
* insurancePolicyRepository.selectQtyGroupByRetailerId(LocalDateTime.MIN,
|
|
|
2006 |
* LocalDateTime.MAX)); LOGGER.info("SmartPhone Amount Summary --- {}",
|
|
|
2007 |
* fofoOrderItemRepository.selectSumAmountGroupByRetailer(LocalDateTime.MIN,
|
|
|
2008 |
* LocalDateTime.MAX, 0, true)); LOGGER.info("Smartphone Qty Summary --- {}",
|
|
|
2009 |
* fofoOrderItemRepository.selectQtyGroupByRetailer(LocalDateTime.MIN,
|
|
|
2010 |
* LocalDateTime.MAX, 0, true));
|
|
|
2011 |
*/
|
|
|
2012 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(3,
|
|
|
2013 |
Optional.of(false));
|
|
|
2014 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
| 27678 |
amit.gupta |
2015 |
String invoiceNumber = insurancePolicy.getInvoiceNumber();
|
|
|
2016 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
|
|
2017 |
PdfModel pdfModel = orderService.getInvoicePdfModel(fofoOrder.getId());
|
|
|
2018 |
java.io.ByteArrayOutputStream byteArrayOutputStream = new java.io.ByteArrayOutputStream();
|
|
|
2019 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
| 28205 |
tejbeer |
2020 |
String pdfInvoiceString = "data:application/pdf;base64,"
|
|
|
2021 |
+ Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());
|
|
|
2022 |
boolean attached = toffeeService.attachInvoice(insurancePolicy.getPolicyNumber().split("#")[1],
|
|
|
2023 |
pdfInvoiceString);
|
|
|
2024 |
if (attached) {
|
| 27678 |
amit.gupta |
2025 |
insurancePolicy.setPosted(true);
|
|
|
2026 |
}
|
|
|
2027 |
}
|
| 25694 |
amit.gupta |
2028 |
}
|
|
|
2029 |
|
|
|
2030 |
public void schemeRollback(List<String> schemeIds) throws Exception {
|
|
|
2031 |
List<Integer> schemeIdsInt = schemeIds.stream().map(x -> Integer.parseInt(x)).collect(Collectors.toList());
|
| 25708 |
amit.gupta |
2032 |
Map<Integer, Scheme> schemesMap = schemeRepository.selectBySchemeIds(schemeIdsInt, 0, schemeIds.size()).stream()
|
| 25694 |
amit.gupta |
2033 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
2034 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectBySchemeIds(new HashSet<>(schemeIdsInt));
|
|
|
2035 |
for (SchemeInOut sio : schemeInOuts) {
|
|
|
2036 |
Scheme scheme = schemesMap.get(sio.getSchemeId());
|
|
|
2037 |
if (scheme.getType().equals(SchemeType.IN)) {
|
|
|
2038 |
|
|
|
2039 |
} else if (scheme.getType().equals(SchemeType.OUT)) {
|
|
|
2040 |
InventoryItem inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
|
|
2041 |
List<ScanRecord> sr = scanRecordRepository.selectByInventoryItemId(sio.getInventoryItemId());
|
|
|
2042 |
ScanRecord scanRecord = sr.stream().filter(x -> x.getType().equals(ScanType.SALE))
|
|
|
2043 |
.max((x1, x2) -> x1.getCreateTimestamp().compareTo(x2.getCreateTimestamp())).get();
|
|
|
2044 |
if (scanRecord.getCreateTimestamp().isAfter(scheme.getEndDateTime())
|
|
|
2045 |
|| scanRecord.getCreateTimestamp().isBefore(scheme.getStartDateTime())) {
|
|
|
2046 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
|
|
2047 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(scanRecord.getOrderId());
|
| 25709 |
amit.gupta |
2048 |
String rollbackReason = "Scheme reversed for "
|
|
|
2049 |
+ itemRepository.selectById(inventoryItem.getItemId()).getItemDescription() + "/Inv - "
|
| 25694 |
amit.gupta |
2050 |
+ fofoOrder.getInvoiceNumber();
|
|
|
2051 |
walletService.rollbackAmountFromWallet(scanRecord.getFofoId(), sio.getAmount(),
|
| 26945 |
amit.gupta |
2052 |
scanRecord.getOrderId(), WalletReferenceType.SCHEME_OUT, rollbackReason,
|
|
|
2053 |
LocalDateTime.now());
|
| 25694 |
amit.gupta |
2054 |
System.out.printf("Amount %f,SchemeId %d,Reason %s\n", sio.getAmount(), sio.getSchemeId(),
|
|
|
2055 |
rollbackReason);
|
|
|
2056 |
}
|
|
|
2057 |
}
|
|
|
2058 |
}
|
| 25721 |
tejbeer |
2059 |
// throw new Exception();
|
| 25694 |
amit.gupta |
2060 |
}
|
| 25721 |
tejbeer |
2061 |
|
|
|
2062 |
public void checkfocusedModelInPartnerStock() throws Exception {
|
|
|
2063 |
|
|
|
2064 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
|
|
|
2065 |
.collect(Collectors.toList());
|
| 27212 |
tejbeer |
2066 |
Map<Integer, Map<Integer, List<SaholicCIS>>> warehouseItemAvailabilityMap = saholicInventoryService
|
|
|
2067 |
.getSaholicStock();
|
| 27213 |
tejbeer |
2068 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
2069 |
Map<Integer, FofoReportingModel> partnerIdSalesHeadersMap = this.getPartnerIdSalesHeaders();
|
| 27212 |
tejbeer |
2070 |
|
|
|
2071 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap = saholicInventoryService
|
|
|
2072 |
.getSaholicPOItems();
|
| 25721 |
tejbeer |
2073 |
Map<Integer, List<FocusedModelShortageModel>> focusedModelShortageReportMap = new HashMap<>();
|
|
|
2074 |
for (Integer fofoId : fofoIds) {
|
| 27102 |
amit.gupta |
2075 |
List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
|
|
|
2076 |
focusedModelShortageReportMap.put(fofoId, focusedModelShortageList);
|
| 25721 |
tejbeer |
2077 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2078 |
Map<Integer, Integer> processingOrderMap = null;
|
|
|
2079 |
Map<Integer, Integer> catalogIdAndQtyMap = null;
|
|
|
2080 |
Map<Integer, Integer> grnPendingOrdersMap = null;
|
|
|
2081 |
|
|
|
2082 |
Map<Integer, Integer> currentInventorySnapshot = currentInventorySnapshotRepository.selectByFofoId(fofoId)
|
|
|
2083 |
.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
|
|
2084 |
|
|
|
2085 |
if (!currentInventorySnapshot.isEmpty()) {
|
|
|
2086 |
catalogIdAndQtyMap = itemRepository.selectByIds(currentInventorySnapshot.keySet()).stream()
|
|
|
2087 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
|
|
2088 |
Collectors.summingInt(x -> currentInventorySnapshot.get(x.getId()))));
|
|
|
2089 |
|
|
|
2090 |
}
|
|
|
2091 |
|
|
|
2092 |
Map<Integer, Integer> grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoId).stream()
|
|
|
2093 |
.collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
|
|
2094 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
|
|
2095 |
if (!grnPendingOrders.isEmpty()) {
|
|
|
2096 |
grnPendingOrdersMap = itemRepository.selectByIds(grnPendingOrders.keySet()).stream()
|
|
|
2097 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
|
|
2098 |
Collectors.summingInt(x -> grnPendingOrders.get(x.getId()))));
|
|
|
2099 |
|
|
|
2100 |
}
|
|
|
2101 |
|
|
|
2102 |
Map<Integer, Integer> processingOrder = orderRepository.selectOrders(fofoId, orderStatusList).stream()
|
|
|
2103 |
.collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
|
|
2104 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
|
|
2105 |
if (!processingOrder.isEmpty()) {
|
|
|
2106 |
processingOrderMap = itemRepository.selectByIds(processingOrder.keySet()).stream()
|
|
|
2107 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
|
|
2108 |
Collectors.summingInt(x -> processingOrder.get(x.getId()))));
|
|
|
2109 |
|
|
|
2110 |
}
|
|
|
2111 |
|
| 25800 |
tejbeer |
2112 |
List<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
|
|
2113 |
.collect(Collectors.toList());
|
|
|
2114 |
|
| 27088 |
tejbeer |
2115 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
|
|
2116 |
.collect(Collectors.toList());
|
| 27095 |
tejbeer |
2117 |
LOGGER.info("regionIds" + regionIds);
|
| 27102 |
amit.gupta |
2118 |
if (regionIds.size() == 0) {
|
|
|
2119 |
LOGGER.info("No region found for partner {}", fofoId);
|
|
|
2120 |
continue;
|
|
|
2121 |
}
|
| 27100 |
amit.gupta |
2122 |
Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = focusedModelRepository
|
| 27102 |
amit.gupta |
2123 |
.selectAllByRegionIds(regionIds).stream().collect(Collectors.groupingBy(FocusedModel::getCatalogId,
|
|
|
2124 |
Collectors.mapping(FocusedModel::getMinimumQty, Collectors.maxBy(Integer::compareTo))));
|
| 25800 |
tejbeer |
2125 |
|
| 25721 |
tejbeer |
2126 |
LOGGER.info("focusedCatalogIdAndQtyMap" + focusedCatalogIdAndQtyMap);
|
|
|
2127 |
|
| 27100 |
amit.gupta |
2128 |
for (Map.Entry<Integer, Optional<Integer>> entry : focusedCatalogIdAndQtyMap.entrySet()) {
|
|
|
2129 |
int minQty = entry.getValue().get();
|
| 25721 |
tejbeer |
2130 |
int inStockQty = 0;
|
|
|
2131 |
int processingQty = 0;
|
|
|
2132 |
int grnPendingQty = 0;
|
| 27208 |
tejbeer |
2133 |
int allColorNetAvailability = 0;
|
| 27253 |
tejbeer |
2134 |
int allColorPoAvailability = 0;
|
| 25721 |
tejbeer |
2135 |
if (processingOrderMap != null) {
|
|
|
2136 |
processingQty = (processingOrderMap.get(entry.getKey()) == null) ? 0
|
|
|
2137 |
: processingOrderMap.get(entry.getKey());
|
|
|
2138 |
|
|
|
2139 |
}
|
|
|
2140 |
if (grnPendingOrdersMap != null) {
|
|
|
2141 |
grnPendingQty = (grnPendingOrdersMap.get(entry.getKey()) == null) ? 0
|
|
|
2142 |
: grnPendingOrdersMap.get(entry.getKey());
|
|
|
2143 |
|
|
|
2144 |
}
|
|
|
2145 |
if (catalogIdAndQtyMap != null) {
|
|
|
2146 |
inStockQty = (catalogIdAndQtyMap.get(entry.getKey()) == null) ? 0
|
|
|
2147 |
: catalogIdAndQtyMap.get(entry.getKey());
|
|
|
2148 |
|
|
|
2149 |
}
|
| 28526 |
tejbeer |
2150 |
|
|
|
2151 |
int grnStockQty = grnPendingQty + inStockQty;
|
| 25721 |
tejbeer |
2152 |
int totalQty = processingQty + grnPendingQty + inStockQty;
|
|
|
2153 |
|
| 27100 |
amit.gupta |
2154 |
if (totalQty < minQty) {
|
| 25721 |
tejbeer |
2155 |
|
| 27100 |
amit.gupta |
2156 |
int shortageQty = minQty - totalQty;
|
| 25721 |
tejbeer |
2157 |
List<Item> item = itemRepository.selectAllByCatalogItemId(entry.getKey());
|
| 27212 |
tejbeer |
2158 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 27213 |
tejbeer |
2159 |
|
| 27212 |
tejbeer |
2160 |
Map<Integer, List<SaholicCIS>> itemAvailabilityMap = warehouseItemAvailabilityMap
|
|
|
2161 |
.get(fofoStore.getWarehouseId());
|
| 25721 |
tejbeer |
2162 |
|
| 27212 |
tejbeer |
2163 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = warehousePoItemAvailabilityMap
|
|
|
2164 |
.get(fofoStore.getWarehouseId());
|
| 27208 |
tejbeer |
2165 |
|
|
|
2166 |
for (Item it : item) {
|
| 28527 |
tejbeer |
2167 |
List<SaholicCIS> currentAvailability = null;
|
| 28528 |
tejbeer |
2168 |
List<SaholicPOItem> poItemAvailability = null;
|
| 28527 |
tejbeer |
2169 |
if (itemAvailabilityMap != null) {
|
|
|
2170 |
currentAvailability = itemAvailabilityMap.get(it.getId());
|
|
|
2171 |
}
|
| 28528 |
tejbeer |
2172 |
|
|
|
2173 |
if (poItemAvailabilityMap != null) {
|
|
|
2174 |
poItemAvailability = poItemAvailabilityMap.get(it.getId());
|
|
|
2175 |
}
|
| 27208 |
tejbeer |
2176 |
if (currentAvailability != null) {
|
|
|
2177 |
allColorNetAvailability += currentAvailability.stream()
|
|
|
2178 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability));
|
|
|
2179 |
}
|
| 27253 |
tejbeer |
2180 |
|
| 27208 |
tejbeer |
2181 |
if (poItemAvailability != null) {
|
| 27253 |
tejbeer |
2182 |
allColorPoAvailability += poItemAvailability.stream()
|
| 27208 |
tejbeer |
2183 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty));
|
|
|
2184 |
}
|
| 27253 |
tejbeer |
2185 |
|
| 27208 |
tejbeer |
2186 |
}
|
|
|
2187 |
|
| 25721 |
tejbeer |
2188 |
FocusedModelShortageModel fm = new FocusedModelShortageModel();
|
|
|
2189 |
fm.setFofoId(fofoId);
|
| 27212 |
tejbeer |
2190 |
fm.setStoreCode(fofoStore.getCode());
|
| 25721 |
tejbeer |
2191 |
fm.setStoreName(customRetailer.getBusinessName());
|
| 27208 |
tejbeer |
2192 |
fm.setBrandName(item.get(0).getBrand());
|
|
|
2193 |
fm.setModelName(item.get(0).getModelName());
|
|
|
2194 |
fm.setModelNumber(item.get(0).getModelNumber());
|
| 28526 |
tejbeer |
2195 |
fm.setGrnStockQty(grnStockQty);
|
|
|
2196 |
fm.setPendingIndentQty(processingQty);
|
| 25721 |
tejbeer |
2197 |
fm.setShortageQty(shortageQty);
|
| 27253 |
tejbeer |
2198 |
fm.setPoAvailabitiy(allColorPoAvailability);
|
| 27208 |
tejbeer |
2199 |
fm.setWarehouseName(warehouseMap.get(customRetailer.getWarehouseId()));
|
| 27213 |
tejbeer |
2200 |
fm.setStateManager(partnerIdSalesHeadersMap.get(fofoId).getRegionalManager());
|
|
|
2201 |
fm.setTerritoryManager(partnerIdSalesHeadersMap.get(fofoId).getTerritoryManager());
|
| 27246 |
tejbeer |
2202 |
fm.setItemName(item.get(0).getBrand() + item.get(0).getModelNumber() + item.get(0).getModelName());
|
| 27208 |
tejbeer |
2203 |
fm.setAvailabitiy(allColorNetAvailability);
|
| 25721 |
tejbeer |
2204 |
|
| 27102 |
amit.gupta |
2205 |
focusedModelShortageList.add(fm);
|
| 25721 |
tejbeer |
2206 |
}
|
|
|
2207 |
|
|
|
2208 |
}
|
| 27233 |
tejbeer |
2209 |
|
| 28529 |
tejbeer |
2210 |
if (!focusedModelShortageList.isEmpty()) {
|
|
|
2211 |
String subject = "Stock Alert";
|
|
|
2212 |
String messageText = this.getMessage(focusedModelShortageList);
|
| 27233 |
tejbeer |
2213 |
|
| 28529 |
tejbeer |
2214 |
this.sendMailWithAttachments(subject, messageText, customRetailer.getEmail());
|
|
|
2215 |
String notificationMessage = this.getNotificationMessage(focusedModelShortageList);
|
|
|
2216 |
|
|
|
2217 |
LOGGER.info("notificationMessage" + notificationMessage);
|
|
|
2218 |
|
|
|
2219 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
2220 |
sendNotificationModel.setCampaignName("Stock Alert");
|
|
|
2221 |
sendNotificationModel.setTitle("Alert");
|
|
|
2222 |
sendNotificationModel.setMessage(notificationMessage);
|
|
|
2223 |
sendNotificationModel.setType("url");
|
|
|
2224 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
|
|
2225 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
|
|
2226 |
sendNotificationModel.setMessageType(MessageType.notification);
|
|
|
2227 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
|
|
2228 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
|
|
2229 |
notificationService.sendNotification(sendNotificationModel);
|
|
|
2230 |
|
|
|
2231 |
}
|
|
|
2232 |
|
| 25721 |
tejbeer |
2233 |
}
|
| 27102 |
amit.gupta |
2234 |
if (!focusedModelShortageReportMap.isEmpty()) {
|
| 25800 |
tejbeer |
2235 |
String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
|
|
2236 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 25837 |
amit.gupta |
2237 |
Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
|
| 25721 |
tejbeer |
2238 |
|
| 25800 |
tejbeer |
2239 |
focusedModelShortageReportMap.entrySet().forEach(x -> {
|
|
|
2240 |
storeGuyMap.entrySet().forEach(y -> {
|
|
|
2241 |
|
|
|
2242 |
if (y.getValue().contains(x.getKey())) {
|
|
|
2243 |
if (!emailRowsMap.containsKey(y.getKey())) {
|
|
|
2244 |
emailRowsMap.put(y.getKey(), new ArrayList<>());
|
|
|
2245 |
}
|
| 27208 |
tejbeer |
2246 |
List<List<? extends Serializable>> fms = x.getValue().stream()
|
|
|
2247 |
.map(r -> Arrays.asList(r.getStoreCode(), r.getStoreName(), r.getBrandName(),
|
| 27213 |
tejbeer |
2248 |
r.getModelName(), r.getModelNumber(), r.getWarehouseName(), r.getStateManager(),
|
| 28526 |
tejbeer |
2249 |
r.getTerritoryManager(), r.getPendingIndentQty(), r.getGrnStockQty(),
|
|
|
2250 |
r.getShortageQty(), r.getAvailabitiy()))
|
| 25800 |
tejbeer |
2251 |
.collect(Collectors.toList());
|
|
|
2252 |
emailRowsMap.get(y.getKey()).addAll(fms);
|
|
|
2253 |
|
| 25721 |
tejbeer |
2254 |
}
|
|
|
2255 |
|
| 25800 |
tejbeer |
2256 |
});
|
| 25721 |
tejbeer |
2257 |
|
|
|
2258 |
});
|
|
|
2259 |
|
| 27212 |
tejbeer |
2260 |
List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number",
|
| 28526 |
tejbeer |
2261 |
"Warehouse Name", "State Manager", "Territory Manager", "Pending Indent", "InStock", "Shortage Qty",
|
|
|
2262 |
"Availability");
|
| 25837 |
amit.gupta |
2263 |
emailRowsMap.entrySet().forEach(entry -> {
|
| 25721 |
tejbeer |
2264 |
|
| 25800 |
tejbeer |
2265 |
ByteArrayOutputStream baos = null;
|
|
|
2266 |
try {
|
| 25837 |
amit.gupta |
2267 |
baos = FileUtil.getCSVByteStream(headers, entry.getValue());
|
| 25800 |
tejbeer |
2268 |
} catch (Exception e2) {
|
|
|
2269 |
e2.printStackTrace();
|
|
|
2270 |
}
|
| 28529 |
tejbeer |
2271 |
String[] sendToArray = new String[] { entry.getKey() };
|
| 28526 |
tejbeer |
2272 |
|
| 25800 |
tejbeer |
2273 |
try {
|
|
|
2274 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Stock Alert", "PFA", fileName,
|
|
|
2275 |
new ByteArrayResource(baos.toByteArray()));
|
|
|
2276 |
} catch (Exception e1) { // TODO Auto-generated catch block
|
|
|
2277 |
e1.printStackTrace();
|
|
|
2278 |
}
|
| 25721 |
tejbeer |
2279 |
|
| 25800 |
tejbeer |
2280 |
});
|
|
|
2281 |
}
|
| 25721 |
tejbeer |
2282 |
}
|
|
|
2283 |
|
|
|
2284 |
private String getNotificationMessage(List<FocusedModelShortageModel> focusedModelShortageModel) {
|
|
|
2285 |
StringBuilder sb = new StringBuilder();
|
|
|
2286 |
sb.append("Focused Model Shortage in Your Stock : \n");
|
|
|
2287 |
for (FocusedModelShortageModel entry : focusedModelShortageModel) {
|
|
|
2288 |
|
|
|
2289 |
sb.append(entry.getItemName() + "-" + entry.getShortageQty());
|
|
|
2290 |
sb.append(String.format("%n", ""));
|
|
|
2291 |
}
|
|
|
2292 |
return sb.toString();
|
|
|
2293 |
}
|
|
|
2294 |
|
|
|
2295 |
private void sendMailWithAttachments(String subject, String messageText, String email) throws Exception {
|
|
|
2296 |
MimeMessage message = mailSender.createMimeMessage();
|
|
|
2297 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
|
|
2298 |
|
|
|
2299 |
helper.setSubject(subject);
|
|
|
2300 |
helper.setText(messageText, true);
|
|
|
2301 |
helper.setTo(email);
|
| 27116 |
amit.gupta |
2302 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smartdukaan Alerts");
|
| 25721 |
tejbeer |
2303 |
helper.setFrom(senderAddress);
|
|
|
2304 |
mailSender.send(message);
|
|
|
2305 |
|
|
|
2306 |
}
|
|
|
2307 |
|
|
|
2308 |
private String getMessage(List<FocusedModelShortageModel> focusedModelShortageModel) {
|
|
|
2309 |
StringBuilder sb = new StringBuilder();
|
|
|
2310 |
sb.append("<html><body><p>Alert</p><p>Focused Model Shortage in Your Stock:-</p>"
|
|
|
2311 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
|
|
2312 |
sb.append("<tbody>\n" + " <tr>\n"
|
|
|
2313 |
+ " <th style='border:1px solid black;padding: 5px'>Item</th>\n"
|
|
|
2314 |
+ " <th style='border:1px solid black;padding: 5px'>Shortage Qty</th>\n"
|
|
|
2315 |
+ " </tr>");
|
|
|
2316 |
for (FocusedModelShortageModel entry : focusedModelShortageModel) {
|
|
|
2317 |
|
|
|
2318 |
sb.append("<tr>");
|
|
|
2319 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getItemName() + "</td>");
|
|
|
2320 |
|
|
|
2321 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getShortageQty() + "</td>");
|
|
|
2322 |
|
|
|
2323 |
sb.append("</tr>");
|
|
|
2324 |
|
|
|
2325 |
}
|
|
|
2326 |
|
|
|
2327 |
sb.append("</tbody></table></body></html>");
|
|
|
2328 |
|
|
|
2329 |
return sb.toString();
|
|
|
2330 |
}
|
|
|
2331 |
|
| 25927 |
amit.gupta |
2332 |
public void notifyLead() throws Exception {
|
|
|
2333 |
List<Lead> leadsToNotify = leadRepository.selectLeadsScheduledBetweenDate(LocalDateTime.now().minusDays(15),
|
|
|
2334 |
LocalDateTime.now().plusHours(4));
|
|
|
2335 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream()
|
|
|
2336 |
.collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
| 27477 |
amit.gupta |
2337 |
LOGGER.info("authUserEmailMap {}", authUserEmailMap);
|
| 25927 |
amit.gupta |
2338 |
Map<String, Integer> dtrEmailMap = dtrUserRepository
|
|
|
2339 |
.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream()
|
|
|
2340 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
| 25936 |
amit.gupta |
2341 |
|
| 27477 |
amit.gupta |
2342 |
LOGGER.info("dtrEmailMap {}", dtrEmailMap);
|
| 26790 |
tejbeer |
2343 |
|
| 25927 |
amit.gupta |
2344 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
|
|
2345 |
|
|
|
2346 |
for (Map.Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
|
|
2347 |
int authId = authUserEmail.getKey();
|
|
|
2348 |
String email = authUserEmail.getValue();
|
|
|
2349 |
authUserKeyMap.put(authId, dtrEmailMap.get(email));
|
|
|
2350 |
}
|
| 27477 |
amit.gupta |
2351 |
LOGGER.info("authUserKeyMap", authUserKeyMap);
|
|
|
2352 |
LOGGER.info("leadsToNotify {}", leadsToNotify);
|
| 26790 |
tejbeer |
2353 |
|
| 25927 |
amit.gupta |
2354 |
String templateMessage = "Lead followup for %s %s, %s is due by %s";
|
|
|
2355 |
for (Lead lead : leadsToNotify) {
|
| 27217 |
amit.gupta |
2356 |
if (authUserKeyMap.get(lead.getAssignTo()) == null) {
|
|
|
2357 |
LOGGER.info("Assignee no longer part of system {}", lead.getAssignTo());
|
| 25927 |
amit.gupta |
2358 |
continue;
|
|
|
2359 |
}
|
|
|
2360 |
String notificationMessage = String.format(templateMessage, lead.getFirstName(), lead.getLastName(),
|
| 27795 |
amit.gupta |
2361 |
lead.getAddress(), leadTimeFormatter.format(lead.getScheduledTimestamp()));
|
| 25927 |
amit.gupta |
2362 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
2363 |
sendNotificationModel.setCampaignName("Lead Reminder");
|
|
|
2364 |
sendNotificationModel.setTitle("Leads followup Reminder");
|
|
|
2365 |
sendNotificationModel.setMessage(notificationMessage);
|
|
|
2366 |
sendNotificationModel.setType("url");
|
| 27206 |
tejbeer |
2367 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 25927 |
amit.gupta |
2368 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
|
|
2369 |
sendNotificationModel.setMessageType(MessageType.reminder);
|
| 26320 |
tejbeer |
2370 |
sendNotificationModel.setUserIds(Arrays.asList(authUserKeyMap.get(lead.getAssignTo())));
|
| 25929 |
amit.gupta |
2371 |
System.out.println(sendNotificationModel);
|
| 25927 |
amit.gupta |
2372 |
notificationService.sendNotification(sendNotificationModel);
|
|
|
2373 |
}
|
|
|
2374 |
}
|
| 26945 |
amit.gupta |
2375 |
|
| 25927 |
amit.gupta |
2376 |
public void notifyVisits() throws Exception {
|
| 26945 |
amit.gupta |
2377 |
List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository
|
|
|
2378 |
.selectVisitsScheduledBetweenDate(LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4));
|
| 25927 |
amit.gupta |
2379 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream()
|
|
|
2380 |
.collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
|
|
2381 |
Map<String, Integer> dtrEmailMap = dtrUserRepository
|
|
|
2382 |
.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream()
|
|
|
2383 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
|
|
2384 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
| 26945 |
amit.gupta |
2385 |
|
| 25927 |
amit.gupta |
2386 |
for (Map.Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
|
|
2387 |
int authId = authUserEmail.getKey();
|
|
|
2388 |
String email = authUserEmail.getValue();
|
|
|
2389 |
authUserKeyMap.put(authId, dtrEmailMap.get(email));
|
|
|
2390 |
}
|
|
|
2391 |
String visitTemplate = "Planned visit to franchisee %s is due by %s";
|
|
|
2392 |
String followupTemplate = "Lead followup for franchisee %s is due by %s";
|
|
|
2393 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("MMM 7, EEEE h:m a");
|
|
|
2394 |
for (FranchiseeVisit visit : franchiseeVisits) {
|
|
|
2395 |
if (authUserKeyMap.containsKey(visit.getAuthId())) {
|
|
|
2396 |
continue;
|
|
|
2397 |
}
|
|
|
2398 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
2399 |
String message = null;
|
| 26945 |
amit.gupta |
2400 |
if (visit.getFranchiseActivityId() == 0) {
|
|
|
2401 |
message = String.format(visitTemplate, visit.getPartnerName(),
|
|
|
2402 |
timeFormatter.format(visit.getSchelduleTimestamp()));
|
|
|
2403 |
sendNotificationModel.setCampaignName("Franchisee visit Reminder");
|
| 25927 |
amit.gupta |
2404 |
} else {
|
| 26945 |
amit.gupta |
2405 |
message = String.format(followupTemplate, visit.getPartnerName(),
|
|
|
2406 |
timeFormatter.format(visit.getSchelduleTimestamp()));
|
| 25927 |
amit.gupta |
2407 |
sendNotificationModel.setCampaignName("Franchisee followup Reminder");
|
|
|
2408 |
}
|
|
|
2409 |
sendNotificationModel.setMessage(message);
|
|
|
2410 |
sendNotificationModel.setType("url");
|
| 26482 |
tejbeer |
2411 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 25927 |
amit.gupta |
2412 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
|
|
2413 |
sendNotificationModel.setMessageType(MessageType.reminder);
|
|
|
2414 |
sendNotificationModel.setUserIds(Arrays.asList(authUserKeyMap.get(visit.getAuthId())));
|
|
|
2415 |
notificationService.sendNotification(sendNotificationModel);
|
|
|
2416 |
}
|
| 25910 |
amit.gupta |
2417 |
}
|
| 25982 |
amit.gupta |
2418 |
|
| 26283 |
tejbeer |
2419 |
public void ticketClosed() throws Exception {
|
|
|
2420 |
|
|
|
2421 |
List<Ticket> tickets = ticketRepository.selectAllNotClosedTicketsWithStatus(ActivityType.RESOLVED);
|
|
|
2422 |
for (Ticket ticket : tickets) {
|
|
|
2423 |
if (ticket.getUpdateTimestamp().toLocalDate().isBefore(LocalDate.now().minusDays(7))) {
|
|
|
2424 |
ticket.setCloseTimestamp(LocalDateTime.now());
|
|
|
2425 |
ticket.setLastActivity(ActivityType.RESOLVED_ACCEPTED);
|
|
|
2426 |
ticket.setUpdateTimestamp(LocalDateTime.now());
|
|
|
2427 |
ticketRepository.persist(ticket);
|
|
|
2428 |
}
|
|
|
2429 |
}
|
|
|
2430 |
|
|
|
2431 |
}
|
|
|
2432 |
|
| 26790 |
tejbeer |
2433 |
public void checkValidateReferral() throws Exception {
|
|
|
2434 |
|
|
|
2435 |
List<Refferal> referrals = refferalRepository.selectByStatus(RefferalStatus.pending);
|
| 26791 |
tejbeer |
2436 |
LOGGER.info("referrals" + referrals);
|
| 26790 |
tejbeer |
2437 |
if (!referrals.isEmpty()) {
|
|
|
2438 |
String subject = "Referral Request";
|
|
|
2439 |
String messageText = this.getMessageForReferral(referrals);
|
|
|
2440 |
|
| 26792 |
tejbeer |
2441 |
MimeMessage message = mailSender.createMimeMessage();
|
|
|
2442 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
|
|
2443 |
String[] email = { "kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com" };
|
|
|
2444 |
helper.setSubject(subject);
|
|
|
2445 |
helper.setText(messageText, true);
|
|
|
2446 |
helper.setTo(email);
|
|
|
2447 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smartdukaan Alerts");
|
|
|
2448 |
helper.setFrom(senderAddress);
|
|
|
2449 |
mailSender.send(message);
|
|
|
2450 |
|
| 26790 |
tejbeer |
2451 |
}
|
|
|
2452 |
}
|
|
|
2453 |
|
|
|
2454 |
private String getMessageForReferral(List<Refferal> referrals) {
|
|
|
2455 |
StringBuilder sb = new StringBuilder();
|
|
|
2456 |
sb.append("<html><body><p>Alert</p><p>Pending Referrals:-</p>"
|
|
|
2457 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
|
|
2458 |
sb.append("<tbody>\n" + " <tr>\n"
|
|
|
2459 |
+ " <th style='border:1px solid black;padding: 5px'>RefereeName</th>\n"
|
|
|
2460 |
+ " <th style='border:1px solid black;padding: 5px'>Referee Email</th>\n"
|
|
|
2461 |
+ " <th style='border:1px solid black;padding: 5px'>Referral Name</th>\n"
|
|
|
2462 |
+ " <th style='border:1px solid black;padding: 5px'>Refferal Mobile</th>\n"
|
|
|
2463 |
+ " <th style='border:1px solid black;padding: 5px'>city</th>\n"
|
|
|
2464 |
+ " <th style='border:1px solid black;padding: 5px'>state</th>\n"
|
|
|
2465 |
+ " </tr>");
|
|
|
2466 |
for (Refferal entry : referrals) {
|
|
|
2467 |
|
|
|
2468 |
sb.append("<tr>");
|
|
|
2469 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getRefereeName() + "</td>");
|
|
|
2470 |
|
|
|
2471 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getRefereeEmail() + "</td>");
|
|
|
2472 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getFirstName() + "</td>");
|
|
|
2473 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getMobile() + "</td>");
|
|
|
2474 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getCity() + "</td>");
|
|
|
2475 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getState() + "</td>");
|
|
|
2476 |
|
|
|
2477 |
sb.append("</tr>");
|
|
|
2478 |
|
|
|
2479 |
}
|
|
|
2480 |
|
|
|
2481 |
sb.append("</tbody></table></body></html>");
|
|
|
2482 |
|
|
|
2483 |
return sb.toString();
|
|
|
2484 |
}
|
|
|
2485 |
|
| 27271 |
amit.gupta |
2486 |
public void reverseWallet() throws Exception {
|
|
|
2487 |
LocalDate localDate = LocalDate.of(2020, 10, 28);
|
| 28205 |
tejbeer |
2488 |
List<UserWalletHistory> uwhList = userWalletHistoryRepository.selectAllByDateType(localDate.atStartOfDay(),
|
|
|
2489 |
localDate.plusDays(1).atStartOfDay(),
|
| 27271 |
amit.gupta |
2490 |
Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
|
|
2491 |
for (UserWalletHistory uwh : uwhList) {
|
| 28205 |
tejbeer |
2492 |
if (uwh.getBusinessTimestamp().getMonth().equals(Month.SEPTEMBER)) {
|
| 27275 |
amit.gupta |
2493 |
UserWallet uw = userWalletRepository.selectById(uwh.getWalletId());
|
| 28205 |
tejbeer |
2494 |
// LOGGER.info("UWH - {}", uwh);
|
|
|
2495 |
// amount += uwh.getAmount();
|
|
|
2496 |
// System.out.println("Amount is - " + amount);
|
|
|
2497 |
// walletService.rollbackAmountFromWallet(uw.getUserId(), uwh.getAmount(),
|
|
|
2498 |
// uwh.getReference(), uwh.getReferenceType(), "Margin reversal for error prone
|
|
|
2499 |
// run", uwh.getBusinessTimestamp());
|
| 27313 |
amit.gupta |
2500 |
int orderId = uwh.getReference();
|
|
|
2501 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(orderId);
|
|
|
2502 |
int inventoryItemId = 0;
|
| 28205 |
tejbeer |
2503 |
// fofoOrderRepository.delete(fofoOrder);
|
| 27313 |
amit.gupta |
2504 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 28205 |
tejbeer |
2505 |
/*
|
|
|
2506 |
* List<PaymentOptionTransaction> paymentOptionTransactions =
|
|
|
2507 |
* paymentOptionTransactionRepository.selectByReferenceIdAndType(fofoOrder.getId
|
|
|
2508 |
* (), PaymentOptionReferenceType.ORDER); for(PaymentOptionTransaction
|
|
|
2509 |
* paymentOptionTransaction : paymentOptionTransactions) {
|
|
|
2510 |
* //paymentOptionTransactionRepository.delete(paymentOptionTransaction); }
|
|
|
2511 |
*/
|
|
|
2512 |
for (FofoOrderItem foi : fofoOrderItems) {
|
|
|
2513 |
// fofoOrderItemRepository.delete(foi);
|
| 27313 |
amit.gupta |
2514 |
List<FofoLineItem> flis = fofoLineItemRepository.selectByFofoOrderItemId(foi.getId());
|
| 28205 |
tejbeer |
2515 |
for (FofoLineItem fli : flis) {
|
|
|
2516 |
// fofoLineItemRepository.delete(fli);
|
| 27313 |
amit.gupta |
2517 |
inventoryItemId = fli.getInventoryItemId();
|
|
|
2518 |
}
|
|
|
2519 |
}
|
| 28205 |
tejbeer |
2520 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(
|
|
|
2521 |
java.util.stream.Stream.of(inventoryItemId).collect(Collectors.toSet()));
|
|
|
2522 |
for (SchemeInOut sio : schemeInOuts) {
|
|
|
2523 |
if (sio.getCreateTimestamp().toLocalDate().equals(localDate)) {
|
| 27314 |
amit.gupta |
2524 |
LOGGER.info("SIO - {}", sio);
|
| 27315 |
amit.gupta |
2525 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 27313 |
amit.gupta |
2526 |
}
|
|
|
2527 |
}
|
| 28205 |
tejbeer |
2528 |
|
| 27271 |
amit.gupta |
2529 |
}
|
|
|
2530 |
}
|
| 28205 |
tejbeer |
2531 |
|
| 27271 |
amit.gupta |
2532 |
}
|
| 28205 |
tejbeer |
2533 |
|
|
|
2534 |
public void partnerProblemAlert() throws Exception {
|
|
|
2535 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
2536 |
Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
|
|
2537 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), 0, false);
|
|
|
2538 |
Map<Integer, Double> mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1),
|
|
|
2539 |
curDate.with(LocalTime.MAX), 0, false);
|
|
|
2540 |
Map<Integer, PartnerDailyInvestment> pdi = partnerDailyInvestmentRepository.selectAll(LocalDate.now()).stream()
|
|
|
2541 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
|
|
2542 |
|
|
|
2543 |
for (Entry<Integer, Double> ls : lmtdSale.entrySet()) {
|
|
|
2544 |
|
|
|
2545 |
double lmtdTwentyPercentSale = ls.getValue() * 0.2;
|
| 28208 |
tejbeer |
2546 |
|
|
|
2547 |
LOGGER.info("lmtdTwentyPercentSale" + lmtdTwentyPercentSale);
|
|
|
2548 |
|
| 28211 |
tejbeer |
2549 |
double mtdSale = mtdSales.get(ls.getKey()) == null ? 0 : mtdSales.get(ls.getKey());
|
| 28208 |
tejbeer |
2550 |
|
|
|
2551 |
LOGGER.info("mtdSale" + mtdSale);
|
|
|
2552 |
|
| 28209 |
tejbeer |
2553 |
double totalSixtyPercentInvestment = pdi.get(ls.getKey()) == null ? 0
|
|
|
2554 |
: pdi.get(ls.getKey()).getTotalInvestment() * 0.6;
|
| 28205 |
tejbeer |
2555 |
|
| 28208 |
tejbeer |
2556 |
LOGGER.info("totalSixtyPercentInvestment" + totalSixtyPercentInvestment);
|
|
|
2557 |
|
| 28209 |
tejbeer |
2558 |
double stockInvestment = pdi.get(ls.getKey()) == null ? 0 : pdi.get(ls.getKey()).getInStockAmount();
|
| 28208 |
tejbeer |
2559 |
|
|
|
2560 |
LOGGER.info("stockInvestment" + stockInvestment);
|
|
|
2561 |
|
| 28205 |
tejbeer |
2562 |
boolean Investmentvalue = partnerInvestmentService.isInvestmentBelow(ls.getKey(), 25);
|
|
|
2563 |
|
|
|
2564 |
PartnerProblem partnerProblem = partnerProblemRepository.selectByFofoId(ls.getKey());
|
|
|
2565 |
|
| 28210 |
tejbeer |
2566 |
if (partnerProblem == null) {
|
| 28205 |
tejbeer |
2567 |
partnerProblem = new PartnerProblem();
|
|
|
2568 |
partnerProblem.setFofoId(ls.getKey());
|
|
|
2569 |
if (mtdSale < lmtdTwentyPercentSale) {
|
|
|
2570 |
partnerProblem.setMtd(1);
|
|
|
2571 |
}
|
|
|
2572 |
if (Investmentvalue) {
|
|
|
2573 |
partnerProblem.setInvestment(1);
|
|
|
2574 |
}
|
|
|
2575 |
|
|
|
2576 |
if (stockInvestment < totalSixtyPercentInvestment) {
|
|
|
2577 |
partnerProblem.setInvestment(1);
|
|
|
2578 |
}
|
|
|
2579 |
|
|
|
2580 |
partnerProblemRepository.persist(partnerProblem);
|
|
|
2581 |
} else {
|
|
|
2582 |
if (mtdSale < lmtdTwentyPercentSale) {
|
|
|
2583 |
partnerProblem.setMtd(partnerProblem.getMtd() + 1);
|
|
|
2584 |
|
|
|
2585 |
} else {
|
|
|
2586 |
partnerProblem.setMtd(0);
|
|
|
2587 |
|
|
|
2588 |
}
|
|
|
2589 |
if (Investmentvalue) {
|
|
|
2590 |
partnerProblem.setInvestment(partnerProblem.getInvestment() + 1);
|
|
|
2591 |
} else {
|
|
|
2592 |
partnerProblem.setInvestment(0);
|
|
|
2593 |
|
|
|
2594 |
}
|
|
|
2595 |
if (stockInvestment < totalSixtyPercentInvestment) {
|
|
|
2596 |
partnerProblem.setStockInvestment(partnerProblem.getStockInvestment() + 1);
|
|
|
2597 |
} else {
|
|
|
2598 |
partnerProblem.setStockInvestment(0);
|
|
|
2599 |
}
|
|
|
2600 |
|
|
|
2601 |
}
|
|
|
2602 |
|
|
|
2603 |
}
|
|
|
2604 |
|
| 28213 |
tejbeer |
2605 |
List<PartnerProblem> partnerProblems = partnerProblemRepository.selectAll().stream()
|
|
|
2606 |
.filter(x -> x.getMtd() + x.getInvestment() + x.getStockInvestment() > 0).collect(Collectors.toList());
|
|
|
2607 |
|
| 28223 |
tejbeer |
2608 |
partnerProblems = partnerProblems.stream().sorted((x1, x2) -> {
|
| 28224 |
tejbeer |
2609 |
return x1.getMtd() + x1.getInvestment() + x1.getStockInvestment() < x2.getMtd() + x2.getInvestment()
|
| 28223 |
tejbeer |
2610 |
+ x2.getStockInvestment() ? 1 : -1;
|
|
|
2611 |
}).collect(Collectors.toList());
|
| 28227 |
tejbeer |
2612 |
|
|
|
2613 |
Map<Integer, PartnerProblem> partnerProblemMap = partnerProblems.stream().sorted((x1, x2) -> {
|
|
|
2614 |
return x1.getMtd() + x1.getInvestment() + x1.getStockInvestment() < x2.getMtd() + x2.getInvestment()
|
|
|
2615 |
+ x2.getStockInvestment() ? 1 : -1;
|
|
|
2616 |
}).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
|
|
2617 |
|
| 28212 |
tejbeer |
2618 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
| 28213 |
tejbeer |
2619 |
|
| 28467 |
tejbeer |
2620 |
List<Integer> assignTo = Arrays.asList(15, 9, 54, 53);
|
| 28213 |
tejbeer |
2621 |
|
|
|
2622 |
Map<Integer, AuthUser> assignAuthUserMap = authRepository.selectAllAuthUserByIds(assignTo).stream()
|
|
|
2623 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
2624 |
|
| 28286 |
tejbeer |
2625 |
List<String> sendTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
| 28467 |
tejbeer |
2626 |
"niranjan.kala@smartdukaan.com", "sm@smartdukaan.com", "tejbeer.kaur@shop2020.in");
|
| 28208 |
tejbeer |
2627 |
LOGGER.info("partnerProblem" + partnerProblems);
|
| 28205 |
tejbeer |
2628 |
StringBuilder sb = new StringBuilder();
|
| 28218 |
tejbeer |
2629 |
sb.append("<htl><body>");
|
| 28222 |
tejbeer |
2630 |
sb.append(
|
|
|
2631 |
"<p>Number against MTD or Investment are the count of days the MTD is low VS LMTD OR Investment is below 75%.</p><br/><p>These partners needs immediate attention.</p><br/><table style='border:1px solid black';cellspacing=0>");
|
| 28205 |
tejbeer |
2632 |
sb.append("<tbody>\n" + " <tr>"
|
|
|
2633 |
+ " <th style='border:1px solid black;padding: 5px'>Partner Name</th>"
|
|
|
2634 |
+ " <th style='border:1px solid black;padding: 5px'>Assign TO</th>"
|
|
|
2635 |
+ " <th style='border:1px solid black;padding: 5px'>Mtd</th>"
|
|
|
2636 |
+ " <th style='border:1px solid black;padding: 5px'>Investment</th>"
|
|
|
2637 |
+ " <th style='border:1px solid black;padding: 5px'>Stock</th>"
|
|
|
2638 |
+ " <th style='border:1px solid black;padding: 5px'>Manager</th>"
|
|
|
2639 |
|
|
|
2640 |
+ " </tr>");
|
|
|
2641 |
|
|
|
2642 |
for (PartnerProblem pp : partnerProblems) {
|
| 28467 |
tejbeer |
2643 |
int value = pp.getFofoId() % 4;
|
| 28205 |
tejbeer |
2644 |
|
|
|
2645 |
Map<EscalationType, AuthUser> authUserMap = csService.getAuthUserAndEsclationByPartnerId(pp.getFofoId());
|
| 28217 |
tejbeer |
2646 |
LOGGER.info("authUserMap" + authUserMap);
|
| 28205 |
tejbeer |
2647 |
sb.append("<tr>");
|
|
|
2648 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
|
|
2649 |
+ customRetailers.get(pp.getFofoId()).getBusinessName() + "</td>");
|
| 28213 |
tejbeer |
2650 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
|
|
2651 |
+ assignAuthUserMap.get(assignTo.get(value)).getName() + "</td>");
|
| 28205 |
tejbeer |
2652 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getMtd() + "</td>");
|
|
|
2653 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getInvestment() + "</td>");
|
|
|
2654 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getStockInvestment() + "</td>");
|
| 28216 |
tejbeer |
2655 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| 28224 |
tejbeer |
2656 |
+ (authUserMap.get(EscalationType.L1) == null ? "N/A"
|
| 28216 |
tejbeer |
2657 |
: authUserMap.get(EscalationType.L1).getFirstName())
|
| 28224 |
tejbeer |
2658 |
+ " ," + (authUserMap.get(EscalationType.L2) == null ? "N/A"
|
| 28218 |
tejbeer |
2659 |
: authUserMap.get(EscalationType.L2).getFirstName())
|
| 28216 |
tejbeer |
2660 |
+ "</td>");
|
| 28205 |
tejbeer |
2661 |
|
|
|
2662 |
sb.append("</tr>");
|
|
|
2663 |
}
|
|
|
2664 |
sb.append("</tbody></table><br><br>");
|
|
|
2665 |
String subject = "Partner Problem Alert!";
|
|
|
2666 |
String[] email = sendTo.toArray(new String[sendTo.size()]);
|
|
|
2667 |
|
| 28222 |
tejbeer |
2668 |
this.sendMailHtmlFormat(email, sb.toString(), null, subject);
|
|
|
2669 |
|
| 28218 |
tejbeer |
2670 |
Map<Integer, List<Integer>> authUserPartnerMapping = csService.getAuthUserIdPartnerIdMapping();
|
|
|
2671 |
|
|
|
2672 |
for (Entry<Integer, List<Integer>> authUserPartner : authUserPartnerMapping.entrySet()) {
|
| 28222 |
tejbeer |
2673 |
AuthUser authUser = authRepository.selectById(authUserPartner.getKey());
|
| 28227 |
tejbeer |
2674 |
for (Integer patnerId : authUserPartner.getValue()) {
|
|
|
2675 |
if (partnerProblemMap.get(patnerId) != null) {
|
| 28218 |
tejbeer |
2676 |
|
| 28227 |
tejbeer |
2677 |
StringBuilder sbbuilder = new StringBuilder();
|
|
|
2678 |
sbbuilder.append("<hml><body>");
|
|
|
2679 |
sb.append(
|
|
|
2680 |
"<p>Number against MTD or Investment are the count of days the MTD is low VS LMTD OR Investment is below 75%.</p><br/><p>These partners needs immediate attention.</p><br/><table style='border:1px solid black';cellspacing=0>");
|
|
|
2681 |
sbbuilder.append("<tbody>\n" + " <tr>"
|
|
|
2682 |
+ " <th style='border:1px solid black;padding: 5px'>Partner Name</th>"
|
|
|
2683 |
+ " <th style='border:1px solid black;padding: 5px'>Mtd</th>"
|
|
|
2684 |
+ " <th style='border:1px solid black;padding: 5px'>Investment</th>"
|
|
|
2685 |
+ " <th style='border:1px solid black;padding: 5px'>Stock</th>"
|
| 28218 |
tejbeer |
2686 |
|
| 28227 |
tejbeer |
2687 |
+ " </tr>");
|
| 28218 |
tejbeer |
2688 |
|
| 28227 |
tejbeer |
2689 |
for (Integer partnerId : authUserPartner.getValue()) {
|
|
|
2690 |
if (partnerProblemMap.get(partnerId) != null) {
|
|
|
2691 |
PartnerProblem pp = partnerProblemMap.get(partnerId);
|
|
|
2692 |
sbbuilder.append("<tr>");
|
|
|
2693 |
sbbuilder.append("<td style='border:1px solid black;padding: 5px'>"
|
|
|
2694 |
+ customRetailers.get(pp.getFofoId()).getBusinessName() + "</td>");
|
|
|
2695 |
sbbuilder
|
|
|
2696 |
.append("<td style='border:1px solid black;padding: 5px'>" + pp.getMtd() + "</td>");
|
|
|
2697 |
sbbuilder.append(
|
|
|
2698 |
"<td style='border:1px solid black;padding: 5px'>" + pp.getInvestment() + "</td>");
|
|
|
2699 |
sbbuilder.append("<td style='border:1px solid black;padding: 5px'>"
|
|
|
2700 |
+ pp.getStockInvestment() + "</td>");
|
|
|
2701 |
|
|
|
2702 |
sbbuilder.append("</tr>");
|
|
|
2703 |
}
|
|
|
2704 |
|
| 28224 |
tejbeer |
2705 |
}
|
| 28227 |
tejbeer |
2706 |
sbbuilder.append("</tbody></table><br><br>");
|
| 28224 |
tejbeer |
2707 |
|
| 28286 |
tejbeer |
2708 |
this.sendMailOfHtmlFormat(authUser.getEmailId(), sbbuilder.toString(), null, subject);
|
| 28230 |
tejbeer |
2709 |
break;
|
| 28218 |
tejbeer |
2710 |
}
|
| 28230 |
tejbeer |
2711 |
|
| 28223 |
tejbeer |
2712 |
}
|
| 28222 |
tejbeer |
2713 |
}
|
|
|
2714 |
}
|
| 28218 |
tejbeer |
2715 |
|
| 28222 |
tejbeer |
2716 |
private void sendMailHtmlFormat(String email[], String body, String cc[], String subject)
|
|
|
2717 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
|
|
2718 |
MimeMessage message = mailSender.createMimeMessage();
|
|
|
2719 |
MimeMessageHelper helper = new MimeMessageHelper(message);
|
|
|
2720 |
helper.setSubject(subject);
|
|
|
2721 |
helper.setText(body, true);
|
|
|
2722 |
helper.setTo(email);
|
|
|
2723 |
if (cc != null) {
|
|
|
2724 |
helper.setCc(cc);
|
| 28218 |
tejbeer |
2725 |
}
|
| 28222 |
tejbeer |
2726 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smart Dukaan");
|
|
|
2727 |
helper.setFrom(senderAddress);
|
|
|
2728 |
mailSender.send(message);
|
| 28205 |
tejbeer |
2729 |
}
|
|
|
2730 |
|
| 26418 |
tejbeer |
2731 |
}
|
| 27438 |
amit.gupta |
2732 |
//2284
|