| Line 19... |
Line 19... |
| 19 |
import javax.mail.internet.InternetAddress;
|
19 |
import javax.mail.internet.InternetAddress;
|
| 20 |
import javax.mail.internet.MimeMessage;
|
20 |
import javax.mail.internet.MimeMessage;
|
| 21 |
import javax.servlet.http.HttpServletRequest;
|
21 |
import javax.servlet.http.HttpServletRequest;
|
| 22 |
|
22 |
|
| 23 |
import org.apache.commons.io.FileUtils;
|
23 |
import org.apache.commons.io.FileUtils;
|
| 24 |
import org.json.JSONObject;
|
- |
|
| 25 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 26 |
import org.apache.logging.log4j.LogManager;
|
24 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
25 |
import org.apache.logging.log4j.Logger;
|
| - |
|
26 |
import org.json.JSONObject;
|
| 27 |
import org.springframework.beans.factory.annotation.Autowired;
|
27 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 28 |
import org.springframework.beans.factory.annotation.Value;
|
28 |
import org.springframework.beans.factory.annotation.Value;
|
| 29 |
import org.springframework.http.ResponseEntity;
|
29 |
import org.springframework.http.ResponseEntity;
|
| 30 |
import org.springframework.mail.javamail.JavaMailSender;
|
30 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 31 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
31 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
| Line 46... |
Line 46... |
| 46 |
import com.spice.profitmandi.common.model.PdfModel;
|
46 |
import com.spice.profitmandi.common.model.PdfModel;
|
| 47 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
47 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 48 |
import com.spice.profitmandi.common.util.InsuranceUtils;
|
48 |
import com.spice.profitmandi.common.util.InsuranceUtils;
|
| 49 |
import com.spice.profitmandi.common.util.PdfUtils;
|
49 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 50 |
import com.spice.profitmandi.common.util.StringUtils;
|
50 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 51 |
import com.spice.profitmandi.common.util.Utils;
|
- |
|
| 52 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
51 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 53 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
52 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 54 |
import com.spice.profitmandi.dao.entity.dtr.GadgetCopsInsuranceCalc;
|
53 |
import com.spice.profitmandi.dao.entity.dtr.GadgetCopsInsuranceCalc;
|
| 55 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
54 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| 56 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
55 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
| Line 67... |
Line 66... |
| 67 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
66 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 68 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
67 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
| 69 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
68 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 70 |
import com.spice.profitmandi.service.pricing.PricingService;
|
69 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 71 |
import com.spice.profitmandi.service.wallet.WalletService;
|
70 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| - |
|
71 |
import com.spice.profitmandi.web.processor.OtpProcessor;
|
| 72 |
|
72 |
|
| 73 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
73 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| 74 |
|
74 |
|
| 75 |
@Controller
|
75 |
@Controller
|
| 76 |
@Transactional(rollbackFor = Throwable.class)
|
76 |
@Transactional(rollbackFor = Throwable.class)
|
| Line 82... |
Line 82... |
| 82 |
private GadgetCopsInsuranceCalcRepository gadgetCopsInsuranceCalcRepository;
|
82 |
private GadgetCopsInsuranceCalcRepository gadgetCopsInsuranceCalcRepository;
|
| 83 |
|
83 |
|
| 84 |
//This is now unused as we are not supporting multiple companies.
|
84 |
//This is now unused as we are not supporting multiple companies.
|
| 85 |
@Value("${fofo.warehouseIds}")
|
85 |
@Value("${fofo.warehouseIds}")
|
| 86 |
private int[] warehouseIds;
|
86 |
private int[] warehouseIds;
|
| - |
|
87 |
|
| - |
|
88 |
@Autowired OtpProcessor otpProcessor;
|
| - |
|
89 |
|
| 87 |
|
90 |
|
| 88 |
@RequestMapping(value = ProfitMandiConstants.URL_INSURANCE_GADGET_COPS_MAPPING, method = RequestMethod.GET)
|
91 |
@RequestMapping(value = ProfitMandiConstants.URL_INSURANCE_GADGET_COPS_MAPPING, method = RequestMethod.GET)
|
| 89 |
public ResponseEntity<?> getById(HttpServletRequest request) {
|
92 |
public ResponseEntity<?> getById(HttpServletRequest request) {
|
| 90 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
93 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 91 |
List<GadgetCopsInsuranceCalc> calcList = gadgetCopsInsuranceCalcRepository.selectAll();
|
94 |
List<GadgetCopsInsuranceCalc> calcList = gadgetCopsInsuranceCalcRepository.selectAll();
|
| Line 205... |
Line 208... |
| 205 |
|
208 |
|
| 206 |
List<File> attachments = this.savePolicyDocs(insurancePolicy.getPolicyNumber(), byteArrayOutputStream, deviceImg, deviceInvoiceImg);
|
209 |
List<File> attachments = this.savePolicyDocs(insurancePolicy.getPolicyNumber(), byteArrayOutputStream, deviceImg, deviceInvoiceImg);
|
| 207 |
String messageText = MessageFormat.format(
|
210 |
String messageText = MessageFormat.format(
|
| 208 |
"Dear {0}, Thank you for purchasing Damage Protection Plan. Your Policy number is {1}",
|
211 |
"Dear {0}, Thank you for purchasing Damage Protection Plan. Your Policy number is {1}",
|
| 209 |
insurancePolicy.getCustomerFirstName(), insurancePolicy.getPolicyNumber());
|
212 |
insurancePolicy.getCustomerFirstName(), insurancePolicy.getPolicyNumber());
|
| 210 |
Utils.sendSms(messageText, insurancePolicy.getCustomerMobileNumber());
|
213 |
otpProcessor.sendSms(messageText, insurancePolicy.getCustomerMobileNumber());
|
| 211 |
messageText += "\n Please find your Invoice and Documents submitted by you.";
|
214 |
messageText += "\n Please find your Invoice and Documents submitted by you.";
|
| 212 |
String subject = "Your Gadget Cop damage Protection purchase is successful";
|
215 |
String subject = "Your Gadget Cop damage Protection purchase is successful";
|
| 213 |
this.sendMailWithAttachments(insuranceModel.getCustomerEmailId() , subject, messageText, attachments);
|
216 |
this.sendMailWithAttachments(insuranceModel.getCustomerEmailId() , subject, messageText, attachments);
|
| 214 |
|
217 |
|
| 215 |
float taxableInsuranceMargin = (insurancePolicy.getSaleAmount() - insurancePolicy.getPurchaseAmount()) / (1 + ProfitMandiConstants.INSURANCE_TAX_RATE / 100);
|
218 |
float taxableInsuranceMargin = (insurancePolicy.getSaleAmount() - insurancePolicy.getPurchaseAmount()) / (1 + ProfitMandiConstants.INSURANCE_TAX_RATE / 100);
|