Subversion Repositories SmartDukaan

Rev

Rev 33525 | Rev 33577 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33507 tejus.loha 1
package com.spice.profitmandi.web.controller;
2
 
3
import com.fasterxml.jackson.databind.ObjectMapper;
4
import com.spice.profitmandi.common.enumuration.BusinessType;
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;
8
import com.spice.profitmandi.dao.entity.brandFee.BrandFee;
9
import com.spice.profitmandi.dao.entity.brandFee.BrandFeeCollection;
10
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.*;
13
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
14
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
15
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.FeePaymentStatus;
16
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.LoiStatus;
17
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
18
import com.spice.profitmandi.dao.model.LoiFormModel;
19
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
20
import com.spice.profitmandi.dao.repository.brandFee.BrandFeeCollectionRepository;
21
import com.spice.profitmandi.dao.repository.brandFee.BrandFeeRepository;
22
import com.spice.profitmandi.dao.repository.cs.CsService;
23
import com.spice.profitmandi.dao.repository.dtr.DistrictMasterRepository;
24
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
25
import com.spice.profitmandi.dao.repository.dtr.OtpRepository;
26
import com.spice.profitmandi.dao.repository.inventory.PartnerOnboardingService;
27
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
28
import com.spice.profitmandi.dao.repository.onboarding.LoiDocMasterRepository;
29
import com.spice.profitmandi.dao.repository.onboarding.LoiDocRepository;
30
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
31
import com.spice.profitmandi.dao.repository.user.LoiFormRepository;
32
import com.spice.profitmandi.dao.service.LoiDocModel;
33
import com.spice.profitmandi.dao.service.OTPResponse;
34
import com.spice.profitmandi.dao.service.OtpProcessor;
35
import com.spice.profitmandi.dao.service.loiForm.LoiFormService;
36
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
37
import com.spice.profitmandi.service.integrations.gstpro.entity.GstDetails;
38
import com.spice.profitmandi.service.user.StoreTimelineTatService;
39
import com.spice.profitmandi.web.model.LoginDetails;
40
import com.spice.profitmandi.web.util.CookiesProcessor;
41
import com.spice.profitmandi.web.util.MVCResponseSender;
42
import org.apache.commons.lang3.tuple.Pair;
43
import org.apache.logging.log4j.LogManager;
44
import org.apache.logging.log4j.Logger;
45
import org.springframework.beans.factory.annotation.Autowired;
46
import org.springframework.http.HttpStatus;
47
import org.springframework.http.ResponseEntity;
48
import org.springframework.mail.javamail.JavaMailSender;
49
import org.springframework.stereotype.Controller;
50
import org.springframework.transaction.annotation.Transactional;
51
import org.springframework.ui.Model;
52
import org.springframework.web.bind.annotation.RequestBody;
53
import org.springframework.web.bind.annotation.RequestMapping;
54
import org.springframework.web.bind.annotation.RequestMethod;
55
import org.springframework.web.bind.annotation.RequestParam;
56
 
57
import javax.servlet.http.HttpServletRequest;
58
import java.time.LocalDateTime;
59
import java.util.*;
60
import java.util.stream.Collectors;
61
 
