Subversion Repositories SmartDukaan

Rev

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

Rev 33658 Rev 33710
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import com.fasterxml.jackson.databind.ObjectMapper;
3
import com.fasterxml.jackson.databind.ObjectMapper;
4
import com.spice.profitmandi.common.enumuration.BusinessType;
4
import com.spice.profitmandi.common.enumuration.BusinessType;
5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
6
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
7
import com.spice.profitmandi.dao.entity.auth.AuthUser;
6
import com.spice.profitmandi.dao.entity.auth.AuthUser;
8
import com.spice.profitmandi.dao.entity.brandFee.BrandFee;
7
import com.spice.profitmandi.dao.entity.brandFee.BrandFee;
9
import com.spice.profitmandi.dao.entity.brandFee.BrandFeeCollection;
8
import com.spice.profitmandi.dao.entity.brandFee.BrandFeeCollection;
10
import com.spice.profitmandi.dao.entity.dtr.Otp;
9
import com.spice.profitmandi.dao.entity.dtr.Otp;
11
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
-
 
12
import com.spice.profitmandi.dao.entity.onBoarding.*;
10
import com.spice.profitmandi.dao.entity.onBoarding.*;
13
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
-
 
14
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
11
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
15
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.FeePaymentStatus;
12
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.FeePaymentStatus;
16
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.LoiStatus;
13
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.LoiStatus;
17
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
14
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
18
import com.spice.profitmandi.dao.model.LoiFormModel;
15
import com.spice.profitmandi.dao.model.LoiFormModel;
Line 119... Line 116...
119
    BrandCategoryRepository brandCategoryRepository;
116
    BrandCategoryRepository brandCategoryRepository;
120
    @Autowired
117
    @Autowired
121
    BillingAddressRepository billingAddressRepository;
118
    BillingAddressRepository billingAddressRepository;
122
    @Autowired
119
    @Autowired
123
    LoiBrandCommitmentRepository brandCommitmentRepository;
120
    LoiBrandCommitmentRepository brandCommitmentRepository;
-
 
121
    List<String> agreedBrandFeeChangerEmail = Arrays.asList("sm@smartdukaan.com");
124
 
122
 
125
    // OnBoarding Form
123
    // OnBoarding Form
126
    @RequestMapping(value = "/onboardingForm", method = RequestMethod.GET)
124
    @RequestMapping(value = "/onboardingForm", method = RequestMethod.GET)
127
    public String loiForm(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
125
    public String loiForm(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
128
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
126
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
Line 176... Line 174...
176
            return "response";
174
            return "response";
177
        }
175
        }
178
    }
176
    }
179
 
177
 
180
    // show all pending Form to specific auth user who have filled the form(type based)
178
    // show all pending Form to specific auth user who have filled the form(type based)
181
    @RequestMapping(value = "/pendingOnboardingForm", method = RequestMethod.GET)
179
    @RequestMapping(value = "/pendingLoiForm", method = RequestMethod.GET)
182
    public String pendingLoiForm(HttpServletRequest request, Model model) throws Exception {
180
    public String pendingLoiForm(HttpServletRequest request, Model model) throws Exception {
183
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
181
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
184
        String email = loginDetails.getEmailId();
182
        String email = loginDetails.getEmailId();
185
        boolean isDocApprover = false;
183
        boolean isDocApprover = false;
186
        //todo:replace
184
        //todo:replace
187
        String approverEmail = "gaurav.sharma@smartdukaan.com";
185
        String approverEmail = "gaurav.sharma@smartdukaan.com";
188
        if (email.equals(approverEmail)) {
186
        if (email.equals(approverEmail)) {
189
            isDocApprover = true;
187
            isDocApprover = true;
190
        }
188
        }
191
        boolean isAuthUser = false;
189
        boolean isAgreedBrandFeeChanger = agreedBrandFeeChangerEmail.stream().anyMatch(x -> x.equals(email));
192
        List<String> authEmail = Arrays.asList("sm@smartdukaan.com", "gaurav.sharma@smartdukaan.com", "tejus.lohani@smartdukaan.com");
190
        List<String> authEmail = Arrays.asList("sm@smartdukaan.com", "gaurav.sharma@smartdukaan.com", "tejus.lohani@smartdukaan.com");
193
        isAuthUser = authEmail.stream().anyMatch(x -> x.equals(email));
191
        boolean isAuthUser = authEmail.stream().anyMatch(x -> x.equals(email));
194
        List<LoiFormModel> pendingFormList = loiFormService.pendingFormList(email);
192
        List<LoiFormModel> pendingFormList = loiFormService.pendingFormList(email);
195
        model.addAttribute("isDocApprover", isDocApprover);
193
        model.addAttribute("isDocApprover", isDocApprover);
196
        model.addAttribute("isAuthUser", isAuthUser);
194
        model.addAttribute("isAuthUser", isAuthUser);
-
 
195
        model.addAttribute("isAgreedBrandFeeChanger", isAgreedBrandFeeChanger);
197
        model.addAttribute("pendingFormList", pendingFormList);
196
        model.addAttribute("pendingFormList", pendingFormList);
198
        return "pendingForm";
197
        return "pendingForm";
199
    }
198
    }
