| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.dao.repository.cs;
|
1 |
package com.spice.profitmandi.dao.repository.cs;
|
| 2 |
|
2 |
|
| 3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 4 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
4 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 6 |
import com.spice.profitmandi.common.util.Utils;
|
- |
|
| 7 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
6 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 8 |
import com.spice.profitmandi.dao.entity.cs.*;
|
7 |
import com.spice.profitmandi.dao.entity.cs.*;
|
| 9 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
8 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
| 10 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
9 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 11 |
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
|
10 |
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
|
| Line 148... |
Line 147... |
| 148 |
this.assignTicket(ticket);
|
147 |
this.assignTicket(ticket);
|
| 149 |
}
|
148 |
}
|
| 150 |
}
|
149 |
}
|
| 151 |
|
150 |
|
| 152 |
@Override
|
151 |
@Override
|
| - |
|
152 |
public void createTicket(int fofoId, int categoryId, int subcategoryId, String message, int createdByAuthId, EscalationType targetEscalation) throws ProfitMandiBusinessException {
|
| - |
|
153 |
ActivityType type = ActivityType.OPENED;
|
| - |
|
154 |
Ticket ticket = new Ticket();
|
| - |
|
155 |
ticket.setSubCategoryId(subcategoryId);
|
| - |
|
156 |
ticket.setFofoId(fofoId);
|
| - |
|
157 |
ticket.setCreateTimestamp(LocalDateTime.now());
|
| - |
|
158 |
ticket.setUpdateTimestamp(LocalDateTime.now());
|
| - |
|
159 |
ticket.setHappyCode(getRandomString());
|
| - |
|
160 |
ticketRepository.persist(ticket);
|
| - |
|
161 |
this.addActivity(ticket, this.createActivity(type, message, createdByAuthId));
|
| - |
|
162 |
ticket.setFirstActivityId(ticket.getLastActivityId());
|
| - |
|
163 |
if (createdByAuthId != 0) {
|
| - |
|
164 |
int authUser = this.getAuthUserIdWithFallback(categoryId, targetEscalation, fofoId);
|
| - |
|
165 |
this.updateTicket(categoryId, subcategoryId, ticket, authUser, targetEscalation);
|
| - |
|
166 |
} else {
|
| - |
|
167 |
this.assignTicket(ticket);
|
| - |
|
168 |
}
|
| - |
|
169 |
}
|
| - |
|
170 |
|
| - |
|
171 |
@Override
|
| - |
|
172 |
public void createTicketWithMedia(int fofoId, int categoryId, int subcategoryId, String message, int createdByAuthId, ActivityMediaModel selectedRecording, EscalationType targetEscalation) throws ProfitMandiBusinessException {
|
| - |
|
173 |
ActivityType type = ActivityType.OPENED;
|
| - |
|
174 |
Ticket ticket = new Ticket();
|
| - |
|
175 |
ticket.setSubCategoryId(subcategoryId);
|
| - |
|
176 |
ticket.setFofoId(fofoId);
|
| - |
|
177 |
ticket.setCreateTimestamp(LocalDateTime.now());
|
| - |
|
178 |
ticket.setUpdateTimestamp(LocalDateTime.now());
|
| - |
|
179 |
ticket.setHappyCode(getRandomString());
|
| - |
|
180 |
ticketRepository.persist(ticket);
|
| - |
|
181 |
this.addActivity(ticket, this.createActivity(type, message, createdByAuthId));
|
| - |
|
182 |
this.addMediaActivity(ticket, this.createMediaActivity(selectedRecording));
|
| - |
|
183 |
ticket.setFirstActivityId(ticket.getLastActivityId());
|
| - |
|
184 |
if (createdByAuthId != 0) {
|
| - |
|
185 |
int authUser = this.getAuthUserIdWithFallback(categoryId, targetEscalation, fofoId);
|
| - |
|
186 |
this.updateTicket(categoryId, subcategoryId, ticket, authUser, targetEscalation);
|
| - |
|
187 |
} else {
|
| - |
|
188 |
this.assignTicket(ticket);
|
| - |
|
189 |
}
|
| - |
|
190 |
}
|
| - |
|
191 |
|
| - |
|
192 |
/**
|
| - |
|
193 |
* Gets auth user ID for given escalation level. If not found, falls back to next level (L1 -> L2 -> L3 -> L4 -> L5)
|
| - |
|
194 |
*/
|
| - |
|
195 |
private int getAuthUserIdWithFallback(int categoryId, EscalationType targetEscalation, int fofoId) throws ProfitMandiBusinessException {
|
| - |
|
196 |
EscalationType currentEscalation = targetEscalation;
|
| - |
|
197 |
while (currentEscalation != null && !currentEscalation.equals(EscalationType.Final)) {
|
| - |
|
198 |
try {
|
| - |
|
199 |
int authUserId = this.getAuthUserId(categoryId, currentEscalation, fofoId);
|
| - |
|
200 |
if (authUserId > 0) {
|
| - |
|
201 |
LOGGER.info("Found auth user {} for escalation level {} and fofoId {}", authUserId, currentEscalation, fofoId);
|
| - |
|
202 |
return authUserId;
|
| - |
|
203 |
}
|
| - |
|
204 |
} catch (Exception e) {
|
| - |
|
205 |
LOGGER.warn("No auth user found for escalation level {} and fofoId {}, trying next level", currentEscalation, fofoId);
|
| - |
|
206 |
}
|
| - |
|
207 |
currentEscalation = currentEscalation.next();
|
| - |
|
208 |
}
|
| - |
|
209 |
// If no user found at any level, return 0 to let default assignment handle it
|
| - |
|
210 |
LOGGER.warn("No auth user found for any escalation level for categoryId {} and fofoId {}", categoryId, fofoId);
|
| - |
|
211 |
return 0;
|
| - |
|
212 |
}
|
| - |
|
213 |
|
| - |
|
214 |
@Override
|
| 153 |
public TicketActivityMedia createMediaActivity(ActivityMediaModel selectedRecording) {
|
215 |
public TicketActivityMedia createMediaActivity(ActivityMediaModel selectedRecording) {
|
| 154 |
TicketActivityMedia activity = new TicketActivityMedia();
|
216 |
TicketActivityMedia activity = new TicketActivityMedia();
|
| 155 |
activity.setMobile(selectedRecording.getMobile());
|
217 |
activity.setMobile(selectedRecording.getMobile());
|
| 156 |
// add a prefix endpoint of mediaUrl
|
218 |
// add a prefix endpoint of mediaUrl
|
| 157 |
// String customValue = "https://ccs1.smartpingcc.io/v2/recording/direct/71287091";
|
219 |
// String customValue = "https://ccs1.smartpingcc.io/v2/recording/direct/71287091";
|