| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.service.wallet;
|
1 |
package com.spice.profitmandi.service.wallet;
|
| 2 |
|
2 |
|
| 3 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
3 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
5 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
6 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
7 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 6 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
8 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 7 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
9 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 8 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
10 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| - |
|
11 |
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
|
| 9 |
import com.spice.profitmandi.dao.entity.transaction.ManualPaymentType;
|
12 |
import com.spice.profitmandi.dao.entity.transaction.ManualPaymentType;
|
| 10 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
13 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 11 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
14 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 12 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
15 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
| - |
|
16 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
| - |
|
17 |
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
|
| 13 |
import com.spice.profitmandi.dao.repository.catalog.ManualPaymentRequestRepository;
|
18 |
import com.spice.profitmandi.dao.repository.catalog.ManualPaymentRequestRepository;
|
| 14 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
19 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 15 |
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
|
20 |
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
|
| 16 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
21 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| 17 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
22 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 18 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
23 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| 19 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
24 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 20 |
import com.spice.profitmandi.dao.repository.user.StoreTimelinetbRepository;
|
25 |
import com.spice.profitmandi.dao.repository.user.StoreTimelinetbRepository;
|
| 21 |
import com.spice.profitmandi.service.NotificationService;
|
26 |
import com.spice.profitmandi.service.NotificationService;
|
| 22 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
27 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| - |
|
28 |
import com.spice.profitmandi.service.order.OrderService;
|
| - |
|
29 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 23 |
import com.spice.profitmandi.service.user.StoreTimelineTatService;
|
30 |
import com.spice.profitmandi.service.user.StoreTimelineTatService;
|
| 24 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
31 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| 25 |
import org.apache.logging.log4j.LogManager;
|
32 |
import org.apache.logging.log4j.LogManager;
|
| 26 |
import org.apache.logging.log4j.Logger;
|
33 |
import org.apache.logging.log4j.Logger;
|
| 27 |
import org.springframework.beans.factory.annotation.Autowired;
|
34 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
35 |
import org.springframework.http.ResponseEntity;
|
| 28 |
import org.springframework.stereotype.Component;
|
36 |
import org.springframework.stereotype.Component;
|
| 29 |
|
37 |
|
| 30 |
import java.time.LocalDateTime;
|
38 |
import java.time.LocalDateTime;
|
| 31 |
import java.util.*;
|
39 |
import java.util.*;
|
| 32 |
import java.util.stream.Collectors;
|
40 |
import java.util.stream.Collectors;
|
| Line 36... |
Line 44... |
| 36 |
|
44 |
|
| 37 |
private static final Logger LOGGER = LogManager.getLogger(WalletServiceImpl.class);
|
45 |
private static final Logger LOGGER = LogManager.getLogger(WalletServiceImpl.class);
|
| 38 |
|
46 |
|
| 39 |
@Autowired
|
47 |
@Autowired
|
| 40 |
ManualPaymentRequestRepository manualPaymentRequestRepository;
|
48 |
ManualPaymentRequestRepository manualPaymentRequestRepository;
|
| - |
|
49 |
@Autowired
|
| - |
|
50 |
AddWalletRequestRepository addWalletRequestRepository;
|
| - |
|
51 |
@Autowired
|
| - |
|
52 |
OrderService orderService;
|
| - |
|
53 |
@Autowired
|
| - |
|
54 |
RetailerService retailerService;
|
| 41 |
ProfitMandiBusinessException pbse = new ProfitMandiBusinessException("Wallet", "Wallet", "Wallet is under maintainance, please try after some time");
|
55 |
ProfitMandiBusinessException pbse = new ProfitMandiBusinessException("Wallet", "Wallet", "Wallet is under maintainance, please try after some time");
|
| 42 |
ProfitMandiBusinessException inactivepbse = new ProfitMandiBusinessException("Wallet", "Wallet", "Investment is incomplete, please add amount to wallet to complete the investment");
|
56 |
ProfitMandiBusinessException inactivepbse = new ProfitMandiBusinessException("Wallet", "Wallet", "Investment is incomplete, please add amount to wallet to complete the investment");
|
| 43 |
|
57 |
|
| 44 |
@Autowired
|
58 |
@Autowired
|
| 45 |
PartnerInvestmentService partnerInvestmentService;
|
59 |
PartnerInvestmentService partnerInvestmentService;
|
| Line 364... |
Line 378... |
| 364 |
}
|
378 |
}
|
| 365 |
paymentType.setCounter(paymentType.getCounter() + 1);
|
379 |
paymentType.setCounter(paymentType.getCounter() + 1);
|
| 366 |
return paymentType.getCounter();
|
380 |
return paymentType.getCounter();
|
| 367 |
|
381 |
|
| 368 |
}
|
382 |
}
|
| - |
|
383 |
|
| - |
|
384 |
@Override
|
| - |
|
385 |
public ResponseEntity<?> createAddWalletRequestReport(LocalDateTime startDate, LocalDateTime endDate, AddWalletRequestStatus status) throws Exception {
|
| - |
|
386 |
List<List<?>> rows = new ArrayList<>();
|
| - |
|
387 |
List<String> header = Arrays.asList(
|
| - |
|
388 |
"Retailer Id",
|
| - |
|
389 |
"Retailer Name",
|
| - |
|
390 |
"Email",
|
| - |
|
391 |
"City",
|
| - |
|
392 |
"State",
|
| - |
|
393 |
"Transaction Reference",
|
| - |
|
394 |
"Bank Name",
|
| - |
|
395 |
"Reference Date",
|
| - |
|
396 |
"Amount",
|
| - |
|
397 |
"status",
|
| - |
|
398 |
"Created On",
|
| - |
|
399 |
"Updated On"
|
| - |
|
400 |
);
|
| - |
|
401 |
|
| - |
|
402 |
List<AddWalletRequest> addWalletRequests = addWalletRequestRepository.selectAllRetailerIdByDateAndStatus(startDate, endDate, status);
|
| - |
|
403 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| - |
|
404 |
for (AddWalletRequest addWalletRequest : addWalletRequests) {
|
| - |
|
405 |
CustomRetailer customRetailer = customRetailerMap.get(addWalletRequest.getRetailerId());
|
| - |
|
406 |
rows.add(Arrays
|
| - |
|
407 |
.asList(
|
| - |
|
408 |
addWalletRequest.getRetailerId(),
|
| - |
|
409 |
customRetailer.getBusinessName(),
|
| - |
|
410 |
customRetailer.getEmail(),
|
| - |
|
411 |
customRetailer.getAddress().getCity(),
|
| - |
|
412 |
customRetailer.getAddress().getState(),
|
| - |
|
413 |
addWalletRequest.getTransaction_reference(),
|
| - |
|
414 |
addWalletRequest.getBank_name(),
|
| - |
|
415 |
addWalletRequest.getReference_date(),
|
| - |
|
416 |
addWalletRequest.getAmount(),
|
| - |
|
417 |
addWalletRequest.getStatus(),
|
| - |
|
418 |
addWalletRequest.getCreateTimestamp(),
|
| - |
|
419 |
addWalletRequest.getUpdateTimestamp()
|
| - |
|
420 |
)
|
| - |
|
421 |
);
|
| - |
|
422 |
}
|
| - |
|
423 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(header, rows);
|
| - |
|
424 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Add-wallet-request-"+status+"-Reort-" + startDate.toLocalDate() + "-To-" + endDate.toLocalDate());
|
| - |
|
425 |
return responseEntity;
|
| - |
|
426 |
}
|
| 369 |
}
|
427 |
}
|
| 370 |
|
428 |
|