| Line 11... |
Line 11... |
| 11 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
11 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 12 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
12 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 13 |
import com.spice.profitmandi.dao.entity.user.User;
|
13 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 14 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
14 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
| 15 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
15 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
| - |
|
16 |
import com.spice.profitmandi.dao.enumuration.transaction.TransactionType;
|
| 16 |
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
|
17 |
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
|
| 17 |
import com.spice.profitmandi.dao.repository.catalog.ManualPaymentRequestRepository;
|
18 |
import com.spice.profitmandi.dao.repository.catalog.ManualPaymentRequestRepository;
|
| 18 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
19 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 19 |
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
|
20 |
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
|
| 20 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
21 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| Line 380... |
Line 381... |
| 380 |
paymentType.setCounter(paymentType.getCounter() + 1);
|
381 |
paymentType.setCounter(paymentType.getCounter() + 1);
|
| 381 |
return paymentType.getCounter();
|
382 |
return paymentType.getCounter();
|
| 382 |
|
383 |
|
| 383 |
}
|
384 |
}
|
| 384 |
|
385 |
|
| - |
|
386 |
/**
|
| - |
|
387 |
* Manual (admin) wallet adjustment. Allocates a manual reference when one is not supplied,
|
| - |
|
388 |
* checks the reference is not already assigned to a different partner, and then moves the
|
| - |
|
389 |
* money through {@link #addAmountToWallet}/{@link #consumeAmountFromWallet} so the balance is
|
| - |
|
390 |
* only ever changed under the wallet row lock those methods take.
|
| - |
|
391 |
*
|
| - |
|
392 |
* @return the reference actually used (allocated here when the caller passed 0)
|
| - |
|
393 |
*/
|
| - |
|
394 |
@Override
|
| - |
|
395 |
public int applyManualAdjustment(int retailerId, int reference, WalletReferenceType referenceType,
|
| - |
|
396 |
TransactionType transactionType, int amount, String description,
|
| - |
|
397 |
LocalDateTime businessTimestamp) throws ProfitMandiBusinessException {
|
| - |
|
398 |
if (reference == 0 && referenceType.getValue() >= WalletReferenceType.INCENTIVES.getValue()) {
|
| - |
|
399 |
reference = this.getManualReference(referenceType);
|
| - |
|
400 |
} else if (reference == 0) {
|
| - |
|
401 |
throw new ProfitMandiBusinessException("RefrenceId", reference,
|
| - |
|
402 |
"System specific reference type cant be used manually");
|
| - |
|
403 |
}
|
| - |
|
404 |
|
| - |
|
405 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
|
| - |
|
406 |
final int walletId = userWallet != null ? userWallet.getId() : 0;
|
| - |
|
407 |
List<UserWalletHistory> existingEntries = userWalletHistoryRepository
|
| - |
|
408 |
.selectAllByreferenceIdandreferenceType(reference, referenceType);
|
| - |
|
409 |
if (!existingEntries.isEmpty()
|
| - |
|
410 |
&& existingEntries.stream().noneMatch(x -> x.getWalletId() == walletId)) {
|
| - |
|
411 |
throw new ProfitMandiBusinessException("RefrenceId", reference, "Reference Id assign to Other partner");
|
| - |
|
412 |
}
|
| - |
|
413 |
|
| - |
|
414 |
if (TransactionType.DEBIT.equals(transactionType)) {
|
| - |
|
415 |
this.consumeAmountFromWallet(retailerId, reference, referenceType, description, amount,
|
| - |
|
416 |
businessTimestamp, true);
|
| - |
|
417 |
} else {
|
| - |
|
418 |
this.addAmountToWallet(retailerId, reference, referenceType, description, amount, businessTimestamp);
|
| - |
|
419 |
}
|
| - |
|
420 |
return reference;
|
| - |
|
421 |
}
|
| - |
|
422 |
|
| 385 |
@Override
|
423 |
@Override
|
| 386 |
public ResponseEntity<?> createAddWalletRequestReport(LocalDateTime startDate, LocalDateTime endDate, AddWalletRequestStatus status) throws Exception {
|
424 |
public ResponseEntity<?> createAddWalletRequestReport(LocalDateTime startDate, LocalDateTime endDate, AddWalletRequestStatus status) throws Exception {
|
| 387 |
List<List<?>> rows = new ArrayList<>();
|
425 |
List<List<?>> rows = new ArrayList<>();
|
| 388 |
List<String> header = Arrays.asList(
|
426 |
List<String> header = Arrays.asList(
|
| 389 |
"Retailer Id",
|
427 |
"Retailer Id",
|