| Line 22... |
Line 22... |
| 22 |
import org.springframework.mail.javamail.JavaMailSender;
|
22 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 23 |
import org.springframework.stereotype.Component;
|
23 |
import org.springframework.stereotype.Component;
|
| 24 |
import org.springframework.transaction.annotation.Transactional;
|
24 |
import org.springframework.transaction.annotation.Transactional;
|
| 25 |
import org.w3c.dom.stylesheets.LinkStyle;
|
25 |
import org.w3c.dom.stylesheets.LinkStyle;
|
| 26 |
|
26 |
|
| - |
|
27 |
import com.itextpdf.text.log.SysoCounter;
|
| 27 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
28 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 28 |
import com.spice.profitmandi.common.util.FileUtil;
|
29 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 29 |
import com.spice.profitmandi.common.util.Utils;
|
30 |
import com.spice.profitmandi.common.util.Utils;
|
| 30 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
31 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 31 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
32 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| Line 33... |
Line 34... |
| 33 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
34 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 34 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
35 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 35 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
36 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 36 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
37 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 37 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
38 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| - |
|
39 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 38 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
40 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
| 39 |
import com.spice.profitmandi.dao.entity.fofo.TargetSlab;
|
41 |
import com.spice.profitmandi.dao.entity.fofo.TargetSlab;
|
| 40 |
import com.spice.profitmandi.dao.entity.inventory.SaholicInventorySnapshot;
|
42 |
import com.spice.profitmandi.dao.entity.inventory.SaholicInventorySnapshot;
|
| 41 |
import com.spice.profitmandi.dao.entity.inventory.SaholicReservationInventorySnapshot;
|
43 |
import com.spice.profitmandi.dao.entity.inventory.SaholicReservationInventorySnapshot;
|
| 42 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
44 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
| 43 |
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
|
45 |
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
|
| 44 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
46 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 45 |
import com.spice.profitmandi.dao.entity.transaction.SellerWarehouse;
|
47 |
import com.spice.profitmandi.dao.entity.transaction.SellerWarehouse;
|
| - |
|
48 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| - |
|
49 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 46 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
50 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| - |
|
51 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 47 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
52 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| - |
|
53 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 48 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
54 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 49 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
55 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 50 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
56 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 51 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
57 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
| 52 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
58 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| Line 122... |
Line 128... |
| 122 |
|
128 |
|
| 123 |
@Autowired
|
129 |
@Autowired
|
| 124 |
private WalletService walletService;
|
130 |
private WalletService walletService;
|
| 125 |
|
131 |
|
| 126 |
@Autowired
|
132 |
@Autowired
|
| - |
|
133 |
private ItemRepository itemRepository;
|
| - |
|
134 |
|
| - |
|
135 |
@Autowired
|
| 127 |
private InventoryService inventoryService;
|
136 |
private InventoryService inventoryService;
|
| 128 |
|
137 |
|
| 129 |
@Autowired
|
138 |
@Autowired
|
| 130 |
private TransactionService transactionService;
|
139 |
private TransactionService transactionService;
|
| 131 |
|
140 |
|
| Line 133... |
Line 142... |
| 133 |
@Autowired
|
142 |
@Autowired
|
| 134 |
private OrderService orderService;
|
143 |
private OrderService orderService;
|
| 135 |
|
144 |
|
| 136 |
@Autowired
|
145 |
@Autowired
|
| 137 |
private SchemeRepository schemeRepository;
|
146 |
private SchemeRepository schemeRepository;
|
| 138 |
|
147 |
|
| 139 |
@Autowired
|
148 |
@Autowired
|
| 140 |
private SchemeItemRepository schemeItemRepository;
|
149 |
private SchemeItemRepository schemeItemRepository;
|
| 141 |
|
150 |
|
| 142 |
@Autowired
|
151 |
@Autowired
|
| 143 |
private ReturnOrderRepository returnOrderRepository;
|
152 |
private ReturnOrderRepository returnOrderRepository;
|
| Line 491... |
Line 500... |
| 491 |
m.put(6.5f, list65);
|
500 |
m.put(6.5f, list65);
|
| 492 |
for (Map.Entry<Float, List<Integer>> itemsListEntry : m.entrySet()) {
|
501 |
for (Map.Entry<Float, List<Integer>> itemsListEntry : m.entrySet()) {
|
| 493 |
Scheme s1 = getScheme();
|
502 |
Scheme s1 = getScheme();
|
| 494 |
s1.setAmount(itemsListEntry.getKey());
|
503 |
s1.setAmount(itemsListEntry.getKey());
|
| 495 |
schemeRepository.persist(s1);
|
504 |
schemeRepository.persist(s1);
|
| 496 |
for(Integer itemId : itemsListEntry.getValue()) {
|
505 |
for (Integer itemId : itemsListEntry.getValue()) {
|
| 497 |
SchemeItem schemeItem = new SchemeItem();
|
506 |
SchemeItem schemeItem = new SchemeItem();
|
| 498 |
schemeItem.setItemId(itemId);
|
507 |
schemeItem.setItemId(itemId);
|
| 499 |
schemeItem.setSchemeId(s1.getId());
|
508 |
schemeItem.setSchemeId(s1.getId());
|
| 500 |
schemeItemRepository.persist(schemeItem);
|
509 |
schemeItemRepository.persist(schemeItem);
|
| 501 |
}
|
510 |
}
|
| 502 |
}
|
511 |
}
|
| 503 |
|
512 |
|
| 504 |
}
|
513 |
}
|
| 505 |
|
514 |
|
| 506 |
private Scheme getScheme() {
|
515 |
private Scheme getScheme() {
|
| 507 |
Scheme s = new Scheme();
|
516 |
Scheme s = new Scheme();
|
| 508 |
s.setName("List Price Margin");
|
517 |
s.setName("List Price Margin");
|
| Line 596... |
Line 605... |
| 596 |
* snapshot.getOrderId()); } });
|
605 |
* snapshot.getOrderId()); } });
|
| 597 |
*/
|
606 |
*/
|
| 598 |
// throw new Exception();
|
607 |
// throw new Exception();
|
| 599 |
}
|
608 |
}
|
| 600 |
|
609 |
|
| 601 |
public void fixSchemePayouts() {
|
610 |
public void fixSchemePayouts() throws Exception {
|
| 602 |
|
- |
|
| 603 |
}
|
- |
|
| 604 |
|
611 |
|
| - |
|
612 |
LocalDateTime startDate = LocalDate.of(2019, 6, 1).atStartOfDay();
|
| - |
|
613 |
List<SchemeInOut> sios = schemeInOutRepository.selectAllByCreateDate(startDate, startDate.plusDays(15));
|
| - |
|
614 |
Float totalRollbackAmount = 0f;
|
| - |
|
615 |
for (SchemeInOut sio : sios) {
|
| - |
|
616 |
InventoryItem ii = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
| - |
|
617 |
Purchase purchase = purchaseRepository.selectByIdAndFofoId(ii.getPurchaseId(), ii.getFofoId());
|
| - |
|
618 |
int schemeId = sio.getSchemeId();
|
| - |
|
619 |
Scheme scheme = schemeRepository.selectById(schemeId);
|
| - |
|
620 |
if (schemeId < 280 && scheme.getType().equals(SchemeType.IN)
|
| - |
|
621 |
&& scheme.getAmountType().equals(AmountType.PERCENTAGE)) {
|
| - |
|
622 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| - |
|
623 |
String rollbackDescription = String.format(
|
| - |
|
624 |
"Rolled back scheme %s for %s and %s (%s) as its no longer active in June", scheme.getName(),
|
| - |
|
625 |
purchase.getPurchaseReference(), itemRepository.selectById(ii.getItemId()).getItemDescription(),
|
| - |
|
626 |
ii.getSerialNumber());
|
| - |
|
627 |
System.out.println(rollbackDescription);
|
| - |
|
628 |
walletService.rollbackAmountFromWallet(purchase.getFofoId(), sio.getAmount(), purchase.getId(),
|
| - |
|
629 |
WalletReferenceType.SCHEME_IN, rollbackDescription);
|
| - |
|
630 |
}
|
| - |
|
631 |
totalRollbackAmount += sio.getAmount();
|
| - |
|
632 |
}
|
| - |
|
633 |
System.out.println("Total Amount Rolled Back is " + totalRollbackAmount);
|
| - |
|
634 |
throw new Exception();
|
| - |
|
635 |
}
|
| 605 |
}
|
636 |
}
|
| 606 |
|
637 |
|