Subversion Repositories SmartDukaan

Rev

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

Rev 5170 Rev 5407
Line 151... Line 151...
151
                if(communicationType == 2) {
151
                if(communicationType == 2) {
152
                    in.shop2020.model.v1.order.TransactionService.Client transactionClient = 
152
                    in.shop2020.model.v1.order.TransactionService.Client transactionClient = 
153
                        (new TransactionClient()).getClient();
153
                        (new TransactionClient()).getClient();
154
                    transactionClient.markOrderCancellationRequestReceived(orderId);
154
                    transactionClient.markOrderCancellationRequestReceived(orderId);
155
                }
155
                }
156
 
-
 
157
                // We need to have tickets for all data communication!
-
 
158
                log.info("Creating ticket!");
-
 
159
                Client crmServiceClient = new CRMClient().getClient();
-
 
160
                Ticket ticket = new Ticket();
-
 
161
                ticket.setAirwayBillNo(awb);
-
 
162
                ticket.setProductName(product);
-
 
163
                ticket.setCategory(ticketCategory);
-
 
164
                ticket.setDescription("From: " + email + "\n\nSubject: " + subject + "\n\nBody: " + message);
-
 
165
                
-
 
166
                if(communicationType == 2) {
-
 
167
                    ticket.setAssigneeId(DEF_ASSIGNEE_FOR_ORDER_CANCEL);
-
 
168
                }
-
 
169
                
-
 
170
                if (orderId != -1) {
-
 
171
                    ticket.setOrderId(orderId);
-
 
172
                }
-
 
173
 
-
 
174
                ticket.setCreatorId(ADMIN_AGENT_ID);
-
 
175
                ticket.setPriority(TicketPriority.MEDIUM);
-
 
176
                ticket.setStatus(TicketStatus.OPEN);
-
 
177
 
-
 
178
                log.info("Creating activity!");
-
 
179
                Activity activity = new Activity();
-
 
180
                activity.setCreatorId(ADMIN_AGENT_ID);
-
 
181
                activity.setDescription("Ticket created");
-
 
182
                activity.setTicketCategory(ticket.getCategory());
-
 
183
                activity.setTicketDescription(ticket.getDescription());
-
 
184
                activity.setTicketPriority(ticket.getPriority());
-
 
185
                activity.setTicketStatus(ticket.getStatus());
-
 
186
                activity.setType(ActivityType.RECEIVED_EMAIL_FROM_CUSTOMER);
-
 
187
 
-
 
188
                if (isUserLoggedIn) {
-
 
189
                    activity.setCustomerId(userId);
-
 
190
                    ticket.setCustomerId(userId);
-
 
191
                } else {
-
 
192
                    User user = userClient.getUserByEmail(email);
-
 
193
                    if (user != null && user.getUserId() != -1) {
-
 
194
                        log.info("Found registered user for: " + email);
-
 
195
                        ticket.setCustomerId(user.getUserId());
-
 
196
                        activity.setCustomerId(user.getUserId());
-
 
197
                    } else {
-
 
198
                        log.info("Setting customer email id to: " + email);
-
 
199
                        ticket.setCustomerEmailId(email);
-
 
200
                    }
-
 
201
                }
-
 
202
 
-
 
203
                crmServiceClient.insertTicket(ticket, activity);                
-
 
204
            }
156
            }
205
        } catch (NumberFormatException e) {
157
        } catch (NumberFormatException e) {
206
            log.error("Unable to get communication type or order id: ", e);
158
            log.error("Unable to get communication type or order id: ", e);
207
        } catch (TTransportException e) {
159
        } catch (TTransportException e) {
208
            log.error("Unable to initialize client: ", e);
160
            log.error("Unable to initialize client: ", e);
209
        } catch (UserCommunicationException e) {
161
        } catch (UserCommunicationException e) {
210
            log.error("Unable to get communication type or order id: ", e);
162
            log.error("Unable to get communication type or order id: ", e);
211
        } catch (TException e) {
163
        } catch (TException e) {
212
            log.error("Thrift exception: ", e);
164
            log.error("Thrift exception: ", e);
213
        } catch (UserContextException e) {
-
 
214
            log.error("Thrift exception: ", e);
-
 
215
        } catch (TransactionServiceException e) {
165
        } catch (TransactionServiceException e) {
216
            log.error("Unable to mark cancellation request recieved", e);
166
            log.error("Unable to mark cancellation request recieved", e);
217
        }
167
        }
218
        return "success";
168
        return "success";
219
    }
169
    }