| Line 59... |
Line 59... |
| 59 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
59 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
| 60 |
import com.spice.profitmandi.dao.repository.dtr.PolicyNumberGenerationSequenceRepository;
|
60 |
import com.spice.profitmandi.dao.repository.dtr.PolicyNumberGenerationSequenceRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.dtr.ThirdPartyInvoiceSequenceRepository;
|
61 |
import com.spice.profitmandi.dao.repository.dtr.ThirdPartyInvoiceSequenceRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
62 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
63 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
| - |
|
64 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 64 |
import com.spice.profitmandi.service.pricing.PricingService;
|
65 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 65 |
import com.spice.profitmandi.service.wallet.WalletService;
|
66 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 66 |
|
67 |
|
| 67 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
68 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| 68 |
|
69 |
|
| Line 110... |
Line 111... |
| 110 |
|
111 |
|
| 111 |
@Autowired
|
112 |
@Autowired
|
| 112 |
WalletService walletService;
|
113 |
WalletService walletService;
|
| 113 |
|
114 |
|
| 114 |
@Autowired
|
115 |
@Autowired
|
| - |
|
116 |
UserWalletRepository userWalletRepositoy;
|
| - |
|
117 |
|
| - |
|
118 |
@Autowired
|
| 115 |
PolicyNumberGenerationSequenceRepository policyNumberGenerationSequenceRepository;
|
119 |
PolicyNumberGenerationSequenceRepository policyNumberGenerationSequenceRepository;
|
| 116 |
|
120 |
|
| 117 |
@RequestMapping(value = ProfitMandiConstants.URL_DAMAGE_INSURANCE, method = RequestMethod.POST)
|
121 |
@RequestMapping(value = ProfitMandiConstants.URL_DAMAGE_INSURANCE, method = RequestMethod.POST)
|
| 118 |
public ResponseEntity<?> createTheftProtection(HttpServletRequest request,
|
122 |
public ResponseEntity<?> createTheftProtection(HttpServletRequest request,
|
| 119 |
@RequestBody GadgetCopsDocumentInsuranceModel insuranceModel) throws Throwable {
|
123 |
@RequestBody GadgetCopsDocumentInsuranceModel insuranceModel) throws Throwable {
|
| Line 162... |
Line 166... |
| 162 |
insurancePolicy.setCustomerCity(insuranceModel.getCustomerCity());
|
166 |
insurancePolicy.setCustomerCity(insuranceModel.getCustomerCity());
|
| 163 |
insurancePolicy.setCustomerPinCode(insuranceModel.getCustomerPinCode());
|
167 |
insurancePolicy.setCustomerPinCode(insuranceModel.getCustomerPinCode());
|
| 164 |
insurancePolicy.setCustomerState(insuranceModel.getCustomerState());
|
168 |
insurancePolicy.setCustomerState(insuranceModel.getCustomerState());
|
| 165 |
insurancePolicyRepository.persist(insurancePolicy);
|
169 |
insurancePolicyRepository.persist(insurancePolicy);
|
| 166 |
|
170 |
|
| - |
|
171 |
walletService.consumeAmountFromWallet(uc.getUserId(), insurancePolicy.getId(), WalletReferenceType.DAMAGE_PROTECTION,
|
| - |
|
172 |
"Purchased Damage Protection policy for " + insurancePolicy.getCustomerFirstName() , insurancePolicy.getSaleAmount());
|
| - |
|
173 |
|
| 167 |
try{
|
174 |
try{
|
| 168 |
InsuranceUtils.submitToGadgetCops(insuranceModel);
|
175 |
InsuranceUtils.submitToGadgetCops(insuranceModel);
|
| 169 |
insurancePolicy.setPosted(true);
|
176 |
insurancePolicy.setPosted(true);
|
| 170 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
177 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| 171 |
LOGGER.info("Unable to submit insurance policy details to {}", insuranceProvider.getName(), profitMandiBusinessException);
|
178 |
LOGGER.info("Unable to submit insurance policy details to {}", insuranceProvider.getName(), profitMandiBusinessException);
|
| 172 |
}
|
179 |
}
|
| 173 |
insurancePolicyRepository.persist(insurancePolicy);
|
180 |
insurancePolicyRepository.persist(insurancePolicy);
|
| 174 |
|
- |
|
| 175 |
walletService.consumeAmountFromWallet(uc.getUserId(), insurancePolicy.getId(), WalletReferenceType.DAMAGE_PROTECTION,
|
- |
|
| 176 |
"Purchased Damage Protection policy for " + insurancePolicy.getCustomerFirstName() , insurancePolicy.getSaleAmount());
|
- |
|
| 177 |
|
181 |
|
| 178 |
PdfModel pdfModel = this.getInvoicePdfModel(insurancePolicy);
|
182 |
PdfModel pdfModel = this.getInvoicePdfModel(insurancePolicy);
|
| 179 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
183 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| 180 |
PdfUtils.generateAndWrite(pdfModel, byteArrayOutputStream);
|
184 |
PdfUtils.generateAndWrite(pdfModel, byteArrayOutputStream);
|
| 181 |
|
185 |
|