Rev 35362 | Rev 35418 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.dao.service;import com.spice.profitmandi.common.model.ProfitMandiConstants;import com.spice.profitmandi.common.util.Utils;import com.spice.profitmandi.dao.entity.auth.AuthUser;import com.spice.profitmandi.dao.entity.fofo.TrialForm;import com.spice.profitmandi.dao.enumuration.cs.EscalationType;import com.spice.profitmandi.dao.repository.auth.AuthRepository;import com.spice.profitmandi.dao.repository.cs.CsService;import com.spice.profitmandi.dao.service.loiForm.LoiFormServiceImpl;import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.mail.javamail.JavaMailSender;import org.springframework.stereotype.Service;import java.util.ArrayList;import java.util.Arrays;import java.util.List;@Servicepublic class TrialServiceImpl implements TrialService {private static final Logger LOGGER = LogManager.getLogger(LoiFormServiceImpl.class);@AutowiredJavaMailSender mailSender;@AutowiredAuthRepository authRepository;@AutowiredCsService csService;@Overridepublic void sentMailForTrialUser(TrialForm trialForm) throws Exception {String body ="Dear Team,<br><br>" +"A new partner has registered via the SmartDukaan Partners App. Please review the details below and initiate the verification process immediately.<br><br>" +"<strong>Applicant Name:</strong> " + trialForm.getFirstName() + " " + trialForm.getLastName() + "<br>" +"<strong>Business Name:</strong> " + trialForm.getBusinessName() + "<br>" +"<strong>Mobile:</strong> " + trialForm.getMobile() + "<br>" +"<strong>Email:</strong> " + trialForm.getEmail() + "<br>" +"<strong>GST Number:</strong> " + trialForm.getGstNumber() + "<br><br>" +"<strong>Address:</strong><br>" +trialForm.getAddressLine1() + "<br>" +(trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "<br>" : "") +trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "<br><br>" +"<strong>Required Actions:</strong><br>" +" Verify Details: Validate KYC documents and basic business information.<br>" +" Assess Potential: Check the location feasibility and estimated sales potential.<br>" +" Assign Territory: Assign the appropriate Area Sales Manager (ASM) and Business Manager (BM) in the system.<br><br>" +"Regards,<br>SmartDukaan Team";String[] emailTo = {"kamini.sharma@smartdukaan.com"};// String[] emailTo = {"aman.gupta@smartdukaan.com"};String[] cc = {"vaibhav.tandon@smartdukaan.com"};LOGGER.info("RegistrationBody - " + body);Utils.sendMailWithAttachments(mailSender, emailTo, cc, "New Trial Registration: " + trialForm.getBusinessName(), body);}public void sentMailToTrialUser(TrialForm trialForm) throws Exception {String applicantName = trialForm.getFirstName() +(trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");String body ="Hi " + applicantName + ",<br><br>" +"Aapki <strong>SmartDukaan registration application</strong> humein mil gayi hai.<br><br>" +"<strong>Current Status:</strong> <strong>Verification In Progress</strong><br><br>" +"Aapki application process ho rahi hai. Account activate karne ke liye, humari team aapke " +"submit kiye gaye documents, business potential aur location verify kar rahi hai.<br><br>" +"<strong>What’s Next?</strong><br>" +" Verification process complete ki jaayegi. (Approx. 48 hours)<br>" +"Account approve hote hi, aapke <strong>registered email</strong> par Login ID, Password, " +"aur saari details bhej di jaayengi.<br>" +"Login karte hi aapka <strong>30-Day Free Trial activate</strong> ho jaayega. <br><br>" +"<strong>Support:</strong><br>" +" 1800-270-0273<br>" +"✉ helpdesk@smartdukaan.com<br><br>" +"Thank you for choosing <strong>SmartDukaan</strong>.<br>" +"We will reach out to you shortly.<br><br>" +"Regards,<br>" +"Team SmartDukaan";String[] emailTo = {trialForm.getEmail()};String[] cc = {};LOGGER.info("RegistrationBody - " + body);Utils.sendMailWithAttachments(mailSender,emailTo,cc,"Application Received! We are verifying your details.",body);}public void sentMailForTrialUserToSales(TrialForm trialForm) throws Exception {String body ="<strong>Sales Team Action:</strong><br>" +"A new verified partner lead has been assigned to your territory. They have successfully passed the initial verification stage.<br><br>" +"<strong>Lead Information:</strong><br>" +"<strong>Applicant Name:</strong> " + trialForm.getFirstName() + " " + trialForm.getLastName() + "<br>" +"<strong>Business Name:</strong> " + trialForm.getBusinessName() + "<br>" +"<strong>Mobile:</strong> " + trialForm.getMobile() + "<br>" +"<strong>Email:</strong> " + trialForm.getEmail() + "<br>" +"<strong>GST Number:</strong> " + trialForm.getGstNumber() + "<br><br>" +"<strong>Address:</strong><br>" +trialForm.getAddressLine1() + "<br>" +(trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "<br>" : "") +trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "<br><br>" +"<strong>Strategic Objective:</strong> The partner has expressed initial interest. Your goal is to move them beyond trial onboarding.<br><br>" +"<strong>Next Steps:</strong><br>" +" Contact Immediately: Call or visit the store within the next 24 hours.<br>" +" The Pitch: Explain the SmartDukaan ecosystem and pitch the Full Franchise Partner Model. Emphasize the long-term higher margins, income boost, brand access, tech support, and branding benefits over the trial version.<br>" +" Update Status: Log your interaction and the partner's interest level in the app immediately after the meeting.<br><br>" +"Good Luck,<br>" +"Regards,<br>SmartDukaan Team";List<AuthUser> salesAuthUserList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Arrays.asList(EscalationType.L3, EscalationType.L4, EscalationType.L5));List<String> salesEmailList = new ArrayList<>();for (AuthUser authUser : salesAuthUserList) {if (authUser.getEmailId() != null && !authUser.getEmailId().trim().isEmpty()) {salesEmailList.add(authUser.getEmailId());}}AuthUser bmAuthUser = authRepository.selectById(trialForm.getBmId());AuthUser asmAuthUser = authRepository.selectById(trialForm.getAsmId());String[] emailTo = new String[]{bmAuthUser.getEmailId()};List<String> ccList = new ArrayList<>(salesEmailList);ccList.add(asmAuthUser.getEmailId());String[] cc = ccList.stream().filter(email -> !email.trim().isEmpty()).toArray(String[]::new);LOGGER.info("RegistrationBody - " + body);LOGGER.info("cc list - " + Arrays.toString(cc));Utils.sendMailWithAttachments(mailSender, emailTo, cc, "NEW LEAD ASSIGNED: " + trialForm.getBusinessName() + "- Call/Visit ASAP", body);}public void sentMailForStoreCodeCreation(TrialForm trialForm) throws Exception {String body ="The trial user has been verified.<br><br>" +"Please create Store Code for: <strong>" + trialForm.getBusinessName() + "</strong><br>" +"Mobile Number: <strong>" + trialForm.getMobile() + "</strong><br><br>" +"Regards,<br>SmartDukaan Team";String[] emailTo = {"gaurav.sharma@smartdukaan.com"};LOGGER.info("RegistrationBody - " + body);String[] cc = {"devkinandan.lal@smartdukaan.com"};LOGGER.info("cc list - " + Arrays.toString(cc));Utils.sendMailWithAttachments(mailSender, emailTo, cc, "Store Code Creation Required for trial user" + trialForm.getBusinessName(), body);}public void sentRejectionMailToTrialUser(TrialForm trialForm) throws Exception {String applicantName = trialForm.getFirstName() +(trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");String body ="Dear " + applicantName + ",<br><br>" +"Humne aapki application carefully review ki hai. Hamein khed hai ki " +"current eligibility criteria ke basis par aapka <strong>30-day free trial request</strong> " +"decline kar diya gaya hai.<br><br>" +"Agar aap is decision ka reason janna chahte hain ya koi issue resolve karna chahte hain, " +"toh aap humein <strong>care@smartdukaan.com</strong> par email karein ya " +"hamare Toll Free number <strong>1800-270-0273</strong> par call karein.<br><br>" +"Apply karne ke liye dhanyavaad. Hum aapke future business endeavors ke liye " +"shubhkamnayein dete hain. Agar future mein humari policies change hoti hain, " +"toh hum aapse zaroor contact karenge.<br><br>" +"Regards,<br>" +"The SmartDukaan Team";String[] emailTo = {trialForm.getEmail()};String[] cc = {};Utils.sendMailWithAttachments(mailSender,emailTo,cc,"Update regarding your SmartDukaan Free Trial Request",body);}public void sendUpgradeRequestMail(TrialForm trialForm) throws Exception {String applicantName = trialForm.getFirstName() +(trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");String body ="Dear " + applicantName + ",<br><br>" +"SmartDukaan Franchise Partner program mein interest dikhane ke liye dhanyawaad.<br><br>" +"Humein aapki request mil gayi hai. Humaari team jald hi aapse connect karegi " +"taaki hum requirements aur onboarding process ke next steps discuss kar sakein.<br><br>" +"Umeed hai ki hum is partnership ko naye level par le jayenge.<br><br>" +"Regards,<br>" +"The SmartDukaan Team";String[] emailTo = {trialForm.getEmail()};String[] cc = {};Utils.sendMailWithAttachments(mailSender,emailTo,cc,"We’ve received your interest for SmartDukaan Franchise",body);}public void sendInternalFranchiseUpgradeMail(TrialForm trialForm) throws Exception {String applicantName = trialForm.getFirstName() +(trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");String body ="Hi Team,<br><br>" +"We have received a new interest request for the <strong>SmartDukaan Franchise Partner upgrade</strong> via the app.<br><br>" +"<strong>Trial User Details:</strong><br>" +"Name: " + applicantName + "<br>" +"Business Name: " + trialForm.getBusinessName() + "<br>" +"Registered Mobile: " + trialForm.getMobile() + "<br>" +"User ID: " + trialForm.getId() + "<br>" +"Request Date: " + trialForm.getUpdatedOn() + "<br><br>" +"<strong>Action Required:</strong><br>" +"Please review the user's profile and initiate the verification/onboarding process immediately.<br><br>" +"Best,<br>" +"SmartDukaan System";String[] emailTo = {"internal-team@smartdukaan.com"};String[] cc = {};Utils.sendMailWithAttachments(mailSender,emailTo,cc,"Franchise Upgrade Request - " + applicantName + ", " + trialForm.getBusinessName(),body);}}