Subversion Repositories SmartDukaan

Rev

Rev 33518 | Rev 33568 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33518 Rev 33525
Line 260... Line 260...
260
    // TODO , add paymnet if brand fee due
260
    // TODO , add paymnet if brand fee due
261
    @RequestMapping(value = "/brandfeeCollection", method = RequestMethod.POST)
261
    @RequestMapping(value = "/brandfeeCollection", method = RequestMethod.POST)
262
    public String addBrandFee(HttpServletRequest request, @RequestBody BrandFeeCollection brandFeeCollection, @RequestParam int loiId, Model model) throws Exception {
262
    public String addBrandFee(HttpServletRequest request, @RequestBody BrandFeeCollection brandFeeCollection, @RequestParam int loiId, Model model) throws Exception {
263
        LoiForm loiForm = loiFormRepository.selectById(loiId);
263
        LoiForm loiForm = loiFormRepository.selectById(loiId);
264
        List<BrandFeeCollection> brandFeeCollections = loiForm.getBrandFeeCollection();
264
        List<BrandFeeCollection> brandFeeCollections = loiForm.getBrandFeeCollection();
265
        double totatcollectedfee = brandFeeCollections.stream().mapToDouble(x -> x.getCollectedAmount()).sum();
265
        double totatcollectedfee = brandFeeCollections.stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM) || x.getPaymentStatus().equals(FeePaymentStatus.PENDING)).mapToDouble(x -> x.getCollectedAmount()).sum();
266
        double brandFee = loiForm.getAgreedBrandFees();
266
        double brandFee = loiForm.getAgreedBrandFees();
267
        double differanceAmount = brandFee - totatcollectedfee;
267
        double differanceAmount = brandFee - totatcollectedfee;
268
        if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
268
        if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
269
            brandFeeCollection.setTimeStamp(LocalDateTime.now());
269
            brandFeeCollection.setTimeStamp(LocalDateTime.now());
270
            brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
270
            brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
Line 296... Line 296...
296
        return "payment-collection-details";
296
        return "payment-collection-details";
297
    }
297
    }
298
 
298
 
299
    // bfcId - Brand Fee Collection Id
299
    // bfcId - Brand Fee Collection Id
300
    @RequestMapping("/feePaymentApproval")
300
    @RequestMapping("/feePaymentApproval")
