Subversion Repositories SmartDukaan

Rev

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

Rev 1774 Rev 1957
Line 12... Line 12...
12
import in.shop2020.model.v1.user.Cart;
12
import in.shop2020.model.v1.user.Cart;
13
import in.shop2020.model.v1.user.Line;
13
import in.shop2020.model.v1.user.Line;
14
import in.shop2020.model.v1.user.User;
14
import in.shop2020.model.v1.user.User;
15
import in.shop2020.model.v1.user.UserContextService;
15
import in.shop2020.model.v1.user.UserContextService;
16
import in.shop2020.serving.controllers.BaseController;
16
import in.shop2020.serving.controllers.BaseController;
-
 
17
import in.shop2020.serving.utils.DataLogger;
17
import in.shop2020.serving.utils.Utils;
18
import in.shop2020.serving.utils.Utils;
-
 
19
import in.shop2020.serving.utils.DataLogger.Event;
18
import in.shop2020.thrift.clients.CatalogServiceClient;
20
import in.shop2020.thrift.clients.CatalogServiceClient;
19
import in.shop2020.thrift.clients.UserContextServiceClient;
21
import in.shop2020.thrift.clients.UserContextServiceClient;
20
 
22
 
21
 
23
 
-
 
24
import org.apache.commons.lang.StringUtils;
22
import org.apache.log4j.Logger;
25
import org.apache.log4j.Logger;
23
import org.apache.struts2.convention.annotation.InterceptorRef;
26
import org.apache.struts2.convention.annotation.InterceptorRef;
24
import org.apache.struts2.convention.annotation.InterceptorRefs;
27
import org.apache.struts2.convention.annotation.InterceptorRefs;
25
import org.apache.struts2.convention.annotation.Result;
28
import org.apache.struts2.convention.annotation.Result;
26
import org.apache.struts2.convention.annotation.Results;
29
import org.apache.struts2.convention.annotation.Results;
Line 38... Line 41...
38
})
41
})
39
public class ShippingController extends BaseController{
42
public class ShippingController extends BaseController{
40
	
43
	
41
	private static final long serialVersionUID = 1L;
44
	private static final long serialVersionUID = 1L;
42
	private static Logger log = Logger.getLogger(Class.class);
45
	private static Logger log = Logger.getLogger(Class.class);
-
 
46
	private static Logger dataLog = DataLogger.getLogger();
43
	
47
	
44
	private long addressId = 0;
48
	private long addressId = 0;
45
	private String errorMsg = "";
49
	private String errorMsg = "";
46
	
50
	
47
	private String name;
51
	private String name;
Line 87... Line 91...
87
		if(actionErrors != null && !actionErrors.isEmpty()){
91
		if(actionErrors != null && !actionErrors.isEmpty()){
88
			for (String str : actionErrors) {
92
			for (String str : actionErrors) {
89
			    errorMsg += "<BR/>" + str;
93
			    errorMsg += "<BR/>" + str;
90
			}
94
			}
91
		}
95
		}
-
 
96
		dataLog.info(StringUtils.join(
-
 
97
                new String[] { Event.SHIPPINIG_ACCESS.name(),
-
 
98
                        userinfo.getEmail(),
-
 
99
                        Long.toString(cartId) }, ", "));
92
		
100
		
93
    	return "index";
101
    	return "index";
94
	 }
102
	 }
95
 
103
 
96
	// POST /entity
104
	// POST /entity
Line 143... Line 151...
143
						address.setEnabled(true);
151
						address.setEnabled(true);
144
						address.setType(AddressType.HOME);
152
						address.setType(AddressType.HOME);
145
						long addressId = userClient.addAddressForUser(userinfo.getUserId(), address, false);
153
						long addressId = userClient.addAddressForUser(userinfo.getUserId(), address, false);
146
						userClient.addAddressToCart(userinfo.getCartId(), addressId);
154
						userClient.addAddressToCart(userinfo.getCartId(), addressId);
147
						addActionMessage("Address added successfully.");
155
						addActionMessage("Address added successfully.");
-
 
156
                        dataLog.info(StringUtils.join(
-
 
157
                                new String[] {
-
 
158
                                        Event.SHIPPINIG_ADD_ADDRESS.name(),
-
 
159
                                        userinfo.getEmail(), address.getName(),
-
 
160
                                        address.getCity(), address.getPhone(),
-
 
161
                                        address.getPin() }, ", "));
148
					}
162
					}
149
					return "redirect";				
163
					return "redirect";				
150
				}
164
				}
151
				
165
				
152
				if(action.equals("change"))	{
166
				if(action.equals("change"))	{
153
					addressId = Long.parseLong(this.request.getParameter("addressid"));
167
					addressId = Long.parseLong(this.request.getParameter("addressid"));
154
					userClient.addAddressToCart(userinfo.getCartId(), addressId);
168
					userClient.addAddressToCart(userinfo.getCartId(), addressId);
155
					
169
					
156
					errorMsg = userClient.validateCart(userinfo.getCartId());
170
					errorMsg = userClient.validateCart(userinfo.getCartId());
-
 
171
                    dataLog.info(StringUtils.join(
-
 
172
                            new String[] { Event.SHIPPINIG_ADD_CHANGE.name(),
-
 
173
                                    userinfo.getEmail(),
-
 
174
                                    Long.toString(userinfo.getCartId()),
-
 
175
                                    Long.toString(addressId) }, ", "));
157
					return "index";
176
					return "index";
158
				}
177
				}
159
			}
178
			}
160
		} catch (Exception e) {
179
		} catch (Exception e) {
161
			return "failure";
180
			return "failure";