| 35921 |
vikas |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import javax.servlet.http.HttpServletRequest;
|
|
|
4 |
|
|
|
5 |
import com.spice.profitmandi.dao.model.FofoRBMReportingModel;
|
|
|
6 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
|
|
7 |
import org.apache.logging.log4j.LogManager;
|
|
|
8 |
import org.apache.logging.log4j.Logger;
|
|
|
9 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
10 |
import org.springframework.http.MediaType;
|
|
|
11 |
import org.springframework.http.ResponseEntity;
|
|
|
12 |
import org.springframework.stereotype.Controller;
|
|
|
13 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
14 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
15 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
16 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
17 |
|
|
|
18 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
19 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
|
|
20 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
|
|
21 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
|
|
22 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
|
|
23 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
|
|
24 |
import com.spice.profitmandi.web.res.SupportTeamResponse;
|
|
|
25 |
import com.spice.profitmandi.web.res.SupportTeamResponse.PersonDetail;
|
|
|
26 |
|
|
|
27 |
import io.swagger.annotations.ApiImplicitParam;
|
|
|
28 |
import io.swagger.annotations.ApiImplicitParams;
|
|
|
29 |
import io.swagger.annotations.ApiOperation;
|
|
|
30 |
|
|
|
31 |
import java.util.Map;
|
|
|
32 |
|
|
|
33 |
@Controller
|
|
|
34 |
@Transactional(rollbackFor = Throwable.class)
|
|
|
35 |
public class SupportController {
|
|
|
36 |
|
|
|
37 |
private static final Logger LOGGER = LogManager.getLogger(SupportController.class);
|
|
|
38 |
|
|
|
39 |
@Autowired
|
|
|
40 |
private ResponseSender<?> responseSender;
|
|
|
41 |
|
|
|
42 |
@Autowired
|
|
|
43 |
private CsService csService;
|
|
|
44 |
|
|
|
45 |
@Autowired
|
|
|
46 |
private AuthRepository authRepository;
|
|
|
47 |
|
|
|
48 |
@RequestMapping(value = "/support/team", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
49 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
|
|
50 |
@ApiOperation(value = "Get assigned ABM, BM, RBM and RBM Manager for a FOFO store")
|
|
|
51 |
public ResponseEntity<?> getSupportTeam(HttpServletRequest request, @RequestParam(value = "fofoId") int fofoId) throws Throwable {
|
|
|
52 |
LOGGER.info("Getting support team for fofoId: {}", fofoId);
|
|
|
53 |
|
|
|
54 |
SupportTeamResponse response = new SupportTeamResponse();
|
|
|
55 |
// ABM = SALES category, L1
|
|
|
56 |
try {
|
|
|
57 |
int abmAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L1, fofoId);
|
|
|
58 |
if (abmAuthUserId > 0) {
|
|
|
59 |
AuthUser abmUser = authRepository.selectById(abmAuthUserId);
|
|
|
60 |
if (abmUser != null) {
|
|
|
61 |
response.setAbm(toPersonDetail(abmUser, "Sales support and regional queries"));
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
} catch (Exception e) {
|
|
|
65 |
LOGGER.warn("Could not fetch ABM for fofoId: {}", fofoId, e);
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
// BM = SALES category, L2
|
|
|
69 |
try {
|
|
|
70 |
int bmAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L2, fofoId);
|
|
|
71 |
if (bmAuthUserId > 0) {
|
|
|
72 |
AuthUser bmUser = authRepository.selectById(bmAuthUserId);
|
|
|
73 |
if (bmUser != null) {
|
|
|
74 |
response.setBm(toPersonDetail(bmUser, "Handles: Orders, Stock, Schemes"));
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
} catch (Exception e) {
|
|
|
78 |
LOGGER.warn("Could not fetch BM for fofoId: {}", fofoId, e);
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
// RBM = RBM category, L1
|
|
|
82 |
try {
|
|
|
83 |
int rbmAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1, fofoId);
|
|
|
84 |
if (rbmAuthUserId > 0) {
|
|
|
85 |
AuthUser rbmUser = authRepository.selectById(rbmAuthUserId);
|
|
|
86 |
if (rbmUser != null) {
|
|
|
87 |
response.setRbm(toPersonDetail(rbmUser, "First point of contact for all queries"));
|
|
|
88 |
}
|
|
|
89 |
}
|
|
|
90 |
} catch (Exception e) {
|
|
|
91 |
LOGGER.warn("Could not fetch RBM for fofoId: {}", fofoId, e);
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
// RBM Manager = RBM category, L2
|
|
|
95 |
try {
|
|
|
96 |
int rbmManagerAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L2, fofoId);
|
|
|
97 |
if (rbmManagerAuthUserId > 0) {
|
|
|
98 |
AuthUser rbmManagerUser = authRepository.selectById(rbmManagerAuthUserId);
|
|
|
99 |
if (rbmManagerUser != null) {
|
|
|
100 |
response.setRbmManager(toPersonDetail(rbmManagerUser,"For escalated regional matters\n" +
|
|
|
101 |
"\n"));
|
|
|
102 |
}
|
|
|
103 |
}
|
|
|
104 |
} catch (Exception e) {
|
|
|
105 |
LOGGER.warn("Could not fetch RBM Manager for fofoId: {}", fofoId, e);
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
// Grievance Manager = CATEGORY_LEGAL category, L3
|
|
|
109 |
try {
|
|
|
110 |
int grievanceManagerAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_LEGAL, EscalationType.L3, fofoId);
|
|
|
111 |
if (grievanceManagerAuthUserId > 0) {
|
|
|
112 |
AuthUser grievanceManagerUser = authRepository.selectById(grievanceManagerAuthUserId);
|
|
|
113 |
if (grievanceManagerUser != null) {
|
|
|
114 |
response.setGrievanceManager(toPersonDetail(grievanceManagerUser,"For unresolved issues & formal complaints"));
|
|
|
115 |
}
|
|
|
116 |
}
|
|
|
117 |
} catch (Exception e) {
|
|
|
118 |
LOGGER.warn("Could not fetch Grievance Manager for fofoId: {}", fofoId, e);
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
// Affordability Manager = TICKET_CATEGORY_FINANCIAL_SERVICES category, L2
|
|
|
122 |
try {
|
|
|
123 |
int affordabilityManagerAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_FINANCIAL_SERVICES, EscalationType.L2, fofoId);
|
|
|
124 |
if (affordabilityManagerAuthUserId > 0) {
|
|
|
125 |
AuthUser affordabilityManagerUser = authRepository.selectById(affordabilityManagerAuthUserId);
|
|
|
126 |
if (affordabilityManagerUser != null) {
|
|
|
127 |
response.setBrandingManager(toPersonDetail(affordabilityManagerUser,"Credit, payment plans, and operations"));
|
|
|
128 |
}
|
|
|
129 |
}
|
|
|
130 |
} catch (Exception e) {
|
|
|
131 |
LOGGER.warn("Could not fetch Affordability Manager for fofoId: {}", fofoId, e);
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
// Branding Manager = CATEGORY_DESIGN category, L1
|
|
|
135 |
try {
|
|
|
136 |
int brandingManagerAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_DESIGN, EscalationType.L1, fofoId);
|
|
|
137 |
if (brandingManagerAuthUserId > 0) {
|
|
|
138 |
AuthUser brandingManagerUser = authRepository.selectById(brandingManagerAuthUserId);
|
|
|
139 |
if (brandingManagerUser != null) {
|
|
|
140 |
response.setBrandingManager(toPersonDetail(brandingManagerUser,"Brand guidelines and marketing support"));
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
} catch (Exception e) {
|
|
|
144 |
LOGGER.warn("Could not fetch Branding Manager for fofoId: {}", fofoId, e);
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
return responseSender.ok(response);
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
private PersonDetail toPersonDetail(AuthUser authUser, String description) {
|
|
|
151 |
return new PersonDetail(
|
|
|
152 |
authUser.getId(),
|
|
|
153 |
authUser.getFullName(),
|
|
|
154 |
authUser.getEmailId(),
|
|
|
155 |
authUser.getMobileNumber(),
|
|
|
156 |
description
|
|
|
157 |
);
|
|
|
158 |
}
|
|
|
159 |
}
|