200
 
199
 
201
    // generate LOI for specific Form data
200
    // generate LOI for specific Form data
Line 306... Line 305...
306
                                     Model model) throws Exception {
305
                                     Model model) throws Exception {
307
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
306
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
308
        String authEmail = loginDetails.getEmailId();
307
        String authEmail = loginDetails.getEmailId();
309
        BrandFeeCollection brandFeeCollection = brandFeeCollectionRepository.selectById(bfcId);
308
        BrandFeeCollection brandFeeCollection = brandFeeCollectionRepository.selectById(bfcId);
310
        LoiForm loiForm = loiFormRepository.selectById(brandFeeCollection.getLoiFormId());
309
        LoiForm loiForm = loiFormRepository.selectById(brandFeeCollection.getLoiFormId());
311
        List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiForm(brandFeeCollection.getLoiFormId());
310
        List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiId(brandFeeCollection.getLoiFormId());
312
        brandFeeCollection.setApproverEmail(authEmail);
311
        brandFeeCollection.setApproverEmail(authEmail);
313
        brandFeeCollection.setPaymentStatus(feePaymentStatus);
312
        brandFeeCollection.setPaymentStatus(feePaymentStatus);
314
        brandFeeCollection.setDescription(description);
313
        brandFeeCollection.setDescription(description);
315
        double agreedBrandFee = loiForm.getAgreedBrandFees();
314
        double agreedBrandFee = loiForm.getAgreedBrandFees();
316
        double totalBrandFeeCollection = brandFeeCollections.stream().mapToDouble(x -> x.getCollectedAmount()).sum() + brandFeeCollection.getCollectedAmount();
315
        double totalBrandFeeCollection = brandFeeCollections.stream().mapToDouble(x -> x.getCollectedAmount()).sum() + brandFeeCollection.getCollectedAmount();
Line 321... Line 320...
321
            loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
320
            loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
322
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
321
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
323
        }
322
        }
324
        if (agreedBrandFee == totalBrandFeeCollection && loiForm.getLoiSignOtp() != null) {
323
        if (agreedBrandFee == totalBrandFeeCollection && loiForm.getLoiSignOtp() != null) {
325
            loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
324
            loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
-
 
325
            loiFormService.createPartnerOnboardingPanel(loiForm.getId());
326
        }
326
        }
327
        return "response";
327
        return "response";
328
 
328
 
329
    }
329
    }
330
 
330
 
Line 407... Line 407...
407
        if (otpResponse.isResult()) {
407
        if (otpResponse.isResult()) {
408
            loiForm.setLoiSignOtp(provideOtp);
408
            loiForm.setLoiSignOtp(provideOtp);
409
            loiForm.setLoiSignedOn(LocalDateTime.now());
409
            loiForm.setLoiSignedOn(LocalDateTime.now());
410
            if (agreedBrandFees == totalCollectfee && loiForm.getLoiSignOtp() != null) {
410
            if (agreedBrandFees == totalCollectfee && loiForm.getLoiSignOtp() != null) {
411
                loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
411
                loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
412
 
-
 
-
 
412
                loiFormService.createPartnerOnboardingPanel(loiId);
413
            } else {
413
            } else {
414
                loiForm.setStatus(LoiStatus.LOI_SIGNED);
414
                loiForm.setStatus(LoiStatus.LOI_SIGNED);
415
            }
415
            }
416
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
416
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
417
        }
417
        }
418
        return "response";
418
        return "response";
419
    }
419
    }
420
 
420
 
421
    @RequestMapping(value = "/completedLoiForms", method = RequestMethod.GET)
-
 
