Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
35337 aman 1
package com.spice.profitmandi.dao.service;
2
 
35360 aman 3
import com.spice.profitmandi.common.model.ProfitMandiConstants;
35337 aman 4
import com.spice.profitmandi.common.util.Utils;
35360 aman 5
import com.spice.profitmandi.dao.entity.auth.AuthUser;
35337 aman 6
import com.spice.profitmandi.dao.entity.fofo.TrialForm;
35360 aman 7
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
8
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
9
import com.spice.profitmandi.dao.repository.cs.CsService;
35337 aman 10
import com.spice.profitmandi.dao.service.loiForm.LoiFormServiceImpl;
11
import org.apache.logging.log4j.LogManager;
12
import org.apache.logging.log4j.Logger;
13
import org.springframework.beans.factory.annotation.Autowired;
14
import org.springframework.mail.javamail.JavaMailSender;
15
import org.springframework.stereotype.Service;
16
 
35360 aman 17
import java.util.ArrayList;
18
import java.util.Arrays;
19
import java.util.List;
20
 
35337 aman 21
@Service
35360 aman 22
public class TrialServiceImpl implements TrialService {
35337 aman 23
 
24
    private static final Logger LOGGER = LogManager.getLogger(LoiFormServiceImpl.class);
25
 
26
    @Autowired
27
    JavaMailSender mailSender;
28
 
35360 aman 29
    @Autowired
30
    AuthRepository authRepository;
31
 
32
    @Autowired
33
    CsService csService;
34
 
35337 aman 35
    @Override
36
    public void sentMailForTrialUser(TrialForm trialForm) throws Exception {
37
        String body =
35362 aman 38
                "Dear Team,<br><br>" +
39
                        "A new partner has registered via the SmartDukaan Partners App. Please review the details below and initiate the verification process immediately.<br><br>" +
40
                        "<strong>Applicant Name:</strong> " + trialForm.getFirstName() + " " + trialForm.getLastName() + "<br>" +
41
                        "<strong>Business Name:</strong> " + trialForm.getBusinessName() + "<br>" +
42
                        "<strong>Mobile:</strong> " + trialForm.getMobile() + "<br>" +
43
                        "<strong>Email:</strong> " + trialForm.getEmail() + "<br>" +
44
                        "<strong>GST Number:</strong> " + trialForm.getGstNumber() + "<br><br>" +
45
                        "<strong>Address:</strong><br>" +
46
                        trialForm.getAddressLine1() + "<br>" +
47
                        (trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "<br>" : "") +
48
                        trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "<br><br>" +
49
                        "<strong>Required Actions:</strong><br>" +
50
                        "• Verify Details: Validate KYC documents and basic business information.<br>" +
51
                        "• Assess Potential: Check the location feasibility and estimated sales potential.<br>" +
52
                        "• Assign Territory: Assign the appropriate Area Sales Manager (ASM) and Business Manager (BM) in the system.<br><br>" +
53
                        "Regards,<br>SmartDukaan Team";
35337 aman 54
 
35360 aman 55
        String[] emailTo = {"kamini.sharma@smartdukaan.com"};
35337 aman 56
//        String[] emailTo = {"aman.gupta@smartdukaan.com"};
35360 aman 57
        String[] cc = {"vaibhav.tandon@smartdukaan.com"};
35337 aman 58
        LOGGER.info("RegistrationBody - " + body);
35360 aman 59
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "New Trial Registration: " + trialForm.getBusinessName(), body);
35337 aman 60
 
61
 
62
    }
35360 aman 63
 
64
    public void sentMailForTrialUserToSales(TrialForm trialForm) throws Exception {
65
        String body =
35362 aman 66
                "<strong>Sales Team Action:</strong><br>" +
67
                        "A new verified partner lead has been assigned to your territory. They have successfully passed the initial verification stage.<br><br>" +
68
                        "<strong>Lead Information:</strong><br>" +
69
                        "<strong>Applicant Name:</strong> " + trialForm.getFirstName() + " " + trialForm.getLastName() + "<br>" +
70
                        "<strong>Business Name:</strong> " + trialForm.getBusinessName() + "<br>" +
71
                        "<strong>Mobile:</strong> " + trialForm.getMobile() + "<br>" +
72
                        "<strong>Email:</strong> " + trialForm.getEmail() + "<br>" +
73
                        "<strong>GST Number:</strong> " + trialForm.getGstNumber() + "<br><br>" +
74
                        "<strong>Address:</strong><br>" +
75
                        trialForm.getAddressLine1() + "<br>" +
76
                        (trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "<br>" : "") +
77
                        trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "<br><br>" +
78
                        "<strong>Strategic Objective:</strong> The partner has expressed initial interest. Your goal is to move them beyond trial onboarding.<br><br>" +
79
                        "<strong>Next Steps:</strong><br>" +
80
                        "• Contact Immediately: Call or visit the store within the next 24 hours.<br>" +
81
                        "• 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>" +
82
                        "• Update Status: Log your interaction and the partner's interest level in the app immediately after the meeting.<br><br>" +
83
                        "Good Luck,<br>" +
84
                        "Regards,<br>SmartDukaan Team";
85
 
35360 aman 86
        List<AuthUser> salesAuthUserList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Arrays.asList(EscalationType.L3, EscalationType.L4, EscalationType.L5));
87
        List<String> salesEmailList = new ArrayList<>();
88
        for (AuthUser authUser : salesAuthUserList) {
89
            if (authUser.getEmailId() != null && !authUser.getEmailId().trim().isEmpty()) {
90
                salesEmailList.add(authUser.getEmailId());
91
            }
92
        }
93
        AuthUser bmAuthUser = authRepository.selectById(trialForm.getBmId());
94
        AuthUser asmAuthUser = authRepository.selectById(trialForm.getAsmId());
95
 
96
        String[] emailTo = new String[]{bmAuthUser.getEmailId()};
97
        List<String> ccList = new ArrayList<>(salesEmailList);
98
        ccList.add(asmAuthUser.getEmailId());
99
        String[] cc = ccList.stream()
100
                .filter(email -> !email.trim().isEmpty())
101
                .toArray(String[]::new);
102
        LOGGER.info("RegistrationBody - " + body);
103
        LOGGER.info("cc list - " + Arrays.toString(cc));
104
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "NEW LEAD ASSIGNED: " + trialForm.getBusinessName() + "- Call/Visit ASAP", body);
105
 
106
 
107
    }
108
 
109
    public void sentMailForStoreCodeCreation(TrialForm trialForm) throws Exception {
110
        String body =
35362 aman 111
                "The trial user has been verified.<br><br>" +
112
                        "Please create Store Code for: <strong>" + trialForm.getBusinessName() + "</strong><br>" +
113
                        "Mobile Number: <strong>" + trialForm.getMobile() + "</strong><br><br>" +
114
                        "Regards,<br>SmartDukaan Team";
115
 
35360 aman 116
        String[] emailTo = {"gaurav.sharma@smartdukaan.com"};
117
        LOGGER.info("RegistrationBody - " + body);
118
        String[] cc = {"devkinandan.lal@smartdukaan.com"};
119
        LOGGER.info("cc list - " + Arrays.toString(cc));
120
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "Store Code Creation Required for trial user" + trialForm.getBusinessName(), body);
121
 
122
 
123
    }
35337 aman 124
}