| Line 4... |
Line 4... |
| 4 |
package in.shop2020.serving.controllers;
|
4 |
package in.shop2020.serving.controllers;
|
| 5 |
|
5 |
|
| 6 |
|
6 |
|
| 7 |
import in.shop2020.model.v1.user.Sex;
|
7 |
import in.shop2020.model.v1.user.Sex;
|
| 8 |
import in.shop2020.model.v1.user.User;
|
8 |
import in.shop2020.model.v1.user.User;
|
| - |
|
9 |
import in.shop2020.model.v1.user.Widget;
|
| - |
|
10 |
import in.shop2020.model.v1.user.WidgetItem;
|
| 9 |
import in.shop2020.serving.utils.DesEncrypter;
|
11 |
import in.shop2020.serving.utils.DesEncrypter;
|
| 10 |
import in.shop2020.serving.utils.Utils;
|
12 |
import in.shop2020.serving.utils.Utils;
|
| 11 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
13 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
| 12 |
|
14 |
|
| 13 |
import java.io.IOException;
|
15 |
import java.io.IOException;
|
| 14 |
import java.util.Date;
|
16 |
import java.util.Date;
|
| - |
|
17 |
import java.util.List;
|
| 15 |
|
18 |
|
| 16 |
import org.apache.log4j.Logger;
|
19 |
import org.apache.log4j.Logger;
|
| 17 |
import org.apache.struts2.convention.annotation.Result;
|
20 |
import org.apache.struts2.convention.annotation.Result;
|
| 18 |
import org.apache.struts2.convention.annotation.Results;
|
21 |
import org.apache.struts2.convention.annotation.Results;
|
| 19 |
|
22 |
|
| Line 133... |
Line 136... |
| 133 |
// TODO: setTotalItems shouldn't be a method on userinfo. This allows
|
136 |
// TODO: setTotalItems shouldn't be a method on userinfo. This allows
|
| 134 |
// for potentially updating the item count wrongly. The method setCartId
|
137 |
// for potentially updating the item count wrongly. The method setCartId
|
| 135 |
// should update the item count as well. Also, there can be a method
|
138 |
// should update the item count as well. Also, there can be a method
|
| 136 |
// called refreshItemCount() that automatically updates the number of
|
139 |
// called refreshItemCount() that automatically updates the number of
|
| 137 |
// items currently in the cart.
|
140 |
// items currently in the cart.
|
| - |
|
141 |
if(userinfo.getCartId() != -1){
|
| 138 |
userClient.mergeCart(userinfo.getCartId(), user.getActiveCartId());
|
142 |
userClient.mergeCart(userinfo.getCartId(), user.getActiveCartId());
|
| - |
|
143 |
|
| - |
|
144 |
Widget browseHistory = userClient.getBrowseHistory(userinfo.getCartId());
|
| - |
|
145 |
if(browseHistory != null){
|
| - |
|
146 |
List<WidgetItem> items = browseHistory.getItems();
|
| - |
|
147 |
if(items != null){
|
| - |
|
148 |
for(WidgetItem item: items){
|
| - |
|
149 |
userClient.updateBrowseHistory(user.getUserId(), item.getItem_id());
|
| - |
|
150 |
}
|
| - |
|
151 |
}
|
| - |
|
152 |
}
|
| - |
|
153 |
}
|
| - |
|
154 |
|
| 139 |
userinfo.setCartId(user.getActiveCartId());
|
155 |
userinfo.setCartId(user.getActiveCartId());
|
| 140 |
int totalItems = userClient.getCart(userinfo.getCartId()).getLinesSize();
|
156 |
int totalItems = userClient.getCart(userinfo.getCartId()).getLinesSize();
|
| 141 |
userinfo.setTotalItems(totalItems);
|
157 |
userinfo.setTotalItems(totalItems);
|
| 142 |
|
158 |
|
| 143 |
return true;
|
159 |
return true;
|