Subversion Repositories SmartDukaan

Rev

Rev 35425 | Rev 35499 | 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"};
35485 aman 57
        String[] cc = {"vaibhav.tandon@smartdukaan.com", "tarun.verma@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>" +
35425 aman 81
                        "Aur jaankaari ya kisi bhi sahayata ke liye, turant contact kariye <br> " +
82
                        "<strong> Support:</strong> : " +
35391 aman 83
                        " 1800-270-0273<br>" +
35418 aman 84
                        "Ya e-mail kariye :<strong> care@smartdukaan.com </strong><br><br>" +
35425 aman 85
                        "Thank you for choosing <strong>SmartDukaan. </strong>" +
86
                        " We will reach out to you shortly.<br><br>" +
35391 aman 87
                        "Regards,<br>" +
88
                        "Team SmartDukaan";
89
 
90
        String[] emailTo = {trialForm.getEmail()};
35485 aman 91
        String[] cc = {"tarun.verma@smartdukaan.com"};
35391 aman 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());
35485 aman 137
        ccList.add("tarun.verma@smartdukaan.com");
35360 aman 138
        String[] cc = ccList.stream()
139
                .filter(email -> !email.trim().isEmpty())
140
                .toArray(String[]::new);
141
        LOGGER.info("RegistrationBody - " + body);
142
        LOGGER.info("cc list - " + Arrays.toString(cc));
143
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "NEW LEAD ASSIGNED: " + trialForm.getBusinessName() + "- Call/Visit ASAP", body);
144
 
145
 
146
    }
147
 
148
    public void sentMailForStoreCodeCreation(TrialForm trialForm) throws Exception {
149
        String body =
35362 aman 150
                "The trial user has been verified.<br><br>" +
151
                        "Please create Store Code for: <strong>" + trialForm.getBusinessName() + "</strong><br>" +
152
                        "Mobile Number: <strong>" + trialForm.getMobile() + "</strong><br><br>" +
153
                        "Regards,<br>SmartDukaan Team";
154
 
35360 aman 155
        String[] emailTo = {"gaurav.sharma@smartdukaan.com"};
156
        LOGGER.info("RegistrationBody - " + body);
35485 aman 157
        String[] cc = {"devkinandan.lal@smartdukaan.com", "tarun.verma@smartdukaan.com"};
35360 aman 158
        LOGGER.info("cc list - " + Arrays.toString(cc));
159
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "Store Code Creation Required for trial user" + trialForm.getBusinessName(), body);
160
 
161
 
162
    }
35391 aman 163
 
164
    public void sentRejectionMailToTrialUser(TrialForm trialForm) throws Exception {
165
 
166
        String applicantName = trialForm.getFirstName() +
167
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
168
 
169
        String body =
170
                "Dear " + applicantName + ",<br><br>" +
171
                        "Humne aapki application carefully review ki hai. Hamein khed hai ki " +
172
                        "current eligibility criteria ke basis par aapka <strong>30-day free trial request</strong> " +
173
                        "decline kar diya gaya hai.<br><br>" +
174
 
175
                        "Agar aap is decision ka reason janna chahte hain ya koi issue resolve karna chahte hain, " +
176
                        "toh aap humein <strong>care@smartdukaan.com</strong> par email karein ya " +
177
                        "hamare Toll Free number <strong>1800-270-0273</strong> par call karein.<br><br>" +
178
 
179
                        "Apply karne ke liye dhanyavaad. Hum aapke future business endeavors ke liye " +
180
                        "shubhkamnayein dete hain. Agar future mein humari policies change hoti hain, " +
181
                        "toh hum aapse zaroor contact karenge.<br><br>" +
182
 
183
                        "Regards,<br>" +
184
                        "The SmartDukaan Team";
185
 
186
        String[] emailTo = {trialForm.getEmail()};
35485 aman 187
        String[] cc = {"tarun.verma@smartdukaan.com"};
35391 aman 188
 
189
        Utils.sendMailWithAttachments(
190
                mailSender,
191
                emailTo,
192
                cc,
193
                "Update regarding your SmartDukaan Free Trial Request",
194
                body
195
        );
196
    }
