Subversion Repositories SmartDukaan

Rev

Rev 37921 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37921 Rev 37936
Line 16... Line 16...
16
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
16
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
17
import com.spice.profitmandi.dao.entity.onBoarding.*;
17
import com.spice.profitmandi.dao.entity.onBoarding.*;
18
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
18
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
19
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
19
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
20
import com.spice.profitmandi.dao.enumuration.dtr.StoreTimeline;
20
import com.spice.profitmandi.dao.enumuration.dtr.StoreTimeline;
-
 
21
import com.spice.profitmandi.dao.enumuration.fofo.StoreStatus;
21
import com.spice.profitmandi.dao.enumuration.onBorading.OnboardingType;
22
import com.spice.profitmandi.dao.enumuration.onBorading.OnboardingType;
22
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.FeePaymentStatus;
23
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.FeePaymentStatus;
23
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.LoiStatus;
24
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.LoiStatus;
24
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
25
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
25
import com.spice.profitmandi.dao.enumuration.transaction.PartnerOnBoardingStatus;
26
import com.spice.profitmandi.dao.enumuration.transaction.PartnerOnBoardingStatus;
Line 43... Line 44...
43
import com.spice.profitmandi.dao.service.OtpProcessor;
44
import com.spice.profitmandi.dao.service.OtpProcessor;
44
import com.spice.profitmandi.dao.service.loiForm.LoiFormService;
45
import com.spice.profitmandi.dao.service.loiForm.LoiFormService;
45
import com.spice.profitmandi.service.AuthService;
46
import com.spice.profitmandi.service.AuthService;
46
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
47
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
47
import com.spice.profitmandi.service.integrations.gstpro.entity.GstDetails;
48
import com.spice.profitmandi.service.integrations.gstpro.entity.GstDetails;
-
 
49
import com.spice.profitmandi.service.user.StoreStatusService;
48
import com.spice.profitmandi.service.user.StoreTimelineTatService;
50
import com.spice.profitmandi.service.user.StoreTimelineTatService;
49
import com.spice.profitmandi.web.model.LoginDetails;
51
import com.spice.profitmandi.web.model.LoginDetails;
50
import com.spice.profitmandi.web.util.CookiesProcessor;
52
import com.spice.profitmandi.web.util.CookiesProcessor;
51
import com.spice.profitmandi.web.util.MVCResponseSender;
53
import com.spice.profitmandi.web.util.MVCResponseSender;
52
import org.apache.commons.lang3.tuple.Pair;
54
import org.apache.commons.lang3.tuple.Pair;
Line 75... Line 77...
75
public class LoiFormController {
77
public class LoiFormController {
76
    private static final Logger LOGGER = LogManager.getLogger(LoiFormController.class);
78
    private static final Logger LOGGER = LogManager.getLogger(LoiFormController.class);
77
    @Autowired
79
    @Autowired
78
    DocumentRepository documentRepository;
80
    DocumentRepository documentRepository;
79
    @Autowired
81
    @Autowired
-
 
82
    private StoreStatusService storeStatusService;
-
 
83
    @Autowired
80
    AuthRepository authRepository;
84
    AuthRepository authRepository;
81
    @Autowired
85
    @Autowired
82
    StateRepository stateRepository;
86
    StateRepository stateRepository;
83
    @Autowired
87
    @Autowired
84
    DistrictMasterRepository districtMasterRepository;
88
    DistrictMasterRepository districtMasterRepository;
Line 253... Line 257...
253
            }
257
            }
254
            FofoStore existing = fofoStoreRepository.selectByStoreCode(oldCode.trim());
258
            FofoStore existing = fofoStoreRepository.selectByStoreCode(oldCode.trim());
255
            if (existing == null) {
259
            if (existing == null) {
256
                return "Old Store Code " + oldCode + " does not exist";
260
                return "Old Store Code " + oldCode + " does not exist";
257
            }
261
            }
-
 
262
            try {
258
            boolean stillActive = fofoStoreRepository.selectActiveStores().stream()
263
                storeStatusService.assertRevivable(existing);
259
                    .anyMatch(s -> oldCode.trim().equalsIgnoreCase(s.getCode()));
264
            } catch (ProfitMandiBusinessException e) {
260
            if (stillActive) {
265
                return e.getCode();
261
                return "Old Store Code " + oldCode + " is still active — revival is only for closed stores";
-
 
262
            }
266
            }
