| Line 166... |
Line 166... |
| 166 |
insurancePolicy.setCustomerAddress2(insuranceModel.getCustomerAddress2());
|
166 |
insurancePolicy.setCustomerAddress2(insuranceModel.getCustomerAddress2());
|
| 167 |
insurancePolicy.setCustomerCity(insuranceModel.getCustomerCity());
|
167 |
insurancePolicy.setCustomerCity(insuranceModel.getCustomerCity());
|
| 168 |
insurancePolicy.setCustomerPinCode(insuranceModel.getCustomerPinCode());
|
168 |
insurancePolicy.setCustomerPinCode(insuranceModel.getCustomerPinCode());
|
| 169 |
insurancePolicy.setCustomerState(insuranceModel.getCustomerState());
|
169 |
insurancePolicy.setCustomerState(insuranceModel.getCustomerState());
|
| 170 |
insurancePolicyRepository.persist(insurancePolicy);
|
170 |
insurancePolicyRepository.persist(insurancePolicy);
|
| - |
|
171 |
String walletDescription = "Purchased Damage Protection policy " + insurancePolicy.getPolicyNumber()
|
| - |
|
172 |
+ " for " + insurancePolicy.getCustomerFirstName();
|
| 171 |
|
173 |
|
| 172 |
walletService.consumeAmountFromWallet(uc.getUserId(), insurancePolicy.getId(), WalletReferenceType.DAMAGE_PROTECTION,
|
174 |
walletService.consumeAmountFromWallet(uc.getUserId(), insurancePolicy.getId(), WalletReferenceType.DAMAGE_PROTECTION, walletDescription, insurancePolicy.getSaleAmount());
|
| 173 |
"Purchased Damage Protection policy for " + insurancePolicy.getCustomerFirstName() , insurancePolicy.getSaleAmount());
|
- |
|
| 174 |
|
175 |
|
| 175 |
try{
|
176 |
try{
|
| 176 |
InsuranceUtils.submitToGadgetCops(insuranceModel);
|
177 |
InsuranceUtils.submitToGadgetCops(insuranceModel);
|
| 177 |
insurancePolicy.setPosted(true);
|
178 |
insurancePolicy.setPosted(true);
|
| 178 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
179 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| Line 193... |
Line 194... |
| 193 |
"Dear {0}, Thank you for purchasing Damage Protection Plan. Your Policy number is {1}",
|
194 |
"Dear {0}, Thank you for purchasing Damage Protection Plan. Your Policy number is {1}",
|
| 194 |
insurancePolicy.getCustomerFirstName(), insurancePolicy.getPolicyNumber());
|
195 |
insurancePolicy.getCustomerFirstName(), insurancePolicy.getPolicyNumber());
|
| 195 |
Utils.sendSms(messageText, insurancePolicy.getCustomerMobileNumber());
|
196 |
Utils.sendSms(messageText, insurancePolicy.getCustomerMobileNumber());
|
| 196 |
List<File> attachments = this.savePolicyDocs(insurancePolicy.getPolicyNumber(), byteArrayOutputStream, deviceImg, deviceInvoiceImg);
|
197 |
List<File> attachments = this.savePolicyDocs(insurancePolicy.getPolicyNumber(), byteArrayOutputStream, deviceImg, deviceInvoiceImg);
|
| 197 |
messageText += "\n Please find your Invoice, and documents submitted by you.";
|
198 |
messageText += "\n Please find your Invoice, and documents submitted by you.";
|
| 198 |
String subject = "Your Gadget Cop damage Protection";
|
199 |
String subject = "Your Gadget Cop damage Protection purchase is successful";
|
| 199 |
this.sendMailWithAttachments(insuranceModel.getCustomerEmailId() , subject, messageText, attachments);
|
200 |
this.sendMailWithAttachments(insuranceModel.getCustomerEmailId() , subject, messageText, attachments);
|
| - |
|
201 |
|
| - |
|
202 |
float taxableInsuranceMargin = insurancePolicy.getSaleAmount() / (1 + ProfitMandiConstants.INSURANCE_TAX_RATE / 100);
|
| - |
|
203 |
walletService.addAmountToWallet(uc.getUserId(), insurancePolicy.getId(), WalletReferenceType.CASHBACK, "Cashback against insurance policy",
|
| - |
|
204 |
taxableInsuranceMargin);
|
| 200 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
205 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 201 |
return responseSender.ok(true);
|
206 |
return responseSender.ok(true);
|
| 202 |
}
|
207 |
}
|
| 203 |
|
208 |
|
| 204 |
private void sendMailWithAttachments(String email, String subject, String body, List<File> attachments) throws Exception {
|
209 |
private void sendMailWithAttachments(String email, String subject, String body, List<File> attachments) throws Exception {
|
| 205 |
|
210 |
|
| 206 |
MimeMessage message = mailSender.createMimeMessage();
|
211 |
MimeMessage message = mailSender.createMimeMessage();
|
| 207 |
MimeMessageHelper helper = new MimeMessageHelper(message,true);
|
212 |
MimeMessageHelper helper = new MimeMessageHelper(message,true);
|
| 208 |
helper.setSubject("New Contact Us message");
|
213 |
helper.setSubject(subject);
|
| 209 |
helper.setText(body);
|
214 |
helper.setText(body);
|
| 210 |
String[] cc = {"amit.gupta@shop2020.in"};
|
- |
|
| 211 |
//String[] cc = {"amit.gupta@shop2020.in"};
|
215 |
//String[] cc = {"amit.gupta@shop2020.in"};
|
| - |
|
216 |
//String[] cc = {"amit.gupta@shop2020.in"};
|
| 212 |
helper.setCc(cc);
|
217 |
//helper.setCc(cc);
|
| 213 |
InternetAddress senderAddress = new InternetAddress("noreply@profitmandi.com", "ProfitMandi Admin");
|
218 |
InternetAddress senderAddress = new InternetAddress("noreply@profitmandi.com", "ProfitMandi Admin");
|
| 214 |
helper.setTo("help@profitmandi.com");
|
219 |
helper.setTo("help@profitmandi.com");
|
| 215 |
helper.setFrom(senderAddress);
|
220 |
helper.setFrom(senderAddress);
|
| 216 |
for (File file : attachments) {
|
221 |
for (File file : attachments) {
|
| 217 |
helper.addAttachment(file.getName(), file);
|
222 |
helper.addAttachment(file.getName(), file);
|