Subversion Repositories SmartDukaan

Rev

Rev 35391 | Rev 35425 | 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>" +
35418 aman 50
                        " 1. Verify Details: Validate KYC documents and basic business information.<br>" +
51
                        " 2. Assess Potential: Check the location feasibility and estimated sales potential.<br>" +
52
                        " 3. Assign Territory: Assign the appropriate Area Sales Manager (ASM) and Business Manager (BM) in the system.<br><br>" +
35362 aman 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
 
35391 aman 64
    public void sentMailToTrialUser(TrialForm trialForm) throws Exception {
65
 
66
        String applicantName = trialForm.getFirstName() +
67
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
68
 
69
        String body =
70
                "Hi " + applicantName + ",<br><br>" +
71
                        "Aapki <strong>SmartDukaan registration application</strong> humein mil gayi hai.<br><br>" +
72
                        "<strong>Current Status:</strong>  <strong>Verification In Progress</strong><br><br>" +
73
                        "Aapki application process ho rahi hai. Account activate karne ke liye, humari team aapke " +
74
                        "submit kiye gaye documents, business potential aur location verify kar rahi hai.<br><br>" +
75
 
76
                        "<strong>What’s Next?</strong><br>" +
35418 aman 77
                        " 1. Verification process complete ki jaayegi. (Approx. 48 hours)<br>" +
78
                        " 2. Account approve hote hi, aapke <strong>registered email</strong> par Login ID, Password, " +
35391 aman 79
                        "aur saari details bhej di jaayengi.<br>" +
35418 aman 80
                        " 3. Login karte hi aapka <strong>30-Day Free Trial activate</strong> ho jaayega. <br><br>" +
81
                        "Aur jaankaari ya kisi bhi sahayata ke liye, turant contact kariye" +
35391 aman 82
                        "<strong>Support:</strong><br>" +
83
                        " 1800-270-0273<br>" +
35418 aman 84
                        "Ya e-mail kariye :<strong> care@smartdukaan.com </strong><br><br>" +
85
                        "Thank you for choosing <strong>SmartDukaan</strong>" +
35391 aman 86
                        "We will reach out to you shortly.<br><br>" +
87
                        "Regards,<br>" +
88
                        "Team SmartDukaan";
89
 
90
        String[] emailTo = {trialForm.getEmail()};
91
        String[] cc = {};
92
        LOGGER.info("RegistrationBody - " + body);
93
        Utils.sendMailWithAttachments(
94
                mailSender,
95
                emailTo,
96
                cc,
97
                "Application Received! We are verifying your details.",
98
                body
99
        );
100
    }
101
 
35360 aman 102
    public void sentMailForTrialUserToSales(TrialForm trialForm) throws Exception {
103
        String body =
35362 aman 104
                "<strong>Sales Team Action:</strong><br>" +
105
                        "A new verified partner lead has been assigned to your territory. They have successfully passed the initial verification stage.<br><br>" +
106
                        "<strong>Lead Information:</strong><br>" +
107
                        "<strong>Applicant Name:</strong> " + trialForm.getFirstName() + " " + trialForm.getLastName() + "<br>" +
108
                        "<strong>Business Name:</strong> " + trialForm.getBusinessName() + "<br>" +
109
                        "<strong>Mobile:</strong> " + trialForm.getMobile() + "<br>" +
110
                        "<strong>Email:</strong> " + trialForm.getEmail() + "<br>" +
111
                        "<strong>GST Number:</strong> " + trialForm.getGstNumber() + "<br><br>" +
112
                        "<strong>Address:</strong><br>" +
113
                        trialForm.getAddressLine1() + "<br>" +
114
                        (trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "<br>" : "") +
115
                        trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "<br><br>" +
116
                        "<strong>Strategic Objective:</strong> The partner has expressed initial interest. Your goal is to move them beyond trial onboarding.<br><br>" +
117
                        "<strong>Next Steps:</strong><br>" +
35418 aman 118
                        " 1. Contact Immediately: Call or visit the store within the next 24 hours.<br>" +
119
                        " 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>" +
120
                        " 3. Update Status: Log your interaction and the partner's interest level in the app immediately after the meeting.<br><br>" +
35362 aman 121
                        "Good Luck,<br>" +
122
                        "Regards,<br>SmartDukaan Team";
123
 
35360 aman 124
        List<AuthUser> salesAuthUserList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Arrays.asList(EscalationType.L3, EscalationType.L4, EscalationType.L5));