422
    public String completeLoiFormList(Model model) throws ProfitMandiBusinessException {
-
 
423
        List<LoiForm> loiForms = loiFormRepository.selectAllCompleteForm();
-
 
424
        List<LoiFormModel> loiFormModels = new ArrayList<>();
-
 
425
        for (LoiForm loiForm : loiForms) {
-
 
426
            LoiFormModel loiFormModel = new LoiFormModel();
-
 
427
            loiFormModel.setId(loiForm.getId());
-
 
428
            loiFormModel.setLoiFormFilledBy(authRepository.selectByEmailOrMobile(loiForm.getFilledBy()).getFullName());
-
 
429
            loiFormModel.setCompanyName(loiForm.getCompanyName());
-
 
430
            loiFormModel.setOwnerName(loiForm.getFullName());
-
 
431
            loiFormModel.setMobile(loiForm.getMobile());
-
 
432
            loiFormModel.setCity(billingAddressRepository.selectByLoiFormId(loiForm.getId()).getLoc());
-
 
433
            loiFormModels.add(loiFormModel);
-
 
434
        }
-
 
435
        List<EscalationType> EscalationTypeList = new ArrayList<>();
-
 
436
        EscalationTypeList.add(EscalationType.L2);
-
 
437
        EscalationTypeList.add(EscalationType.L1);
-
 
438
        EscalationTypeList.add(EscalationType.L4);
-
 
439
        List<AuthUser> authUsers = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_RBM,
-
 
440
                EscalationTypeList);
-
 
441
        model.addAttribute("loiFormModels", loiFormModels);
-
 
442
        model.addAttribute("authUsers", authUsers);
-
 
443
        return "loiForm/completed-loi-form";
-
 
444
    }
-
 
445
 
-
 
446
    @RequestMapping(value = "/createNewOnboardingPanel", method = RequestMethod.POST)
-
 
447
    public String CreateNewOnboardingPanel(@RequestParam int loiId, @RequestParam int authId, Model model) throws Exception {
-
 
448
        PartnerOnBoardingPanel partnerOnboardingPanel = loiFormService.createPartnerOnboardingPanel(loiId, authId);
-
 
449
        loiFormRepository.selectById(loiId).setStatus(LoiStatus.IN_ONBOARDING_PROCESS);
-
 
450
        if (partnerOnboardingPanel.getId() != 0)
-
 
451
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
-
 
452
        else
-
 
453
            model.addAttribute("response1", mvcResponseSender.createResponseString(false));
-
 
454
        return "response";
-
 
455
    }
-
 
456
 
-
 
457
    @RequestMapping(value = "/downloadLoiFromReport", method = RequestMethod.GET)
421
    @RequestMapping(value = "/downloadLoiFromReport", method = RequestMethod.GET)
458
    public ResponseEntity<?> downloadAllLoiForm(@RequestParam LocalDate from, @RequestParam LocalDate to) throws Exception {
422
    public ResponseEntity<?> downloadAllLoiForm(@RequestParam LocalDate from, @RequestParam LocalDate to) throws Exception {
459
        ResponseEntity<?> responseEntity = loiFormService.createLoiFormReport(from, to);
423
        ResponseEntity<?> responseEntity = loiFormService.createLoiFormReport(from, to);
460
 
-
 
461
        return responseEntity;
424
        return responseEntity;
462
    }
425
    }
463
 
426
 
464
    @RequestMapping(value = "/updatePayment", method = RequestMethod.POST)
427
    @RequestMapping(value = "/updatePayment", method = RequestMethod.POST)
465
    public String updateForm(@RequestBody BrandFeeCollection brandFeeCollection, Model model) throws Exception {
428
    public String updateForm(@RequestBody BrandFeeCollection brandFeeCollection, Model model) throws Exception {
Line 470... Line 433...
470
        brandFeeCollection1.setPaymentMode(brandFeeCollection.getPaymentMode());
433
        brandFeeCollection1.setPaymentMode(brandFeeCollection.getPaymentMode());
471
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
434
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
472
        return "response";
435
        return "response";
473
    }
436
    }
474
 
437
 
-
 
438
    @RequestMapping(value = "/updateAgreedBrandFee", method = RequestMethod.PUT)
-
 
439
    public String updateAgreedBrandFee(HttpServletRequest request, @RequestParam int loiId, @RequestParam double brandFee, Model model) throws Exception {
-
 
440
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
441
        boolean isAgreedBrandFeeChanger = agreedBrandFeeChangerEmail.stream().anyMatch(x -> x.equals(loginDetails.getEmailId()));
-
 
442
        if (isAgreedBrandFeeChanger) {
-
 
443
            LoiForm loiForm = loiFormRepository.selectById(loiId);
-
 
444
            loiForm.setAgreedBrandFees(brandFee);
-
 
445
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
-
 
446
            return "response";
-
 
447
        } else {
-
 
448
            throw new ProfitMandiBusinessException("failed in Authority check ", null, "Sorry " + authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getName() + " you have no authority to change agreed brand fee");
-
 
449
        }
-
 
450
 
-
 
451
    }
-
 
452
 
475
}
453
}