Subversion Repositories SmartDukaan

Rev

Rev 35337 | Rev 35362 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35337 Rev 35360
Line 1... Line 1...
1
package com.spice.profitmandi.dao.service;
1
package com.spice.profitmandi.dao.service;
2
 
2
 
-
 
3
import com.spice.profitmandi.common.model.ProfitMandiConstants;
3
import com.spice.profitmandi.common.util.Utils;
4
import com.spice.profitmandi.common.util.Utils;
-
 
5
import com.spice.profitmandi.dao.entity.auth.AuthUser;
4
import com.spice.profitmandi.dao.entity.fofo.TrialForm;
6
import com.spice.profitmandi.dao.entity.fofo.TrialForm;
-
 
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;
5
import com.spice.profitmandi.dao.service.loiForm.LoiFormServiceImpl;
10
import com.spice.profitmandi.dao.service.loiForm.LoiFormServiceImpl;
6
import org.apache.logging.log4j.LogManager;
11
import org.apache.logging.log4j.LogManager;
7
import org.apache.logging.log4j.Logger;
12
import org.apache.logging.log4j.Logger;
8
import org.springframework.beans.factory.annotation.Autowired;
13
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.mail.javamail.JavaMailSender;
14
import org.springframework.mail.javamail.JavaMailSender;
10
import org.springframework.stereotype.Service;
15
import org.springframework.stereotype.Service;
11
 
16
 
-
 
17
import java.util.ArrayList;
-
 
18
import java.util.Arrays;
-
 
19
import java.util.List;
-
 
20
 
12
@Service
21
@Service
13
public class TrialServiceImpl implements TrialService{
22
public class TrialServiceImpl implements TrialService {
14
 
23
 
15
    private static final Logger LOGGER = LogManager.getLogger(LoiFormServiceImpl.class);
24
    private static final Logger LOGGER = LogManager.getLogger(LoiFormServiceImpl.class);
16
 
25
 
17
    @Autowired
26
    @Autowired
18
    JavaMailSender mailSender;
27
    JavaMailSender mailSender;
19
 
28
 
-
 
29
    @Autowired
-
 
30
    AuthRepository authRepository;
-
 
31
 
-
 
32
    @Autowired
-
 
33
    CsService csService;
-
 
34
 
20
    @Override
35
    @Override
21
    public void sentMailForTrialUser(TrialForm trialForm) throws Exception {
36
    public void sentMailForTrialUser(TrialForm trialForm) throws Exception {
22
        String body =
37
        String body =
23
                "Dear Team,\n\n" +
38
                "Dear Team,\r\n\r\n" +
24
                        "A new trial registration has been received. Below are the submitted details:\n\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" +
25
                        "Applicant Name: " + trialForm.getFirstName() + " " + trialForm.getLastName() + "\n" +
40
                        "Applicant Name: " + trialForm.getFirstName() + " " + trialForm.getLastName() + "\r\n" +
26
                        "Business Name: " + trialForm.getBusinessName() + "\n" +
41
                        "Business Name: " + trialForm.getBusinessName() + "\r\n" +
27
                        "Mobile: " + trialForm.getMobile() + "\n" +
42
                        "Mobile: " + trialForm.getMobile() + "\r\n" +
28
                        "Email: " + trialForm.getEmail() + "\n" +
43
                        "Email: " + trialForm.getEmail() + "\r\n" +
29
                        "GST Number: " + trialForm.getGstNumber() + "\n\n" +
44
                        "GST Number: " + trialForm.getGstNumber() + "\r\n\r\n" +
30
                        "Address:\n" +
45
                        "Address:\r\n" +
31
                        trialForm.getAddressLine1() + "\n" +
46
                        trialForm.getAddressLine1() + "\r\n" +
32
                        (trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "\n" : "") +
47
                        (trialForm.getAddressLine2() != null ? trialForm.getAddressLine2() + "\r\n" : "") +
33
                        trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "\n\n" +
48
                        trialForm.getCity() + ", " + trialForm.getState() + " - " + trialForm.getPincode() + "\r\n\r\n" +
34
 
49
 
-
 
50
                        "Required Actions:\n" +
-
 
51
                        "Verify Details: Validate KYC documents and basic business information.\r\n" +
35
                        "Please review the documents (PAN, Aadhaar, GST) and proceed with the next steps as required.\n\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";
36
        String[] emailTo = {"manish.gupta1@smartdukaan.com"};
55
        String[] emailTo = {"kamini.sharma@smartdukaan.com"};
37
//        String[] emailTo = {"aman.gupta@smartdukaan.com"};
56
//        String[] emailTo = {"aman.gupta@smartdukaan.com"};
-
 
57
        String[] cc = {"vaibhav.tandon@smartdukaan.com"};
-
 
58
        LOGGER.info("RegistrationBody - " + body);
-
 
59
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "New Trial Registration: " + trialForm.getBusinessName(), body);
-
 
60
 
-
 
61
 
-
 
62
    }
-
 
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";
38
        String[] cc = {"sm@smartdukaan.com", "gaurav.sharma@smartdukaan.com","tarun.verma@smartdukaan.com"};
114
        String[] emailTo = {"gaurav.sharma@smartdukaan.com"};
39
        LOGGER.info("RegistrationBody - " + body);
115
        LOGGER.info("RegistrationBody - " + body);
-
 
116
        String[] cc = {"devkinandan.lal@smartdukaan.com"};
-
 
117
        LOGGER.info("cc list - " + Arrays.toString(cc));
40
        Utils.sendMailWithAttachments(mailSender, emailTo, cc,  "New Trial Registration: "  + trialForm.getBusinessName(), body);
118
        Utils.sendMailWithAttachments(mailSender, emailTo, cc, "Store Code Creation Required for trial user" + trialForm.getBusinessName(), body);
41
 
119
 
42
 
120
 
43
    }
121
    }
44
}
122
}