125
        List<String> salesEmailList = new ArrayList<>();
126
        for (AuthUser authUser : salesAuthUserList) {
127
            if (authUser.getEmailId() != null && !authUser.getEmailId().trim().isEmpty()) {
128
                salesEmailList.add(authUser.getEmailId());
129
            }
130
        }
131
        AuthUser bmAuthUser = authRepository.selectById(trialForm.getBmId());
132
        AuthUser asmAuthUser = authRepository.selectById(trialForm.getAsmId());
133
 
134
        String[] emailTo = new String[]{bmAuthUser.getEmailId()};
135
        List<String> ccList = new ArrayList<>(salesEmailList);
136
        ccList.add(asmAuthUser.getEmailId());
137
        String[] cc = ccList.stream()
138
                .filter(email -> !email.trim().isEmpty())
139
                .toArray(String[]::new);
140
        LOGGER.info("RegistrationBody - " + body);
141
        LOGGER.info("cc list - " + Arrays.toString(cc));
142
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "NEW LEAD ASSIGNED: " + trialForm.getBusinessName() + "- Call/Visit ASAP", body);
143
 
144
 
145
    }
146
 
147
    public void sentMailForStoreCodeCreation(TrialForm trialForm) throws Exception {
148
        String body =
35362 aman 149
                "The trial user has been verified.<br><br>" +
150
                        "Please create Store Code for: <strong>" + trialForm.getBusinessName() + "</strong><br>" +
151
                        "Mobile Number: <strong>" + trialForm.getMobile() + "</strong><br><br>" +
152
                        "Regards,<br>SmartDukaan Team";
153
 
35360 aman 154
        String[] emailTo = {"gaurav.sharma@smartdukaan.com"};
155
        LOGGER.info("RegistrationBody - " + body);
156
        String[] cc = {"devkinandan.lal@smartdukaan.com"};
157
        LOGGER.info("cc list - " + Arrays.toString(cc));
158
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "Store Code Creation Required for trial user" + trialForm.getBusinessName(), body);
159
 
160
 
161
    }
35391 aman 162
 
163
    public void sentRejectionMailToTrialUser(TrialForm trialForm) throws Exception {
164
 
165
        String applicantName = trialForm.getFirstName() +
166
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
167
 
168
        String body =
169
                "Dear " + applicantName + ",<br><br>" +
170
                        "Humne aapki application carefully review ki hai. Hamein khed hai ki " +
171
                        "current eligibility criteria ke basis par aapka <strong>30-day free trial request</strong> " +
172
                        "decline kar diya gaya hai.<br><br>" +
173
 
174
                        "Agar aap is decision ka reason janna chahte hain ya koi issue resolve karna chahte hain, " +
175
                        "toh aap humein <strong>care@smartdukaan.com</strong> par email karein ya " +
176
                        "hamare Toll Free number <strong>1800-270-0273</strong> par call karein.<br><br>" +
177
 
178
                        "Apply karne ke liye dhanyavaad. Hum aapke future business endeavors ke liye " +
179
                        "shubhkamnayein dete hain. Agar future mein humari policies change hoti hain, " +
180
                        "toh hum aapse zaroor contact karenge.<br><br>" +
181
 
182
                        "Regards,<br>" +
183
                        "The SmartDukaan Team";
184
 
185
        String[] emailTo = {trialForm.getEmail()};
186
        String[] cc = {};
187
 
188
        Utils.sendMailWithAttachments(
189
                mailSender,
190
                emailTo,
191
                cc,
192
                "Update regarding your SmartDukaan Free Trial Request",
193
                body
194
        );
195
    }