263
        }
267
        }
264
        return null;
268
        return null;
265
    }
269
    }
266
 
270
 
Line 406... Line 410...
406
        brandFeeCollection.setApprovalTimeStamp(LocalDateTime.now());
410
        brandFeeCollection.setApprovalTimeStamp(LocalDateTime.now());
407
        if (feePaymentStatus.equals(FeePaymentStatus.CONFIRM)) {
411
        if (feePaymentStatus.equals(FeePaymentStatus.CONFIRM)) {
408
            // Payment Approval timeline entry
412
            // Payment Approval timeline entry
409
            storeTimelineTatService.createStoreTimeline(brandFeeCollection.getLoiFormId(), StoreTimeline.PAYMENT_APPROVAL);
413
            storeTimelineTatService.createStoreTimeline(brandFeeCollection.getLoiFormId(), StoreTimeline.PAYMENT_APPROVAL);
410
            LoiForm approvedLoi = loiFormRepository.selectById(brandFeeCollection.getLoiFormId());
414
            LoiForm approvedLoi = loiFormRepository.selectById(brandFeeCollection.getLoiFormId());
411
            applyRevivalPaymentHooks(approvedLoi);
415
            applyRevivalPaymentHooks(approvedLoi, authEmail);
412
            loiFormService.checkLoiDetailsCompletion(approvedLoi);
416
            loiFormService.checkLoiDetailsCompletion(approvedLoi);
413
        }
417
        }
414
        loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
418
        loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
415
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
419
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
416
        return "response";
420
        return "response";
Line 718... Line 722...
718
    //   3. Reset the backing panel fields (billingStatus, inaugrationDate,
722
    //   3. Reset the backing panel fields (billingStatus, inaugrationDate,
719
    //      deploymentDate, receeActual, status) and the training panel's
723
    //      deploymentDate, receeActual, status) and the training panel's
720
    //      appTraining / dashboardTraning flags so the events can actually re-fire.
724
    //      appTraining / dashboardTraning flags so the events can actually re-fire.
721
    //   4. Wipe the AgreementEsign record so the upload widget starts blank.
725
    //   4. Wipe the AgreementEsign record so the upload widget starts blank.
722
    // No-op for NEW and ANY_OTHER LOIs.
726
    // No-op for NEW and ANY_OTHER LOIs.
723
    private void applyRevivalPaymentHooks(LoiForm loi) throws ProfitMandiBusinessException {
727
    private void applyRevivalPaymentHooks(LoiForm loi, String approvedBy) throws ProfitMandiBusinessException {
724
        if (loi == null || loi.getOnboardingType() != OnboardingType.REVIVAL) return;
728
        if (loi == null || loi.getOnboardingType() != OnboardingType.REVIVAL) return;
725
        String oldCode = loi.getOldStoreCode();
729
        String oldCode = loi.getOldStoreCode();
726
        if (oldCode != null && !oldCode.trim().isEmpty()) {
730
        if (oldCode != null && !oldCode.trim().isEmpty()) {
-
 
731
            // A SUSPENDED store comes back on the same code. A CLOSED store stays closed; its new code is issued
-
 
732
            // when the store is created (RetailerServiceImpl.takeoverClosedStoreIdentity).
727
            FofoStore store = fofoStoreRepository.selectByStoreCode(oldCode.trim());
733
            FofoStore store = fofoStoreRepository.selectByStoreCode(oldCode.trim());
728
            if (store != null && !store.isActive()) {
734
            if (store != null && store.getStoreStatus() == StoreStatus.SUSPENDED) {
729
                store.setActive(true);
-
 
730
                store.setActiveTimeStamp(LocalDateTime.now());
735
                storeStatusService.reviveSameStore(store.getId(), loi.getId(), approvedBy);
731
                fofoStoreRepository.persist(store);
-
 
732
                LOGGER.info("Revival PAYMENT_APPROVAL: reactivated FofoStore code=" + oldCode);
736
                LOGGER.info("Revival PAYMENT_APPROVAL: reactivated FofoStore code=" + oldCode);
733
            }
737
            }
734
        }
738
        }
735
        int onboardingId = loi.getOnBoardingId();
739
        int onboardingId = loi.getOnBoardingId();
736
        if (onboardingId > 0) {
740
        if (onboardingId > 0) {