| Line 40... |
Line 40... |
| 40 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
40 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 41 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
41 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 42 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
42 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| 43 |
import com.spice.profitmandi.common.util.FileUtil;
|
43 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 44 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
44 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| - |
|
45 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 45 |
import com.spice.profitmandi.common.util.Utils;
|
46 |
import com.spice.profitmandi.common.util.Utils;
|
| - |
|
47 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 46 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
48 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
| 47 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
49 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
| 48 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
50 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
| 49 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
51 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
| 50 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
52 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| Line 54... |
Line 56... |
| 54 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
56 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 55 |
import com.spice.profitmandi.dao.entity.fofo.SaleHeadDetails;
|
57 |
import com.spice.profitmandi.dao.entity.fofo.SaleHeadDetails;
|
| 56 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
58 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 57 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
59 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 58 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
60 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| - |
|
61 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 59 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
62 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 60 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
63 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
64 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
65 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
66 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| Line 137... |
Line 140... |
| 137 |
@Autowired
|
140 |
@Autowired
|
| 138 |
private RechargeProviderCreditWalletHistoryRepository rechargeProviderCreditWalletHistoryRepository;
|
141 |
private RechargeProviderCreditWalletHistoryRepository rechargeProviderCreditWalletHistoryRepository;
|
| 139 |
|
142 |
|
| 140 |
@Autowired
|
143 |
@Autowired
|
| 141 |
private FofoOrderRepository fofoOrderRepository;
|
144 |
private FofoOrderRepository fofoOrderRepository;
|
| 142 |
|
145 |
|
| 143 |
@Autowired
|
146 |
@Autowired
|
| 144 |
private InventoryItemRepository inventoryItemRepository;
|
147 |
private InventoryItemRepository inventoryItemRepository;
|
| 145 |
|
148 |
|
| 146 |
@Autowired
|
149 |
@Autowired
|
| 147 |
private WalletService walletService;
|
150 |
private WalletService walletService;
|
| Line 173... |
Line 176... |
| 173 |
@Autowired
|
176 |
@Autowired
|
| 174 |
private RetailerService retailerService;
|
177 |
private RetailerService retailerService;
|
| 175 |
|
178 |
|
| 176 |
@Autowired
|
179 |
@Autowired
|
| 177 |
private TransactionService transactionService;
|
180 |
private TransactionService transactionService;
|
| 178 |
|
181 |
|
| 179 |
@Autowired
|
182 |
@Autowired
|
| 180 |
private ItemRepository itemRepository;
|
183 |
private ItemRepository itemRepository;
|
| 181 |
|
184 |
|
| 182 |
@Autowired
|
185 |
@Autowired
|
| 183 |
private OrderRepository orderRepository;
|
186 |
private OrderRepository orderRepository;
|
| Line 337... |
Line 340... |
| 337 |
|
340 |
|
| 338 |
// Temporary Method
|
341 |
// Temporary Method
|
| 339 |
public void evaluateExcessSchemeOut() {
|
342 |
public void evaluateExcessSchemeOut() {
|
| 340 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
343 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
| 341 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
344 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
| 342 |
LOGGER.info("{}\t{}\t{}\t{}",
|
345 |
LOGGER.info("{}\t{}\t{}\t{}", "Scheme Id", "Item Id", "Item", "Partner", "Amount", "Credited On", "Sale On",
|
| 343 |
"Scheme Id", "Item Id", "Item", "Partner", "Amount", "Credited On", "Sale On", "Scheme", "Start","End","Active On", "Expired On");
|
346 |
"Scheme", "Start", "End", "Active On", "Expired On");
|
| 344 |
schemeRepository.selectAll().stream().forEach(x -> {
|
347 |
schemeRepository.selectAll().stream().forEach(x -> {
|
| - |
|
348 |
if (x.getType().equals(SchemeType.OUT)) {
|
| 345 |
List<SchemeInOut> sioList = schemeInOutRepository
|
349 |
List<SchemeInOut> sioList = schemeInOutRepository
|
| 346 |
.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
|
350 |
.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
|
| 347 |
if (x.getActiveTimestamp() != null) {
|
351 |
if (x.getActiveTimestamp() != null) {
|
| 348 |
LocalDateTime endDateTime = x.getEndDateTime();
|
352 |
LocalDateTime endDateTime = x.getEndDateTime();
|
| 349 |
if (x.getExpireTimestamp() != null && x.getExpireTimestamp().isBefore(x.getEndDateTime())) {
|
353 |
if (x.getExpireTimestamp() != null && x.getExpireTimestamp().isBefore(x.getEndDateTime())) {
|
| 350 |
endDateTime = x.getExpireTimestamp();
|
354 |
endDateTime = x.getExpireTimestamp();
|
| 351 |
}
|
- |
|
| 352 |
for (SchemeInOut sio : sioList) {
|
- |
|
| 353 |
InventoryItem inventoryItem =null;
|
- |
|
| 354 |
try {
|
- |
|
| 355 |
inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
- |
|
| 356 |
} catch (ProfitMandiBusinessException e) {
|
- |
|
| 357 |
// TODO Auto-generated catch block
|
- |
|
| 358 |
e.printStackTrace();
|
- |
|
| 359 |
}
|
355 |
}
|
| - |
|
356 |
for (SchemeInOut sio : sioList) {
|
| - |
|
357 |
InventoryItem inventoryItem = null;
|
| - |
|
358 |
try {
|
| 360 |
Optional<ScanRecord> record = scanRecordRepository.selectByInventoryItemId(sio.getInventoryItemId())
|
359 |
inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
| - |
|
360 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
361 |
// TODO Auto-generated catch block
|
| - |
|
362 |
e.printStackTrace();
|
| - |
|
363 |
}
|
| - |
|
364 |
Optional<ScanRecord> record = scanRecordRepository
|
| - |
|
365 |
.selectByInventoryItemId(sio.getInventoryItemId()).stream()
|
| 361 |
.stream().filter(y -> y.getType().equals(ScanType.SALE)).findFirst();
|
366 |
.filter(y -> y.getType().equals(ScanType.SALE)).findFirst();
|
| 362 |
if (record.isPresent()) {
|
367 |
if (record.isPresent()) {
|
| 363 |
int fofoId = record.get().getFofoId();
|
368 |
int fofoId = record.get().getFofoId();
|
| 364 |
if (record.get().getCreateTimestamp().isAfter(endDateTime)
|
369 |
if (record.get().getCreateTimestamp().isAfter(endDateTime)
|
| 365 |
|| record.get().getCreateTimestamp().isBefore(x.getStartDateTime())) {
|
370 |
|| record.get().getCreateTimestamp().isBefore(x.getStartDateTime())) {
|
| 366 |
if (!userAmountMap.containsKey(fofoId)) {
|
371 |
if (!userAmountMap.containsKey(fofoId)) {
|
| 367 |
userAmountMap.put(fofoId, 0f);
|
372 |
userAmountMap.put(fofoId, 0f);
|
| 368 |
}
|
373 |
}
|
| 369 |
userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
|
374 |
userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
|
| - |
|
375 |
/*
|
| - |
|
376 |
* LOGGER.
|
| 370 |
/*LOGGER.info("Scheme disbursed to user {} for inventoryItem {} and scheme {} for amount {}",
|
377 |
* info("Scheme disbursed to user {} for inventoryItem {} and scheme {} for amount {}"
|
| 371 |
userNameMap.get(fofoId), sio.getInventoryItemId(), sio.getSchemeId(),
|
378 |
* , userNameMap.get(fofoId), sio.getInventoryItemId(), sio.getSchemeId(),
|
| 372 |
sio.getAmount());*/
|
379 |
* sio.getAmount());
|
| - |
|
380 |
*/
|
| 373 |
try {
|
381 |
try {
|
| 374 |
LOGGER.info("{}\t{}\t{}\t{}\t{}\t{}\t{}",
|
382 |
LOGGER.info("{}\t{}\t{}\t{}\t{}\t{}\t{}", x.getDescription(),
|
| 375 |
x.getDescription(), itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(), userNameMap.get(fofoId),
|
383 |
itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(),
|
| - |
|
384 |
userNameMap.get(fofoId), sio.getAmount(), FormattingUtils.formatReporitcoDate(sio.getCreateTimestamp()),
|
| 376 |
sio.getAmount(), sio.getCreateTimestamp(), record.get().getCreateTimestamp(), x.getStartDateTime(), x.getEndDateTime(), x.getActiveTimestamp(), x.getExpireTimestamp());
|
385 |
FormattingUtils.formatReporitcoDate(record.get().getCreateTimestamp()), FormattingUtils.formatReporitcoDate(x.getStartDateTime()),
|
| - |
|
386 |
FormattingUtils.formatReporitcoDate(x.getEndDateTime()),
|
| - |
|
387 |
FormattingUtils.formatReporitcoDate(x.getActiveTimestamp()), FormattingUtils.formatReporitcoDate(x.getExpireTimestamp()));
|
| 377 |
}catch (Exception e) {
|
388 |
} catch (Exception e) {
|
| 378 |
e.printStackTrace();
|
389 |
e.printStackTrace();
|
| - |
|
390 |
}
|
| 379 |
}
|
391 |
}
|
| 380 |
}
|
392 |
}
|
| 381 |
}
|
393 |
}
|
| 382 |
}
|
394 |
}
|
| 383 |
}
|
395 |
}
|