Subversion Repositories SmartDukaan

Rev

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

Rev 4277 Rev 4377
Line 144... Line 144...
144
            if(communicationType == 2) {
144
            if(communicationType == 2) {
145
            in.shop2020.model.v1.order.TransactionService.Client transactionClient = 
145
            in.shop2020.model.v1.order.TransactionService.Client transactionClient = 
146
                                                    (new TransactionClient()).getClient();
146
                                                    (new TransactionClient()).getClient();
147
            transactionClient.markOrderCancellationRequestReceived(orderId);
147
            transactionClient.markOrderCancellationRequestReceived(orderId);
148
            }
148
            }
-
 
149
 
-
 
150
            TicketCategory ticketCategory = TicketCategory.findByValue((int) communicationType);
149
            
151
            
-
 
152
            // Validating ticket category to avoid cases where someone tries to programmatically
-
 
153
            // send requests to us with invalid communication types
-
 
154
            if (ticketCategory != null) {
150
            // We need to have tickets for all data communication!
155
                // We need to have tickets for all data communication!
151
            log.info("Creating ticket!");
156
                log.info("Creating ticket!");
152
            Client crmServiceClient = new CRMClient().getClient();
157
                Client crmServiceClient = new CRMClient().getClient();
153
            Ticket ticket = new Ticket();
158
                Ticket ticket = new Ticket();
154
            ticket.setAirwayBillNo(awb);
159
                ticket.setAirwayBillNo(awb);
155
            ticket.setProductName(product);
160
                ticket.setProductName(product);
156
            ticket.setCategory(TicketCategory
161
                ticket.setCategory(ticketCategory);
157
                    .findByValue((int) communicationType));
-
 
158
            ticket.setDescription("From: " + email + "\n\nSubject: " + subject + "\n\nBody: " + message);
162
                ticket.setDescription("From: " + email + "\n\nSubject: " + subject + "\n\nBody: " + message);
159
 
163
 
160
            if (orderId != -1) {
164
                if (orderId != -1) {
161
                ticket.setOrderId(orderId);
165
                    ticket.setOrderId(orderId);
162
            }
166
                }
-
 
167
 
-
 
168
                ticket.setCreatorId(ADMIN_AGENT_ID);
-
 
169
                ticket.setPriority(TicketPriority.MEDIUM);
-
 
170
                ticket.setStatus(TicketStatus.OPEN);
163
 
171
 
164
            ticket.setCreatorId(ADMIN_AGENT_ID);
-
 
165
            ticket.setPriority(TicketPriority.MEDIUM);
-
 
166
            ticket.setStatus(TicketStatus.OPEN);
-
 
167
 
-
 
168
            log.info("Creating activity!");
172
                log.info("Creating activity!");
169
            Activity activity = new Activity();
173
                Activity activity = new Activity();
170
            activity.setCreatorId(ADMIN_AGENT_ID);
174
                activity.setCreatorId(ADMIN_AGENT_ID);
171
            activity.setDescription("Ticket created");
175
                activity.setDescription("Ticket created");
172
            activity.setTicketCategory(ticket.getCategory());
176
                activity.setTicketCategory(ticket.getCategory());
173
            activity.setTicketDescription(ticket.getDescription());
177
                activity.setTicketDescription(ticket.getDescription());
174
            activity.setTicketPriority(ticket.getPriority());
178
                activity.setTicketPriority(ticket.getPriority());
175
            activity.setTicketStatus(ticket.getStatus());
179
                activity.setTicketStatus(ticket.getStatus());
176
            activity.setType(ActivityType.RECEIVED_EMAIL_FROM_CUSTOMER);
180
                activity.setType(ActivityType.RECEIVED_EMAIL_FROM_CUSTOMER);
177
 
181
 
178
            if (isUserLoggedIn) {
182
                if (isUserLoggedIn) {
179
                activity.setCustomerId(userId);
183
                    activity.setCustomerId(userId);
180
                ticket.setCustomerId(userId);
184
                    ticket.setCustomerId(userId);
181
            } else {
-
 
182
                User user = userClient.getUserByEmail(email);
-
 
183
                if (user != null && user.getUserId() != -1) {
-
 
184
                    log.info("Found registered user for: " + email);
-
 
185
                    ticket.setCustomerId(user.getUserId());
-
 
186
                    activity.setCustomerId(user.getUserId());
-
 
187
                } else {
185
                } else {
-
 
186
                    User user = userClient.getUserByEmail(email);
-
 
187
                    if (user != null && user.getUserId() != -1) {
-
 
188
                        log.info("Found registered user for: " + email);
-
 
189
                        ticket.setCustomerId(user.getUserId());
-
 
190
                        activity.setCustomerId(user.getUserId());
-
 
191
                    } else {
188
                    log.info("Setting customer email id to: " + email);
192
                        log.info("Setting customer email id to: " + email);
189
                    ticket.setCustomerEmailId(email);
193
                        ticket.setCustomerEmailId(email);
-
 
194
                    }
190
                }
195
                }
191
            }
-
 
192
 
196
 
193
            crmServiceClient.insertTicket(ticket, activity);
197
                crmServiceClient.insertTicket(ticket, activity);                
-
 
198
            }
194
        } catch (NumberFormatException e) {
199
        } catch (NumberFormatException e) {
195
            log.error("Unable to get communication type or order id: ", e);
200
            log.error("Unable to get communication type or order id: ", e);
196
        } catch (TTransportException e) {
201
        } catch (TTransportException e) {
197
            log.error("Unable to initialize client: ", e);
202
            log.error("Unable to initialize client: ", e);
198
        } catch (UserCommunicationException e) {
203
        } catch (UserCommunicationException e) {