| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.controllers;
|
1 |
package in.shop2020.serving.controllers;
|
| 2 |
|
2 |
|
| 3 |
import java.util.ArrayList;
|
- |
|
| 4 |
import java.util.Collection;
|
- |
|
| 5 |
import java.util.HashMap;
|
- |
|
| 6 |
import java.util.List;
|
- |
|
| 7 |
import java.util.Map;
|
- |
|
| 8 |
|
- |
|
| 9 |
import in.shop2020.datalogger.EventType;
|
3 |
import in.shop2020.datalogger.EventType;
|
| 10 |
import in.shop2020.model.v1.catalog.Item;
|
4 |
import in.shop2020.model.v1.catalog.Item;
|
| 11 |
import in.shop2020.model.v1.user.Address;
|
5 |
import in.shop2020.model.v1.user.Address;
|
| 12 |
import in.shop2020.model.v1.user.AddressType;
|
6 |
import in.shop2020.model.v1.user.AddressType;
|
| 13 |
import in.shop2020.model.v1.user.Cart;
|
7 |
import in.shop2020.model.v1.user.Cart;
|
| 14 |
import in.shop2020.model.v1.user.Line;
|
8 |
import in.shop2020.model.v1.user.Line;
|
| 15 |
import in.shop2020.model.v1.user.User;
|
9 |
import in.shop2020.model.v1.user.User;
|
| 16 |
import in.shop2020.model.v1.user.UserContextService;
|
10 |
import in.shop2020.model.v1.user.UserContextService;
|
| 17 |
import in.shop2020.serving.controllers.BaseController;
|
- |
|
| 18 |
import in.shop2020.serving.utils.DataLogger;
|
11 |
import in.shop2020.serving.utils.DataLogger;
|
| 19 |
import in.shop2020.serving.utils.FormattingUtils;
|
12 |
import in.shop2020.serving.utils.FormattingUtils;
|
| 20 |
import in.shop2020.serving.utils.Utils;
|
13 |
import in.shop2020.serving.utils.Utils;
|
| 21 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
14 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
| 22 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
15 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
| 23 |
|
16 |
|
| - |
|
17 |
import java.util.ArrayList;
|
| - |
|
18 |
import java.util.Collection;
|
| - |
|
19 |
import java.util.HashMap;
|
| - |
|
20 |
import java.util.List;
|
| - |
|
21 |
import java.util.Map;
|
| 24 |
|
22 |
|
| 25 |
import org.apache.log4j.Logger;
|
23 |
import org.apache.log4j.Logger;
|
| 26 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
24 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
| 27 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
25 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
| 28 |
import org.apache.struts2.convention.annotation.Result;
|
26 |
import org.apache.struts2.convention.annotation.Result;
|
| Line 88... |
Line 86... |
| 88 |
if(actionErrors != null && !actionErrors.isEmpty()){
|
86 |
if(actionErrors != null && !actionErrors.isEmpty()){
|
| 89 |
for (String str : actionErrors) {
|
87 |
for (String str : actionErrors) {
|
| 90 |
errorMsg += "<BR/>" + str;
|
88 |
errorMsg += "<BR/>" + str;
|
| 91 |
}
|
89 |
}
|
| 92 |
}
|
90 |
}
|
| 93 |
DataLogger.logData(EventType.SHIPPINIG_ACCESS.name(), session.getId(), Long.toString(userinfo.getUserId()), userinfo.getEmail(),
|
91 |
DataLogger.logData(EventType.SHIPPINIG_ACCESS, session.getId(), userinfo.getUserId(), userinfo.getEmail(),
|
| 94 |
Long.toString(cartId));
|
92 |
Long.toString(cartId));
|
| 95 |
|
93 |
|
| 96 |
return "index";
|
94 |
return "index";
|
| 97 |
}
|
95 |
}
|
| 98 |
|
96 |
|
| Line 146... |
Line 144... |
| 146 |
address.setEnabled(true);
|
144 |
address.setEnabled(true);
|
| 147 |
address.setType(AddressType.HOME);
|
145 |
address.setType(AddressType.HOME);
|
| 148 |
long addressId = userClient.addAddressForUser(userinfo.getUserId(), address, false);
|
146 |
long addressId = userClient.addAddressForUser(userinfo.getUserId(), address, false);
|
| 149 |
userClient.addAddressToCart(userinfo.getCartId(), addressId);
|
147 |
userClient.addAddressToCart(userinfo.getCartId(), addressId);
|
| 150 |
addActionMessage("Address added successfully.");
|
148 |
addActionMessage("Address added successfully.");
|
| 151 |
DataLogger.logData(EventType.SHIPPINIG_ADD_ADDRESS.name(), session.getId(), Long.toString(userinfo.getUserId()), userinfo.getEmail(), address.getName(),
|
149 |
DataLogger.logData(EventType.SHIPPINIG_ADD_ADDRESS, session.getId(), userinfo.getUserId(), userinfo.getEmail(), address.getName(),
|
| 152 |
address.getCity(), address.getPhone(), address.getPin());
|
150 |
address.getCity(), address.getPhone(), address.getPin());
|
| 153 |
}
|
151 |
}
|
| 154 |
return "redirect";
|
152 |
return "redirect";
|
| 155 |
}
|
153 |
}
|
| 156 |
|
154 |
|
| 157 |
if(action.equals("change")) {
|
155 |
if(action.equals("change")) {
|
| 158 |
addressId = Long.parseLong(this.request.getParameter("addressid"));
|
156 |
addressId = Long.parseLong(this.request.getParameter("addressid"));
|
| 159 |
userClient.addAddressToCart(userinfo.getCartId(), addressId);
|
157 |
userClient.addAddressToCart(userinfo.getCartId(), addressId);
|
| 160 |
|
158 |
|
| 161 |
errorMsg = userClient.validateCart(userinfo.getCartId());
|
159 |
errorMsg = userClient.validateCart(userinfo.getCartId());
|
| 162 |
DataLogger.logData(EventType.SHIPPINIG_ADD_CHANGE.name(), session.getId(), Long.toString(userinfo.getUserId()), userinfo.getEmail(),
|
160 |
DataLogger.logData(EventType.SHIPPINIG_ADD_CHANGE, session.getId(), userinfo.getUserId(), userinfo.getEmail(),
|
| 163 |
Long.toString(userinfo.getCartId()), Long.toString(addressId));
|
161 |
Long.toString(userinfo.getCartId()), Long.toString(addressId));
|
| 164 |
return "index";
|
162 |
return "index";
|
| 165 |
}
|
163 |
}
|
| 166 |
}
|
164 |
}
|
| 167 |
} catch (Exception e) {
|
165 |
} catch (Exception e) {
|