62
@Controller
63
@Transactional(rollbackFor = Throwable.class)
64
public class LoiFormController {
65
    private static final Logger LOGGER = LogManager.getLogger(PartnerOnBoardingPanelController.class);
66
    @Autowired
67
    DocumentRepository documentRepository;
68
    @Autowired
69
    AuthRepository authRepository;
70
    @Autowired
71
    StateRepository stateRepository;
72
    @Autowired
73
    DistrictMasterRepository districtMasterRepository;
74
    @Autowired
75
    LoiFormRepository loiFormRepository;
76
    @Autowired
77
    GstProService gstProService;
78
    @Autowired
79
    ObjectMapper objectMapper;
80
    @Autowired
81
    OrderRepository orderRepository;
82
    @Autowired
83
    LoiFormService loiFormService;
84
    @Autowired
85
    BrandFeeCollectionRepository brandFeeCollectionRepository;
86
    @Autowired
87
    BrandFeeRepository brandFeeRepository;
88
    @Autowired
89
    OtpProcessor otpProcessor;
90
    @Autowired
91
    OtpRepository otpRepository;
92
    @Autowired
93
    JavaMailSender mailSender;
94
    @Autowired
95
    LoiDocMasterRepository loiDocMasterList;
96
    @Autowired
97
    CsService csService;
98
    @Autowired
99
    PartnerOnboardingService partnerOnboardingService;
100
    @Autowired
101
    StoreTimelineTatService storeTimelineTatService;
102
    @Autowired
103
    LoiDocRepository loiDocRepository;
104
    @Autowired
105
    MVCResponseSender mvcResponseSender;
106
    @Autowired
107
    private CookiesProcessor cookiesProcessor;
108
 
109
    // OnBoarding Form
110
    @RequestMapping(value = "/onboardingForm", method = RequestMethod.GET)
111
    public String loiForm(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
112
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
113
        AuthUser selfAuth = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
114
        List<AuthUser> authUsersList = loiFormService.getSalesAuthList();
115
        List<BrandFee> brandFee = brandFeeRepository.selectFeeOnDate(LocalDateTime.now());
116
        LOGGER.info("brandFee - " + brandFee);
117
        Set<Pair<StoreType, BrandFee>> storeTypeFeePairs = new HashSet<>();
118
        for (BrandFee fee : brandFee) {
119
            for (StoreType storeType : StoreType.values()) {
120
                storeTypeFeePairs.add(Pair.of(storeType, fee));
121
            }
122
        }
123
        List<BusinessType> businessTypes = Arrays.asList(BusinessType.Proprietorship, BusinessType.Partnership, BusinessType.Company);
124
        model.addAttribute("businessTypes", businessTypes);
125
        model.addAttribute("storeTypeFeePairs", storeTypeFeePairs);
126
        model.addAttribute("authUsersList", authUsersList);
127
        model.addAttribute("selfAuth", selfAuth);
128
        return "partner-onboarding-form";
129
    }
130
 
131
    // use to validate GSTIN
132
    @RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
133
    public ResponseEntity<?> gstValidate(HttpServletRequest request, @RequestParam String gstNo) throws Exception {
134
        LOGGER.info("gstNo -" + gstNo);
135
        GstDetails gstDetails = gstProService.getGstDetails(gstNo);
136
        LOGGER.info("gstDetails -" + gstDetails);
137
        List<GstDetails.Pradr> adadr = gstDetails.getAdadr();
138
        adadr.add(gstDetails.getPradr());
139
        Collections.reverse(adadr);
140
        LOGGER.info("list_of_adadr-" + adadr);
141
        String status = gstDetails.getSts();
142
        if (status.equals("Active")) {
143
            return ResponseEntity.ok(gstDetails);
144
        } else {
145
            String errorMsg = "GSTIN - " + gstNo + " Not Active";
146
            return new ResponseEntity(errorMsg, HttpStatus.INTERNAL_SERVER_ERROR);
147
        }
148
    }
149
 
150
    // bind the form data and save in fofo.Onboarding_form table
151
    @RequestMapping(value = "/submitOnboardingForm", method = RequestMethod.POST)
33568 tejus.loha 152
    public String submitLoiForm(HttpServletRequest request, @RequestBody LoiFormData loiFormData, Model model) throws Exception {
33507 tejus.loha 153
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
33568 tejus.loha 154
        boolean isDataCreated = loiFormService.createLoiForm(loiFormData);
33507 tejus.loha 155
        List<LoiFormModel> formList = loiFormService.pendingFormList(loginDetails.getEmailId());
156
        model.addAttribute("formList", formList);
157
        if (isDataCreated) {
158
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
159
            return "response";
160
        } else {
161
            model.addAttribute("response1", mvcResponseSender.createResponseString(false));
162
            return "response";
163
        }
164
    }
165
 
166
    // show all pending Form to specific auth user who have filled the form(type based)
167
    @RequestMapping("/pendingOnboardingForm")
168
    public String pendingLoiForm(HttpServletRequest request, Model model) throws Exception {
169
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
170
        String email = loginDetails.getEmailId();
171
        boolean isDocApprover = false;
172
        //todo:replace
173
        String approverEmail = "gaurav.sharma@smartdukaan.com";
174
        if (email.equals(approverEmail)) {
175
            isDocApprover = true;
176
        }
177
        List<LoiFormModel> pendingFormList = loiFormService.pendingFormList(email);
178
        LOGGER.info("pendingFormList {}", pendingFormList);
179
        model.addAttribute("isDocApprover", isDocApprover);
180
        model.addAttribute("pendingFormList", pendingFormList);
181
        return "pendingForm";
182
    }
183
 
184
    // generate LOI for specific Form data
185
    @RequestMapping(value = "/generateLoi", method = RequestMethod.GET)
186
    public String generateLoi(HttpServletRequest request, @RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
187
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
188
        int authId = authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getId();
189
        LoiForm loiForm = loiFormRepository.selectById(loiId);
190
        loiForm.setLoiGeneratedBy(authId);
191
        loiForm.setLoiGeneratedOn(LocalDateTime.now());
192
        loiForm.setStatus(LoiStatus.LOI_GENERATED);
193
        BrandFee brandFee = brandFeeRepository.selectById(1);
194
        BrandFee givenFee = brandFeeRepository.selectById(loiForm.getBrandFeeId());
195
        BillingAddress address = loiForm.getBillingAddress();
196
        double brandFeeAmount = loiForm.getBrandFeeCollection().stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM)).mapToDouble(x -> x.getCollectedAmount()).sum();
