Subversion Repositories SmartDukaan

Rev

Rev 36399 | 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;
35642 aman 4
import com.spice.profitmandi.common.services.EmailService;
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
 
35499 aman 17
import java.time.LocalDate;
35360 aman 18
import java.util.ArrayList;
19
import java.util.Arrays;
20
import java.util.List;
21
 
35337 aman 22
@Service
35360 aman 23
public class TrialServiceImpl implements TrialService {
35337 aman 24
 
25
    private static final Logger LOGGER = LogManager.getLogger(LoiFormServiceImpl.class);
26
 
27
    @Autowired
36399 amit 28
    JavaMailSender gmailRelaySender;
35337 aman 29
 
35360 aman 30
    @Autowired
31
    AuthRepository authRepository;
32
 
33
    @Autowired
34
    CsService csService;
35
 
35642 aman 36
    @Autowired
37
    EmailService emailService;
38
 
35337 aman 39
    @Override
40
    public void sentMailForTrialUser(TrialForm trialForm) throws Exception {
41
        String body =
35362 aman 42
                "Dear Team,<br><br>" +
43
                        "A new partner has registered via the SmartDukaan Partners App. Please review the details below and initiate the verification process immediately.<br><br>" +
44
                        "<strong>Applicant Name:</strong> " + trialForm.getFirstName() + " " + trialForm.getLastName() + "<br>" +
45
                        "<strong>Business Name:</strong> " + trialForm.getBusinessName() + "<br>" +
46
                        "<strong>Mobile:</strong> " + trialForm.getMobile() + "<br>" +
47
                        "<strong>Email:</strong> " + trialForm.getEmail() + "<br>" +
48
                        "<strong>GST Number:</strong> " + trialForm.getGstNumber() + "<br><br>" +
49
                        "<strong>Address:</strong><br>" +
50
                        trialForm.getAddressLine1() + "<br>" +
51
                        (trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "<br>" : "") +
52
                        trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "<br><br>" +
35499 aman 53
                        "<strong>Date:</strong> " + LocalDate.now() + "<br>" +
35362 aman 54
                        "<strong>Required Actions:</strong><br>" +
35418 aman 55
                        " 1. Verify Details: Validate KYC documents and basic business information.<br>" +
56
                        " 2. Assess Potential: Check the location feasibility and estimated sales potential.<br>" +
57
                        " 3. Assign Territory: Assign the appropriate Area Sales Manager (ASM) and Business Manager (BM) in the system.<br><br>" +
35362 aman 58
                        "Regards,<br>SmartDukaan Team";
35337 aman 59
 
35360 aman 60
        String[] emailTo = {"kamini.sharma@smartdukaan.com"};
35485 aman 61
        String[] cc = {"vaibhav.tandon@smartdukaan.com", "tarun.verma@smartdukaan.com"};
35337 aman 62
        LOGGER.info("RegistrationBody - " + body);
36399 amit 63
        emailService.sendMailWithAttachments(gmailRelaySender, emailTo, cc, "New Trial Registration: " + trialForm.getBusinessName(), body);
35337 aman 64
 
65
 
66
    }
35360 aman 67
 
35391 aman 68
    public void sentMailToTrialUser(TrialForm trialForm) throws Exception {
69
 
70
        String applicantName = trialForm.getFirstName() +
71
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
72
 
73
        String body =
74
                "Hi " + applicantName + ",<br><br>" +
35499 aman 75
                        "We have successfully received your <strong>SmartDukaan registration application</strong>.<br><br>" +
35391 aman 76
 
35499 aman 77
                        "<strong>Current Status:</strong> <strong>Verification in Progress</strong><br><br>" +
78
 
79
                        "Your application is currently under review. Before activating your account, our team is verifying the " +
80
                        "documents you submitted, your business potential, and your location. Taaki onboarding bilkul smooth " +
81
                        "aur transparent ho.<br><br>" +
82
 
83
                        "<strong>What Happens Next?</strong><br>" +
36008 aman 84
                        "1. Our team will complete the verification process (approx. 2-3 days).<br>" +
35499 aman 85
                        "2. Once approved, you will receive your <strong>Login ID, Password,</strong> and onboarding details " +
86
                        "on your registered email address.<br>" +
87
                        "3. Simply log in using these details and start enjoying the <strong>SmartDukaan advantage</strong> immediately.<br><br>" +
88
 
89
                        "For any assistance, feel free to contact us:<br>" +
90
                        "<strong>Toll-Free:</strong> 1800-270-0273<br>" +
91
                        "<strong>Email:</strong> care@smartdukaan.com<br><br>" +
92
 
93
                        "Thank you for choosing <strong>SmartDukaan</strong>. We will connect with you shortly.<br><br>" +
94
 
35391 aman 95
                        "Regards,<br>" +
96
                        "Team SmartDukaan";
97
 
35499 aman 98
 
35391 aman 99
        String[] emailTo = {trialForm.getEmail()};
35758 vikas 100
        String[] cc = {"sdtech@smartdukaan.com"}; // tarun.verma@smartdukaan.com
35391 aman 101
        LOGGER.info("RegistrationBody - " + body);
35642 aman 102
        emailService.sendMailWithAttachments(
36399 amit 103
                gmailRelaySender,
35391 aman 104
                emailTo,
105
                cc,
35995 aman 106
                "Application Received - Verification in Progress",
35391 aman 107
                body
108
        );
109
    }
110
 
35360 aman 111
    public void sentMailForTrialUserToSales(TrialForm trialForm) throws Exception {
112
        String body =
35362 aman 113
                "<strong>Sales Team Action:</strong><br>" +
114
                        "A new verified partner lead has been assigned to your territory. They have successfully passed the initial verification stage.<br><br>" +
115
                        "<strong>Lead Information:</strong><br>" +
116
                        "<strong>Applicant Name:</strong> " + trialForm.getFirstName() + " " + trialForm.getLastName() + "<br>" +
117
                        "<strong>Business Name:</strong> " + trialForm.getBusinessName() + "<br>" +
118
                        "<strong>Mobile:</strong> " + trialForm.getMobile() + "<br>" +
119
                        "<strong>Email:</strong> " + trialForm.getEmail() + "<br>" +
120
                        "<strong>GST Number:</strong> " + trialForm.getGstNumber() + "<br><br>" +
121
                        "<strong>Address:</strong><br>" +
122
                        trialForm.getAddressLine1() + "<br>" +
123
                        (trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "<br>" : "") +
124
                        trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "<br><br>" +
125
                        "<strong>Strategic Objective:</strong> The partner has expressed initial interest. Your goal is to move them beyond trial onboarding.<br><br>" +
126
                        "<strong>Next Steps:</strong><br>" +
35418 aman 127
                        " 1. Contact Immediately: Call or visit the store within the next 24 hours.<br>" +
128
                        " 2. 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>" +
129
                        " 3. Update Status: Log your interaction and the partner's interest level in the app immediately after the meeting.<br><br>" +
35362 aman 130
                        "Good Luck,<br>" +
131
                        "Regards,<br>SmartDukaan Team";
132
 
35360 aman 133
        List<AuthUser> salesAuthUserList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Arrays.asList(EscalationType.L3, EscalationType.L4, EscalationType.L5));
134
        List<String> salesEmailList = new ArrayList<>();
135
        for (AuthUser authUser : salesAuthUserList) {
136
            if (authUser.getEmailId() != null && !authUser.getEmailId().trim().isEmpty()) {
137
                salesEmailList.add(authUser.getEmailId());
138
            }
139
        }
140
        AuthUser bmAuthUser = authRepository.selectById(trialForm.getBmId());
141
        AuthUser asmAuthUser = authRepository.selectById(trialForm.getAsmId());
142
 
143
        String[] emailTo = new String[]{bmAuthUser.getEmailId()};
144
        List<String> ccList = new ArrayList<>(salesEmailList);
145
        ccList.add(asmAuthUser.getEmailId());
35485 aman 146
        ccList.add("tarun.verma@smartdukaan.com");
35360 aman 147
        String[] cc = ccList.stream()
148
                .filter(email -> !email.trim().isEmpty())
149
                .toArray(String[]::new);
150
        LOGGER.info("RegistrationBody - " + body);
151
        LOGGER.info("cc list - " + Arrays.toString(cc));
36399 amit 152
        emailService.sendMailWithAttachments(gmailRelaySender, emailTo, cc, "NEW LEAD ASSIGNED: " + trialForm.getBusinessName() + "- Call/Visit ASAP", body);
35360 aman 153
 
154
 
155
    }
