| Line 285... |
Line 285... |
| 285 |
@Autowired
|
285 |
@Autowired
|
| 286 |
private ScanRecordRepository scanRecordRepository;
|
286 |
private ScanRecordRepository scanRecordRepository;
|
| 287 |
|
287 |
|
| 288 |
@Autowired
|
288 |
@Autowired
|
| 289 |
private JavaMailSender mailSender;
|
289 |
private JavaMailSender mailSender;
|
| 290 |
|
290 |
|
| 291 |
private static final String ACCOUNT_ID = "aZ6flHhrgPIEl18buHdPBdueEN4";
|
291 |
private static final String ACCOUNT_ID = "aZ6flHhrgPIEl18buHdPBdueEN4";
|
| 292 |
private static final String SECRET_KEY = "a7rsX5B4UNNfTTx1-IJ19qdH48BT4YvBKlQJg3n3_KKNe7WWych55g";
|
292 |
private static final String SECRET_KEY = "a7rsX5B4UNNfTTx1-IJ19qdH48BT4YvBKlQJg3n3_KKNe7WWych55g";
|
| 293 |
|
293 |
|
| 294 |
|
- |
|
| 295 |
public void populateGrnTimestamp() {
|
294 |
public void populateGrnTimestamp() {
|
| 296 |
List<Purchase> allPurchases = purchaseRepository.selectAll();
|
295 |
List<Purchase> allPurchases = purchaseRepository.selectAll();
|
| 297 |
for (Purchase p : allPurchases) {
|
296 |
for (Purchase p : allPurchases) {
|
| 298 |
String invoiceNumber = p.getPurchaseReference();
|
297 |
String invoiceNumber = p.getPurchaseReference();
|
| 299 |
if (p.getCompleteTimestamp() == null) {
|
298 |
if (p.getCompleteTimestamp() == null) {
|
| Line 995... |
Line 994... |
| 995 |
LOGGER.info("PENDING LEADES {}", leadRepository
|
994 |
LOGGER.info("PENDING LEADES {}", leadRepository
|
| 996 |
.selectLeadsScheduledBetweenDate(LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4)));
|
995 |
.selectLeadsScheduledBetweenDate(LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4)));
|
| 997 |
}
|
996 |
}
|
| 998 |
|
997 |
|
| 999 |
public void removeDuplicateOrders() throws Exception {
|
998 |
public void removeDuplicateOrders() throws Exception {
|
| - |
|
999 |
List<String> invoiceNumbers = Arrays.asList(/*
|
| 1000 |
List<String> invoiceNumbers = Arrays.asList(/*"DLWE066/1108", "DLWE066/299", "DLWE066/348", "HRFB004/242",
|
1000 |
* "DLWE066/1108", "DLWE066/299", "DLWE066/348", "HRFB004/242",
|
| 1001 |
"HRFB004/243", "HRFB004/514", "HRFTB155/29", "HRJND076/1146", "HRJND076/966", "HRKA134/295",
|
1001 |
* "HRFB004/243", "HRFB004/514", "HRFTB155/29", "HRJND076/1146",
|
| - |
|
1002 |
* "HRJND076/966", "HRKA134/295", "HRKA134/421", "HRKK091/381",
|
| 1002 |
"HRKA134/421", "HRKK091/381", "HRMGH106/576", "HRSP056/139", "HRYN030/103", "UPGZ019/395",
|
1003 |
* "HRMGH106/576", "HRSP056/139", "HRYN030/103", "UPGZ019/395",
|
| 1003 |
"UPHRD130/1299", "UPHRD130/456", "UPHRD130/634", "UPLKO063/897", "UPMRT149/54", "UPSJP119/748",
|
1004 |
* "UPHRD130/1299", "UPHRD130/456", "UPHRD130/634", "UPLKO063/897",
|
| - |
|
1005 |
* "UPMRT149/54", "UPSJP119/748", "UPSJP119/980", "UPSTP065/1218",
|
| 1004 |
"UPSJP119/980", "UPSTP065/1218", "UPSTP065/2039", "UPSTP090/437", "UPSTP120/164", */
|
1006 |
* "UPSTP065/2039", "UPSTP090/437", "UPSTP120/164",
|
| - |
|
1007 |
*/
|
| 1005 |
"HRMGH106/1576");
|
1008 |
"HRMGH106/1576");
|
| 1006 |
|
1009 |
|
| 1007 |
int totalAmount = 0;
|
1010 |
int totalAmount = 0;
|
| 1008 |
float saleAmount = 0;
|
1011 |
float saleAmount = 0;
|
| 1009 |
float schemeReverseAmount = 0;
|
1012 |
float schemeReverseAmount = 0;
|
| 1010 |
for(String invoiceNumber : invoiceNumbers) {
|
1013 |
for (String invoiceNumber : invoiceNumbers) {
|
| 1011 |
List<FofoOrder> orders = fofoOrderRepository.selectByInvoiceNumberLike(invoiceNumber);
|
1014 |
List<FofoOrder> orders = fofoOrderRepository.selectByInvoiceNumberLike(invoiceNumber);
|
| 1012 |
orders = orders.stream().skip(1).collect(Collectors.toList());
|
1015 |
orders = orders.stream().skip(1).collect(Collectors.toList());
|
| 1013 |
for (FofoOrder fofoOrder : orders) {
|
1016 |
for (FofoOrder fofoOrder : orders) {
|
| 1014 |
LOGGER.info("Fofo Order Id - {}, Invoice {}", fofoOrder.getId(), invoiceNumber);
|
1017 |
LOGGER.info("Fofo Order Id - {}, Invoice {}", fofoOrder.getId(), invoiceNumber);
|
| 1015 |
int inventoryItemId = 0;
|
1018 |
int inventoryItemId = 0;
|
| 1016 |
saleAmount += fofoOrder.getTotalAmount();
|
1019 |
saleAmount += fofoOrder.getTotalAmount();
|
| 1017 |
fofoOrderRepository.delete(fofoOrder);
|
1020 |
fofoOrderRepository.delete(fofoOrder);
|
| 1018 |
LOGGER.info("Fofo Order Id - {}, Invoice {}", fofoOrder.getId(), invoiceNumber);
|
1021 |
LOGGER.info("Fofo Order Id - {}, Invoice {}", fofoOrder.getId(), invoiceNumber);
|
| 1019 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
1022 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 1020 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
1023 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository
|
| - |
|
1024 |
.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
| 1021 |
for(PaymentOptionTransaction paymentOptionTransaction : paymentOptionTransactions) {
|
1025 |
for (PaymentOptionTransaction paymentOptionTransaction : paymentOptionTransactions) {
|
| 1022 |
paymentOptionTransactionRepository.delete(paymentOptionTransaction);
|
1026 |
paymentOptionTransactionRepository.delete(paymentOptionTransaction);
|
| 1023 |
}
|
1027 |
}
|
| 1024 |
for(FofoOrderItem foi : fofoOrderItems) {
|
1028 |
for (FofoOrderItem foi : fofoOrderItems) {
|
| 1025 |
List<FofoLineItem> flis = fofoLineItemRepository.selectByFofoOrderItemId(foi.getId());
|
1029 |
List<FofoLineItem> flis = fofoLineItemRepository.selectByFofoOrderItemId(foi.getId());
|
| 1026 |
fofoOrderItemRepository.delete(foi);
|
1030 |
fofoOrderItemRepository.delete(foi);
|
| 1027 |
for(FofoLineItem fli : flis) {
|
1031 |
for (FofoLineItem fli : flis) {
|
| 1028 |
inventoryItemId = fli.getInventoryItemId();
|
1032 |
inventoryItemId = fli.getInventoryItemId();
|
| 1029 |
fofoLineItemRepository.delete(fli);
|
1033 |
fofoLineItemRepository.delete(fli);
|
| 1030 |
}
|
1034 |
}
|
| 1031 |
}
|
1035 |
}
|
| 1032 |
//Rollback entry with reversal reason
|
1036 |
// Rollback entry with reversal reason
|
| 1033 |
if(fofoOrder.getCreateTimestamp().isAfter(LocalDate.of(2020, 4, 1).atStartOfDay())) {
|
1037 |
if (fofoOrder.getCreateTimestamp().isAfter(LocalDate.of(2020, 4, 1).atStartOfDay())) {
|
| 1034 |
float invoiceSchemeReversalAmount = 0;
|
1038 |
float invoiceSchemeReversalAmount = 0;
|
| - |
|
1039 |
List<UserWalletHistory> userWalletHistory = userWalletHistoryRepository
|
| 1035 |
List<UserWalletHistory> userWalletHistory = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(fofoOrder.getId(), WalletReferenceType.SCHEME_OUT);
|
1040 |
.selectAllByreferenceIdandreferenceType(fofoOrder.getId(), WalletReferenceType.SCHEME_OUT);
|
| 1036 |
float invoiceWalletAmount = userWalletHistory.stream().collect(Collectors.summingInt(y->y.getAmount()));
|
1041 |
float invoiceWalletAmount = userWalletHistory.stream()
|
| - |
|
1042 |
.collect(Collectors.summingInt(y -> y.getAmount()));
|
| 1037 |
totalAmount += invoiceWalletAmount;
|
1043 |
totalAmount += invoiceWalletAmount;
|
| 1038 |
try {
|
1044 |
try {
|
| 1039 |
walletService.rollbackAmountFromWallet(fofoOrder.getFofoId(), invoiceWalletAmount, fofoOrder.getId(), WalletReferenceType.SCHEME_OUT,
|
1045 |
walletService.rollbackAmountFromWallet(fofoOrder.getFofoId(), invoiceWalletAmount,
|
| - |
|
1046 |
fofoOrder.getId(), WalletReferenceType.SCHEME_OUT,
|
| 1040 |
"Same order for Invoice-"+ invoiceNumber + "created twice, duplicate invoice rollback", fofoOrder.getCancelledTimestamp());
|
1047 |
"Same order for Invoice-" + invoiceNumber + "created twice, duplicate invoice rollback",
|
| - |
|
1048 |
fofoOrder.getCancelledTimestamp());
|
| 1041 |
} catch (Exception e) {
|
1049 |
} catch (Exception e) {
|
| 1042 |
LOGGER.info("Failed wallet update Reson [{}]", e.getMessage());
|
1050 |
LOGGER.info("Failed wallet update Reson [{}]", e.getMessage());
|
| 1043 |
}
|
1051 |
}
|
| 1044 |
LOGGER.info("inventoryItemId - {}", inventoryItemId);
|
1052 |
LOGGER.info("inventoryItemId - {}", inventoryItemId);
|
| - |
|
1053 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository
|
| 1045 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId)));
|
1054 |
.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId)));
|
| 1046 |
Set<Integer> schemeIds = new HashSet<>();
|
1055 |
Set<Integer> schemeIds = new HashSet<>();
|
| 1047 |
Set<Integer> schemeIdsRolledback = new HashSet<>();
|
1056 |
Set<Integer> schemeIdsRolledback = new HashSet<>();
|
| 1048 |
for(SchemeInOut sio : schemeInOuts) {
|
1057 |
for (SchemeInOut sio : schemeInOuts) {
|
| 1049 |
if(Math.abs(sio.getCreateTimestamp().until(fofoOrder.getCreateTimestamp(), ChronoUnit.MINUTES)) <= 35 && sio.getRolledBackTimestamp() == null) {
|
1058 |
if (Math.abs(sio.getCreateTimestamp().until(fofoOrder.getCreateTimestamp(),
|
| - |
|
1059 |
ChronoUnit.MINUTES)) <= 35 && sio.getRolledBackTimestamp() == null) {
|
| 1050 |
LOGGER.info(sio);
|
1060 |
LOGGER.info(sio);
|
| 1051 |
if(!schemeIds.contains(sio.getSchemeId())) {
|
1061 |
if (!schemeIds.contains(sio.getSchemeId())) {
|
| 1052 |
schemeIds.add(sio.getSchemeId());
|
1062 |
schemeIds.add(sio.getSchemeId());
|
| 1053 |
} else if (!schemeIdsRolledback.contains(sio.getSchemeId())) {
|
1063 |
} else if (!schemeIdsRolledback.contains(sio.getSchemeId())) {
|
| 1054 |
schemeIdsRolledback.add(sio.getSchemeId());
|
1064 |
schemeIdsRolledback.add(sio.getSchemeId());
|
| 1055 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
1065 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 1056 |
schemeReverseAmount += sio.getAmount();
|
1066 |
schemeReverseAmount += sio.getAmount();
|
| 1057 |
invoiceSchemeReversalAmount += sio.getAmount();
|
1067 |
invoiceSchemeReversalAmount += sio.getAmount();
|
| 1058 |
}
|
1068 |
}
|
| 1059 |
}
|
1069 |
}
|
| 1060 |
}
|
1070 |
}
|
| 1061 |
if(Math.abs(invoiceWalletAmount - invoiceSchemeReversalAmount) > 3) {
|
1071 |
if (Math.abs(invoiceWalletAmount - invoiceSchemeReversalAmount) > 3) {
|
| 1062 |
LOGGER.info("No Matchhhh");
|
1072 |
LOGGER.info("No Matchhhh");
|
| 1063 |
}
|
1073 |
}
|
| 1064 |
LOGGER.info("invoiceWalletAmount - {}, invoiceSchemeReversalAmount {}", invoiceWalletAmount, invoiceSchemeReversalAmount);
|
1074 |
LOGGER.info("invoiceWalletAmount - {}, invoiceSchemeReversalAmount {}", invoiceWalletAmount,
|
| - |
|
1075 |
invoiceSchemeReversalAmount);
|
| 1065 |
}
|
1076 |
}
|
| 1066 |
}
|
1077 |
}
|
| 1067 |
}
|
1078 |
}
|
| - |
|
1079 |
LOGGER.info(
|
| 1068 |
LOGGER.info("Total Sale Amount Reversal - {}, Total Wallet Amount Reversal {}, Total Scheme Reversal Amount - {}", saleAmount, totalAmount, schemeReverseAmount);
|
1080 |
"Total Sale Amount Reversal - {}, Total Wallet Amount Reversal {}, Total Scheme Reversal Amount - {}",
|
| - |
|
1081 |
saleAmount, totalAmount, schemeReverseAmount);
|
| 1069 |
//throw new Exception();
|
1082 |
// throw new Exception();
|
| 1070 |
}
|
1083 |
}
|
| 1071 |
|
1084 |
|
| 1072 |
public void createGeofence() throws IOException, ProfitMandiBusinessException {
|
1085 |
public void createGeofence() throws IOException, ProfitMandiBusinessException {
|
| 1073 |
|
1086 |
|
| 1074 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
1087 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
| 1075 |
for (FofoStore fofoStore : fofoStores) {
|
1088 |
for (FofoStore fofoStore : fofoStores) {
|
| 1076 |
if (fofoStore.getLatitude() != null && fofoStore.getLongitude() != null) {
|
1089 |
if (fofoStore.getLatitude() != null && fofoStore.getLongitude() != null) {
|
| 1077 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoStore.getId());
|
1090 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoStore.getId());
|
| 1078 |
OkHttpClient client = new OkHttpClient();
|
1091 |
OkHttpClient client = new OkHttpClient();
|
| 1079 |
|
- |
|
| 1080 |
okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json");
|
1092 |
okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json");
|
| 1081 |
JSONObject geofe = new JSONObject();
|
1093 |
JSONObject geofe = new JSONObject();
|
| 1082 |
JSONArray geofences = new JSONArray();
|
1094 |
JSONArray geofences = new JSONArray();
|
| 1083 |
JSONObject geometry = new JSONObject();
|
1095 |
JSONObject geometry = new JSONObject();
|
| 1084 |
JSONObject geo = new JSONObject();
|
1096 |
JSONObject geo = new JSONObject();
|
| 1085 |
JSONArray coordinates = new JSONArray();
|
1097 |
JSONArray coordinates = new JSONArray();
|
| - |
|
1098 |
ArrayList<String> crds = new ArrayList<>();
|
| - |
|
1099 |
crds.add(fofoStore.getLongitude());
|
| - |
|
1100 |
crds.add(fofoStore.getLatitude());
|
| - |
|
1101 |
|
| 1086 |
coordinates.put(fofoStore.getLongitude());
|
1102 |
coordinates.put(fofoStore.getLongitude());
|
| 1087 |
coordinates.put(fofoStore.getLatitude());
|
1103 |
coordinates.put(fofoStore.getLatitude());
|
| 1088 |
geo.put("type", "Point");
|
1104 |
geo.put("type", "Point");
|
| 1089 |
geo.put("coordinates", coordinates);
|
1105 |
geo.put("coordinates", crds);
|
| 1090 |
geometry.put("geometry", geo);
|
1106 |
geometry.put("geometry", geo);
|
| 1091 |
JSONObject metadata = new JSONObject();
|
1107 |
JSONObject metadata = new JSONObject();
|
| 1092 |
metadata.put("name", customRetailer.getBusinessName());
|
1108 |
metadata.put("name", customRetailer.getBusinessName());
|
| 1093 |
metadata.put("city", customRetailer.getAddress().getCity());
|
1109 |
metadata.put("city", customRetailer.getAddress().getCity());
|
| 1094 |
geometry.put("metadata", metadata);
|
1110 |
geometry.put("metadata", metadata);
|
| Line 1109... |
Line 1125... |
| 1109 |
}
|
1125 |
}
|
| 1110 |
}
|
1126 |
}
|
| 1111 |
|
1127 |
|
| 1112 |
}
|
1128 |
}
|
| 1113 |
|
1129 |
|
| 1114 |
|
- |
|
| 1115 |
public void getAllGeofences()
|
- |
|
| 1116 |
throws IOException, ProfitMandiBusinessException {
|
1130 |
public void getAllGeofences() throws IOException, ProfitMandiBusinessException {
|
| 1117 |
|
1131 |
|
| 1118 |
OkHttpClient client = new OkHttpClient();
|
1132 |
OkHttpClient client = new OkHttpClient();
|
| 1119 |
|
1133 |
|
| 1120 |
String authString = "Basic "
|
1134 |
String authString = "Basic "
|
| 1121 |
+ Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
|
1135 |
+ Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
|
| Line 1123... |
Line 1137... |
| 1123 |
// Get geofences created for all app users
|
1137 |
// Get geofences created for all app users
|
| 1124 |
Request request1 = new Request.Builder().url("https://v3.api.hypertrack.com/geofences")
|
1138 |
Request request1 = new Request.Builder().url("https://v3.api.hypertrack.com/geofences")
|
| 1125 |
.addHeader("Authorization", authString).build();
|
1139 |
.addHeader("Authorization", authString).build();
|
| 1126 |
|
1140 |
|
| 1127 |
Response response = client.newCall(request1).execute();
|
1141 |
Response response = client.newCall(request1).execute();
|
| 1128 |
|
1142 |
|
| 1129 |
LOGGER.info("response" + response.body().string());
|
1143 |
LOGGER.info("response" + response.body().string());
|
| 1130 |
}
|
1144 |
}
|
| 1131 |
|
1145 |
|
| 1132 |
public void processSchemeOut(int fofoId, int orderId) throws Exception {
|
1146 |
public void processSchemeOut(int fofoId, int orderId) throws Exception {
|
| 1133 |
schemeService.processSchemeOut(orderId, fofoId);
|
1147 |
schemeService.processSchemeOut(orderId, fofoId);
|
| 1134 |
|
1148 |
|
| 1135 |
}
|
1149 |
}
|
| 1136 |
}
|
1150 |
}
|
| 1137 |
|
1151 |
|
| 1138 |
//7015845171
|
1152 |
//7015845171
|
| 1139 |
|
1153 |
|