Rev 35337 | Rev 35362 | 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,\r\n\r\n" +"A new partner has registered via the SmartDukaan Partners App. Please review the details below and initiate the verification process immediately.\r\n\r\n" +"Applicant Name: " + trialForm.getFirstName() + " " + trialForm.getLastName() + "\r\n" +"Business Name: " + trialForm.getBusinessName() + "\r\n" +"Mobile: " + trialForm.getMobile() + "\r\n" +"Email: " + trialForm.getEmail() + "\r\n" +"GST Number: " + trialForm.getGstNumber() + "\r\n\r\n" +"Address:\r\n" +trialForm.getAddressLine1() + "\r\n" +(trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "\r\n" : "") +trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "\r\n\r\n" +"Required Actions:\n" +"Verify Details: Validate KYC documents and basic business information.\r\n" +"Assess Potential: Check the location feasibility and estimated sales potential.\r\n" +"Assign Territory: Assign the appropriate Area Sales Manager (ASM) and Business Manager (BM) in the system.\n\r\n\r\n" +"Regards,\r\nSmartDukaan 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 sentMailForTrialUserToSales(TrialForm trialForm) throws Exception {String body ="Sales Team Action:\r\n" +"A new verified partner lead has been assigned to your territory. They have successfully passed the initial verification stage.\n\r\n" +"Lead Information:" +"Applicant Name: " + trialForm.getFirstName() + " " + trialForm.getLastName() + "\r\n" +"Business Name: " + trialForm.getBusinessName() + "\r\n" +"Mobile: " + trialForm.getMobile() + "\r\n" +"Email: " + trialForm.getEmail() + "\r\n" +"GST Number: " + trialForm.getGstNumber() + "\r\n\r\n" +"Address:\r\n" +trialForm.getAddressLine1() + "\r\n" +(trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "\r\n" : "") +trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "\r\n\r\n" +"Strategic Objective: The partner has expressed initial interest. Your goal is to move them beyond trial onboarding.\r\n" +"Next Steps:\n" +"Contact Immediately: Call or visit the store within the next 24 hours.\n" +"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.\n" +"Update Status: Log your interaction and the partner’s interest level in the app immediately after the meeting.\n\r\n\r\n" +"Good Luck, \r\n" +"Regards,\r\nSmartDukaan 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.\r\n" +"Please create Store Code for . \r\n" + trialForm.getBusinessName() +"Mobile Number. \r\n" + trialForm.getMobile() +"Regards,\r\nSmartDukaan 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);}}