156
 
157
    public void sentMailForStoreCodeCreation(TrialForm trialForm) throws Exception {
158
        String body =
35362 aman 159
                "The trial user has been verified.<br><br>" +
160
                        "Please create Store Code for: <strong>" + trialForm.getBusinessName() + "</strong><br>" +
161
                        "Mobile Number: <strong>" + trialForm.getMobile() + "</strong><br><br>" +
162
                        "Regards,<br>SmartDukaan Team";
163
 
35360 aman 164
        String[] emailTo = {"gaurav.sharma@smartdukaan.com"};
165
        LOGGER.info("RegistrationBody - " + body);
35485 aman 166
        String[] cc = {"devkinandan.lal@smartdukaan.com", "tarun.verma@smartdukaan.com"};
35360 aman 167
        LOGGER.info("cc list - " + Arrays.toString(cc));
36399 amit 168
        emailService.sendMailWithAttachments(gmailRelaySender, emailTo, cc, "Store Code Creation Required for trial user" + trialForm.getBusinessName(), body);
35360 aman 169
 
170
 
171
    }
35391 aman 172
 
173
    public void sentRejectionMailToTrialUser(TrialForm trialForm) throws Exception {
174
 
175
        String applicantName = trialForm.getFirstName() +
176
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
177
 
178
        String body =
179
                "Dear " + applicantName + ",<br><br>" +
35499 aman 180
                        "After a detailed review of your application, we regret to inform you that your " +
181
                        "<strong>30-Day Free Trial request</strong> cannot be approved based on the current " +
182
                        "eligibility criteria.<br><br>" +
35391 aman 183
 
35499 aman 184
                        "If you would like to understand the reason for this decision or discuss any concerns, " +
185
                        "please feel free to reach out to us at <strong>care@smartdukaan.com</strong> or call our " +
186
                        "Toll-Free number <strong>1800-270-0273</strong>.<br><br>" +
35391 aman 187
 
35499 aman 188
                        "Thank you for applying. We wish you continued success in your business journey. " +
189
                        "Aur agar future mein humari policies change hoti hain, hum aapse zaroor sampark karenge.<br><br>" +
35391 aman 190
 
191
                        "Regards,<br>" +
35499 aman 192
                        "Team SmartDukaan";
35391 aman 193
 
35499 aman 194
 
35391 aman 195
        String[] emailTo = {trialForm.getEmail()};
35758 vikas 196
        String[] cc = {"sdtech@smartdukaan.com"};
35391 aman 197
 
35642 aman 198
        emailService.sendMailWithAttachments(
36399 amit 199
                gmailRelaySender,
35391 aman 200
                emailTo,
201
                cc,
35499 aman 202
                "Update on Your SmartDukaan Free Trial Request",
35391 aman 203
                body
204
        );
205
    }