197
 
198
    public void sendUpgradeRequestMail(TrialForm trialForm) throws Exception {
199
 
200
        String applicantName = trialForm.getFirstName() +
201
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
202
 
203
        String body =
204
                "Dear " + applicantName + ",<br><br>" +
205
                        "SmartDukaan Franchise Partner program mein interest dikhane ke liye dhanyawaad.<br><br>" +
206
 
207
                        "Humein aapki request mil gayi hai. Humaari team jald hi aapse connect karegi " +
208
                        "taaki hum requirements aur onboarding process ke next steps discuss kar sakein.<br><br>" +
209
 
210
                        "Umeed hai ki hum is partnership ko naye level par le jayenge.<br><br>" +
211
 
212
                        "Regards,<br>" +
213
                        "The SmartDukaan Team";
214
 
215
        String[] emailTo = {trialForm.getEmail()};
35485 aman 216
        String[] cc = {"tarun.verma@smartdukaan.com"};
35391 aman 217
 
218
        Utils.sendMailWithAttachments(
219
                mailSender,
220
                emailTo,
221
                cc,
222
                "We’ve received your interest for SmartDukaan Franchise",
223
                body
224
        );
225
    }
226
 
227
    public void sendInternalFranchiseUpgradeMail(TrialForm trialForm) throws Exception {
228
 
229
        String applicantName = trialForm.getFirstName() +
230
                (trialForm.getLastName() != null ? " " + trialForm.getLastName() : "");
231
 
232
        String body =
233
                "Hi Team,<br><br>" +
234
                        "We have received a new interest request for the <strong>SmartDukaan Franchise Partner upgrade</strong> via the app.<br><br>" +
235
 
236
                        "<strong>Trial User Details:</strong><br>" +
237
                        "Name: " + applicantName + "<br>" +
238
                        "Business Name: " + trialForm.getBusinessName() + "<br>" +
239
                        "Registered Mobile: " + trialForm.getMobile() + "<br>" +
240
                        "User ID: " + trialForm.getId() + "<br>" +
241
                        "Request Date: " + trialForm.getUpdatedOn() + "<br><br>" +
242
 
243
                        "<strong>Action Required:</strong><br>" +
244
                        "Please review the user's profile and initiate the verification/onboarding process immediately.<br><br>" +
245
 
246
                        "Best,<br>" +
247
                        "SmartDukaan System";
35418 aman 248
        List<AuthUser> salesAuthUserList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Arrays.asList(EscalationType.L3, EscalationType.L4, EscalationType.L5));
249
        List<String> salesEmailList = new ArrayList<>();
250
        for (AuthUser authUser : salesAuthUserList) {
251
            if (authUser.getEmailId() != null && !authUser.getEmailId().trim().isEmpty()) {
252
                salesEmailList.add(authUser.getEmailId());
253
            }
254
        }
255
        AuthUser bmAuthUser = authRepository.selectById(trialForm.getBmId());
256
        AuthUser asmAuthUser = authRepository.selectById(trialForm.getAsmId());
35391 aman 257
 
35418 aman 258
        String[] emailTo = new String[]{bmAuthUser.getEmailId()};
259
        List<String> ccList = new ArrayList<>(salesEmailList);
260
        ccList.add(asmAuthUser.getEmailId());
35485 aman 261
        ccList.add("tarun.verma@smartdukaan.com");
35418 aman 262
        String[] cc = ccList.stream()
263
                .filter(email -> !email.trim().isEmpty())
264
                .toArray(String[]::new);
35391 aman 265
        Utils.sendMailWithAttachments(
266
                mailSender,
267
                emailTo,
268
                cc,
269
                "Franchise Upgrade Request - " + applicantName + ", " + trialForm.getBusinessName(),
270
                body
271
        );
272
    }
273
 
35337 aman 274
}