197
        BrandFeeCollection brandFeeCollection = loiForm.getBrandFeeCollection().get(0);
198
        model.addAttribute("brandFeeAmount", brandFeeAmount);
199
        model.addAttribute("brandFee", brandFee);
200
        model.addAttribute("givenFee", givenFee);
201
        model.addAttribute("brandFeeCollection", brandFeeCollection);
202
        model.addAttribute("address", address);
203
        model.addAttribute("pod", loiForm);
204
        return "auto-Loi";
205
 
206
    }
207
 
208
    @RequestMapping("saveLoiDoc")
209
    public String saveLoiDoc(@RequestParam int loiId, @RequestParam int loiDocId, Model model) throws Exception {
210
        LOGGER.info("loi_docId-" + loiDocId);
211
        LoiForm loiForm = loiFormRepository.selectById(loiId);
212
        LOGGER.info("loiForm - " + loiForm);
213
        int loiDoc = loiForm.getLoiDoc();
214
        if (loiDoc == 0) {
215
            loiForm.setLoiDoc(loiDocId);
216
            loiFormService.sendSignedLoiPdfToPartner(loiForm);
217
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
218
            return "response";
219
        } else {
220
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
221
            return "response";
222
        }
223
 
224
    }
225
 
226
    // send Filled form for update purpose
227
    @RequestMapping("/updateOnboardingForm")
228
    public String UpdateLoiForm(HttpServletRequest request,
229
                                @RequestParam int loiId,
230
                                Model model) throws ProfitMandiBusinessException {
231
        LoiForm loiForm = loiFormRepository.selectById(loiId);
232
        List<AuthUser> salesAuthList = loiFormService.getSalesAuthList();
233
        List<BrandFee> brandFee = brandFeeRepository.selectFeeOnDate(LocalDateTime.now());
234
        Set<Pair<StoreType, BrandFee>> storeTypeFeePairs = new HashSet<>();
235
        for (BrandFee fee : brandFee) {
236
            for (StoreType storeType : StoreType.values()) {
237
                storeTypeFeePairs.add(Pair.of(storeType, fee));
238
            }
239
        }
240
        model.addAttribute("storeTypeFeePairs", storeTypeFeePairs);
241
        model.addAttribute("authUsersList", salesAuthList);
242
        model.addAttribute("onBoardingData", loiForm);
243
        return "partner-onboarding-form";
244
    }
245
 
