| Line 238... |
Line 238... |
| 238 |
log.info("Initiator = " + request.getParameter("cancellationInitiator"));
|
238 |
log.info("Initiator = " + request.getParameter("cancellationInitiator"));
|
| 239 |
log.info("orderId = " + request.getParameter("orderId"));
|
239 |
log.info("orderId = " + request.getParameter("orderId"));
|
| 240 |
|
240 |
|
| 241 |
order = transactionServiceClient.getClient().getOrder(orderId);
|
241 |
order = transactionServiceClient.getClient().getOrder(orderId);
|
| 242 |
|
242 |
|
| - |
|
243 |
/**
|
| - |
|
244 |
* If the order is from store then refund the order directly.
|
| - |
|
245 |
*/
|
| 243 |
if (order.getSource() == 2) {
|
246 |
if (order.getSource() == 2) {
|
| 244 |
String plainTextbody = "";
|
247 |
String plainTextbody = "";
|
| 245 |
if(body!=null && !body.isEmpty()){
|
248 |
if(body!=null && !body.isEmpty()){
|
| 246 |
plainTextbody = new Source(body).getTextExtractor().toString();
|
249 |
plainTextbody = new Source(body).getTextExtractor().toString();
|
| 247 |
}
|
250 |
}
|
| Line 249... |
Line 252... |
| 249 |
transactionServiceClient.getClient().markOrderCancellationRequestReceived(orderId);
|
252 |
transactionServiceClient.getClient().markOrderCancellationRequestReceived(orderId);
|
| 250 |
transactionServiceClient.getClient().markOrderCancellationRequestConfirmed(orderId);
|
253 |
transactionServiceClient.getClient().markOrderCancellationRequestConfirmed(orderId);
|
| 251 |
}
|
254 |
}
|
| 252 |
transactionServiceClient.getClient().saveRefundAmountsForStoreOrder(orderId, order.getStoreId(), cashAmount, cardAmount);
|
255 |
transactionServiceClient.getClient().saveRefundAmountsForStoreOrder(orderId, order.getStoreId(), cashAmount, cardAmount);
|
| 253 |
transactionServiceClient.getClient().refundOrder(orderId, currentAgentEmailId, cancelReason + " : " + plainTextbody);
|
256 |
transactionServiceClient.getClient().refundOrder(orderId, currentAgentEmailId, cancelReason + " : " + plainTextbody);
|
| 254 |
}
|
257 |
} else {
|
| 255 |
|
- |
|
| 256 |
if (cancellationInitiator.equals("CUSTOMER")) {
|
258 |
if (cancellationInitiator.equals("CUSTOMER")) {
|
| 257 |
transactionServiceClient.getClient().markOrderCancellationRequestReceived(orderId);
|
259 |
transactionServiceClient.getClient().markOrderCancellationRequestReceived(orderId);
|
| 258 |
long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId();
|
260 |
long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId();
|
| 259 |
Ticket ticket = new Ticket();
|
261 |
Ticket ticket = new Ticket();
|
| 260 |
String plainTextbody = "";
|
262 |
String plainTextbody = "";
|
| 261 |
if(body!=null && !body.isEmpty()){
|
263 |
if(body!=null && !body.isEmpty()){
|
| 262 |
plainTextbody = new Source(body).getTextExtractor().toString();
|
264 |
plainTextbody = new Source(body).getTextExtractor().toString();
|
| 263 |
}
|
265 |
}
|
| 264 |
ticket.setDescription("Creating ticket for Cancellation Request Received, Reason : " + cancelReason + " : " + plainTextbody);
|
266 |
ticket.setDescription("Creating ticket for Cancellation Request Received, Reason : " + cancelReason + " : " + plainTextbody);
|
| 265 |
ticket.setCreatorId(creatorId);
|
267 |
ticket.setCreatorId(creatorId);
|
| 266 |
ticket.setStatus(TicketStatus.OPEN);
|
268 |
ticket.setStatus(TicketStatus.OPEN);
|
| 267 |
ticket.setPriority(TicketPriority.HIGH);
|
269 |
ticket.setPriority(TicketPriority.HIGH);
|
| 268 |
ticket.setCategory(TicketCategory.ORDER_CANCELLATION);
|
270 |
ticket.setCategory(TicketCategory.ORDER_CANCELLATION);
|
| 269 |
ticket.setOrderId(orderId);
|
271 |
ticket.setOrderId(orderId);
|
| 270 |
|
272 |
|
| 271 |
Activity activity = new Activity();
|
273 |
Activity activity = new Activity();
|
| 272 |
activity.setDescription("Creating Ticket");
|
274 |
activity.setDescription("Creating Ticket");
|
| 273 |
activity.setType(ActivityType.OTHER);
|
275 |
activity.setType(ActivityType.OTHER);
|
| 274 |
activity.setTicketPriority(TicketPriority.HIGH);
|
276 |
activity.setTicketPriority(TicketPriority.HIGH);
|
| 275 |
activity.setTicketStatus(TicketStatus.OPEN);
|
277 |
activity.setTicketStatus(TicketStatus.OPEN);
|
| 276 |
activity.setCreatorId(creatorId);
|
278 |
activity.setCreatorId(creatorId);
|
| 277 |
activity.setTicketDescription("Creating ticket for Cancellation Request Received, Reason : " + cancelReason + " : " + plainTextbody);
|
279 |
activity.setTicketDescription("Creating ticket for Cancellation Request Received, Reason : " + cancelReason + " : " + plainTextbody);
|
| 278 |
activity.setTicketCategory(TicketCategory.ORDER_CANCELLATION);
|
280 |
activity.setTicketCategory(TicketCategory.ORDER_CANCELLATION);
|
| 279 |
|
281 |
|
| 280 |
ticket.setCustomerId(order.getCustomer_id());
|
282 |
ticket.setCustomerId(order.getCustomer_id());
|
| 281 |
activity.setCustomerId(order.getCustomer_id());
|
283 |
activity.setCustomerId(order.getCustomer_id());
|
| 282 |
ticket.setCustomerName(order.getCustomer_name());
|
284 |
ticket.setCustomerName(order.getCustomer_name());
|
| 283 |
activity.setCustomerName(order.getCustomer_name());
|
285 |
activity.setCustomerName(order.getCustomer_name());
|
| 284 |
ticket.setCustomerEmailId(order.getCustomer_email());
|
286 |
ticket.setCustomerEmailId(order.getCustomer_email());
|
| 285 |
activity.setCustomerEmailId(order.getCustomer_email());
|
287 |
activity.setCustomerEmailId(order.getCustomer_email());
|
| 286 |
ticket.setCustomerMobileNumber(order.getCustomer_mobilenumber());
|
288 |
ticket.setCustomerMobileNumber(order.getCustomer_mobilenumber());
|
| 287 |
activity.setCustomerMobileNumber(order.getCustomer_mobilenumber());
|
289 |
activity.setCustomerMobileNumber(order.getCustomer_mobilenumber());
|
| 288 |
|
290 |
|
| 289 |
crmServiceClient = new CRMClient().getClient();
|
291 |
crmServiceClient = new CRMClient().getClient();
|
| 290 |
crmServiceClient.insertTicket(ticket, activity);
|
292 |
crmServiceClient.insertTicket(ticket, activity);
|
| 291 |
}
|
293 |
}
|
| 292 |
else if (cancellationInitiator.equals("INTERNAL")) {
|
294 |
else if (cancellationInitiator.equals("INTERNAL")) {
|
| 293 |
String plainTextbody = "";
|
295 |
String plainTextbody = "";
|
| 294 |
if(body!=null && !body.isEmpty()){
|
296 |
if(body!=null && !body.isEmpty()){
|
| 295 |
plainTextbody = new Source(body).getTextExtractor().toString();
|
297 |
plainTextbody = new Source(body).getTextExtractor().toString();
|
| 296 |
}
|
298 |
}
|
| 297 |
boolean status_returned = transactionServiceClient.getClient().refundOrder(orderId, currentAgentEmailId, cancelReason + " : " + plainTextbody);
|
299 |
boolean status_returned = transactionServiceClient.getClient().refundOrder(orderId, currentAgentEmailId, cancelReason + " : " + plainTextbody);
|
| 298 |
if (status_returned) {
|
300 |
if (status_returned) {
|
| 299 |
order = transactionServiceClient.getClient().getOrder(orderId);
|
301 |
order = transactionServiceClient.getClient().getOrder(orderId);
|
| 300 |
long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId();
|
302 |
long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId();
|
| 301 |
Ticket ticket = new Ticket();
|
303 |
Ticket ticket = new Ticket();
|
| 302 |
ticket.setDescription("Creating ticket for Order Cancellation due to Low inventory");
|
304 |
ticket.setDescription("Creating ticket for Order Cancellation due to Low inventory");
|
| 303 |
ticket.setCreatorId(creatorId);
|
305 |
ticket.setCreatorId(creatorId);
|
| 304 |
ticket.setAssigneeId(36);
|
306 |
ticket.setAssigneeId(36);
|
| 305 |
ticket.setStatus(TicketStatus.OPEN);
|
307 |
ticket.setStatus(TicketStatus.OPEN);
|
| 306 |
ticket.setPriority(TicketPriority.MEDIUM);
|
308 |
ticket.setPriority(TicketPriority.MEDIUM);
|
| 307 |
ticket.setCategory(TicketCategory.LOW_INVENTORY_CANCELLED_ORDERS);
|
309 |
ticket.setCategory(TicketCategory.LOW_INVENTORY_CANCELLED_ORDERS);
|
| 308 |
ticket.setOrderId(orderId);
|
310 |
ticket.setOrderId(orderId);
|
| 309 |
ticket.setCustomerId(order.getCustomer_id());
|
311 |
ticket.setCustomerId(order.getCustomer_id());
|
| 310 |
ticket.setCustomerName(order.getCustomer_name());
|
312 |
ticket.setCustomerName(order.getCustomer_name());
|
| 311 |
ticket.setCustomerEmailId(order.getCustomer_email());
|
313 |
ticket.setCustomerEmailId(order.getCustomer_email());
|
| 312 |
ticket.setCustomerMobileNumber(order.getCustomer_mobilenumber());
|
314 |
ticket.setCustomerMobileNumber(order.getCustomer_mobilenumber());
|
| 313 |
|
315 |
|
| 314 |
Activity activity = new Activity();
|
316 |
Activity activity = new Activity();
|
| 315 |
activity.setDescription("Creating Ticket");
|
317 |
activity.setDescription("Creating Ticket");
|
| 316 |
activity.setType(ActivityType.OTHER);
|
318 |
activity.setType(ActivityType.OTHER);
|
| 317 |
activity.setTicketPriority(TicketPriority.MEDIUM);
|
319 |
activity.setTicketPriority(TicketPriority.MEDIUM);
|
| 318 |
activity.setTicketStatus(TicketStatus.OPEN);
|
320 |
activity.setTicketStatus(TicketStatus.OPEN);
|
| 319 |
activity.setCreatorId(creatorId);
|
321 |
activity.setCreatorId(creatorId);
|
| 320 |
activity.setTicketAssigneeId(36);
|
322 |
activity.setTicketAssigneeId(36);
|
| 321 |
activity.setTicketCategory(TicketCategory.LOW_INVENTORY_CANCELLED_ORDERS);
|
323 |
activity.setTicketCategory(TicketCategory.LOW_INVENTORY_CANCELLED_ORDERS);
|
| 322 |
activity.setTicketDescription("Creating ticket for Order Cancellation due to Low inventory");
|
324 |
activity.setTicketDescription("Creating ticket for Order Cancellation due to Low inventory");
|
| 323 |
activity.setCustomerId(order.getCustomer_id());
|
325 |
activity.setCustomerId(order.getCustomer_id());
|
| 324 |
activity.setCustomerName(order.getCustomer_name());
|
326 |
activity.setCustomerName(order.getCustomer_name());
|
| 325 |
activity.setCustomerEmailId(order.getCustomer_email());
|
327 |
activity.setCustomerEmailId(order.getCustomer_email());
|
| 326 |
activity.setCustomerMobileNumber(order.getCustomer_mobilenumber());
|
328 |
activity.setCustomerMobileNumber(order.getCustomer_mobilenumber());
|
| 327 |
|
329 |
|
| 328 |
crmServiceClient = new CRMClient().getClient();
|
330 |
crmServiceClient = new CRMClient().getClient();
|
| 329 |
crmServiceClient.insertTicket(ticket, activity);
|
331 |
crmServiceClient.insertTicket(ticket, activity);
|
| - |
|
332 |
}
|
| 330 |
}
|
333 |
}
|
| 331 |
}
|
334 |
}
|
| 332 |
} catch(Exception e) {
|
335 |
} catch(Exception e) {
|
| 333 |
log.error("Could not mark order for Cancellation, OrderId : " + orderId, e);
|
336 |
log.error("Could not mark order for Cancellation, OrderId : " + orderId, e);
|
| 334 |
}
|
337 |
}
|
| 335 |
return index();
|
338 |
return index();
|