| Line 88... |
Line 88... |
| 88 |
import com.spice.profitmandi.dao.entity.transaction.PriceDropIMEI;
|
88 |
import com.spice.profitmandi.dao.entity.transaction.PriceDropIMEI;
|
| 89 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
89 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 90 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
90 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 91 |
import com.spice.profitmandi.dao.entity.user.Address;
|
91 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 92 |
import com.spice.profitmandi.dao.entity.user.Device;
|
92 |
import com.spice.profitmandi.dao.entity.user.Device;
|
| - |
|
93 |
import com.spice.profitmandi.dao.entity.user.FranchiseeVisit;
|
| 93 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
94 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
| 94 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
95 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 95 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
96 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 96 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
97 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 97 |
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
|
98 |
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
|
| Line 104... |
Line 105... |
| 104 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
105 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 105 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
106 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 106 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
107 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 107 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
108 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
| 108 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
109 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
110 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeActivityRepository;
|
| - |
|
111 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeVisitRepository;
|
| 109 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
112 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
| 110 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
113 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 111 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
114 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 112 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
115 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
| 113 |
import com.spice.profitmandi.dao.repository.dtr.PushNotificationRepository;
|
116 |
import com.spice.profitmandi.dao.repository.dtr.PushNotificationRepository;
|
| Line 149... |
Line 152... |
| 149 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
152 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 150 |
import com.spice.profitmandi.service.user.RetailerService;
|
153 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 151 |
import com.spice.profitmandi.service.wallet.WalletService;
|
154 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 152 |
|
155 |
|
| 153 |
import in.shop2020.model.v1.order.OrderStatus;
|
156 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 154 |
import in.shop2020.model.v1.order.WalletReferenceType;;
|
157 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| - |
|
158 |
import javassist.tools.framedump;;
|
| 155 |
|
159 |
|
| 156 |
@Component
|
160 |
@Component
|
| 157 |
@Transactional(rollbackFor = Throwable.class)
|
161 |
@Transactional(rollbackFor = Throwable.class)
|
| 158 |
public class ScheduledTasks {
|
162 |
public class ScheduledTasks {
|
| 159 |
|
163 |
|
| Line 166... |
Line 170... |
| 166 |
@Autowired
|
170 |
@Autowired
|
| 167 |
private PartnerTypeChangeService partnerTypeChangeService;
|
171 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 168 |
|
172 |
|
| 169 |
@Autowired
|
173 |
@Autowired
|
| 170 |
private LeadRepository leadRepository;
|
174 |
private LeadRepository leadRepository;
|
| 171 |
|
175 |
|
| 172 |
@Autowired
|
176 |
@Autowired
|
| 173 |
private AuthRepository authRepository;
|
177 |
private AuthRepository authRepository;
|
| 174 |
|
178 |
|
| 175 |
@Autowired
|
179 |
@Autowired
|
| 176 |
private PriceDropService priceDropService;
|
180 |
private PriceDropService priceDropService;
|
| - |
|
181 |
|
| - |
|
182 |
@Autowired
|
| - |
|
183 |
private FranchiseeVisitRepository franchiseeVisitRepository;
|
| 177 |
|
184 |
|
| - |
|
185 |
@Autowired
|
| - |
|
186 |
private FranchiseeActivityRepository franchiseeActivityRepository;
|
| - |
|
187 |
|
| 178 |
@Autowired
|
188 |
@Autowired
|
| 179 |
private CsService csService;
|
189 |
private CsService csService;
|
| 180 |
|
190 |
|
| 181 |
@Autowired
|
191 |
@Autowired
|
| 182 |
private InsurancePolicyRepository insurancePolicyRepository;
|
192 |
private InsurancePolicyRepository insurancePolicyRepository;
|
| Line 234... |
Line 244... |
| 234 |
private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[] { "kamini.sharma@smartdukaan.com",
|
244 |
private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[] { "kamini.sharma@smartdukaan.com",
|
| 235 |
"prakash.rai@smartdukaan.com", "tarun.verma@smartdukaan.com", "chaitnaya.vats@smartdukaan.com",
|
245 |
"prakash.rai@smartdukaan.com", "tarun.verma@smartdukaan.com", "chaitnaya.vats@smartdukaan.com",
|
| 236 |
"kuldeep.kumar@smartdukaan.com" };
|
246 |
"kuldeep.kumar@smartdukaan.com" };
|
| 237 |
|
247 |
|
| 238 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
248 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 239 |
|
249 |
|
| 240 |
private Object[] REPORT_HEADERS = {"Store Code", "Firm Name", "Store Name", "State Manager", "Teritory Manager"};
|
250 |
private Object[] REPORT_HEADERS = { "Store Code", "Firm Name", "Store Name", "State Manager", "Teritory Manager" };
|
| 241 |
|
251 |
|
| 242 |
@Autowired
|
252 |
@Autowired
|
| 243 |
private ReporticoService reporticoService;
|
253 |
private ReporticoService reporticoService;
|
| 244 |
|
254 |
|
| 245 |
@Autowired
|
255 |
@Autowired
|
| Line 368... |
Line 378... |
| 368 |
|
378 |
|
| 369 |
@Autowired
|
379 |
@Autowired
|
| 370 |
private UserAccountRepository userAccountRepository;
|
380 |
private UserAccountRepository userAccountRepository;
|
| 371 |
|
381 |
|
| 372 |
@Autowired
|
382 |
@Autowired
|
| 373 |
private UserRepository userRepository;
|
383 |
private UserRepository userUserRepository;
|
| - |
|
384 |
|
| - |
|
385 |
@Autowired
|
| - |
|
386 |
private com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
|
| 374 |
|
387 |
|
| 375 |
@Autowired
|
388 |
@Autowired
|
| 376 |
private UserCampaignRepository userCampaignRepository;
|
389 |
private UserCampaignRepository userCampaignRepository;
|
| 377 |
|
390 |
|
| 378 |
@Autowired
|
391 |
@Autowired
|
| Line 701... |
Line 714... |
| 701 |
if (retailer == null || partnerIdSalesHeaderMap.get(fofoStore.getId()) == null) {
|
714 |
if (retailer == null || partnerIdSalesHeaderMap.get(fofoStore.getId()) == null) {
|
| 702 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
715 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
| 703 |
continue;
|
716 |
continue;
|
| 704 |
}
|
717 |
}
|
| 705 |
List<Serializable> row = partnerIdSalesHeaderMap.get(fofoStore.getId());
|
718 |
List<Serializable> row = partnerIdSalesHeaderMap.get(fofoStore.getId());
|
| - |
|
719 |
row.addAll(
|
| 706 |
row.addAll(Arrays.asList(partnerDailyInvestment.getWalletAmount(), partnerDailyInvestment.getInStockAmount(), 0,
|
720 |
Arrays.asList(partnerDailyInvestment.getWalletAmount(), partnerDailyInvestment.getInStockAmount(),
|
| 707 |
partnerDailyInvestment.getUnbilledAmount(), partnerDailyInvestment.getGrnPendingAmount(),
|
721 |
0, partnerDailyInvestment.getUnbilledAmount(), partnerDailyInvestment.getGrnPendingAmount(),
|
| 708 |
partnerDailyInvestment.getMinInvestment(), partnerDailyInvestment.getTotalInvestment(),
|
722 |
partnerDailyInvestment.getMinInvestment(), partnerDailyInvestment.getTotalInvestment(),
|
| 709 |
partnerDailyInvestment.getShortInvestment(), partnerDailyInvestment.getUnbilledQty()));
|
723 |
partnerDailyInvestment.getShortInvestment(), partnerDailyInvestment.getUnbilledQty()));
|
| 710 |
partnerRowsMap.put(fofoStore.getId(), row);
|
724 |
partnerRowsMap.put(fofoStore.getId(), row);
|
| 711 |
rows.add(row);
|
725 |
rows.add(row);
|
| 712 |
|
726 |
|
| 713 |
}
|
727 |
}
|
| 714 |
|
728 |
|
| 715 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
729 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 716 |
|
730 |
|
| 717 |
if(sendTo==null) {
|
731 |
if (sendTo == null) {
|
| 718 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
732 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
| 719 |
List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x))
|
733 |
List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x))
|
| 720 |
.filter(x -> x != null).collect(Collectors.toList());
|
734 |
.filter(x -> x != null).collect(Collectors.toList());
|
| 721 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
735 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
| 722 |
String[] sendToArray = new String[] { storeGuyEntry.getKey() };
|
736 |
String[] sendToArray = new String[] { storeGuyEntry.getKey() };
|
| Line 724... |
Line 738... |
| 724 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
738 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
| 725 |
}
|
739 |
}
|
| 726 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
740 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| 727 |
"prakash.rai@smartdukaan.com", "amit.gupta@shop2020.in", "amod.sen@smartdukaan.com");
|
741 |
"prakash.rai@smartdukaan.com", "amit.gupta@shop2020.in", "amod.sen@smartdukaan.com");
|
| 728 |
}
|
742 |
}
|
| 729 |
|
- |
|
| 730 |
|
743 |
|
| 731 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
744 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| 732 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
745 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
| 733 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
746 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
| 734 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
747 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
| Line 772... |
Line 785... |
| 772 |
|
785 |
|
| 773 |
Map<Integer, List<Serializable>> partnerIdSalesHeadersMap = new HashMap<>();
|
786 |
Map<Integer, List<Serializable>> partnerIdSalesHeadersMap = new HashMap<>();
|
| 774 |
|
787 |
|
| 775 |
for (CustomRetailer cr : allCrList) {
|
788 |
for (CustomRetailer cr : allCrList) {
|
| 776 |
FofoStore fofoStore = fofoStoresMap.get(cr.getPartnerId());
|
789 |
FofoStore fofoStore = fofoStoresMap.get(cr.getPartnerId());
|
| 777 |
if(fofoStore==null) {
|
790 |
if (fofoStore == null) {
|
| 778 |
LOGGER.info("Could not find Store {} in active Store", cr.getBusinessName());
|
791 |
LOGGER.info("Could not find Store {} in active Store", cr.getBusinessName());
|
| 779 |
continue;
|
792 |
continue;
|
| 780 |
}
|
793 |
}
|
| 781 |
String code = fofoStore.getCode() + "";
|
794 |
String code = fofoStore.getCode() + "";
|
| 782 |
String storeName = "SmartDukaan-" + fofoStore.getCode().replaceAll("[a-zA-Z]", "");
|
795 |
String storeName = "SmartDukaan-" + fofoStore.getCode().replaceAll("[a-zA-Z]", "");
|
| Line 829... |
Line 842... |
| 829 |
String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
842 |
String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 830 |
Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
|
843 |
Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
|
| 831 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
|
844 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
|
| 832 |
if (storeGuyEntry.getValue().size() == 0)
|
845 |
if (storeGuyEntry.getValue().size() == 0)
|
| 833 |
continue;
|
846 |
continue;
|
| 834 |
List<List<?>> storeGuyRows = storeGuyEntry.getValue().stream().filter(x -> partnerRowMap.containsKey(x)).map(x -> partnerRowMap.get(x))
|
847 |
List<List<?>> storeGuyRows = storeGuyEntry.getValue().stream().filter(x -> partnerRowMap.containsKey(x))
|
| 835 |
.collect(Collectors.toList());
|
848 |
.map(x -> partnerRowMap.get(x)).collect(Collectors.toList());
|
| 836 |
ByteArrayOutputStream authUserStream = FileUtil.getCSVByteStream(headers, storeGuyRows);
|
849 |
ByteArrayOutputStream authUserStream = FileUtil.getCSVByteStream(headers, storeGuyRows);
|
| 837 |
Attachment attache = new Attachment(fileName, new ByteArrayResource(authUserStream.toByteArray()));
|
850 |
Attachment attache = new Attachment(fileName, new ByteArrayResource(authUserStream.toByteArray()));
|
| 838 |
System.out.println(storeGuyEntry.getValue());
|
851 |
System.out.println(storeGuyEntry.getValue());
|
| 839 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { storeGuyEntry.getKey() }, null,
|
852 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { storeGuyEntry.getKey() }, null,
|
| 840 |
"Franchise Stock Report", "PFA", attache);
|
853 |
"Franchise Stock Report", "PFA", attache);
|
| Line 1313... |
Line 1326... |
| 1313 |
|
1326 |
|
| 1314 |
}
|
1327 |
}
|
| 1315 |
|
1328 |
|
| 1316 |
public void sendDailySalesNotificationToPartner(Integer fofoIdInt)
|
1329 |
public void sendDailySalesNotificationToPartner(Integer fofoIdInt)
|
| 1317 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
1330 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
| 1318 |
|
1331 |
|
| 1319 |
LocalDateTime now = LocalDateTime.now();
|
1332 |
LocalDateTime now = LocalDateTime.now();
|
| 1320 |
LocalDateTime from = now.with(LocalTime.MIN);
|
1333 |
LocalDateTime from = now.with(LocalTime.MIN);
|
| 1321 |
String timeString = "Today %s";
|
1334 |
String timeString = "Today %s";
|
| 1322 |
//Send yesterday's report
|
1335 |
// Send yesterday's report
|
| 1323 |
if(now.getHour() < 13) {
|
1336 |
if (now.getHour() < 13) {
|
| 1324 |
timeString = "Yesterday %s";
|
1337 |
timeString = "Yesterday %s";
|
| 1325 |
from = now.minusDays(1);
|
1338 |
from = now.minusDays(1);
|
| 1326 |
now = from.with(LocalTime.MAX);
|
1339 |
now = from.with(LocalTime.MAX);
|
| 1327 |
|
1340 |
|
| 1328 |
}
|
1341 |
}
|
| 1329 |
List<Integer> fofoIds = null;
|
1342 |
List<Integer> fofoIds = null;
|
| 1330 |
if (fofoIdInt == null) {
|
1343 |
if (fofoIdInt == null) {
|
| 1331 |
fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
|
1344 |
fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
|
| 1332 |
.collect(Collectors.toList());
|
1345 |
.collect(Collectors.toList());
|
| Line 1343... |
Line 1356... |
| 1343 |
0, true);
|
1356 |
0, true);
|
| 1344 |
Map<Integer, Long> partnerOrderQtyMap = fofoOrderItemRepository.selectQtyGroupByRetailer(from, now, 0, true);
|
1357 |
Map<Integer, Long> partnerOrderQtyMap = fofoOrderItemRepository.selectQtyGroupByRetailer(from, now, 0, true);
|
| 1345 |
Map<Integer, SaleTargetReportModel> saleTargetReportModelMap = new HashMap<>();
|
1358 |
Map<Integer, SaleTargetReportModel> saleTargetReportModelMap = new HashMap<>();
|
| 1346 |
for (int fofoId : fofoIds) {
|
1359 |
for (int fofoId : fofoIds) {
|
| 1347 |
SaleTargetReportModel model = new SaleTargetReportModel();
|
1360 |
SaleTargetReportModel model = new SaleTargetReportModel();
|
| - |
|
1361 |
model.setInsuranceSale(
|
| 1348 |
model.setInsuranceSale(partnerPolicyAmountMap.containsKey(fofoId) ? partnerPolicyAmountMap.get(fofoId).doubleValue() : 0);
|
1362 |
partnerPolicyAmountMap.containsKey(fofoId) ? partnerPolicyAmountMap.get(fofoId).doubleValue() : 0);
|
| 1349 |
model.setInsruanceQty(partnerPolicyQtyMap.containsKey(fofoId) ? partnerPolicyQtyMap.get(fofoId) : 0);
|
1363 |
model.setInsruanceQty(partnerPolicyQtyMap.containsKey(fofoId) ? partnerPolicyQtyMap.get(fofoId) : 0);
|
| 1350 |
model.setSmartphoneSale(partnerOrderAmountMap.containsKey(fofoId) ? partnerOrderAmountMap.get(fofoId) : 0);
|
1364 |
model.setSmartphoneSale(partnerOrderAmountMap.containsKey(fofoId) ? partnerOrderAmountMap.get(fofoId) : 0);
|
| 1351 |
model.setSmartphoneQty(partnerOrderQtyMap.containsKey(fofoId) ? partnerOrderQtyMap.get(fofoId) : 0);
|
1365 |
model.setSmartphoneQty(partnerOrderQtyMap.containsKey(fofoId) ? partnerOrderQtyMap.get(fofoId) : 0);
|
| 1352 |
model.setTotalSale(salesByFofoIdMap.containsKey(fofoId) ? salesByFofoIdMap.get(fofoId) : 0);
|
1366 |
model.setTotalSale(salesByFofoIdMap.containsKey(fofoId) ? salesByFofoIdMap.get(fofoId) : 0);
|
| 1353 |
model.setFofoId(fofoId);
|
1367 |
model.setFofoId(fofoId);
|
| Line 1358... |
Line 1372... |
| 1358 |
for (Integer fofoId : fofoIds) {
|
1372 |
for (Integer fofoId : fofoIds) {
|
| 1359 |
SaleTargetReportModel model = saleTargetReportModelMap.get(fofoId);
|
1373 |
SaleTargetReportModel model = saleTargetReportModelMap.get(fofoId);
|
| 1360 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
1374 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 1361 |
sendNotificationModel.setCampaignName("Sales update alert");
|
1375 |
sendNotificationModel.setCampaignName("Sales update alert");
|
| 1362 |
sendNotificationModel.setTitle("Sale Update");
|
1376 |
sendNotificationModel.setTitle("Sale Update");
|
| 1363 |
sendNotificationModel.setMessage(String.format(
|
1377 |
sendNotificationModel
|
| 1364 |
"Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.", model.getSmartphoneSale(),
|
1378 |
.setMessage(String.format("Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.",
|
| - |
|
1379 |
model.getSmartphoneSale(), model.getInsuranceSale(), model.getTotalSale(),
|
| 1365 |
model.getInsuranceSale(), model.getTotalSale(), String.format(timeString, now.format(timeFormatter))));
|
1380 |
String.format(timeString, now.format(timeFormatter))));
|
| 1366 |
sendNotificationModel.setType("url");
|
1381 |
sendNotificationModel.setType("url");
|
| 1367 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
1382 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
| 1368 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
1383 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 1369 |
sendNotificationModel.setMessageType(MessageType.notification);
|
1384 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 1370 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
1385 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
| Line 1504... |
Line 1519... |
| 1504 |
+ " <th style='border:1px solid black;padding: 5px'>Insurance Sale</th>\n"
|
1519 |
+ " <th style='border:1px solid black;padding: 5px'>Insurance Sale</th>\n"
|
| 1505 |
+ " <th style='border:1px solid black;padding: 5px'>Insurance Qty</th>\n"
|
1520 |
+ " <th style='border:1px solid black;padding: 5px'>Insurance Qty</th>\n"
|
| 1506 |
+ " </tr>");
|
1521 |
+ " </tr>");
|
| 1507 |
List<Integer> sortedPartnerSalesHeaders = partnerSalesHeadersMap.entrySet().stream()
|
1522 |
List<Integer> sortedPartnerSalesHeaders = partnerSalesHeadersMap.entrySet().stream()
|
| 1508 |
.sorted((x, y) -> ((String) (x.getValue().get(3))).compareTo((String) (y.getValue().get(3))))
|
1523 |
.sorted((x, y) -> ((String) (x.getValue().get(3))).compareTo((String) (y.getValue().get(3))))
|
| 1509 |
.map(x->x.getKey()).collect(Collectors.toList());
|
1524 |
.map(x -> x.getKey()).collect(Collectors.toList());
|
| 1510 |
for (Integer fofoId : sortedPartnerSalesHeaders)
|
1525 |
for (Integer fofoId : sortedPartnerSalesHeaders) {
|
| 1511 |
{
|
- |
|
| 1512 |
sb.append("<tr>");
|
1526 |
sb.append("<tr>");
|
| 1513 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + partnerSalesHeadersMap.get(fofoId).get(0)
|
1527 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + partnerSalesHeadersMap.get(fofoId).get(0)
|
| 1514 |
+ "</td>");
|
1528 |
+ "</td>");
|
| 1515 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + partnerSalesHeadersMap.get(fofoId).get(1)
|
1529 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + partnerSalesHeadersMap.get(fofoId).get(1)
|
| 1516 |
+ "</td>");
|
1530 |
+ "</td>");
|
| Line 1933... |
Line 1947... |
| 1933 |
sb.append("</tbody></table></body></html>");
|
1947 |
sb.append("</tbody></table></body></html>");
|
| 1934 |
|
1948 |
|
| 1935 |
return sb.toString();
|
1949 |
return sb.toString();
|
| 1936 |
}
|
1950 |
}
|
| 1937 |
|
1951 |
|
| 1938 |
public void notifyLead() throws Exception{
|
1952 |
public void notifyLead() throws Exception {
|
| 1939 |
List<Lead> leadsToNotify = leadRepository.selectLeadsScheduledBetweenDate(LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(2));
|
1953 |
List<Lead> leadsToNotify = leadRepository.selectLeadsScheduledBetweenDate(LocalDateTime.now().minusDays(15),
|
| - |
|
1954 |
LocalDateTime.now().plusHours(4));
|
| - |
|
1955 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream()
|
| - |
|
1956 |
.collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
| - |
|
1957 |
Map<String, Integer> dtrEmailMap = dtrUserRepository
|
| - |
|
1958 |
.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream()
|
| - |
|
1959 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
| - |
|
1960 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
| - |
|
1961 |
|
| - |
|
1962 |
for (Map.Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
| - |
|
1963 |
int authId = authUserEmail.getKey();
|
| - |
|
1964 |
String email = authUserEmail.getValue();
|
| - |
|
1965 |
authUserKeyMap.put(authId, dtrEmailMap.get(email));
|
| 1940 |
|
1966 |
}
|
| - |
|
1967 |
String templateMessage = "Lead followup for %s %s, %s is due by %s";
|
| - |
|
1968 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
|
| - |
|
1969 |
for (Lead lead : leadsToNotify) {
|
| - |
|
1970 |
if (authUserKeyMap.get(lead.getAuthId()) == null) {
|
| - |
|
1971 |
continue;
|
| - |
|
1972 |
}
|
| - |
|
1973 |
String notificationMessage = String.format(templateMessage, lead.getFirstName(), lead.getLastName(),
|
| - |
|
1974 |
lead.getAddress(), String.format(templateMessage,
|
| - |
|
1975 |
timeFormatter.format(lead.getLeadActivity().getSchelduleTimestamp())));
|
| - |
|
1976 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
1977 |
sendNotificationModel.setCampaignName("Lead Reminder");
|
| - |
|
1978 |
sendNotificationModel.setTitle("Leads followup Reminder");
|
| - |
|
1979 |
sendNotificationModel.setMessage(notificationMessage);
|
| - |
|
1980 |
sendNotificationModel.setType("url");
|
| - |
|
1981 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
| - |
|
1982 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
| - |
|
1983 |
sendNotificationModel.setMessageType(MessageType.reminder);
|
| - |
|
1984 |
sendNotificationModel.setUserIds(Arrays.asList(authUserKeyMap.get(lead.getAuthId())));
|
| - |
|
1985 |
notificationService.sendNotification(sendNotificationModel);
|
| 1941 |
|
1986 |
}
|
| 1942 |
|
1987 |
}
|
| - |
|
1988 |
public void notifyVisits() throws Exception {
|
| - |
|
1989 |
List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository.selectVisitsScheduledBetweenDate(LocalDateTime.now().minusDays(15),
|
| - |
|
1990 |
LocalDateTime.now().plusHours(4));
|
| - |
|
1991 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream()
|
| - |
|
1992 |
.collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
| - |
|
1993 |
Map<String, Integer> dtrEmailMap = dtrUserRepository
|
| - |
|
1994 |
.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream()
|
| - |
|
1995 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
| - |
|
1996 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
| 1943 |
|
1997 |
|
| - |
|
1998 |
for (Map.Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
| - |
|
1999 |
int authId = authUserEmail.getKey();
|
| 1944 |
String notificationMessage = "";
|
2000 |
String email = authUserEmail.getValue();
|
| - |
|
2001 |
authUserKeyMap.put(authId, dtrEmailMap.get(email));
|
| - |
|
2002 |
}
|
| - |
|
2003 |
String visitTemplate = "Planned visit to franchisee %s is due by %s";
|
| - |
|
2004 |
String followupTemplate = "Lead followup for franchisee %s is due by %s";
|
| - |
|
2005 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("MMM 7, EEEE h:m a");
|
| - |
|
2006 |
for (FranchiseeVisit visit : franchiseeVisits) {
|
| - |
|
2007 |
if (authUserKeyMap.containsKey(visit.getAuthId())) {
|
| - |
|
2008 |
continue;
|
| - |
|
2009 |
}
|
| 1945 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
2010 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
2011 |
String message = null;
|
| - |
|
2012 |
if(visit.getFranchiseActivityId()==0) {
|
| - |
|
2013 |
message = String.format(visitTemplate, visit.getPartnerName(), timeFormatter.format(visit.getSchelduleTimestamp()));
|
| 1946 |
sendNotificationModel.setCampaignName("Stock Alert");
|
2014 |
sendNotificationModel.setCampaignName("Franchisee visit Reminder");
|
| - |
|
2015 |
} else {
|
| - |
|
2016 |
message = String.format(followupTemplate, visit.getPartnerName(), timeFormatter.format(visit.getSchelduleTimestamp()));
|
| 1947 |
sendNotificationModel.setTitle("Alert");
|
2017 |
sendNotificationModel.setCampaignName("Franchisee followup Reminder");
|
| - |
|
2018 |
}
|
| 1948 |
sendNotificationModel.setMessage(notificationMessage);
|
2019 |
sendNotificationModel.setMessage(message);
|
| 1949 |
sendNotificationModel.setType("url");
|
2020 |
sendNotificationModel.setType("url");
|
| 1950 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
2021 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
| 1951 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
2022 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
| 1952 |
sendNotificationModel.setMessageType(MessageType.reminder);
|
2023 |
sendNotificationModel.setMessageType(MessageType.reminder);
|
| 1953 |
int userId = userAccountRepository.selectUserIdByRetailerId(0);
|
- |
|
| 1954 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
2024 |
sendNotificationModel.setUserIds(Arrays.asList(authUserKeyMap.get(visit.getAuthId())));
|
| 1955 |
notificationService.sendNotification(sendNotificationModel);
|
2025 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
2026 |
}
|
| 1956 |
}
|
2027 |
}
|
| - |
|
2028 |
|
| - |
|
2029 |
|
| 1957 |
|
2030 |
|
| 1958 |
}
|
2031 |
}
|
| 1959 |
|
2032 |
|