| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import java.util.Collection;
|
3 |
import java.util.Collection;
|
| 4 |
|
4 |
|
| 5 |
import in.shop2020.model.v1.user.Address;
|
5 |
import in.shop2020.model.v1.user.Address;
|
| 6 |
import in.shop2020.model.v1.user.AddressType;
|
6 |
import in.shop2020.model.v1.user.AddressType;
|
| - |
|
7 |
import in.shop2020.model.v1.user.Cart;
|
| 7 |
import in.shop2020.model.v1.user.UserContextService;
|
8 |
import in.shop2020.model.v1.user.UserContextService;
|
| 8 |
import in.shop2020.serving.controllers.BaseController;
|
9 |
import in.shop2020.serving.controllers.BaseController;
|
| 9 |
import in.shop2020.serving.utils.Utils;
|
10 |
import in.shop2020.serving.utils.Utils;
|
| 10 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
11 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
| 11 |
|
12 |
|
| Line 13... |
Line 14... |
| 13 |
import org.apache.log4j.Logger;
|
14 |
import org.apache.log4j.Logger;
|
| 14 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
15 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
| 15 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
16 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
| 16 |
import org.apache.struts2.convention.annotation.Result;
|
17 |
import org.apache.struts2.convention.annotation.Result;
|
| 17 |
import org.apache.struts2.convention.annotation.Results;
|
18 |
import org.apache.struts2.convention.annotation.Results;
|
| - |
|
19 |
import org.apache.thrift.TApplicationException;
|
| 18 |
|
20 |
|
| 19 |
@InterceptorRefs({
|
21 |
@InterceptorRefs({
|
| 20 |
@InterceptorRef("myDefault"),
|
22 |
@InterceptorRef("myDefault"),
|
| 21 |
@InterceptorRef("login")
|
23 |
@InterceptorRef("login")
|
| 22 |
})
|
24 |
})
|
| Line 52... |
Line 54... |
| 52 |
boolean isLoggedIn = userinfo.isLoggedIn();
|
54 |
boolean isLoggedIn = userinfo.isLoggedIn();
|
| 53 |
long cartId = userinfo.getCartId();
|
55 |
long cartId = userinfo.getCartId();
|
| 54 |
try {
|
56 |
try {
|
| 55 |
UserContextService.Client userClient = (new UserContextServiceClient()).getClient();
|
57 |
UserContextService.Client userClient = (new UserContextServiceClient()).getClient();
|
| 56 |
userClient.checkOut(cartId);
|
58 |
userClient.checkOut(cartId);
|
| - |
|
59 |
Cart cart = userClient.getCart(cartId);
|
| - |
|
60 |
long defaultAddressId = cart.getAddressId();
|
| - |
|
61 |
if (defaultAddressId == 0) {
|
| 57 |
long defaultAddressId = userClient.getDefaultAddressId(userId);
|
62 |
defaultAddressId = userClient.getDefaultAddressId(userId);
|
| - |
|
63 |
}
|
| 58 |
log.info("The default address id of this user is: " + defaultAddressId);
|
64 |
log.info("The default address id of this user is: " + defaultAddressId);
|
| 59 |
if(defaultAddressId > 0)
|
65 |
if(defaultAddressId > 0)
|
| 60 |
userClient.addAddressToCart(cartId, defaultAddressId);
|
66 |
userClient.addAddressToCart(cartId, defaultAddressId);
|
| 61 |
if(!userClient.validateCart(cartId))
|
67 |
if(!userClient.validateCart(cartId))
|
| 62 |
errorMsg = "Your cart has been updated.";
|
68 |
errorMsg = "Your cart has been updated.";
|
| Line 139... |
Line 145... |
| 139 |
}
|
145 |
}
|
| 140 |
return "redirect";
|
146 |
return "redirect";
|
| 141 |
}
|
147 |
}
|
| 142 |
|
148 |
|
| 143 |
if(action.equals("change")){
|
149 |
if(action.equals("change")){
|
| 144 |
long addressId = Long.parseLong(this.request.getParameter("addressid"));
|
150 |
addressId = Long.parseLong(this.request.getParameter("addressid"));
|
| 145 |
userClient.addAddressToCart(userinfo.getCartId(), addressId);
|
151 |
userClient.addAddressToCart(userinfo.getCartId(), addressId);
|
| 146 |
return "success";
|
152 |
return "success";
|
| 147 |
}
|
153 |
}
|
| 148 |
}
|
154 |
}
|
| 149 |
} catch (Exception e) {
|
155 |
} catch (Exception e) {
|