| Line 7... |
Line 7... |
| 7 |
import in.shop2020.crm.ActivityType;
|
7 |
import in.shop2020.crm.ActivityType;
|
| 8 |
import in.shop2020.crm.Agent;
|
8 |
import in.shop2020.crm.Agent;
|
| 9 |
import in.shop2020.crm.CRMService.Iface;
|
9 |
import in.shop2020.crm.CRMService.Iface;
|
| 10 |
import in.shop2020.crm.SearchFilter;
|
10 |
import in.shop2020.crm.SearchFilter;
|
| 11 |
import in.shop2020.crm.Ticket;
|
11 |
import in.shop2020.crm.Ticket;
|
| - |
|
12 |
import in.shop2020.crm.TicketCategory;
|
| - |
|
13 |
import in.shop2020.crm.TicketPriority;
|
| - |
|
14 |
import in.shop2020.crm.TicketStatus;
|
| 12 |
import in.shop2020.crm.handler.ActivityHandler;
|
15 |
import in.shop2020.crm.handler.ActivityHandler;
|
| 13 |
import in.shop2020.crm.handler.AgentHandler;
|
16 |
import in.shop2020.crm.handler.AgentHandler;
|
| 14 |
import in.shop2020.crm.handler.TicketHandler;
|
17 |
import in.shop2020.crm.handler.TicketHandler;
|
| - |
|
18 |
import in.shop2020.model.v1.order.Order;
|
| - |
|
19 |
import in.shop2020.model.v1.order.OrderStatus;
|
| - |
|
20 |
import in.shop2020.model.v1.order.Transaction;
|
| - |
|
21 |
import in.shop2020.model.v1.order.TransactionService.Client;
|
| - |
|
22 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| - |
|
23 |
import in.shop2020.model.v1.user.User;
|
| - |
|
24 |
import in.shop2020.model.v1.user.UserContextException;
|
| - |
|
25 |
import in.shop2020.thrift.clients.TransactionClient;
|
| - |
|
26 |
import in.shop2020.thrift.clients.UserClient;
|
| 15 |
|
27 |
|
| 16 |
import java.text.ParseException;
|
28 |
import java.text.ParseException;
|
| 17 |
import java.util.ArrayList;
|
29 |
import java.util.ArrayList;
|
| 18 |
import java.util.Date;
|
30 |
import java.util.Date;
|
| 19 |
import java.util.List;
|
31 |
import java.util.List;
|
| 20 |
|
32 |
|
| - |
|
33 |
import org.apache.commons.logging.Log;
|
| - |
|
34 |
import org.apache.commons.logging.LogFactory;
|
| 21 |
import org.apache.thrift.TException;
|
35 |
import org.apache.thrift.TException;
|
| 22 |
import org.springframework.context.ApplicationContext;
|
36 |
import org.springframework.context.ApplicationContext;
|
| 23 |
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
37 |
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
| 24 |
import org.springframework.stereotype.Service;
|
38 |
import org.springframework.stereotype.Service;
|
| 25 |
import org.springframework.transaction.annotation.Transactional;
|
39 |
import org.springframework.transaction.annotation.Transactional;
|
| Line 29... |
Line 43... |
| 29 |
*
|
43 |
*
|
| 30 |
* @author mandeep
|
44 |
* @author mandeep
|
| 31 |
*/
|
45 |
*/
|
| 32 |
@Service
|
46 |
@Service
|
| 33 |
public class CRMServiceHandler implements Iface {
|
47 |
public class CRMServiceHandler implements Iface {
|
| - |
|
48 |
public static final long ADMIN_AGENT_ID = 1;
|
| 34 |
ApplicationContext context = new ClassPathXmlApplicationContext(
|
49 |
ApplicationContext context = new ClassPathXmlApplicationContext(
|
| 35 |
"context.xml");
|
50 |
"context.xml");
|
| 36 |
TicketHandler ticketHandler = context.getBean(TicketHandler.class);
|
51 |
TicketHandler ticketHandler = context.getBean(TicketHandler.class);
|
| 37 |
ActivityHandler activityHandler = context.getBean(ActivityHandler.class);
|
52 |
ActivityHandler activityHandler = context.getBean(ActivityHandler.class);
|
| 38 |
AgentHandler agentHandler = context.getBean(AgentHandler.class);
|
53 |
AgentHandler agentHandler = context.getBean(AgentHandler.class);
|
| 39 |
|
54 |
|
| - |
|
55 |
private static final Log log = LogFactory.getLog(CRMServiceHandler.class);
|
| - |
|
56 |
private static final double TRUST_THRESHOLD_LEVEL = 0;
|
| - |
|
57 |
|
| 40 |
public List<Ticket> getTickets(SearchFilter searchFilter) throws TException {
|
58 |
public List<Ticket> getTickets(SearchFilter searchFilter) throws TException {
|
| 41 |
List<Ticket> ttickets = new ArrayList<Ticket>();
|
59 |
List<Ticket> ttickets = new ArrayList<Ticket>();
|
| 42 |
for (in.shop2020.crm.domain.Ticket ticket : ticketHandler
|
60 |
for (in.shop2020.crm.domain.Ticket ticket : ticketHandler
|
| 43 |
.getTickets(in.shop2020.crm.domain.SearchFilter
|
61 |
.getTickets(in.shop2020.crm.domain.SearchFilter
|
| 44 |
.create(searchFilter))) {
|
62 |
.create(searchFilter))) {
|
| Line 170... |
Line 188... |
| 170 |
|
188 |
|
| 171 |
public void closeSession() throws TException {
|
189 |
public void closeSession() throws TException {
|
| 172 |
// TODO Auto-generated method stub
|
190 |
// TODO Auto-generated method stub
|
| 173 |
|
191 |
|
| 174 |
}
|
192 |
}
|
| - |
|
193 |
|
| - |
|
194 |
public void processCODTxn(long transactionId) throws TException {
|
| - |
|
195 |
try {
|
| - |
|
196 |
log.info("Processing txn id: " + transactionId);
|
| - |
|
197 |
Client client = new TransactionClient().getClient();
|
| - |
|
198 |
Transaction transaction = client.getTransaction(transactionId);
|
| - |
|
199 |
in.shop2020.model.v1.user.UserContextService.Client userClient = new UserClient().getClient();
|
| - |
|
200 |
User user = userClient.getUserById(transaction.getCustomer_id());
|
| - |
|
201 |
log.info(TRUST_THRESHOLD_LEVEL);
|
| - |
|
202 |
log.info(user.getTrustLevel());
|
| - |
|
203 |
if (user.getTrustLevel() - TRUST_THRESHOLD_LEVEL < 1e-4) {
|
| - |
|
204 |
log.info("Logging tickets");
|
| - |
|
205 |
for (Order order : transaction.getOrders()) {
|
| - |
|
206 |
log.info("Processing order: " + order.getId());
|
| - |
|
207 |
if (order.isCod()) {
|
| - |
|
208 |
log.info("Processing COD order: " + order.getId());
|
| - |
|
209 |
Ticket ticket = new Ticket();
|
| - |
|
210 |
ticket.setCategory(TicketCategory.COD_VERIFICATION);
|
| - |
|
211 |
ticket.setCreatorId(ADMIN_AGENT_ID);
|
| - |
|
212 |
ticket.setCustomerId(transaction.getCustomer_id());
|
| - |
|
213 |
ticket.setDescription("Requires COD verification for orders: " + transaction.getOrders());
|
| - |
|
214 |
ticket.setPriority(TicketPriority.HIGH);
|
| - |
|
215 |
ticket.setStatus(TicketStatus.OPEN);
|
| - |
|
216 |
ticket.setOrderId(order.getId());
|
| - |
|
217 |
|
| - |
|
218 |
Activity activity = new Activity();
|
| - |
|
219 |
activity.setCreatorId(ticket.getCreatorId());
|
| - |
|
220 |
activity.setCustomerId(ticket.getCustomerId());
|
| - |
|
221 |
activity.setDescription("Creating ticket");
|
| - |
|
222 |
activity.setTicketCategory(ticket.getCategory());
|
| - |
|
223 |
activity.setTicketDescription(ticket.getDescription());
|
| - |
|
224 |
activity.setTicketPriority(ticket.getPriority());
|
| - |
|
225 |
activity.setTicketStatus(ticket.getStatus());
|
| - |
|
226 |
activity.setType(ActivityType.OTHER);
|
| - |
|
227 |
|
| - |
|
228 |
this.insertTicket(ticket, activity);
|
| - |
|
229 |
}
|
| - |
|
230 |
}
|
| - |
|
231 |
}
|
| - |
|
232 |
else {
|
| - |
|
233 |
log.info("Autoverifying orders");
|
| - |
|
234 |
// Submit order for processing
|
| - |
|
235 |
for (Order order : transaction.getOrders()) {
|
| - |
|
236 |
log.info("Processing order: " + order.getId());
|
| - |
|
237 |
client.changeOrderStatus(order.getId(), OrderStatus.SUBMITTED_FOR_PROCESSING, "In Process");
|
| - |
|
238 |
}
|
| - |
|
239 |
}
|
| - |
|
240 |
} catch (TransactionServiceException e) {
|
| - |
|
241 |
log.error("Could not fetch transaction details", e);
|
| - |
|
242 |
} catch (UserContextException e) {
|
| - |
|
243 |
e.printStackTrace();
|
| - |
|
244 |
}
|
| - |
|
245 |
}
|
| 175 |
}
|
246 |
}
|