Subversion Repositories SmartDukaan

Rev

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

Rev 37632 Rev 37660
Line 31... Line 31...
31
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
31
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
32
import com.spice.profitmandi.dao.repository.inventory.PartnerOnboardingService;
32
import com.spice.profitmandi.dao.repository.inventory.PartnerOnboardingService;
33
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
33
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
34
import com.spice.profitmandi.dao.repository.onboarding.*;
34
import com.spice.profitmandi.dao.repository.onboarding.*;
35
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
35
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
-
 
36
import com.spice.profitmandi.dao.repository.user.AgreementEsignRepository;
36
import com.spice.profitmandi.dao.repository.user.BillingAddressRepository;
37
import com.spice.profitmandi.dao.repository.user.BillingAddressRepository;
37
import com.spice.profitmandi.dao.repository.user.LoiFormRepository;
38
import com.spice.profitmandi.dao.repository.user.LoiFormRepository;
-
 
39
import com.spice.profitmandi.dao.repository.user.StoreTimelinetbRepository;
38
import com.spice.profitmandi.dao.service.LoiDocModel;
40
import com.spice.profitmandi.dao.service.LoiDocModel;
39
import com.spice.profitmandi.dao.service.OTPResponse;
41
import com.spice.profitmandi.dao.service.OTPResponse;
40
import com.spice.profitmandi.dao.service.OtpProcessor;
42
import com.spice.profitmandi.dao.service.OtpProcessor;
41
import com.spice.profitmandi.dao.service.loiForm.LoiFormService;
43
import com.spice.profitmandi.dao.service.loiForm.LoiFormService;
42
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
44
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
Line 132... Line 134...
132
 
134
 
133
    @Autowired
135
    @Autowired
134
    FofoStoreRepository fofoStoreRepository;
136
    FofoStoreRepository fofoStoreRepository;
135
 
137
 
136
    @Autowired
138
    @Autowired
-
 
139
    StoreTimelinetbRepository storeTimelinetbRepository;
-
 
140
 
-
 
141
    @Autowired
-
 
142
    AgreementEsignRepository agreementEsignRepository;
-
 
143
 
-
 
144
    @Autowired
137
    ResponseSender responseSender;
145
    ResponseSender responseSender;
138
 
146
 
139
    List<String> agreedBrandFeeChangerEmail = Arrays.asList("kamini.sharma@smartdukaan.com");
147
    List<String> agreedBrandFeeChangerEmail = Arrays.asList("kamini.sharma@smartdukaan.com");
140
 
148
 
141
    // Loi Form
149
    // Loi Form
Line 383... Line 391...
383
        brandFeeCollection.setDescription(description);
391
        brandFeeCollection.setDescription(description);
384
        brandFeeCollection.setApprovalTimeStamp(LocalDateTime.now());
392
        brandFeeCollection.setApprovalTimeStamp(LocalDateTime.now());
385
        if (feePaymentStatus.equals(FeePaymentStatus.CONFIRM)) {
393
        if (feePaymentStatus.equals(FeePaymentStatus.CONFIRM)) {
386
            // Payment Approval timeline entry
394
            // Payment Approval timeline entry
387
            storeTimelineTatService.createStoreTimeline(brandFeeCollection.getLoiFormId(), StoreTimeline.PAYMENT_APPROVAL);
395
            storeTimelineTatService.createStoreTimeline(brandFeeCollection.getLoiFormId(), StoreTimeline.PAYMENT_APPROVAL);
388
            loiFormService.checkLoiDetailsCompletion(loiFormRepository.selectById(brandFeeCollection.getLoiFormId()));
396
            LoiForm approvedLoi = loiFormRepository.selectById(brandFeeCollection.getLoiFormId());
-
 
397
            applyRevivalPaymentHooks(approvedLoi);
-
 
398
            loiFormService.checkLoiDetailsCompletion(approvedLoi);
389
        }
399
        }
390
        loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
400
        loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
391
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
401
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
392
        return "response";
402
        return "response";
393
 
403
 
Line 673... Line 683...
673
            }
683
            }
674
        }
684
        }
675
        return "response";
685
        return "response";
676
    }
686
    }
677
 
687
 
-
 
688
    // For a REVIVAL LOI whose brand-fee payment just got confirmed:
-
 
689
    //   1. Reactivate the FofoStore behind the old code so orders / wallet / inventory
-
 
690
    //      start honoring the store again.
-
 
691
    //   2. Wipe the previous partner-life's AGREEMENT_ESIGN + PO_CREATION + PO_APPROVAL
-
 
692
    //      timeline rows on the reused onboarding so the partner appears back on the
-
 
693
    //      agreement-esign panel and gaurav.sharma can re-verify a freshly signed doc.
-
 
694
    //   3. Wipe the AgreementEsign record so the upload widget starts blank.
-
 
695
    // No-op for NEW and ANY_OTHER LOIs.
-
 
696
    private void applyRevivalPaymentHooks(LoiForm loi) {
-
 
697
        if (loi == null || loi.getOnboardingType() != OnboardingType.REVIVAL) return;
-
 
698
        String oldCode = loi.getOldStoreCode();
-
 
699
        if (oldCode != null && !oldCode.trim().isEmpty()) {
-
 
700
            FofoStore store = fofoStoreRepository.selectByStoreCode(oldCode.trim());
-
 
701
            if (store != null && !store.isActive()) {
-
 
702
                store.setActive(true);
-
 
703
                store.setActiveTimeStamp(LocalDateTime.now());
-
 
704
                fofoStoreRepository.persist(store);
-
 
705
                LOGGER.info("Revival PAYMENT_APPROVAL: reactivated FofoStore code=" + oldCode);
-
 
706
            }
-
 
707
        }
-
 
708
        int onboardingId = loi.getOnBoardingId();
-
 
709
        if (onboardingId > 0) {
-
 
710
            storeTimelinetbRepository.deleteByOnboardingIdAndEvent(onboardingId, StoreTimeline.AGREEMENT_ESIGN);
-
 
711
            storeTimelinetbRepository.deleteByOnboardingIdAndEvent(onboardingId, StoreTimeline.PO_CREATION);
-
 
712
            storeTimelinetbRepository.deleteByOnboardingIdAndEvent(onboardingId, StoreTimeline.PO_APPROVAL);
-
 
713
            agreementEsignRepository.deleteByOnboardingId(onboardingId);
-
 
714
            LOGGER.info("Revival PAYMENT_APPROVAL: cleared AGREEMENT_ESIGN + PO_CREATION + PO_APPROVAL + AgreementEsign row for onboardingId=" + onboardingId);
-
 
715
        }
678
 
716
    }
679
}
717
}