| Line 4... |
Line 4... |
| 4 |
import java.io.Serializable;
|
4 |
import java.io.Serializable;
|
| 5 |
import java.sql.Timestamp;
|
5 |
import java.sql.Timestamp;
|
| 6 |
import java.time.LocalDate;
|
6 |
import java.time.LocalDate;
|
| 7 |
import java.time.LocalDateTime;
|
7 |
import java.time.LocalDateTime;
|
| 8 |
import java.time.LocalTime;
|
8 |
import java.time.LocalTime;
|
| 9 |
import java.time.ZoneOffset;
|
- |
|
| 10 |
import java.time.format.DateTimeFormatter;
|
9 |
import java.time.format.DateTimeFormatter;
|
| 11 |
import java.time.temporal.ChronoUnit;
|
10 |
import java.time.temporal.ChronoUnit;
|
| 12 |
import java.util.ArrayList;
|
11 |
import java.util.ArrayList;
|
| 13 |
import java.util.Arrays;
|
12 |
import java.util.Arrays;
|
| 14 |
import java.util.Collections;
|
13 |
import java.util.Collections;
|
| Line 49... |
Line 48... |
| 49 |
import com.google.gson.GsonBuilder;
|
48 |
import com.google.gson.GsonBuilder;
|
| 50 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
49 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 51 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
50 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
| 52 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
51 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
| 53 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
52 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 54 |
import com.spice.profitmandi.common.model.CatalogIdAggregateValue;
|
- |
|
| 55 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
53 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 56 |
import com.spice.profitmandi.common.model.FocusedModelShortageModel;
|
54 |
import com.spice.profitmandi.common.model.FocusedModelShortageModel;
|
| 57 |
import com.spice.profitmandi.common.model.GstRate;
|
55 |
import com.spice.profitmandi.common.model.GstRate;
|
| 58 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
56 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 59 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
57 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| - |
|
58 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 60 |
import com.spice.profitmandi.common.services.ReporticoService;
|
59 |
import com.spice.profitmandi.common.services.ReporticoService;
|
| 61 |
import com.spice.profitmandi.common.util.FileUtil;
|
60 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 62 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
61 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 63 |
import com.spice.profitmandi.common.util.Utils;
|
62 |
import com.spice.profitmandi.common.util.Utils;
|
| 64 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
63 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
| Line 69... |
Line 68... |
| 69 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
68 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 70 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
69 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 71 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
70 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 72 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
71 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
| 73 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
72 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
| 74 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaigns;
|
- |
|
| 75 |
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
|
73 |
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
|
| 76 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
74 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
| 77 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
75 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
| 78 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
76 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
| 79 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
77 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
| 80 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
- |
|
| 81 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
78 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
| 82 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
79 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
| 83 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
80 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 84 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
81 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 85 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
82 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| Line 223... |
Line 220... |
| 223 |
private SchemeService schemeService;
|
220 |
private SchemeService schemeService;
|
| 224 |
|
221 |
|
| 225 |
private static final String[] STOCK_AGEING_MAIL_LIST = new String[] { "amod.sen@smartdukaan.com",
|
222 |
private static final String[] STOCK_AGEING_MAIL_LIST = new String[] { "amod.sen@smartdukaan.com",
|
| 226 |
"adeel.yazdani@smartdukaan.com", "manoj.singh@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
223 |
"adeel.yazdani@smartdukaan.com", "manoj.singh@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| 227 |
"mohinder.mutreja@smartdukaan.com", " ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
224 |
"mohinder.mutreja@smartdukaan.com", " ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
| 228 |
"chaitnaya.vats@smartdukaan.com", "kuldeep.kumar@smartdukaan.com", "prakash.rai@smartdukaan.com" };
|
225 |
"chaitnaya.vats@smartdukaan.com", "kuldeep.kumar@smartdukaan.com", "prakash.rai@smartdukaan.com" };
|
| 229 |
|
226 |
|
| 230 |
private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[] { "kamini.sharma@smartdukaan.com",
|
227 |
private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[] { "kamini.sharma@smartdukaan.com",
|
| 231 |
"prakash.rai@smartdukaan.com", "tarun.verma@smartdukaan.com", "chaitnaya.vats@smartdukaan.com", "kuldeep.kumar@smartdukaan.com" };
|
228 |
"prakash.rai@smartdukaan.com", "tarun.verma@smartdukaan.com", "chaitnaya.vats@smartdukaan.com",
|
| - |
|
229 |
"kuldeep.kumar@smartdukaan.com" };
|
| 232 |
|
230 |
|
| 233 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
231 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 234 |
|
232 |
|
| 235 |
@Autowired
|
233 |
@Autowired
|
| 236 |
private ReporticoService reporticoService;
|
234 |
private ReporticoService reporticoService;
|
| Line 671... |
Line 669... |
| 671 |
|
669 |
|
| 672 |
}
|
670 |
}
|
| 673 |
|
671 |
|
| 674 |
public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
|
672 |
public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
|
| 675 |
if (sendTo == null) {
|
673 |
if (sendTo == null) {
|
| 676 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
674 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| 677 |
"amit.gupta@shop2020.in", "amod.sen@smartdukaan.com");
|
675 |
"prakash.rai@smartdukaan.com", "amit.gupta@shop2020.in", "amod.sen@smartdukaan.com");
|
| 678 |
}
|
676 |
}
|
| 679 |
LocalDate yesterDay = LocalDate.now().minusDays(1);
|
677 |
LocalDate yesterDay = LocalDate.now().minusDays(1);
|
| 680 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
678 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
| 681 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService
|
679 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService
|
| 682 |
.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
680 |
.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| Line 823... |
Line 821... |
| 823 |
}
|
821 |
}
|
| 824 |
|
822 |
|
| 825 |
}
|
823 |
}
|
| 826 |
|
824 |
|
| 827 |
String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
825 |
String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| - |
|
826 |
/*
|
| 828 |
/*for (Map.Entry<String, Set<String>> storeGuyEntry : csService.getAuthUserPartnerEmailMapping().entrySet()) {
|
827 |
* for (Map.Entry<String, Set<String>> storeGuyEntry :
|
| - |
|
828 |
* csService.getAuthUserPartnerEmailMapping().entrySet()) { List<List<? extends
|
| 829 |
List<List<? extends Serializable>> filteredRows = storeGuyEntry.getValue().stream()
|
829 |
* Serializable>> filteredRows = storeGuyEntry.getValue().stream() .map(x ->
|
| 830 |
.map(x -> partnerRowMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
830 |
* partnerRowMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
| 831 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
831 |
* ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers,
|
| 832 |
String[] sendToArray = new String[] { storeGuyEntry.getKey() };
|
832 |
* filteredRows); String[] sendToArray = new String[] { storeGuyEntry.getKey()
|
| 833 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA",
|
833 |
* }; Utils.sendMailWithAttachment(googleMailSender, sendToArray, null,
|
| - |
|
834 |
* "Target vs Sales Summary", "PFA", fileName, new
|
| 834 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
835 |
* ByteArrayResource(baos.toByteArray())); }
|
| 835 |
}*/
|
836 |
*/
|
| 836 |
|
837 |
|
| 837 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
838 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| 838 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
839 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
| 839 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA", fileName,
|
840 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA", fileName,
|
| 840 |
new ByteArrayResource(baos.toByteArray()));
|
841 |
new ByteArrayResource(baos.toByteArray()));
|
| Line 1340... |
Line 1341... |
| 1340 |
partnerTargetDetail.getBrandName());
|
1341 |
partnerTargetDetail.getBrandName());
|
| 1341 |
dailyTarget.put(fofoId, dailyAverageSale.get(fofoId));
|
1342 |
dailyTarget.put(fofoId, dailyAverageSale.get(fofoId));
|
| 1342 |
break;
|
1343 |
break;
|
| 1343 |
}
|
1344 |
}
|
| 1344 |
}
|
1345 |
}
|
| 1345 |
NotificationCampaigns notification = new NotificationCampaigns();
|
1346 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 1346 |
notification.setName("Daily Sales");
|
- |
|
| 1347 |
notification.setTitle("Daily Sale Update");
|
1347 |
sendNotificationModel.setCampaignName("Sales update alert");
|
| 1348 |
if (dailyAverageSale != null && dailyAverageSale.get(fofoId) != null) {
|
1348 |
if (dailyAverageSale != null && dailyAverageSale.get(fofoId) != null) {
|
| 1349 |
notification.setMessage(String.format("Rs.%.0f till %s. Today's Target is Rs.%.0f", sale,
|
1349 |
sendNotificationModel.setMessage(String.format("Rs.%.0f till %s. Today's Target is Rs.%.0f", sale,
|
| 1350 |
now.format(timeFormatter), dailyAverageSale.get(fofoId)));
|
1350 |
now.format(timeFormatter), dailyAverageSale.get(fofoId)));
|
| 1351 |
} else {
|
1351 |
} else {
|
| 1352 |
notification.setMessage(String.format("Rs.%.0f till %s", sale, now.format(timeFormatter)));
|
1352 |
sendNotificationModel.setMessage(String.format("Rs.%.0f till %s", sale, now.format(timeFormatter)));
|
| 1353 |
}
|
1353 |
}
|
| 1354 |
// notification.setMessage("Your sale is "+salesbyfofoId.get(fofoId));
|
- |
|
| 1355 |
notification.setType("url");
|
1354 |
sendNotificationModel.setType("url");
|
| 1356 |
notification.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
1355 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
| 1357 |
LOGGER.info("UserID" + userAccountRepository.selectUserIdByRetailerId(fofoId));
|
- |
|
| 1358 |
notification.setSql("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
|
- |
|
| 1359 |
+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
|
- |
|
| 1360 |
+ " where d2.id is null and d1.user_id = "
|
- |
|
| 1361 |
+ userAccountRepository.selectUserIdByRetailerId(fofoId));
|
- |
|
| 1362 |
LOGGER.info("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
|
- |
|
| 1363 |
+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
|
- |
|
| 1364 |
+ " where d2.id is null and d1.user_id = "
|
- |
|
| 1365 |
+ userAccountRepository.selectUserIdByRetailerId(fofoId));
|
- |
|
| 1366 |
notification.setExpiresat(LocalDateTime.now().plusDays(1).toEpochSecond(ZoneOffset.UTC) * 1000);
|
1356 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 1367 |
notification.setStatus("active");
|
- |
|
| 1368 |
notification.setSmsprocessed(0);
|
- |
|
| 1369 |
notification.setNotification_processed(0);
|
- |
|
| 1370 |
notification.setNotification_type("GENERAL_NOTIFICATION");
|
- |
|
| 1371 |
mongoClient.persistNotificationCmpInfo(notification);
|
1357 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 1372 |
salesByFofoIdMap.put(fofoId, sale);
|
1358 |
salesByFofoIdMap.put(fofoId, sale);
|
| 1373 |
LOGGER.info(sale);
|
1359 |
LOGGER.info(sale);
|
| 1374 |
}
|
1360 |
}
|
| 1375 |
String saleReport = this.getDailySalesReportByPartnerId(salesByFofoIdMap, dailyTarget);
|
1361 |
String saleReport = this.getDailySalesReportByPartnerId(salesByFofoIdMap, dailyTarget);
|
| 1376 |
LOGGER.info(saleReport);
|
1362 |
LOGGER.info(saleReport);
|
| 1377 |
String cc[] = { "Tarun.verma@smartdukaan.com", "Kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
1363 |
String cc[] = {};/*{ "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
| 1378 |
"chaitnaya.vats@smartdukaan.com", "adeel.yazdani@smartdukaan.com", "mohinder.mutreja@smartdukaan.com" };
|
1364 |
"chaitnaya.vats@smartdukaan.com", "adeel.yazdani@smartdukaan.com", "mohinder.mutreja@smartdukaan.com" };*/
|
| 1379 |
String subject = "sale report till" + " " + now.format(timeFormatter);
|
1365 |
String subject = "sale report till" + " " + now.format(timeFormatter);
|
| - |
|
1366 |
this.sendMailOfHtmlFomat("amit.gupta@shop2020.in", saleReport, cc, subject);
|
| 1380 |
this.sendMailOfHtmlFomat("amod.sen@smartdukaan.com", saleReport, cc, subject);
|
1367 |
//this.sendMailOfHtmlFomat("amod.sen@smartdukaan.com", saleReport, cc, subject);
|
| 1381 |
}
|
1368 |
}
|
| 1382 |
|
1369 |
|
| 1383 |
public String getDailySalesReportByPartnerId(Map<Integer, Double> salesByFofoIdMap, Map<Integer, Float> dailyTarget)
|
1370 |
public String getDailySalesReportByPartnerId(Map<Integer, Double> salesByFofoIdMap, Map<Integer, Float> dailyTarget)
|
| 1384 |
throws ProfitMandiBusinessException {
|
1371 |
throws ProfitMandiBusinessException {
|
| 1385 |
StringBuilder sb = new StringBuilder();
|
1372 |
StringBuilder sb = new StringBuilder();
|