301
    public String feePaymentApproval(HttpServletRequest request, @RequestParam int bfcId, @RequestParam FeePaymentStatus feePaymentStatus, Model model) throws Exception {
301
    public String feePaymentApproval(HttpServletRequest request, @RequestParam int bfcId, @RequestParam FeePaymentStatus feePaymentStatus, @RequestParam String description,
-
 
302
                                     Model model) throws Exception {
302
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
303
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
303
        String authEmail = loginDetails.getEmailId();
304
        String authEmail = loginDetails.getEmailId();
304
        BrandFeeCollection brandFeeCollection = brandFeeCollectionRepository.selectById(bfcId);
305
        BrandFeeCollection brandFeeCollection = brandFeeCollectionRepository.selectById(bfcId);
305
        LoiForm loiForm = brandFeeCollection.getLoiData();
306
        LoiForm loiForm = brandFeeCollection.getLoiData();
306
        List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiAuth(loiForm);
307
        List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiForm(loiForm);
307
        brandFeeCollection.setApproverEmail(authEmail);
308
        brandFeeCollection.setApproverEmail(authEmail);
308
        brandFeeCollection.setPaymentStatus(feePaymentStatus);
309
        brandFeeCollection.setPaymentStatus(feePaymentStatus);
-
 
310
        brandFeeCollection.setDescription(description);
309
        double agreedBrandFee = loiForm.getAgreedBrandFees();
311
        double agreedBrandFee = loiForm.getAgreedBrandFees();
310
        double totalBrandFeeCollection = brandFeeCollections.stream().mapToDouble(x -> x.getCollectedAmount()).sum() + brandFeeCollection.getCollectedAmount();
312
        double totalBrandFeeCollection = brandFeeCollections.stream().mapToDouble(x -> x.getCollectedAmount()).sum() + brandFeeCollection.getCollectedAmount();
311
        LOGGER.info("agreedBrandeFee -" + agreedBrandFee);
313
        LOGGER.info("agreedBrandeFee -" + agreedBrandFee);
312
        LOGGER.info("totalBrandFeeCollection -" + totalBrandFeeCollection);
314
        LOGGER.info("totalBrandFeeCollection -" + totalBrandFeeCollection);
313
        boolean b = agreedBrandFee == totalBrandFeeCollection && loiForm.getLoiSignOtp() != null;
315
        boolean b = agreedBrandFee == totalBrandFeeCollection && loiForm.getLoiSignOtp() != null;
-
 
316
        if (brandFeeCollection.getPaymentStatus().equals(FeePaymentStatus.REJECT)) {
-
 
317
            loiFormService.sendPaymentApprovalMail(brandFeeCollection);
-
 
318
            model.addAttribute("response1", mvcResponseSender.createResponseString(false));
314
        LOGGER.info("b -" + b);
319
        } else {
-
 
320
            loiFormService.sendPaymentApprovalMail(brandFeeCollection);
-
 
321
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
-
 
322
        }
315
        if (agreedBrandFee == totalBrandFeeCollection && loiForm.getLoiSignOtp() != null) {
323
        if (agreedBrandFee == totalBrandFeeCollection && loiForm.getLoiSignOtp() != null) {
316
            loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
324
            loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
317
            // loiFormService.sendFinalMail(loiForm);
-
 
318
        }
325
        }
319
        String msg = "Payment is confirmed";
-
 
320
        model.addAttribute("response1", mvcResponseSender.createResponseString(msg));
-
 
321
        return "response";
326
        return "response";
322
 
327
 
323
    }
328
    }
324
 
329
 
325
    @RequestMapping("/uploadDocumentForm")
330
    @RequestMapping("/uploadDocumentForm")
Line 374... Line 379...
374
 
379
 
375
    @RequestMapping(value = "/loiAcceptanceOtp", method = RequestMethod.POST)
380
    @RequestMapping(value = "/loiAcceptanceOtp", method = RequestMethod.POST)
376
    public String sentLoiAcceptanceOtp(@RequestParam int loiId, Model model) throws Exception {
381
    public String sentLoiAcceptanceOtp(@RequestParam int loiId, Model model) throws Exception {
377
        LoiForm pod = loiFormRepository.selectById(loiId);
382
        LoiForm pod = loiFormRepository.selectById(loiId);
378
        String mobile = String.valueOf(pod.getMobile());
383
        String mobile = String.valueOf(pod.getMobile());
379
        otpProcessor.generateOtp(mobile, OtpType.LOI_ACCEPTANCE);
384
        OTPResponse otpResponse = otpProcessor.generateOtp(mobile, OtpType.LOI_ACCEPTANCE);
380
        String message = "OTP send to your register mobile number -";
385
        String message = "OTP send to your register mobile number -";
-
 
386
        if (otpResponse.getMessage().equals("OTP generated successfully") && otpResponse.getMessage().equals("OTP generated less than 2 minutes ago")) {
381
        model.addAttribute("response1", mvcResponseSender.createResponseString(message + mobile));
387
            model.addAttribute("response1", mvcResponseSender.createResponseString(message + mobile));
-
 
388
        } else {
-
 
389
            model.addAttribute("response1", mvcResponseSender.createResponseString("Something went wrong.."));
-
 
390
        }
382
        return "response";
391
        return "response";
383
    }
392
    }
384
 
393
 
385
    @RequestMapping(value = "/validateLoiOtp", method = RequestMethod.PUT)
394
    @RequestMapping(value = "/validateLoiOtp", method = RequestMethod.PUT)
386
    public String validateLoiAcceptanceOtp(@RequestParam int loiId, @RequestParam String provideOtp, Model model) throws Exception {
395
    public String validateLoiAcceptanceOtp(@RequestParam int loiId, @RequestParam String provideOtp, Model model) throws Exception {