246
    @RequestMapping(value = "/updateOnboardingFormData", method = RequestMethod.POST)
247
    public String UpdateLoiFormDetail(HttpServletRequest request,
248
                                      @RequestParam int loiId,
249
                                      @RequestBody LoiFormData partnerOnBoardingFormData,
250
                                      Model model) throws Exception {
251
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
252
        String email = loginDetails.getEmailId();
253
        loiFormService.updateLoiForm(partnerOnBoardingFormData, loiId);
254
        List<LoiFormModel> pendingFormList = loiFormService.pendingFormList(email);
255
        model.addAttribute("formList", pendingFormList);
256
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
257
        return "response";
258
    }
259
 
260
    // TODO , add paymnet if brand fee due
261
    @RequestMapping(value = "/brandfeeCollection", method = RequestMethod.POST)
262
    public String addBrandFee(HttpServletRequest request, @RequestBody BrandFeeCollection brandFeeCollection, @RequestParam int loiId, Model model) throws Exception {
263
        LoiForm loiForm = loiFormRepository.selectById(loiId);
264
        List<BrandFeeCollection> brandFeeCollections = loiForm.getBrandFeeCollection();
33525 tejus.loha 265
        double totatcollectedfee = brandFeeCollections.stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM) || x.getPaymentStatus().equals(FeePaymentStatus.PENDING)).mapToDouble(x -> x.getCollectedAmount()).sum();
33507 tejus.loha 266
        double brandFee = loiForm.getAgreedBrandFees();
267
        double differanceAmount = brandFee - totatcollectedfee;
268
        if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
269
            brandFeeCollection.setTimeStamp(LocalDateTime.now());
270
            brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
271
            brandFeeCollection.setLoiData(loiForm);
272
            brandFeeCollections.add(brandFeeCollection);
273
            loiForm.setBrandFeeCollection(brandFeeCollections);
274
            loiFormService.sentMailToPaymentApprover(brandFeeCollection);
275
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
276
            return "response";
277
        } else {
278
            throw new ProfitMandiBusinessException("You need to add only due brand fee that is Only, " + differanceAmount + " INR", null, "Pay differance amount or less then differance amount");
279
        }
280
    }
281
 
282
 
283
    @RequestMapping("/paymentsDetail")
284
    public String paymentsDetails(HttpServletRequest request, @RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
285
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
286
        String email = loginDetails.getEmailId();
287
        boolean isNiraj = false;
288
        if (email.equals("neeraj.gupta@smartdukaan.com")) {
289
            isNiraj = true;
290
        }
291
        LoiForm loiForm = loiFormRepository.selectById(loiId);
292
        List<BrandFeeCollection> brandFeeCollections = loiForm.getBrandFeeCollection();
293
        model.addAttribute("brandFeeCollections", brandFeeCollections);
294
        model.addAttribute("confirm", FeePaymentStatus.CONFIRM);
295
        model.addAttribute("isNiraj", isNiraj);
296
        return "payment-collection-details";
297
    }
298
 
299
    // bfcId - Brand Fee Collection Id
300
    @RequestMapping("/feePaymentApproval")