196
 
197
    public void sendUpgradeRequestMail(TrialForm trialForm) throws Exception {
198
 
199
        String applicantName = trialForm.getFirstName() +
200
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
201
 
202
        String body =
203
                "Dear " + applicantName + ",<br><br>" +
204
                        "SmartDukaan Franchise Partner program mein interest dikhane ke liye dhanyawaad.<br><br>" +
205
 
206
                        "Humein aapki request mil gayi hai. Humaari team jald hi aapse connect karegi " +
207
                        "taaki hum requirements aur onboarding process ke next steps discuss kar sakein.<br><br>" +
208
 
209
                        "Umeed hai ki hum is partnership ko naye level par le jayenge.<br><br>" +
210
 
211
                        "Regards,<br>" +
212
                        "The SmartDukaan Team";
213
 
214
        String[] emailTo = {trialForm.getEmail()};
215
        String[] cc = {};
216
 
217
        Utils.sendMailWithAttachments(
218
                mailSender,
219
                emailTo,
220
                cc,
221
                "We’ve received your interest for SmartDukaan Franchise",
222
                body
223
        );
224
    }
225
 
226
    public void sendInternalFranchiseUpgradeMail(TrialForm trialForm) throws Exception {
227
 
228
        String applicantName = trialForm.getFirstName() +
229
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
230
 
231
        String body =
232
                "Hi Team,<br><br>" +
233
                        "We have received a new interest request for the <strong>SmartDukaan Franchise Partner upgrade</strong> via the app.<br><br>" +
234
 
235
                        "<strong>Trial User Details:</strong><br>" +
236
                        "Name: " + applicantName + "<br>" +
237
                        "Business Name: " + trialForm.getBusinessName() + "<br>" +
238
                        "Registered Mobile: " + trialForm.getMobile() + "<br>" +
239
                        "User ID: " + trialForm.getId() + "<br>" +
240
                        "Request Date: " + trialForm.getUpdatedOn() + "<br><br>" +
241
 
242
                        "<strong>Action Required:</strong><br>" +
243
                        "Please review the user's profile and initiate the verification/onboarding process immediately.<br><br>" +
244
 
245
                        "Best,<br>" +
246
                        "SmartDukaan System";
35418 aman 247
        List<AuthUser> salesAuthUserList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Arrays.asList(EscalationType.L3, EscalationType.L4, EscalationType.L5));
248
        List<String> salesEmailList = new ArrayList<>();
249
        for (AuthUser authUser : salesAuthUserList) {
250
            if (authUser.getEmailId() != null && !authUser.getEmailId().trim().isEmpty()) {
251
                salesEmailList.add(authUser.getEmailId());
252
            }
253
        }
254
        AuthUser bmAuthUser = authRepository.selectById(trialForm.getBmId());
255
        AuthUser asmAuthUser = authRepository.selectById(trialForm.getAsmId());
35391 aman 256
 
35418 aman 257
        String[] emailTo = new String[]{bmAuthUser.getEmailId()};
258
        List<String> ccList = new ArrayList<>(salesEmailList);
259
        ccList.add(asmAuthUser.getEmailId());
260
        String[] cc = ccList.stream()
261
                .filter(email -> !email.trim().isEmpty())
262
                .toArray(String[]::new);
35391 aman 263
        Utils.sendMailWithAttachments(
264
                mailSender,
265
                emailTo,
266
                cc,
267
                "Franchise Upgrade Request - " + applicantName + ", " + trialForm.getBusinessName(),
268
                body
269
        );
270
    }
271
 
35337 aman 272
}