| Line 28... |
Line 28... |
| 28 |
|
28 |
|
| 29 |
import org.apache.commons.logging.Log;
|
29 |
import org.apache.commons.logging.Log;
|
| 30 |
import org.apache.commons.logging.LogFactory;
|
30 |
import org.apache.commons.logging.LogFactory;
|
| 31 |
import org.apache.thrift.TException;
|
31 |
import org.apache.thrift.TException;
|
| 32 |
import org.apache.thrift.transport.TTransportException;
|
32 |
import org.apache.thrift.transport.TTransportException;
|
| - |
|
33 |
import org.springframework.context.ApplicationContext;
|
| - |
|
34 |
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
| 33 |
import org.springframework.transaction.annotation.Transactional;
|
35 |
import org.springframework.transaction.annotation.Transactional;
|
| 34 |
|
36 |
|
| 35 |
/**
|
37 |
/**
|
| 36 |
* @author mandeep
|
38 |
* @author mandeep
|
| 37 |
* Processor all the COD transactions booked by customers, creates a ticket per
|
39 |
* Processor all the COD transactions booked by customers, creates a ticket per
|
| 38 |
* customer so as our Outbound team can work on them like verifying users
|
40 |
* customer so as our Outbound team can work on them like verifying users
|
| 39 |
* validity and order details.
|
41 |
* validity and order details.
|
| 40 |
*/
|
42 |
*/
|
| 41 |
public class CODTransactionProcessorTask implements Runnable {
|
43 |
public class CODTransactionProcessorTask {
|
| 42 |
private static Log log = LogFactory.getLog(CODTransactionProcessorTask.class);
|
44 |
private static Log log = LogFactory.getLog(CODTransactionProcessorTask.class);
|
| 43 |
private static final double TRUST_THRESHOLD_LEVEL = 4.5;
|
45 |
private static final double TRUST_THRESHOLD_LEVEL = 4.5;
|
| 44 |
private static final long ADMIN_AGENT_ID = 1;
|
46 |
private static final long ADMIN_AGENT_ID = 1;
|
| 45 |
private static final long OUTBOUND_DEFAULT_ASSIGNEE_ID = 12;
|
47 |
private static final long OUTBOUND_DEFAULT_ASSIGNEE_ID = 12;
|
| 46 |
|
48 |
|
| 47 |
private TicketHandler ticketHandler;
|
49 |
private TicketHandler ticketHandler;
|
| 48 |
private ActivityHandler activityHandler;
|
50 |
private ActivityHandler activityHandler;
|
| 49 |
|
51 |
|
| 50 |
public CODTransactionProcessorTask(TicketHandler ticketHandler,
|
52 |
public CODTransactionProcessorTask()
|
| 51 |
ActivityHandler activityHandler)
|
- |
|
| 52 |
{
|
53 |
{
|
| - |
|
54 |
ApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
|
| 53 |
this.ticketHandler = ticketHandler;
|
55 |
ticketHandler = context.getBean(TicketHandler.class);
|
| 54 |
this.activityHandler = activityHandler;
|
56 |
activityHandler = context.getBean(ActivityHandler.class);
|
| 55 |
}
|
57 |
}
|
| 56 |
|
58 |
|
| 57 |
/* (non-Javadoc)
|
- |
|
| 58 |
* @see java.lang.Runnable#run()
|
- |
|
| 59 |
*/
|
59 |
|
| 60 |
public void run() {
|
60 |
public static void main(String[] args) {
|
| 61 |
try {
|
61 |
try {
|
| - |
|
62 |
CODTransactionProcessorTask newTask = new CODTransactionProcessorTask();
|
| 62 |
Client client = new TransactionClient().getClient();
|
63 |
Client client = new TransactionClient().getClient();
|
| 63 |
List<Long> transactionIds = client.getTransactionsRequiringExtraProcessing(ExtraTransactionProcessingType.COD_VERIFICATION);
|
64 |
List<Long> transactionIds = client.getTransactionsRequiringExtraProcessing(ExtraTransactionProcessingType.COD_VERIFICATION);
|
| 64 |
if (transactionIds != null && !transactionIds.isEmpty()) {
|
65 |
if (transactionIds != null && !transactionIds.isEmpty()) {
|
| 65 |
log.info("Fetched " + transactionIds.size() + " transactions");
|
66 |
log.info("Fetched " + transactionIds.size() + " transactions");
|
| 66 |
for (Long transactionId : transactionIds) {
|
67 |
for (Long transactionId : transactionIds) {
|
| 67 |
processCODTxn(transactionId);
|
68 |
newTask.processCODTxn(transactionId);
|
| 68 |
client = new TransactionClient().getClient();
|
69 |
client = new TransactionClient().getClient();
|
| 69 |
client.markTransactionAsProcessed(transactionId, ExtraTransactionProcessingType.COD_VERIFICATION);
|
70 |
client.markTransactionAsProcessed(transactionId, ExtraTransactionProcessingType.COD_VERIFICATION);
|
| 70 |
}
|
71 |
}
|
| 71 |
}
|
72 |
}
|
| 72 |
else {
|
73 |
else {
|