| Line 14... |
Line 14... |
| 14 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
14 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 15 |
import com.spice.profitmandi.dao.entity.catalog.SchemeRegion;
|
15 |
import com.spice.profitmandi.dao.entity.catalog.SchemeRegion;
|
| 16 |
import com.spice.profitmandi.dao.entity.catalog.SchemesImeisModel;
|
16 |
import com.spice.profitmandi.dao.entity.catalog.SchemesImeisModel;
|
| 17 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
17 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 18 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
18 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| - |
|
19 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 19 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
20 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| 20 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
21 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 21 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
22 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 22 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
23 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
| 23 |
import com.spice.profitmandi.dao.model.CreateSchemeRequest;
|
24 |
import com.spice.profitmandi.dao.model.CreateSchemeRequest;
|
| 24 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
25 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 25 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
26 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
27 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 27 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
28 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| - |
|
29 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| 28 |
import com.spice.profitmandi.service.NotificationService;
|
30 |
import com.spice.profitmandi.service.NotificationService;
|
| 29 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
31 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 30 |
import com.spice.profitmandi.service.inventory.PurchaseService;
|
32 |
import com.spice.profitmandi.service.inventory.PurchaseService;
|
| 31 |
import com.spice.profitmandi.service.wallet.WalletService;
|
33 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 32 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
34 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| Line 854... |
Line 856... |
| 854 |
priceDrop.getAffectedOn());
|
856 |
priceDrop.getAffectedOn());
|
| 855 |
}
|
857 |
}
|
| 856 |
}
|
858 |
}
|
| 857 |
}
|
859 |
}
|
| 858 |
|
860 |
|
| - |
|
861 |
@Autowired
|
| - |
|
862 |
UserWalletHistoryRepository userWalletHistoryRepository;
|
| - |
|
863 |
|
| 859 |
@Override
|
864 |
@Override
|
| 860 |
// Always being called from cancel order/bad return means no SCHEME IN is considered
|
865 |
// Always being called from cancel order/bad return means no SCHEME IN is considered
|
| 861 |
public void reverseSchemes(List<InventoryItem> inventoryItems, int reversalReference, String reversalReason,
|
866 |
public void reverseSchemes(List<InventoryItem> inventoryItems, int reversalReference, String reversalReason,
|
| 862 |
List<SchemeType> schemeTypes) throws ProfitMandiBusinessException {
|
867 |
List<SchemeType> schemeTypes) throws ProfitMandiBusinessException {
|
| 863 |
Map<Integer, InventoryItem> inventoryItemsMap = inventoryItems.stream()
|
868 |
Map<Integer, InventoryItem> inventoryItemsMap = inventoryItems.stream()
|
| Line 891... |
Line 896... |
| 891 |
}
|
896 |
}
|
| 892 |
}
|
897 |
}
|
| 893 |
|
898 |
|
| 894 |
}
|
899 |
}
|
| 895 |
int fofoId = inventoryItems.get(0).getFofoId();
|
900 |
int fofoId = inventoryItems.get(0).getFofoId();
|
| 896 |
WalletReferenceType walletReferenceType = schemeTypes.containsAll(SchemeService.OUT_SCHEME_TYPES)
|
901 |
WalletReferenceType walletReferenceType = schemeTypes.containsAll(SchemeService.OUT_SCHEME_TYPES) ? WalletReferenceType.SCHEME_OUT
|
| 897 |
? WalletReferenceType.SCHEME_OUT
|
902 |
: schemeTypes.contains(SchemeType.ACTIVATION) ? WalletReferenceType.ACTIVATION_SCHEME
|
| 898 |
: (schemeTypes.contains(SchemeType.ACTIVATION) ? WalletReferenceType.ACTIVATION_SCHEME
|
903 |
: schemeTypes.contains(SchemeType.SPECIAL_SUPPORT) ? WalletReferenceType.SPECIAL_SUPPORT
|
| 899 |
: (schemeTypes.contains(SchemeType.SPECIAL_SUPPORT)) ? WalletReferenceType.SPECIAL_SUPPORT : WalletReferenceType.INVESTMENT_PAYOUT);
|
904 |
: schemeTypes.contains(SchemeType.INVESTMENT) ? WalletReferenceType.INVESTMENT_PAYOUT : null;
|
| - |
|
905 |
|
| 900 |
if (amountToRollback > 0) {
|
906 |
if (walletReferenceType == null)
|
| - |
|
907 |
if (amountToRollback > 0 && walletReferenceType != null) {
|
| 901 |
// Mark appropriate reference of rollback investment margin
|
908 |
// Mark appropriate reference of rollback investment margin
|
| 902 |
if (schemeTypes.contains(SchemeType.INVESTMENT)) {
|
909 |
if (schemeTypes.contains(SchemeType.INVESTMENT)) {
|
| - |
|
910 |
List<UserWalletHistory> userWalletHistoryList = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(reversalReference, walletReferenceType);
|
| - |
|
911 |
if (userWalletHistoryList.size() == 0) {
|
| 903 |
reversalReference = Integer
|
912 |
reversalReference = Integer
|
| 904 |
.parseInt(FormattingUtils.getYearMonth(schemeTypeMap.get(SchemeType.INVESTMENT).getCreditTimestamp().minusMonths(1)));
|
913 |
.parseInt(FormattingUtils.getYearMonth(schemeTypeMap.get(SchemeType.INVESTMENT).getCreditTimestamp().minusMonths(1)));
|
| - |
|
914 |
}
|
| - |
|
915 |
|
| 905 |
}
|
916 |
}
|
| 906 |
walletService.rollbackAmountFromWallet(fofoId, amountToRollback, reversalReference, walletReferenceType,
|
917 |
walletService.rollbackAmountFromWallet(fofoId, amountToRollback, reversalReference, walletReferenceType,
|
| 907 |
reversalReason, LocalDateTime.now());
|
918 |
reversalReason, LocalDateTime.now());
|
| 908 |
}
|
919 |
}
|
| 909 |
}
|
920 |
}
|
| 910 |
|
921 |
|
| 911 |
@Override
|
922 |
@Override
|