Subversion Repositories SmartDukaan

Rev

Rev 35337 | Rev 35362 | 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 =
35360 aman 38
                "Dear Team,\r\n\r\n" +
39
                        "A new partner has registered via the SmartDukaan Partners App. Please review the details below and initiate the verification process immediately.\r\n\r\n" +
40
                        "Applicant Name: " + trialForm.getFirstName() + " " + trialForm.getLastName() + "\r\n" +
41
                        "Business Name: " + trialForm.getBusinessName() + "\r\n" +
42
                        "Mobile: " + trialForm.getMobile() + "\r\n" +
43
                        "Email: " + trialForm.getEmail() + "\r\n" +
44
                        "GST Number: " + trialForm.getGstNumber() + "\r\n\r\n" +
45
                        "Address:\r\n" +
46
                        trialForm.getAddressLine1() + "\r\n" +
47
                        (trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "\r\n" : "") +
48
                        trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "\r\n\r\n" +
35337 aman 49
 
35360 aman 50
                        "Required Actions:\n" +
51
                        "Verify Details: Validate KYC documents and basic business information.\r\n" +
52
                        "Assess Potential: Check the location feasibility and estimated sales potential.\r\n" +
53
                        "Assign Territory: Assign the appropriate Area Sales Manager (ASM) and Business Manager (BM) in the system.\n\r\n\r\n" +
54
                        "Regards,\r\nSmartDukaan Team";
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
 
64
    public void sentMailForTrialUserToSales(TrialForm trialForm) throws Exception {
65
        String body =
66
                "Sales Team Action:\r\n" +
67
                        "A new verified partner lead has been assigned to your territory. They have successfully passed the initial verification stage.\n\r\n" +
68
                        "Lead Information:" +
69
                        "Applicant Name: " + trialForm.getFirstName() + " " + trialForm.getLastName() + "\r\n" +
70
                        "Business Name: " + trialForm.getBusinessName() + "\r\n" +
71
                        "Mobile: " + trialForm.getMobile() + "\r\n" +
72
                        "Email: " + trialForm.getEmail() + "\r\n" +
73
                        "GST Number: " + trialForm.getGstNumber() + "\r\n\r\n" +
74
                        "Address:\r\n" +
75
                        trialForm.getAddressLine1() + "\r\n" +
76
                        (trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "\r\n" : "") +
77
                        trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "\r\n\r\n" +
78
                        "Strategic Objective: The partner has expressed initial interest. Your goal is to move them beyond trial onboarding.\r\n" +
79
                        "Next Steps:\n" +
80
                        "Contact Immediately: Call or visit the store within the next 24 hours.\n" +
81
                        "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.\n" +
82
                        "Update Status: Log your interaction and the partner’s interest level in the app immediately after the meeting.\n\r\n\r\n" +
83
                        "Good Luck, \r\n" +
84
                        "Regards,\r\nSmartDukaan Team";
85
        List<AuthUser> salesAuthUserList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Arrays.asList(EscalationType.L3, EscalationType.L4, EscalationType.L5));
86
        List<String> salesEmailList = new ArrayList<>();
87
        for (AuthUser authUser : salesAuthUserList) {
88
            if (authUser.getEmailId() != null && !authUser.getEmailId().trim().isEmpty()) {
89
                salesEmailList.add(authUser.getEmailId());
90
            }
91
        }
92
        AuthUser bmAuthUser = authRepository.selectById(trialForm.getBmId());
93
        AuthUser asmAuthUser = authRepository.selectById(trialForm.getAsmId());
94
 
95
        String[] emailTo = new String[]{bmAuthUser.getEmailId()};
96
        List<String> ccList = new ArrayList<>(salesEmailList);
97
        ccList.add(asmAuthUser.getEmailId());
98
        String[] cc = ccList.stream()
99
                .filter(email -> !email.trim().isEmpty())
100
                .toArray(String[]::new);
101
        LOGGER.info("RegistrationBody - " + body);
102
        LOGGER.info("cc list - " + Arrays.toString(cc));
103
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "NEW LEAD ASSIGNED: " + trialForm.getBusinessName() + "- Call/Visit ASAP", body);
104
 
105
 
106
    }
107
 
108
    public void sentMailForStoreCodeCreation(TrialForm trialForm) throws Exception {
109
        String body =
110
                "The trial user has been verified.\r\n" +
111
                        "Please create Store Code for . \r\n" + trialForm.getBusinessName() +
112
                        "Mobile Number. \r\n" + trialForm.getMobile() +
113
                        "Regards,\r\nSmartDukaan Team";
114
        String[] emailTo = {"gaurav.sharma@smartdukaan.com"};
115
        LOGGER.info("RegistrationBody - " + body);
116
        String[] cc = {"devkinandan.lal@smartdukaan.com"};
117
        LOGGER.info("cc list - " + Arrays.toString(cc));
118
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "Store Code Creation Required for trial user" + trialForm.getBusinessName(), body);
119
 
120
 
121
    }
35337 aman 122
}