| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.text.MessageFormat;
|
- |
|
| 4 |
import java.time.LocalDateTime;
|
- |
|
| 5 |
import java.util.List;
|
- |
|
| 6 |
import java.util.Map;
|
- |
|
| 7 |
import java.util.Optional;
|
- |
|
| 8 |
|
- |
|
| 9 |
import javax.mail.internet.InternetAddress;
|
- |
|
| 10 |
import javax.mail.internet.MimeMessage;
|
- |
|
| 11 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 12 |
|
- |
|
| 13 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 14 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 15 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 16 |
import org.springframework.beans.factory.annotation.Qualifier;
|
- |
|
| 17 |
import org.springframework.http.MediaType;
|
- |
|
| 18 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 19 |
import org.springframework.mail.javamail.JavaMailSender;
|
- |
|
| 20 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
- |
|
| 21 |
import org.springframework.stereotype.Controller;
|
- |
|
| 22 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 23 |
import org.springframework.ui.Model;
|
- |
|
| 24 |
import org.springframework.web.bind.annotation.PathVariable;
|
- |
|
| 25 |
import org.springframework.web.bind.annotation.RequestBody;
|
- |
|
| 26 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 27 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 28 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 29 |
|
- |
|
| 30 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 31 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
4 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 32 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 33 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
6 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 34 |
import com.spice.profitmandi.dao.entity.fofo.FofoPayment;
|
7 |
import com.spice.profitmandi.dao.entity.fofo.FofoPayment;
|
| Line 43... |
Line 16... |
| 43 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
16 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 44 |
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
|
17 |
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
|
| 45 |
import com.spice.profitmandi.service.user.RetailerService;
|
18 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 46 |
import com.spice.profitmandi.service.wallet.WalletService;
|
19 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 47 |
import com.spice.profitmandi.web.req.CreateAddMoneyRequest;
|
20 |
import com.spice.profitmandi.web.req.CreateAddMoneyRequest;
|
| 48 |
|
- |
|
| 49 |
import io.swagger.annotations.ApiImplicitParam;
|
21 |
import io.swagger.annotations.ApiImplicitParam;
|
| 50 |
import io.swagger.annotations.ApiImplicitParams;
|
22 |
import io.swagger.annotations.ApiImplicitParams;
|
| 51 |
import io.swagger.annotations.ApiOperation;
|
23 |
import io.swagger.annotations.ApiOperation;
|
| - |
|
24 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
25 |
import org.apache.logging.log4j.Logger;
|
| - |
|
26 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
27 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| - |
|
28 |
import org.springframework.http.MediaType;
|
| - |
|
29 |
import org.springframework.http.ResponseEntity;
|
| - |
|
30 |
import org.springframework.mail.javamail.JavaMailSender;
|
| - |
|
31 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
| - |
|
32 |
import org.springframework.stereotype.Controller;
|
| - |
|
33 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
34 |
import org.springframework.ui.Model;
|
| - |
|
35 |
import org.springframework.web.bind.annotation.*;
|
| - |
|
36 |
|
| - |
|
37 |
import javax.mail.internet.InternetAddress;
|
| - |
|
38 |
import javax.mail.internet.MimeMessage;
|
| - |
|
39 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
40 |
import java.text.MessageFormat;
|
| - |
|
41 |
import java.time.LocalDateTime;
|
| - |
|
42 |
import java.util.List;
|
| - |
|
43 |
import java.util.Map;
|
| - |
|
44 |
import java.util.Optional;
|
| 52 |
|
45 |
|
| 53 |
@Controller
|
46 |
@Controller
|
| 54 |
@Transactional(rollbackFor = Throwable.class)
|
47 |
@Transactional(rollbackFor = Throwable.class)
|
| 55 |
public class WalletController {
|
48 |
public class WalletController {
|
| 56 |
|
49 |
|
| Line 119... |
Line 112... |
| 119 |
Optional<PaymentOptionModel> optPaymentOptionModel = paymentOptionModels.stream().filter(x->x.getPaymentMethod().equals(payMethod)).findFirst();
|
112 |
Optional<PaymentOptionModel> optPaymentOptionModel = paymentOptionModels.stream().filter(x->x.getPaymentMethod().equals(payMethod)).findFirst();
|
| 120 |
|
113 |
|
| 121 |
if(!optPaymentOptionModel.isPresent()) {
|
114 |
if(!optPaymentOptionModel.isPresent()) {
|
| 122 |
return responseSender.badRequest(new ProfitMandiBusinessException("", "", "Bad parameters in request"));
|
115 |
return responseSender.badRequest(new ProfitMandiBusinessException("", "", "Bad parameters in request"));
|
| 123 |
} else {
|
116 |
} else {
|
| - |
|
117 |
double interimValue = optPaymentOptionModel.get().getSurcharge() * 1.18 / 100;
|
| 124 |
double calculatedSurcharge = Math.round(loanAmount*optPaymentOptionModel.get().getSurcharge()*1.18/100);
|
118 |
double calculatedSurcharge = Math.round(loanAmount * interimValue / (1 - interimValue));
|
| 125 |
if(Math.abs(calculatedSurcharge - surcharge) >= 1) {
|
119 |
if (Math.abs(calculatedSurcharge - surcharge) >= 1) {
|
| 126 |
return responseSender.badRequest(new ProfitMandiBusinessException("", "", "Bad parameters in request"));
|
120 |
return responseSender.badRequest(new ProfitMandiBusinessException("", "", "Bad parameters in request"));
|
| 127 |
}
|
121 |
}
|
| 128 |
}
|
122 |
}
|
| 129 |
int userId = (int) request.getAttribute("userId");
|
123 |
int userId = (int) request.getAttribute("userId");
|
| 130 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
124 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|