Subversion Repositories SmartDukaan

Rev

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

Rev 1309 Rev 1380
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
3
import java.io.IOException;
3
import java.io.IOException;
4
import java.text.ParseException;
4
import java.lang.NumberFormatException;
5
import java.util.ArrayList;
5
import java.util.ArrayList;
6
import java.util.Date;
6
import java.util.Date;
7
import java.util.List;
7
import java.util.List;
8
import java.util.StringTokenizer;
-
 
9
 
8
 
10
import in.shop2020.model.v1.order.LineItem;
9
import in.shop2020.model.v1.order.LineItem;
11
import in.shop2020.model.v1.order.Order;
10
import in.shop2020.model.v1.order.Order;
-
 
11
import in.shop2020.model.v1.order.OrderStatus;
12
import in.shop2020.model.v1.user.UserContextException;
12
import in.shop2020.model.v1.user.UserContextException;
13
import in.shop2020.model.v1.user.UserContextService;
13
import in.shop2020.model.v1.user.UserContextService;
14
import in.shop2020.serving.controllers.BaseController;
14
import in.shop2020.serving.controllers.BaseController;
15
import in.shop2020.thrift.clients.HelperServiceClient;
15
import in.shop2020.thrift.clients.HelperServiceClient;
16
import in.shop2020.thrift.clients.TransactionServiceClient;
16
import in.shop2020.thrift.clients.TransactionServiceClient;
Line 31... Line 31...
31
	private String id;
31
	private String id;
32
	private static final long serialVersionUID = 1L;
32
	private static final long serialVersionUID = 1L;
33
	private static Logger log = Logger.getLogger(Class.class);
33
	private static Logger log = Logger.getLogger(Class.class);
34
	List<Order> orders = null;
34
	List<Order> orders = null;
35
	List<LineItem> products = null;
35
	List<LineItem> products = null;
-
 
36
	List<Long> order_ids = null;
36
	
37
	
37
	public ContactUsController(){
38
	public ContactUsController(){
38
		super();
39
		super();
39
	}
40
	}
40
	
41
	
Line 53... Line 54...
53
 
54
 
54
	public String show() throws SecurityException, IOException	{
55
	public String show() throws SecurityException, IOException	{
55
		try	{
56
		try	{
56
			TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
57
			TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
57
			in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
58
			in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
-
 
59
 
-
 
60
			if (id.equals("to_return"))	{
-
 
61
				order_ids = orderClient.getReturnableOrdersForCustomer(userinfo.getUserId(), 0);
-
 
62
			}
-
 
63
			else if (id.equals("to_cancel"))	{
-
 
64
				order_ids = orderClient.getCancellableOrdersForCustomer(userinfo.getUserId(), 0);
58
			
65
			}
-
 
66
			else if (id.equals("all_orders"))	{
-
 
67
				orders = orderClient.getOrdersForCustomer(userinfo.getUserId(), 0, (new Date()).getTime(), null);
-
 
68
			}
-
 
69
			else	{
59
			long orderId = Integer.parseInt(id);
70
				long orderId = Integer.parseInt(id);
60
			products = orderClient.getLineItemsForOrder(orderId);
71
				products = orderClient.getLineItemsForOrder(orderId);
-
 
72
			}
-
 
73
		}
-
 
74
		catch (NumberFormatException e)	{
-
 
75
			e.printStackTrace();
61
		}
76
		}
62
		catch (Exception e) {
77
		catch (Exception e) {
63
			e.printStackTrace();
78
			e.printStackTrace();
64
		}
79
		}
65
		return "ajax";
80
		return "ajax";
Line 94... Line 109...
94
		} catch (Exception e) {
109
		} catch (Exception e) {
95
			e.printStackTrace();
110
			e.printStackTrace();
96
		} finally	{
111
		} finally	{
97
		
112
		
98
		}
113
		}
99
		
-
 
100
/*	    	Mail mail = new Mail();
114
		return "success";
101
	    	List<String> mailTo = new ArrayList<String>();
-
 
102
	    	
115
	}
103
	    	this.userMailId = request.getParameter("mailFrom");
-
 
104
	    	String mailSubject = request.getParameter("mailSubject");
-
 
105
	    	String mailBody = request.getParameter("mailBody");
-
 
106
	    	mailTo.add(customerCareMailId);
-
 
107
	    	
-
 
108
	    	mail.setSubject(mailSubject);
-
 
109
	    	mail.setSender(userMailId);
-
 
110
	    	mail.setTo(mailTo);
-
 
111
	    	mail.setData(mailBody);
-
 
112
	    	
116
	
113
	    	HelperServiceClient helperServiceClient;
-
 
114
	    	try {
-
 
115
				helperServiceClient = new HelperServiceClient();
-
 
116
				helperServiceClient.getClient().sendMail(mail);
-
 
117
			} catch (Exception e) {
117
	public String getId()	{
118
				log.error("Helper service not working properly. Error while sending mail to user.");
-
 
119
				e.printStackTrace();
118
		return this.id;
120
			}*/
119
	}
121
	    	
-
 
122
	    	return "success";
-
 
123
	    }
120
	
124
	/**
121
	/**
125
     * 
-
 
126
     * @param id
122
     * @param id
127
     */
123
     */
128
    public void setId(String id) {
124
    public void setId(String id) {
129
    	this.id = id;
125
    	this.id = id;
130
    }
126
    }
131
    
127
    
132
	public String getSuccessMsg() {
128
	public String getSuccessMsg() {
133
		return UserMessage.USER_COMMUNICATION_SUCCESS;
129
		return UserMessage.USER_COMMUNICATION_SUCCESS;
134
	}
130
	}
135
 
131
 
136
	public String getOrderIdSelector()	{
132
	private String getOrderIdSelector(List<Long> order_ids)	{
137
		String html = "";
133
		String html = "";
138
		
134
		
139
		if (orders == null || orders.size() == 0)	{
135
		if (order_ids == null || order_ids.size() == 0)	{
140
			html += "<option value='-1'>No Orders Found</option>";
136
			html += "<option value='-1'>No Orders Found</option>";
141
		} else	{
137
		} else	{
142
			html += "<option value='-1'>Select Order ID</option>";
138
			html += "<option value='-1'>Select Order ID</option>";
143
 
139
 
144
			for(Order order: orders)	{
140
			for(long order_id: order_ids)	{
145
				html += "<option value='" + order.getId() + "'>" + order.getId() + "</option>";
141
				html += "<option value='" + order_id + "'>" + order_id + "</option>";
146
			}
142
			}
147
		}
143
		}
148
		return html;
144
		return html;
149
	}
145
	}
150
	
146
	
Line 164... Line 160...
164
				html += "</option>";
160
				html += "</option>";
165
			}
161
			}
166
		}
162
		}
167
		return html;
163
		return html;
168
	}
164
	}
-
 
165
	
-
 
166
	public String getIdsOfAllOrders()	{
-
 
167
		List<Long> order_ids = new ArrayList<Long>();
-
 
168
		
-
 
169
		for(Order order: this.orders)	{
-
 
170
			order_ids.add(order.getId());
-
 
171
		}
-
 
172
		return getOrderIdSelector(order_ids); 
-
 
173
	}
-
 
174
	
-
 
175
	public String getIdsOfReturnableOrders()	{
-
 
176
		return getOrderIdSelector(this.order_ids);
-
 
177
	}
-
 
178
	
-
 
179
	public String getIdsOfCancellableOrders()	{
-
 
180
		return getOrderIdSelector(this.order_ids);
-
 
181
	}
169
}
182
}
170
183