Subversion Repositories SmartDukaan

Rev

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