Subversion Repositories SmartDukaan

Rev

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