| 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;
|
- |
|
| 46 |
import com.spice.profitmandi.common.util.Utils;
|
45 |
import com.spice.profitmandi.common.util.Utils;
|
| 47 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
- |
|
| 48 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
46 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
| 49 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
47 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
| 50 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
48 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
| 51 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
49 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
| 52 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
50 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| Line 342... |
Line 340... |
| 342 |
public void evaluateExcessSchemeOut() throws Exception {
|
340 |
public void evaluateExcessSchemeOut() throws Exception {
|
| 343 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
341 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
| 344 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
342 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
| 345 |
|
343 |
|
| 346 |
List<List<Object>> rows = new ArrayList<>();
|
344 |
List<List<Object>> rows = new ArrayList<>();
|
| 347 |
List<String> headers = Arrays.asList("Scheme Id", "Item Id", "Item", "Partner", "Amount", "Credited On",
|
345 |
List<String> headers = Arrays.asList("Scheme", "Item","Partner", "Amount", "Credited On",
|
| 348 |
"Sale On", "Scheme", "Start", "End", "Active On", "Expired On");
|
346 |
"Invoice Number", "Sale On", "Scheme Start", "Scheme End", "Active On", "Expired On");
|
| 349 |
schemeRepository.selectAll().stream().forEach(x -> {
|
347 |
schemeRepository.selectAll().stream().forEach(x -> {
|
| 350 |
if (x.getType().equals(SchemeType.OUT)) {
|
348 |
if (x.getType().equals(SchemeType.OUT)) {
|
| 351 |
List<SchemeInOut> sioList = schemeInOutRepository
|
349 |
List<SchemeInOut> sioList = schemeInOutRepository
|
| 352 |
.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
|
350 |
.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
|
| 353 |
if (x.getActiveTimestamp() != null) {
|
351 |
if (x.getActiveTimestamp() != null) {
|
| Line 355... |
Line 353... |
| 355 |
if (x.getExpireTimestamp() != null && x.getExpireTimestamp().isBefore(x.getEndDateTime())) {
|
353 |
if (x.getExpireTimestamp() != null && x.getExpireTimestamp().isBefore(x.getEndDateTime())) {
|
| 356 |
endDateTime = x.getExpireTimestamp();
|
354 |
endDateTime = x.getExpireTimestamp();
|
| 357 |
}
|
355 |
}
|
| 358 |
for (SchemeInOut sio : sioList) {
|
356 |
for (SchemeInOut sio : sioList) {
|
| 359 |
InventoryItem inventoryItem = null;
|
357 |
InventoryItem inventoryItem = null;
|
| - |
|
358 |
FofoOrder fofoOrder = null;
|
| 360 |
try {
|
359 |
try {
|
| 361 |
inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
360 |
inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
| - |
|
361 |
fofoOrder = fofoOrderRepository.selectByFofoIdAndSerialNumber(inventoryItem.getFofoId(), inventoryItem.getSerialNumber(),
|
| - |
|
362 |
null, null, 0, 1).get(0);
|
| 362 |
} catch (ProfitMandiBusinessException e) {
|
363 |
} catch (ProfitMandiBusinessException e) {
|
| 363 |
// TODO Auto-generated catch block
|
364 |
// TODO Auto-generated catch block
|
| 364 |
e.printStackTrace();
|
365 |
e.printStackTrace();
|
| 365 |
}
|
366 |
}
|
| 366 |
Optional<ScanRecord> record = scanRecordRepository
|
367 |
Optional<ScanRecord> record = scanRecordRepository
|
| Line 376... |
Line 377... |
| 376 |
userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
|
377 |
userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
|
| 377 |
try {
|
378 |
try {
|
| 378 |
rows.add(Arrays.asList(x.getDescription(),
|
379 |
rows.add(Arrays.asList(x.getDescription(),
|
| 379 |
itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(),
|
380 |
itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(),
|
| 380 |
userNameMap.get(fofoId), sio.getAmount(),
|
381 |
userNameMap.get(fofoId), sio.getAmount(),
|
| 381 |
FormattingUtils.formatReporitcoDate(sio.getCreateTimestamp()),
|
382 |
FormattingUtils.formatDate(sio.getCreateTimestamp()),
|
| - |
|
383 |
fofoOrder.getInvoiceNumber(),
|
| 382 |
FormattingUtils.formatReporitcoDate(record.get().getCreateTimestamp()),
|
384 |
FormattingUtils.formatDate(record.get().getCreateTimestamp()),
|
| 383 |
FormattingUtils.formatReporitcoDate(x.getStartDateTime()),
|
385 |
FormattingUtils.formatDate(x.getStartDateTime()),
|
| 384 |
FormattingUtils.formatReporitcoDate(x.getEndDateTime()),
|
386 |
FormattingUtils.formatDate(x.getEndDateTime()),
|
| 385 |
FormattingUtils.formatReporitcoDate(x.getActiveTimestamp()),
|
387 |
FormattingUtils.formatDate(x.getActiveTimestamp()),
|
| 386 |
FormattingUtils.formatReporitcoDate(x.getExpireTimestamp())));
|
388 |
FormattingUtils.formatDate(x.getExpireTimestamp())));
|
| 387 |
} catch (Exception e) {
|
389 |
} catch (Exception e) {
|
| 388 |
e.printStackTrace();
|
390 |
e.printStackTrace();
|
| 389 |
}
|
391 |
}
|
| 390 |
}
|
392 |
}
|
| 391 |
}
|
393 |
}
|