33525 tejus.loha 301
    public String feePaymentApproval(HttpServletRequest request, @RequestParam int bfcId, @RequestParam FeePaymentStatus feePaymentStatus, @RequestParam String description,
302
                                     Model model) throws Exception {
33507 tejus.loha 303
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
304
        String authEmail = loginDetails.getEmailId();
305
        BrandFeeCollection brandFeeCollection = brandFeeCollectionRepository.selectById(bfcId);
306
        LoiForm loiForm = brandFeeCollection.getLoiData();
33525 tejus.loha 307
        List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiForm(loiForm);
33507 tejus.loha 308
        brandFeeCollection.setApproverEmail(authEmail);
309
        brandFeeCollection.setPaymentStatus(feePaymentStatus);
33525 tejus.loha 310
        brandFeeCollection.setDescription(description);
33507 tejus.loha 311
        double agreedBrandFee = loiForm.getAgreedBrandFees();
312
        double totalBrandFeeCollection = brandFeeCollections.stream().mapToDouble(x -> x.getCollectedAmount()).sum() + brandFeeCollection.getCollectedAmount();
313
        LOGGER.info("agreedBrandeFee -" + agreedBrandFee);
314
        LOGGER.info("totalBrandFeeCollection -" + totalBrandFeeCollection);
315
        boolean b = agreedBrandFee == totalBrandFeeCollection && loiForm.getLoiSignOtp() != null;
33525 tejus.loha 316
        if (brandFeeCollection.getPaymentStatus().equals(FeePaymentStatus.REJECT)) {
317
            loiFormService.sendPaymentApprovalMail(brandFeeCollection);
318
            model.addAttribute("response1", mvcResponseSender.createResponseString(false));
319
        } else {
320
            loiFormService.sendPaymentApprovalMail(brandFeeCollection);
321
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
322
        }
33507 tejus.loha 323
        if (agreedBrandFee == totalBrandFeeCollection && loiForm.getLoiSignOtp() != null) {
324
            loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
325
        }
326
        return "response";
327
 
328
    }
329
 
330
    @RequestMapping("/uploadDocumentForm")
331
    public String uploadDocumentForm(HttpServletRequest request, @RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
332
        List<LoiDocMaster> activeDocMasterList = loiDocMasterList.getAllActiveDoc();
333
        LoiForm loiForm = loiFormRepository.selectById(loiId);
334
        //TODO:replace
335
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
336
        String authEmail = authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getEmailId();
337
        String approverEmail = "gaurav.sharma@smartdukaan.com";
338
        boolean isApprover = false;
339
        if (authEmail.equals(approverEmail)) {
340
            isApprover = true;
341
        }
342
        Map<Integer, LoiDoc> masterDocIdLoiDocMap = loiForm.getLoiDocs().stream().collect(Collectors.toMap(x -> x.getMasterDocId(), x -> x));
343
        model.addAttribute("isApprover", isApprover);
344
        model.addAttribute("loiId", loiId);
345
        model.addAttribute("activeDocMasterList", activeDocMasterList);
346
        model.addAttribute("masterDocIdLoiDocMap", masterDocIdLoiDocMap);
347
        return "loiForm/document-upload";
348
    }
349
 
350
    @RequestMapping(value = "/uploadOnboardingDocument", method = RequestMethod.POST)
351
    public String uploadDocument(HttpServletRequest request, @RequestParam int loiId, @RequestBody List<LoiDocModel> loiDocModels, Model model) throws Exception {
352
        LoiForm loiForm = loiFormRepository.selectById(loiId);
353
        LOGGER.info("loiForm - " + loiForm);
354
        LOGGER.info("loiDocModels - " + loiDocModels);
355
        loiFormService.setDocs(loiForm, loiDocModels);
356
        model.addAttribute("response1", mvcResponseSender.createResponseString("Document uploaded successfully"));
357
        return "response";
358
 
359
    }
360
 
361
 
362
    @RequestMapping("/documentVerify")
363
    public String docApproval(HttpServletRequest request, @RequestParam int loiId, @RequestParam int docMasterId, @RequestParam boolean flag, Model model) throws Exception {
364
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
365
        AuthUser auth = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
366
        LoiDoc loiDoc = loiDocRepository.selectByLoiIdAndMasterDocId(loiId, docMasterId);
367
        if (flag) {
368
            loiDoc.setOk(true);
369
            loiDoc.setVerifyBy(auth.getId());
370
            model.addAttribute("response1", mvcResponseSender.createResponseString(loiDoc.getDocType() + " is Accepted "));
371
            return "response";
372
        } else {
373
            loiDoc.setOk(false);
374
            loiDoc.setVerifyBy(auth.getId());
375
            model.addAttribute("response1", mvcResponseSender.createResponseString(loiDoc.getDocType() + " is Rejected"));
376
            return "response";
377
        }
378
    }
379
 
380
    @RequestMapping(value = "/loiAcceptanceOtp", method = RequestMethod.POST)