206
 
207
    public void sendUpgradeRequestMail(TrialForm trialForm) throws Exception {
208
 
209
        String applicantName = trialForm.getFirstName() +
210
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
211
 
212
        String body =
213
                "Dear " + applicantName + ",<br><br>" +
35499 aman 214
                        "Thank you for expressing your interest in the <strong>SmartDukaan Franchise Partner Program</strong>.<br><br>" +
35391 aman 215
 
35499 aman 216
                        "We have successfully received your request. Our team will connect with you shortly to discuss the " +
217
                        "requirements, eligibility, and the next steps. Taaki hum milkar ek strong aur long-term partnership " +
218
                        "build kar saken.<br><br>" +
35391 aman 219
 
35499 aman 220
                        "We look forward to taking this conversation forward.<br><br>" +
35391 aman 221
 
222
                        "Regards,<br>" +
35499 aman 223
                        "Team SmartDukaan";
35391 aman 224
 
35499 aman 225
 
35391 aman 226
        String[] emailTo = {trialForm.getEmail()};
35758 vikas 227
        String[] cc = {"sdtech@smartdukaan.com"};
35391 aman 228
 
35642 aman 229
        emailService.sendMailWithAttachments(
36399 amit 230
                gmailRelaySender,
35391 aman 231
                emailTo,
232
                cc,
35499 aman 233
                "We’ve Received Your Interest in the SmartDukaan Franchise",
35391 aman 234
                body
235
        );
236
    }
237
 
238
    public void sendInternalFranchiseUpgradeMail(TrialForm trialForm) throws Exception {
239
 
240
        String applicantName = trialForm.getFirstName() +
241
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
242
 
243
        String body =
244
                "Hi Team,<br><br>" +
245
                        "We have received a new interest request for the <strong>SmartDukaan Franchise Partner upgrade</strong> via the app.<br><br>" +
246
 
247
                        "<strong>Trial User Details:</strong><br>" +
248
                        "Name: " + applicantName + "<br>" +
249
                        "Business Name: " + trialForm.getBusinessName() + "<br>" +
250
                        "Registered Mobile: " + trialForm.getMobile() + "<br>" +
251
                        "User ID: " + trialForm.getId() + "<br>" +
252
                        "Request Date: " + trialForm.getUpdatedOn() + "<br><br>" +
253
 
254
                        "<strong>Action Required:</strong><br>" +
255
                        "Please review the user's profile and initiate the verification/onboarding process immediately.<br><br>" +
256
 
257
                        "Best,<br>" +
258
                        "SmartDukaan System";
35418 aman 259
        List<AuthUser> salesAuthUserList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Arrays.asList(EscalationType.L3, EscalationType.L4, EscalationType.L5));
260
        List<String> salesEmailList = new ArrayList<>();
261
        for (AuthUser authUser : salesAuthUserList) {
262
            if (authUser.getEmailId() != null && !authUser.getEmailId().trim().isEmpty()) {
263
                salesEmailList.add(authUser.getEmailId());
264
            }
265
        }
266
        AuthUser bmAuthUser = authRepository.selectById(trialForm.getBmId());
267
        AuthUser asmAuthUser = authRepository.selectById(trialForm.getAsmId());
35391 aman 268
 
35418 aman 269
        String[] emailTo = new String[]{bmAuthUser.getEmailId()};
270
        List<String> ccList = new ArrayList<>(salesEmailList);
271
        ccList.add(asmAuthUser.getEmailId());
35485 aman 272
        ccList.add("tarun.verma@smartdukaan.com");
35418 aman 273
        String[] cc = ccList.stream()
274
                .filter(email -> !email.trim().isEmpty())
275
                .toArray(String[]::new);
35642 aman 276
        emailService.sendMailWithAttachments(
36399 amit 277
                gmailRelaySender,
35391 aman 278
                emailTo,
279
                cc,
280
                "Franchise Upgrade Request - " + applicantName + ", " + trialForm.getBusinessName(),
281
                body
282
        );
283
    }
284
 
35337 aman 285
}