| Line 910... |
Line 910... |
| 910 |
|
910 |
|
| 911 |
LocalDateTime startDate = LocalDate.of(2018, 9, 1).atStartOfDay();
|
911 |
LocalDateTime startDate = LocalDate.of(2018, 9, 1).atStartOfDay();
|
| 912 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
912 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
| 913 |
List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
|
913 |
List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
|
| 914 |
|
914 |
|
| 915 |
Map<Integer, String> storeNameMap = fofoStoreRepository.getStoresMap();
|
- |
|
| 916 |
purchases.stream().forEach(purchase -> {
|
915 |
purchases.stream().forEach(purchase -> {
|
| 917 |
float amountToRollback = 0;
|
916 |
float amountToRollback = 0;
|
| 918 |
String description = "Adjustment of Duplicate Scheme for Purchase Invoice "
|
917 |
String description = "Adjustment of Duplicate Scheme for Purchase Invoice "
|
| 919 |
+ purchase.getPurchaseReference();
|
918 |
+ purchase.getPurchaseReference();
|
| 920 |
Map<Integer, String> inventorySerialNumberMap = inventoryItemRepository.selectByPurchaseId(purchase.getId())
|
919 |
Map<Integer, String> inventorySerialNumberMap = inventoryItemRepository.selectByPurchaseId(purchase.getId())
|
| Line 956... |
Line 955... |
| 956 |
}
|
955 |
}
|
| 957 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
956 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 958 |
amountToRollback += sio.getAmount();
|
957 |
amountToRollback += sio.getAmount();
|
| 959 |
// sio.setSchemeType(SchemeType.OUT);
|
958 |
// sio.setSchemeType(SchemeType.OUT);
|
| 960 |
sio.setSerialNumber(serialNumber);
|
959 |
sio.setSerialNumber(serialNumber);
|
| 961 |
sio.setStoreCode(storeNameMap.get(purchase.getFofoId()));
|
- |
|
| 962 |
sio.setReference(purchase.getId());
|
- |
|
| 963 |
rolledbackSios.add(sio);
|
960 |
rolledbackSios.add(sio);
|
| 964 |
}
|
961 |
}
|
| 965 |
}
|
962 |
}
|
| 966 |
|
963 |
|
| 967 |
}
|
964 |
}
|
| 968 |
}
|
965 |
}
|
| 969 |
if (amountToRollback > 0) {
|
966 |
if (amountToRollback > 0) {
|
| 970 |
//Address address = addressRepository.selectAllByRetailerId(purchase.getFofoId(), 0, 10).get(0);
|
967 |
Address address = addressRepository.selectAllByRetailerId(purchase.getFofoId(), 0, 10).get(0);
|
| 971 |
UserWalletHistory uwh = new UserWalletHistory();
|
968 |
UserWalletHistory uwh = new UserWalletHistory();
|
| 972 |
uwh.setAmount(Math.round(amountToRollback));
|
969 |
uwh.setAmount(Math.round(amountToRollback));
|
| 973 |
uwh.setDescription(description);
|
970 |
uwh.setDescription(description);
|
| 974 |
uwh.setTimestamp(LocalDateTime.now());
|
971 |
uwh.setTimestamp(LocalDateTime.now());
|
| 975 |
uwh.setReferenceType(WalletReferenceType.SCHEME_IN);
|
972 |
uwh.setReferenceType(WalletReferenceType.SCHEME_OUT);
|
| 976 |
uwh.setReference(purchase.getId());
|
973 |
uwh.setReference(purchase.getId());
|
| 977 |
uwh.setWalletId(userWalletMap.get(purchase.getFofoId()));
|
974 |
uwh.setWalletId(userWalletMap.get(purchase.getFofoId()));
|
| 978 |
uwh.setFofoId(purchase.getFofoId());
|
975 |
uwh.setFofoId(purchase.getFofoId());
|
| 979 |
uwh.setStoreCode(storeNameMap.get(purchase.getFofoId()));
|
976 |
uwh.setStoreCode(address.getName());
|
| 980 |
userWalletHistory.add(uwh);
|
977 |
userWalletHistory.add(uwh);
|
| 981 |
}
|
978 |
}
|
| 982 |
});
|
979 |
});
|
| 983 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
980 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| 984 |
Arrays.asList("User Id", "Store Code", "Reference Type", "Reference", "Amount", "Description",
|
981 |
Arrays.asList("User Id", "Store Code", "Reference Type", "Reference", "Amount", "Description",
|
| Line 987... |
Line 984... |
| 987 |
.map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(),
|
984 |
.map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(),
|
| 988 |
x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
|
985 |
x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
|
| 989 |
.collect(Collectors.toList()));
|
986 |
.collect(Collectors.toList()));
|
| 990 |
|
987 |
|
| 991 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
988 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
| 992 |
Arrays.asList("Scheme ID", "SchemeType", "Reference", "Store Code", "Serial Number", "Amount", "Created",
|
989 |
Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created",
|
| 993 |
"Rolledback"),
|
990 |
"Rolledback"),
|
| 994 |
rolledbackSios.stream()
|
991 |
rolledbackSios.stream()
|
| 995 |
.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getReference(), x.getStoreCode(),
|
992 |
.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
|
| 996 |
x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
|
993 |
x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
|
| 997 |
.collect(Collectors.toList()));
|
994 |
.collect(Collectors.toList()));
|
| 998 |
|
995 |
|
| 999 |
Utils.sendMailWithAttachments(googleMailSender,
|
996 |
Utils.sendMailWithAttachments(googleMailSender,
|
| 1000 |
new String[] { "amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com" }, null,
|
997 |
new String[] { "amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com" }, null,
|
| Line 1046... |
Line 1043... |
| 1046 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
1043 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 1047 |
amountToRollback += sio.getAmount();
|
1044 |
amountToRollback += sio.getAmount();
|
| 1048 |
// sio.setSchemeType(SchemeType.OUT);
|
1045 |
// sio.setSchemeType(SchemeType.OUT);
|
| 1049 |
sio.setSerialNumber(serialNumber);
|
1046 |
sio.setSerialNumber(serialNumber);
|
| 1050 |
sio.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
1047 |
sio.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
| 1051 |
sio.setReference(fofoOrder.getId());
|
- |
|
| 1052 |
rolledbackSios.add(sio);
|
1048 |
rolledbackSios.add(sio);
|
| 1053 |
}
|
1049 |
}
|
| 1054 |
description = description.concat(" " + serialNumber + " ");
|
1050 |
description = description.concat(" " + serialNumber + " ");
|
| 1055 |
} else {
|
1051 |
} else {
|
| 1056 |
serialNumbersConsidered.add(serialNumber);
|
1052 |
serialNumbersConsidered.add(serialNumber);
|
| Line 1067... |
Line 1063... |
| 1067 |
continue;
|
1063 |
continue;
|
| 1068 |
}
|
1064 |
}
|
| 1069 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
1065 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 1070 |
amountToRollback += sio.getAmount();
|
1066 |
amountToRollback += sio.getAmount();
|
| 1071 |
// sio.setSchemeType(SchemeType.OUT);
|
1067 |
// sio.setSchemeType(SchemeType.OUT);
|
| 1072 |
sio.setReference(fofoOrder.getId());
|
- |
|
| 1073 |
sio.setSerialNumber(serialNumber);
|
1068 |
sio.setSerialNumber(serialNumber);
|
| 1074 |
sio.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
1069 |
sio.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
| 1075 |
rolledbackSios.add(sio);
|
1070 |
rolledbackSios.add(sio);
|
| 1076 |
}
|
1071 |
}
|
| 1077 |
}
|
1072 |
}
|
| Line 1091... |
Line 1086... |
| 1091 |
userWalletHistory.add(uwh);
|
1086 |
userWalletHistory.add(uwh);
|
| 1092 |
}
|
1087 |
}
|
| 1093 |
});
|
1088 |
});
|
| 1094 |
|
1089 |
|
| 1095 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
1090 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| 1096 |
Arrays.asList("Wallet Id", "Store Code", "Reference Type", "Reference", "Amount", "Description",
|
1091 |
Arrays.asList("User Id", "Store Code", "Reference Type", "Reference", "Amount", "Description",
|
| 1097 |
"Timestamp"),
|
1092 |
"Timestamp"),
|
| 1098 |
userWalletHistory.stream()
|
1093 |
userWalletHistory.stream()
|
| 1099 |
.map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(),
|
1094 |
.map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(),
|
| 1100 |
x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
|
1095 |
x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
|
| 1101 |
.collect(Collectors.toList()));
|
1096 |
.collect(Collectors.toList()));
|
| Line 1108... |
Line 1103... |
| 1108 |
x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
|
1103 |
x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
|
| 1109 |
.collect(Collectors.toList()));
|
1104 |
.collect(Collectors.toList()));
|
| 1110 |
|
1105 |
|
| 1111 |
Utils.sendMailWithAttachments(googleMailSender,
|
1106 |
Utils.sendMailWithAttachments(googleMailSender,
|
| 1112 |
new String[] { "amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com" }, null,
|
1107 |
new String[] { "amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com" }, null,
|
| 1113 |
"Partner Excess Amount Scheme Out", "PFA",
|
1108 |
"Partner Excess Amount", "PFA",
|
| 1114 |
new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
|
1109 |
new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
|
| 1115 |
new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
|
1110 |
new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
|
| 1116 |
|
1111 |
|
| 1117 |
throw new Exception();
|
1112 |
throw new Exception();
|
| 1118 |
}
|
1113 |
}
|
| Line 1319... |
Line 1314... |
| 1319 |
else
|
1314 |
else
|
| 1320 |
{
|
1315 |
{
|
| 1321 |
notification.setTitle("Your today sale till" + " " + now.format(timeFormatter) +" "+"is" + " " + sale+" "+"vs" +" "+"daily target = 0.0");
|
1316 |
notification.setTitle("Your today sale till" + " " + now.format(timeFormatter) +" "+"is" + " " + sale+" "+"vs" +" "+"daily target = 0.0");
|
| 1322 |
LOGGER.info("Your today sale till" + " " + now.format(timeFormatter) +" "+ "is" + " " + sale+" "+"vs" +" "+"daily target = 0.0");
|
1317 |
LOGGER.info("Your today sale till" + " " + now.format(timeFormatter) +" "+ "is" + " " + sale+" "+"vs" +" "+"daily target = 0.0");
|
| 1323 |
}
|
1318 |
}
|
| 1324 |
// notification.setMessage("Your sale is "+salesbyfofoId.get(fofoId));
|
1319 |
//notification.setMessage("Your sale is "+salesbyfofoId.get(fofoId));
|
| 1325 |
notification.setType("Url");
|
1320 |
notification.setType("Url");
|
| 1326 |
notification.setUrl("http://app.profitmandi.com/pages/home/dashboard");
|
1321 |
notification.setUrl("http://app.profitmandi.com/pages/home/dashboard");
|
| 1327 |
LOGGER.info("UserID" +userAccountRepository.selectUserIdByRetailerId(fofoId));
|
1322 |
LOGGER.info("UserID" +userAccountRepository.selectUserIdByRetailerId(fofoId));
|
| 1328 |
notification
|
1323 |
notification
|
| 1329 |
.setSql("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
|
1324 |
.setSql("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
|
| 1330 |
+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
|
1325 |
+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
|
| 1331 |
+ " where d2.id is null and d1.user_id = "+userAccountRepository.selectUserIdByRetailerId(175120474));
|
1326 |
+ " where d2.id is null and d1.user_id = "+userAccountRepository.selectUserIdByRetailerId(fofoId));
|
| 1332 |
LOGGER.info("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
|
1327 |
LOGGER.info("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
|
| 1333 |
+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
|
1328 |
+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
|
| 1334 |
+ " where d2.id is null and d1.user_id = "+userAccountRepository.selectUserIdByRetailerId(175120474));
|
1329 |
+ " where d2.id is null and d1.user_id = "+userAccountRepository.selectUserIdByRetailerId(fofoId));
|
| 1335 |
notification.setExpiresat(LocalDateTime.now().plusDays(1).toEpochSecond(ZoneOffset.UTC) * 1000);
|
1330 |
notification.setExpiresat(LocalDateTime.now().plusDays(1).toEpochSecond(ZoneOffset.UTC) * 1000);
|
| 1336 |
notification.setStatus("active");
|
1331 |
notification.setStatus("active");
|
| 1337 |
notification.setSmsprocessed(0);
|
1332 |
notification.setSmsprocessed(0);
|
| 1338 |
notification.setNotification_processed(0);
|
1333 |
notification.setNotification_processed(0);
|
| 1339 |
notification.setNotification_type("GENERAL_NOTIFICATION");
|
1334 |
notification.setNotification_type("GENERAL_NOTIFICATION");
|
| Line 1344... |
Line 1339... |
| 1344 |
String saleReport = this.getDailySalesReportByPartnerId(salesByFofoIdMap,dailyTarget);
|
1339 |
String saleReport = this.getDailySalesReportByPartnerId(salesByFofoIdMap,dailyTarget);
|
| 1345 |
LOGGER.info(saleReport);
|
1340 |
LOGGER.info(saleReport);
|
| 1346 |
String cc[] = { "Tarun.verma@smartdukaan.com", "Kamini.sharma@smartdukaan.com",
|
1341 |
String cc[] = { "Tarun.verma@smartdukaan.com", "Kamini.sharma@smartdukaan.com",
|
| 1347 |
"chaitnaya.vats@smartdukaan.com","adeel.yazdani@smartdukaan.com","mohinder.mutreja@smartdukaan.com"};
|
1342 |
"chaitnaya.vats@smartdukaan.com","adeel.yazdani@smartdukaan.com","mohinder.mutreja@smartdukaan.com"};
|
| 1348 |
String subject = "sale report till" + " " + now.format(timeFormatter);
|
1343 |
String subject = "sale report till" + " " + now.format(timeFormatter);
|
| 1349 |
//this.sendMailOfHtmlFomat("amod.sen@smartdukaan.com", saleReport, cc, subject);
|
1344 |
this.sendMailOfHtmlFomat("amod.sen@smartdukaan.com", saleReport, cc, subject);
|
| 1350 |
}
|
1345 |
}
|
| 1351 |
|
1346 |
|
| 1352 |
public String getDailySalesReportByPartnerId(Map<Integer, Double> salesByFofoIdMap,Map<Integer, Float> dailyTarget)
|
1347 |
public String getDailySalesReportByPartnerId(Map<Integer, Double> salesByFofoIdMap,Map<Integer, Float> dailyTarget)
|
| 1353 |
throws ProfitMandiBusinessException {
|
1348 |
throws ProfitMandiBusinessException {
|
| 1354 |
StringBuilder sb = new StringBuilder();
|
1349 |
StringBuilder sb = new StringBuilder();
|