381
    public String sentLoiAcceptanceOtp(@RequestParam int loiId, Model model) throws Exception {
382
        LoiForm pod = loiFormRepository.selectById(loiId);
383
        String mobile = String.valueOf(pod.getMobile());
33525 tejus.loha 384
        OTPResponse otpResponse = otpProcessor.generateOtp(mobile, OtpType.LOI_ACCEPTANCE);
33507 tejus.loha 385
        String message = "OTP send to your register mobile number -";
33568 tejus.loha 386
        LOGGER.info("OTPResponse Message - " + otpResponse.getMessage());
387
        if (otpResponse.isResult()) {
33525 tejus.loha 388
            model.addAttribute("response1", mvcResponseSender.createResponseString(message + mobile));
33568 tejus.loha 389
            return "response";
33525 tejus.loha 390
        } else {
391
            model.addAttribute("response1", mvcResponseSender.createResponseString("Something went wrong.."));
33568 tejus.loha 392
            return "response";
33525 tejus.loha 393
        }
33507 tejus.loha 394
    }
395
 
396
    @RequestMapping(value = "/validateLoiOtp", method = RequestMethod.PUT)
397
    public String validateLoiAcceptanceOtp(@RequestParam int loiId, @RequestParam String provideOtp, Model model) throws Exception {
398
        LOGGER.info("loiId -" + loiId);
399
        LOGGER.info("provideOtp -" + provideOtp);
400
        LoiForm pod = loiFormRepository.selectById(loiId);
401
        double brandFee = pod.getAgreedBrandFees();
402
        double totalCollectfee = pod.getBrandFeeCollection().stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM)).mapToDouble(x -> x.getCollectedAmount()).sum();
403
        String mobile = String.valueOf(pod.getMobile());
404
        Otp otp = otpRepository.selectAllByMobileWithTime(mobile).get(0);
405
        LOGGER.info("otp-" + otp);
406
        OTPResponse otpResponse = otpProcessor.validateOtp(otp.getId(), mobile, provideOtp);
407
        if (!otpResponse.isResult()) {
408
            model.addAttribute("response1", mvcResponseSender.createResponseString(false));
409
            throw new ProfitMandiBusinessException("Your given OTP ", provideOtp, " is wrong.");
410
        }
411
        if (otpResponse.isResult()) {
412
            pod.setLoiSignOtp(provideOtp);
413
            pod.setLoiSignedOn(LocalDateTime.now());
414
            if (brandFee == totalCollectfee && pod.getLoiSignOtp() != null) {
415
                pod.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
416
            } else {
417
                pod.setStatus(LoiStatus.LOI_SIGNED);
418
            }
419
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
420
        }
421
        return "response";
422
    }
423
 
424
    @RequestMapping(value = "/completedLoiForms")
425
    public String completeLoiFormList(Model model) {
426
        List<LoiForm> loiForms = loiFormRepository.selectAllCompleteForm();
427
        List<EscalationType> EscalationTypeList = new ArrayList<>();
428
        EscalationTypeList.add(EscalationType.L2);
429
        EscalationTypeList.add(EscalationType.L1);
430
        EscalationTypeList.add(EscalationType.L4);
431
        List<AuthUser> authUsers = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_RBM,
432
                EscalationTypeList);
433
        model.addAttribute("loiForms", loiForms);
434
        model.addAttribute("authUsers", authUsers);
435
        return "loiForm/completed-loi-form";
436
    }
437
 
438
    @RequestMapping(value = "/createNewOnboardingPanel")
439
    public String CreateNewOnboardingPanel(@RequestParam int loiId, @RequestParam int authId, Model model) throws Exception {
440
        PartnerOnBoardingPanel partnerOnboardingPanel = loiFormService.createPartnerOnboardingPanel(loiId, authId);
441
        loiFormRepository.selectById(loiId).setStatus(LoiStatus.IN_ONBOARDING_PROCESS);
442
        if (partnerOnboardingPanel.getId() != 0)
443
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
444
        else
445
            model.addAttribute("response1", mvcResponseSender.createResponseString(false));
446
        return "response";
447
    }
448
}