| Line 30... |
Line 30... |
| 30 |
import com.spice.profitmandi.dao.entity.warehouse.BrandRegionMapping;
|
30 |
import com.spice.profitmandi.dao.entity.warehouse.BrandRegionMapping;
|
| 31 |
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
|
31 |
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
|
| 32 |
import com.spice.profitmandi.dao.entity.warehouse.WarehouseScan;
|
32 |
import com.spice.profitmandi.dao.entity.warehouse.WarehouseScan;
|
| 33 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
33 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| 34 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
34 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| - |
|
35 |
import com.spice.profitmandi.dao.enumuration.catalog.StockTransactionType;
|
| 35 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
36 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
| 36 |
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
|
37 |
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
|
| 37 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
38 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 38 |
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
|
39 |
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
|
| 39 |
import com.spice.profitmandi.dao.model.*;
|
40 |
import com.spice.profitmandi.dao.model.*;
|
| Line 1900... |
Line 1901... |
| 1900 |
|
1901 |
|
| 1901 |
public void processSchemeByIds(List<Integer> schemeIds) throws Exception {
|
1902 |
public void processSchemeByIds(List<Integer> schemeIds) throws Exception {
|
| 1902 |
List<Scheme> schemes = schemeRepository.selectBySchemeIds(schemeIds);
|
1903 |
List<Scheme> schemes = schemeRepository.selectBySchemeIds(schemeIds);
|
| 1903 |
for (Scheme scheme : schemes) {
|
1904 |
for (Scheme scheme : schemes) {
|
| 1904 |
List<Integer> catalogIds = schemeItemRepository.selectBySchemeIds(new HashSet<>(Arrays.asList(scheme.getId()))).stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
|
1905 |
List<Integer> catalogIds = schemeItemRepository.selectBySchemeIds(new HashSet<>(Arrays.asList(scheme.getId()))).stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
|
| 1905 |
if (Arrays.asList(SchemeType.SPECIAL_SUPPORT, SchemeType.ACTIVATION, SchemeType.CATEGORY, SchemeType.INVESTMENT, SchemeType.ACTIVATION, SchemeType.SPECIAL_SUPPORT).contains(scheme.getType())) {
|
1906 |
if (scheme.getType().getTransactionType().equals(StockTransactionType.OUT)) {
|
| 1906 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectOrderByModelAndSaleBetween(catalogIds, scheme.getStartDateTime(), scheme.getEndDateTime());
|
1907 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectOrderByModelAndSaleBetween(catalogIds, scheme.getStartDateTime(), scheme.getEndDateTime());
|
| 1907 |
for (FofoOrder fofoOrder : fofoOrders) {
|
1908 |
for (FofoOrder fofoOrder : fofoOrders) {
|
| 1908 |
System.out.println("Processing fofoOrder --- " + fofoOrder.getInvoiceNumber());
|
1909 |
System.out.println("Processing fofoOrder --- " + fofoOrder.getInvoiceNumber());
|
| 1909 |
System.out.println("Processing fofoOrder --- " + fofoOrder.getInvoiceNumber());
|
1910 |
System.out.println("Processing fofoOrder --- " + fofoOrder.getInvoiceNumber());
|
| 1910 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
|
1911 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
|
| 1911 |
}
|
1912 |
}
|
| 1912 |
} else if (Arrays.asList(SchemeType.IN).contains(scheme.getType())) {
|
1913 |
} else if (Arrays.asList(StockTransactionType.IN).contains(scheme.getType())) {
|
| 1913 |
List<Purchase> purchases = purchaseRepository.selectPurchaseByCatalogsAndSaleBetween(catalogIds, scheme.getStartDateTime(), scheme.getEndDateTime());
|
1914 |
List<Purchase> purchases = purchaseRepository.selectPurchaseByCatalogsAndSaleBetween(catalogIds, scheme.getStartDateTime(), scheme.getEndDateTime());
|
| 1914 |
for (Purchase purchase : purchases) {
|
1915 |
for (Purchase purchase : purchases) {
|
| 1915 |
System.out.println("Processing purchase --- " + purchase.getPurchaseReference());
|
1916 |
System.out.println("Processing purchase --- " + purchase.getPurchaseReference());
|
| 1916 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
1917 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
| 1917 |
}
|
1918 |
}
|
| Line 1921... |
Line 1922... |
| 1921 |
}
|
1922 |
}
|
| 1922 |
|
1923 |
|
| 1923 |
@Autowired
|
1924 |
@Autowired
|
| 1924 |
InsurancePolicyRepository insurancePolicyRepository;
|
1925 |
InsurancePolicyRepository insurancePolicyRepository;
|
| 1925 |
|
1926 |
|
| - |
|
1927 |
@Autowired
|
| - |
|
1928 |
CreditNoteLineRepository creditNoteLineRepository;
|
| - |
|
1929 |
|
| - |
|
1930 |
@Autowired
|
| - |
|
1931 |
CreditNoteRepository creditNoteRepository;
|
| - |
|
1932 |
|
| 1926 |
public void addMissingWalletDebitsForInsurance() throws Exception {
|
1933 |
public void addMissingWalletDebitsForInsurance() throws Exception {
|
| 1927 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(5, Optional.empty());
|
1934 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(5, Optional.empty());
|
| 1928 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
1935 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
| 1929 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(insurancePolicy.getInvoiceNumber());
|
1936 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(insurancePolicy.getInvoiceNumber());
|
| 1930 |
List<UserWalletHistory> userWalletHistories = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(insurancePolicy.getId(), WalletReferenceType.DAMAGE_PROTECTION);
|
1937 |
List<UserWalletHistory> userWalletHistories = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(insurancePolicy.getId(), WalletReferenceType.DAMAGE_PROTECTION);
|
| Line 1936... |
Line 1943... |
| 1936 |
}
|
1943 |
}
|
| 1937 |
|
1944 |
|
| 1938 |
public void changeFulfillmentWarehouse(int orderId, int whId) throws ProfitMandiBusinessException {
|
1945 |
public void changeFulfillmentWarehouse(int orderId, int whId) throws ProfitMandiBusinessException {
|
| 1939 |
transactionService.changeFulfillmentWarehouse(orderId, whId);
|
1946 |
transactionService.changeFulfillmentWarehouse(orderId, whId);
|
| 1940 |
}
|
1947 |
}
|
| - |
|
1948 |
|
| - |
|
1949 |
|
| - |
|
1950 |
public void findCNDiff() throws ProfitMandiBusinessException {
|
| - |
|
1951 |
LocalDate startDate = LocalDate.of(2022, 9, 01);
|
| - |
|
1952 |
List<UserWalletHistory> userWalletHistories = userWalletHistoryRepository.selectAllByDateType(startDate.atStartOfDay(), startDate.plusYears(3).atStartOfDay().withMonth(Month.JANUARY.getValue()), Arrays.asList(WalletReferenceType.ACTIVATION_SCHEME, WalletReferenceType.ADDITIONAL_SCHEME, WalletReferenceType.INVESTMENT_PAYOUT
|
| - |
|
1953 |
, WalletReferenceType.SPECIAL_SUPPORT, WalletReferenceType.PRICE_DROP, WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
| - |
|
1954 |
|
| - |
|
1955 |
Map<Integer, Map<YearMonth, Double>> fofoMonthAmount = userWalletHistories.stream().collect(Collectors.groupingBy(x -> x.getWalletId(),
|
| - |
|
1956 |
Collectors.groupingBy(x -> YearMonth.from(x.getTimestamp()), Collectors.summingDouble(x -> x.getAmount()))));
|
| - |
|
1957 |
|
| - |
|
1958 |
System.out.println("FofoId\tYearMonth\tWallet\tCN");
|
| - |
|
1959 |
for (Map.Entry<Integer, Map<YearMonth, Double>> fofoMonthAmountEntry : fofoMonthAmount.entrySet()) {
|
| - |
|
1960 |
int walletId = fofoMonthAmountEntry.getKey();
|
| - |
|
1961 |
int fofoId = userWalletRepository.selectById(walletId).getUserId();
|
| - |
|
1962 |
for (Map.Entry<YearMonth, Double> yearMonthAmountEntry : fofoMonthAmountEntry.getValue().entrySet()) {
|
| - |
|
1963 |
YearMonth yearMonth = yearMonthAmountEntry.getKey();
|
| - |
|
1964 |
double walletAmount = yearMonthAmountEntry.getValue();
|
| - |
|
1965 |
double cnAmount = 0;
|
| - |
|
1966 |
List<Integer> creditNoteIds = creditNoteRepository.selectAll(fofoId, yearMonth).stream().map(cn -> cn.getId()).collect(Collectors.toList());
|
| - |
|
1967 |
if(creditNoteIds.size() > 0) {
|
| - |
|
1968 |
cnAmount = creditNoteLineRepository.selectAllByCreditNoteIds(creditNoteIds).stream().collect(Collectors.summingDouble(CreditNoteLine::getAmount));
|
| - |
|
1969 |
}
|
| - |
|
1970 |
if(cnAmount != walletAmount) {
|
| - |
|
1971 |
System.out.println(fofoId + "\t" + yearMonth + "\t" + walletAmount + "\t" + cnAmount);
|
| - |
|
1972 |
}
|
| - |
|
1973 |
|
| - |
|
1974 |
|
| - |
|
1975 |
}
|
| - |
|
1976 |
}
|
| - |
|
1977 |
|
| - |
|
1978 |
}
|
| 1941 |
}
|
1979 |
}
|
| 1942 |
|
1980 |
|
| 1943 |
//7015845171
|
1981 |
//7015845171
|
| 1944 |
|
1982 |
|