Subversion Repositories SmartDukaan

Rev

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

Rev 1170 Rev 1297
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.text.ParseException;
4
import java.text.ParseException;
4
import java.util.ArrayList;
5
import java.util.ArrayList;
-
 
6
import java.util.Date;
5
import java.util.List;
7
import java.util.List;
-
 
8
import java.util.StringTokenizer;
6
 
9
 
-
 
10
import in.shop2020.model.v1.order.LineItem;
-
 
11
import in.shop2020.model.v1.order.Order;
7
import in.shop2020.model.v1.user.UserContextException;
12
import in.shop2020.model.v1.user.UserContextException;
8
import in.shop2020.model.v1.user.UserContextService;
13
import in.shop2020.model.v1.user.UserContextService;
9
import in.shop2020.serving.controllers.BaseController;
14
import in.shop2020.serving.controllers.BaseController;
10
import in.shop2020.thrift.clients.HelperServiceClient;
15
import in.shop2020.thrift.clients.HelperServiceClient;
-
 
16
import in.shop2020.thrift.clients.TransactionServiceClient;
11
import in.shop2020.thrift.clients.UserContextServiceClient;
17
import in.shop2020.thrift.clients.UserContextServiceClient;
12
import in.shop2020.serving.utils.UserMessage;
18
import in.shop2020.serving.utils.UserMessage;
13
 
19
 
14
import org.apache.log4j.Logger;
20
import org.apache.log4j.Logger;
15
import org.apache.struts2.rest.DefaultHttpHeaders;
21
import org.apache.struts2.rest.DefaultHttpHeaders;
16
import org.apache.struts2.rest.HttpHeaders;
22
import org.apache.struts2.rest.HttpHeaders;
-
 
23
import org.apache.velocity.VelocityContext;
17
 
24
 
18
public class ContactUsController extends BaseController{
25
public class ContactUsController extends BaseController{
19
	
26
 
-
 
27
	private String id;
20
	private static final long serialVersionUID = 1L;
28
	private static final long serialVersionUID = 1L;
21
	private static Logger log = Logger.getLogger(Class.class);
29
	private static Logger log = Logger.getLogger(Class.class);
22
/*	private static String customerCareMailId = "help@saholic.com";
-
 
23
	private String userMailId;
30
	List<Order> orders = null;
24
		
-
 
25
	static {
-
 
26
		try {
-
 
27
			customerCareMailId = ConfigClient.getClient().get("saholic_customer_care_mail");
-
 
28
		} catch (ConfigException e) {
-
 
29
			customerCareMailId = "help@saholic.com";
-
 
30
			e.printStackTrace();
31
	List<LineItem> products = null;
31
		}
-
 
32
	}
32
	
33
	*/
-
 
34
	public ContactUsController(){
33
	public ContactUsController(){
35
		super();	
34
		super();
36
	}
35
	}
37
		
36
	
38
	// GET /Show Form
37
	// GET /Show Form
39
	public HttpHeaders index() {
38
	public String index() {
-
 
39
		try	{
40
		return new DefaultHttpHeaders("index").disableCaching();
40
			TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
-
 
41
			in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
-
 
42
			orders = orderClient.getOrdersForCustomer(userinfo.getUserId(), 0, (new Date()).getTime(), null);
-
 
43
 
-
 
44
		} catch(Exception e)	{
-
 
45
			e.printStackTrace();
-
 
46
		}
-
 
47
		return "index";
41
	}
48
	}
42
 
49
 
-
 
50
	public String show() throws SecurityException, IOException	{
-
 
51
		try	{
-
 
52
			TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
-
 
53
			in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
-
 
54
			
-
 
55
			long orderId = Integer.parseInt(id);
-
 
56
			products = orderClient.getLineItemsForOrder(orderId);
-
 
57
		}
-
 
58
		catch (Exception e) {
-
 
59
			e.printStackTrace();
-
 
60
		}
-
 
61
		return "ajax";
-
 
62
	}
-
 
63
	
43
	// POST /Save Communication
64
	// POST /Save Communication
44
	public String create() {
65
	public String create() {
45
		long communicationType = -1;
66
		long communicationType = -1;
46
		long orderId = -1;
67
		long orderId = -1;
47
 
68
 
Line 94... Line 115...
94
				e.printStackTrace();
115
				e.printStackTrace();
95
			}*/
116
			}*/
96
	    	
117
	    	
97
	    	return "success";
118
	    	return "success";
98
	    }
119
	    }
-
 
120
	/**
-
 
121
     * 
-
 
122
     * @param id
-
 
123
     */
-
 
124
    public void setId(String id) {
-
 
125
    	this.id = id;
-
 
126
    }
-
 
127
    
-
 
128
	public String getSuccessMsg() {
-
 
129
		return UserMessage.USER_COMMUNICATION_SUCCESS;
-
 
130
	}
-
 
131
 
-
 
132
	public String getOrderIdSelector()	{
-
 
133
		String html = "";
-
 
134
		
-
 
135
		if (orders == null || orders.size() == 0)	{
-
 
136
			html += "<option value='-1'>No Orders Found</option>";
-
 
137
		} else	{
-
 
138
			html += "<option value='-1'>Select Order ID</option>";
99
 
139
 
100
		public String getSuccessMsg() {
140
			for(Order order: orders)	{
101
			return UserMessage.USER_COMMUNICATION_SUCCESS;
141
				html += "<option value='" + order.getId() + "'>" + order.getId() + "</option>";
-
 
142
			}
102
		}
143
		}
-
 
144
		return html;
-
 
145
	}
-
 
146
	
-
 
147
	public String getProductsForOrder()	{
-
 
148
		String html = "";
-
 
149
		
-
 
150
		if(products == null || products.size() == 0)	{
-
 
151
			html += "<option value='-1'>No Products Found</option>";
-
 
152
		} else	{
-
 
153
			for (LineItem product: products)	{
-
 
154
				html += "<option value='" + product.getId() + "'>";
-
 
155
				
-
 
156
				if(product.getBrand() != null)	html += product.getBrand() + " ";
-
 
157
				if(product.getModel_name() != null)	html += product.getModel_name() + " ";
-
 
158
				if(product.getModel_number() != null)	html += product.getModel_number();
-
 
159
				
-
 
160
				html += "</option>";
-
 
161
			}
-
 
162
		}
-
 
163
		return html;
-
 
164
	}
103
}
165
}
104
166