| 317 |
ashish |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.serving.controllers;
|
|
|
5 |
|
| 650 |
rajveer |
6 |
|
| 2306 |
vikas |
7 |
import in.shop2020.datalogger.EventType;
|
| 4934 |
amit.gupta |
8 |
import in.shop2020.logistics.DeliveryType;
|
| 9840 |
amit.gupta |
9 |
import in.shop2020.logistics.ItemText;
|
| 11672 |
anikendra |
10 |
import in.shop2020.logistics.LogisticsInfo;
|
| 4934 |
amit.gupta |
11 |
import in.shop2020.logistics.LogisticsService;
|
| 11672 |
anikendra |
12 |
import in.shop2020.logistics.LogisticsServiceException;
|
| 12620 |
amit.gupta |
13 |
import in.shop2020.model.v1.catalog.ExclusiveAffiliateItemInfo;
|
| 2306 |
vikas |
14 |
import in.shop2020.model.v1.catalog.Item;
|
|
|
15 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
| 3242 |
vikas |
16 |
import in.shop2020.serving.cache.EhcacheWrapper;
|
| 3561 |
rajveer |
17 |
import in.shop2020.serving.services.ContentServingService;
|
|
|
18 |
import in.shop2020.serving.utils.SnippetType;
|
| 12620 |
amit.gupta |
19 |
import in.shop2020.serving.utils.Utils;
|
| 3126 |
rajveer |
20 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 4934 |
amit.gupta |
21 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 3126 |
rajveer |
22 |
import in.shop2020.thrift.clients.UserClient;
|
| 2511 |
vikas |
23 |
import in.shop2020.utils.DataLogger;
|
| 375 |
ashish |
24 |
|
| 317 |
ashish |
25 |
import java.io.IOException;
|
| 11672 |
anikendra |
26 |
import java.text.SimpleDateFormat;
|
| 9840 |
amit.gupta |
27 |
import java.util.ArrayList;
|
| 11672 |
anikendra |
28 |
import java.util.Calendar;
|
|
|
29 |
import java.util.GregorianCalendar;
|
| 3225 |
vikas |
30 |
import java.util.HashMap;
|
| 4934 |
amit.gupta |
31 |
import java.util.List;
|
| 375 |
ashish |
32 |
import java.util.Map;
|
| 11970 |
amit.gupta |
33 |
import java.util.Set;
|
| 317 |
ashish |
34 |
|
| 3225 |
vikas |
35 |
import net.sf.ehcache.CacheManager;
|
|
|
36 |
|
| 5026 |
varun.gupt |
37 |
import org.apache.commons.lang.StringUtils;
|
| 832 |
rajveer |
38 |
import org.apache.log4j.Logger;
|
| 507 |
rajveer |
39 |
import org.apache.struts2.convention.annotation.Action;
|
|
|
40 |
import org.apache.struts2.convention.annotation.Actions;
|
| 974 |
vikas |
41 |
import org.apache.struts2.convention.annotation.Result;
|
| 2306 |
vikas |
42 |
import org.apache.struts2.convention.annotation.Results;
|
| 11672 |
anikendra |
43 |
import org.apache.thrift.TException;
|
| 2306 |
vikas |
44 |
import org.json.JSONException;
|
|
|
45 |
import org.json.JSONObject;
|
| 317 |
ashish |
46 |
|
| 4934 |
amit.gupta |
47 |
import com.google.gson.Gson;
|
|
|
48 |
|
| 317 |
ashish |
49 |
/**
|
|
|
50 |
*
|
| 650 |
rajveer |
51 |
* @author rajveer
|
| 317 |
ashish |
52 |
*
|
|
|
53 |
*/
|
| 650 |
rajveer |
54 |
|
| 2306 |
vikas |
55 |
@Results({
|
|
|
56 |
@Result(name = "show", location = "entity-show.vm"),
|
| 5266 |
rajveer |
57 |
@Result(name = "redirect", location = "${redirectUrl}", type = "redirect", params={"statusCode", "301"})
|
| 2306 |
vikas |
58 |
})
|
| 650 |
rajveer |
59 |
public class EntityController extends BaseController {
|
|
|
60 |
|
|
|
61 |
private static final long serialVersionUID = 1L;
|
| 1957 |
vikas |
62 |
private static Logger log = Logger.getLogger(Class.class);
|
| 11672 |
anikendra |
63 |
private Long firstItem = 0l;
|
| 3225 |
vikas |
64 |
private static final String PRODUCT_PROERTIES_SNIPPET_KEY = "PRODUCT_PROPERTIES";
|
|
|
65 |
private static final String PRODUCT_SUMMARY_SNIPPET_KEY = "PRODUCT_SUMMARY";
|
|
|
66 |
private static final String PRODUCT_SLIDEGUIDE_KEY = "SLIDEGUIDE";
|
| 11964 |
amit.gupta |
67 |
private static final String ENTITY_DETAIL_KEY = "ENTITY_DETAIL";
|
| 11672 |
anikendra |
68 |
private String entityLogisticsEstimation = "[]";
|
| 5037 |
rajveer |
69 |
private static final String DEFAULT_PINCODE = "110001";
|
| 317 |
ashish |
70 |
private String id;
|
| 2306 |
vikas |
71 |
private String redirectUrl;
|
| 620 |
rajveer |
72 |
private long productId;
|
| 2867 |
rajveer |
73 |
private boolean isMobile = false;
|
| 12620 |
amit.gupta |
74 |
private List<ExclusiveAffiliateItemInfo> entityItemsExclusiveInfo = new ArrayList<ExclusiveAffiliateItemInfo>();
|
| 2867 |
rajveer |
75 |
|
| 12620 |
amit.gupta |
76 |
public List<ExclusiveAffiliateItemInfo> getEntityItemsExclusiveInfo() {
|
|
|
77 |
return entityItemsExclusiveInfo;
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
public String getEntityItemsExclusiveInfoJson(){
|
|
|
81 |
return new Gson().toJson(entityItemsExclusiveInfo);
|
|
|
82 |
}
|
|
|
83 |
|
| 6084 |
rajveer |
84 |
private Map<String, Double> discounts = new HashMap<String, Double>();
|
| 3225 |
vikas |
85 |
private Map<String, String> snippets;
|
| 5094 |
phani.kuma |
86 |
private static Map<Long, String> label = new HashMap<Long, String>();
|
| 11672 |
anikendra |
87 |
|
|
|
88 |
public static Map<Integer, String> businessDayToActualDateMap = new HashMap<Integer, String>();
|
|
|
89 |
private Map<String, String> deliveryEstimate = new HashMap<String, String>();
|
|
|
90 |
|
| 5094 |
phani.kuma |
91 |
static{
|
|
|
92 |
setRetargettingLabel();
|
|
|
93 |
}
|
| 3225 |
vikas |
94 |
|
| 375 |
ashish |
95 |
public EntityController(){
|
|
|
96 |
super();
|
|
|
97 |
}
|
| 507 |
rajveer |
98 |
|
| 974 |
vikas |
99 |
// GET /*/1000001
|
| 507 |
rajveer |
100 |
@Actions({
|
| 974 |
vikas |
101 |
@Action("/mobile-phones"),
|
| 5873 |
amit.gupta |
102 |
@Action("/cameras"),
|
| 1005 |
vikas |
103 |
@Action("/mobile-accessories"),
|
| 2460 |
rajveer |
104 |
@Action("/tablets"),
|
| 3715 |
rajveer |
105 |
@Action("/laptops"),
|
| 5182 |
varun.gupt |
106 |
@Action("/laptop-accessories"),
|
| 6593 |
amit.gupta |
107 |
@Action("/entity"),
|
| 8315 |
amit.gupta |
108 |
@Action("/music-players"),
|
| 12525 |
amit.gupta |
109 |
@Action("/smart-watches"),
|
| 13236 |
amit.gupta |
110 |
@Action("/projectors"),
|
|
|
111 |
@Action("/smart-watch-accessories")
|
| 507 |
rajveer |
112 |
})
|
| 2306 |
vikas |
113 |
public String show() throws SecurityException, IOException, JSONException {
|
| 317 |
ashish |
114 |
log.info("id=" + id);
|
| 637 |
rajveer |
115 |
|
| 2306 |
vikas |
116 |
String entityUrl = "";
|
|
|
117 |
String metaDescription = "";
|
|
|
118 |
String pageTitle = "";
|
| 2434 |
rajveer |
119 |
String productName = "";
|
| 3830 |
chandransh |
120 |
String categoryName = "";
|
|
|
121 |
String categoryUrl = "";
|
| 2652 |
rajveer |
122 |
String displayAccessories = "FALSE";
|
| 3830 |
chandransh |
123 |
String breadCrumb = "";
|
| 5347 |
amit.gupta |
124 |
String parentCategory = "";
|
| 5930 |
amit.gupta |
125 |
String compareCategory = "";
|
| 10190 |
amit.gupta |
126 |
String isComparable = "false";
|
| 2306 |
vikas |
127 |
try {
|
| 3225 |
vikas |
128 |
setSnippets();
|
|
|
129 |
htmlSnippets.put("PRODUCT_PROPERTIES", snippets.get(PRODUCT_PROERTIES_SNIPPET_KEY));
|
|
|
130 |
JSONObject productPropertiesInJson = new JSONObject(htmlSnippets.get("PRODUCT_PROPERTIES"));
|
| 2306 |
vikas |
131 |
entityUrl = productPropertiesInJson.getString("entityUrl");
|
|
|
132 |
metaDescription = productPropertiesInJson.getString("metaDescription");
|
|
|
133 |
pageTitle = productPropertiesInJson.getString("title");
|
| 2434 |
rajveer |
134 |
productName = productPropertiesInJson.getString("name");
|
| 3830 |
chandransh |
135 |
categoryName = productPropertiesInJson.getString("categoryName");
|
|
|
136 |
categoryUrl = productPropertiesInJson.getString("categoryUrl");
|
| 2652 |
rajveer |
137 |
displayAccessories = productPropertiesInJson.getString("displayAccessories");
|
| 3830 |
chandransh |
138 |
breadCrumb = productPropertiesInJson.getString("breadCrumb");
|
| 5347 |
amit.gupta |
139 |
parentCategory = productPropertiesInJson.getString("parentCategory");
|
| 5930 |
amit.gupta |
140 |
compareCategory = productPropertiesInJson.getString("compareCategory");
|
| 10190 |
amit.gupta |
141 |
isComparable = productPropertiesInJson.getString("isComparable");
|
| 2306 |
vikas |
142 |
}
|
|
|
143 |
catch (JSONException e) {
|
| 4965 |
rajveer |
144 |
log.warn("Unable to parse product properties JSON", e);
|
| 2306 |
vikas |
145 |
try {
|
| 3126 |
rajveer |
146 |
CatalogClient catalogClientService = new CatalogClient();
|
| 5945 |
mandeep.dh |
147 |
in.shop2020.model.v1.catalog.CatalogService.Client client = catalogClientService.getClient();
|
| 2306 |
vikas |
148 |
|
|
|
149 |
Item item = client.getItemsByCatalogId(productId).get(0);
|
| 2307 |
vikas |
150 |
redirectUrl = "/" + item.getBrand().toLowerCase().replace(" ", "-");
|
| 2306 |
vikas |
151 |
} catch (Exception e1) {
|
| 4965 |
rajveer |
152 |
log.warn("Unable to get items by catalog id", e1);
|
| 2306 |
vikas |
153 |
redirectUrl = "/";
|
|
|
154 |
}
|
|
|
155 |
log.info(redirectUrl);
|
|
|
156 |
return "redirect";
|
|
|
157 |
}
|
|
|
158 |
String currentUrl = request.getRequestURL().toString();
|
| 1197 |
varun.gupt |
159 |
|
| 2306 |
vikas |
160 |
if (!currentUrl.contains(entityUrl)) {
|
|
|
161 |
redirectUrl = entityUrl;
|
|
|
162 |
return "redirect";
|
|
|
163 |
}
|
|
|
164 |
|
| 2434 |
rajveer |
165 |
//Extracting base url
|
| 1689 |
rajveer |
166 |
String rootUrl = currentUrl.split("/")[2];
|
| 2194 |
varun.gupt |
167 |
|
| 3225 |
vikas |
168 |
htmlSnippets.put("PRODUCT_SUMMARY", snippets.get(PRODUCT_SUMMARY_SNIPPET_KEY));
|
| 1258 |
varun.gupt |
169 |
htmlSnippets.put("PRODUCT_ID", productId + "");
|
|
|
170 |
htmlSnippets.put("PRODUCT_NAME", productName);
|
| 3830 |
chandransh |
171 |
htmlSnippets.put("CATEGORY_NAME", categoryName);
|
|
|
172 |
htmlSnippets.put("CATEGORY_URL", categoryUrl);
|
| 1689 |
rajveer |
173 |
htmlSnippets.put("PRODUCT_URL", currentUrl);
|
| 2194 |
varun.gupt |
174 |
htmlSnippets.put("ROOT_URL", "http://" + rootUrl);
|
| 3225 |
vikas |
175 |
htmlSnippets.put("SLIDE_GUIDE", snippets.get(PRODUCT_SLIDEGUIDE_KEY));
|
| 1269 |
varun.gupt |
176 |
htmlSnippets.put("PAGE_TITLE", pageTitle.trim());
|
| 2306 |
vikas |
177 |
htmlSnippets.put("PAGE_METADESC", metaDescription);
|
| 3830 |
chandransh |
178 |
htmlSnippets.put("BREADCRUMB", breadCrumb);
|
| 5347 |
amit.gupta |
179 |
htmlSnippets.put("PARENT_CATEGORY", parentCategory);
|
| 5930 |
amit.gupta |
180 |
htmlSnippets.put("COMPARE_CATEGORY", compareCategory);
|
| 10190 |
amit.gupta |
181 |
htmlSnippets.put("IS_COMPARABLE", isComparable);
|
| 3830 |
chandransh |
182 |
|
| 2652 |
rajveer |
183 |
if(displayAccessories.equals("TRUE")){
|
| 2867 |
rajveer |
184 |
setMobile(true);
|
| 2652 |
rajveer |
185 |
}
|
|
|
186 |
|
| 650 |
rajveer |
187 |
try {
|
| 5188 |
rajveer |
188 |
if(userinfo.getUserId() != -1){
|
|
|
189 |
long itemId = Long.parseLong(id);
|
|
|
190 |
UserClient userServiceClient = new UserClient();
|
|
|
191 |
Client client = userServiceClient.getClient();
|
|
|
192 |
client.updateBrowseHistory(userinfo.getUserId(), itemId);
|
| 1511 |
rajveer |
193 |
}
|
| 650 |
rajveer |
194 |
|
| 449 |
rajveer |
195 |
} catch (Exception e) {
|
| 2949 |
chandransh |
196 |
log.warn("Unable to update the browsing history because of: ", e);
|
| 449 |
rajveer |
197 |
}
|
| 4494 |
varun.gupt |
198 |
|
| 12616 |
anikendra |
199 |
// DataLogger.logData(EventType.PRODUCT_VIEW, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), userinfo.getPincode(),
|
|
|
200 |
// productName, Long.toString(productId), StringUtils.substring(request.getHeader("referer"), 0, 500));
|
| 11672 |
anikendra |
201 |
|
|
|
202 |
try {
|
| 11676 |
amit.gupta |
203 |
setEntityLogisticsEstimation();
|
| 12620 |
amit.gupta |
204 |
getDeliveryEstimate(firstItem, userinfo.getPincode());
|
| 11672 |
anikendra |
205 |
} catch (Exception e1) {
|
|
|
206 |
log.warn("Unable to get delivery estimates for "+ id);
|
|
|
207 |
}
|
| 2149 |
vikas |
208 |
return "show";
|
| 317 |
ashish |
209 |
}
|
| 11672 |
anikendra |
210 |
|
|
|
211 |
/**
|
|
|
212 |
*
|
|
|
213 |
* @return
|
|
|
214 |
*/
|
|
|
215 |
public void getDeliveryEstimate(Long itemId, String pincode){
|
|
|
216 |
LogisticsClient logisticsServiceClient = null;
|
|
|
217 |
String days = "-1";
|
|
|
218 |
long businessDays = -1;
|
|
|
219 |
boolean isCODAvailable=false;
|
|
|
220 |
boolean isOTGAvailable=false;
|
|
|
221 |
String codDays = "-1";
|
|
|
222 |
try {
|
|
|
223 |
logisticsServiceClient = new LogisticsClient();
|
|
|
224 |
LogisticsService.Client logisticsClient = logisticsServiceClient.getClient();
|
|
|
225 |
LogisticsInfo logistincInfo = logisticsClient.getLogisticsEstimation(itemId, pincode, DeliveryType.PREPAID);
|
|
|
226 |
|
|
|
227 |
if(logistincInfo.getDeliveryTime()!=-1L){
|
|
|
228 |
days = getDeliveryDateString((int)logistincInfo.getDeliveryTime(), DeliveryType.PREPAID);
|
|
|
229 |
if(logistincInfo.isCodAllowed()){
|
|
|
230 |
codDays = getDeliveryDateString((int)(logistincInfo.getDeliveryTime()), DeliveryType.COD);
|
|
|
231 |
}
|
|
|
232 |
}
|
|
|
233 |
businessDays = logistincInfo.getDeliveryTime();
|
|
|
234 |
isCODAvailable = logistincInfo.isCodAllowed();
|
|
|
235 |
isOTGAvailable = logistincInfo.isOtgAvailable();
|
|
|
236 |
|
|
|
237 |
log.info("busines days = " + businessDays + "is COD avaialbale " + isCODAvailable + "is OTG available " + isOTGAvailable + " days "+days+" cod days "+codDays);
|
|
|
238 |
} catch (LogisticsServiceException e) {
|
|
|
239 |
log.error("Unable to get estimate/COD availability for " + itemId, e);
|
|
|
240 |
} catch(TException e) {
|
|
|
241 |
|
|
|
242 |
} catch (Exception e) {
|
|
|
243 |
|
|
|
244 |
}
|
|
|
245 |
deliveryEstimate.put("delivery_estimate", days);
|
|
|
246 |
deliveryEstimate.put("cod_delivery_estimate", codDays);
|
|
|
247 |
deliveryEstimate.put("is_cod_available_for_location", Boolean.toString(isCODAvailable));
|
|
|
248 |
deliveryEstimate.put("on_time_guarantee", Boolean.toString(isOTGAvailable));
|
|
|
249 |
deliveryEstimate.put("business_days", businessDays + "");
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
private static String getDeliveryDateString(int days, DeliveryType type) throws TException {
|
|
|
253 |
Calendar now = new GregorianCalendar();
|
|
|
254 |
int hour = now.get(Calendar.HOUR_OF_DAY);
|
|
|
255 |
if(type == DeliveryType.COD && hour < 15){
|
|
|
256 |
days = days + 1;
|
|
|
257 |
}
|
|
|
258 |
if(businessDayToActualDateMap.containsKey(days)){
|
|
|
259 |
if(hour != 0){
|
|
|
260 |
return businessDayToActualDateMap.get(days);
|
|
|
261 |
}
|
|
|
262 |
businessDayToActualDateMap.clear();
|
|
|
263 |
}
|
|
|
264 |
|
|
|
265 |
now.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
|
|
|
266 |
|
|
|
267 |
LogisticsClient logisticsServiceClient = null;
|
|
|
268 |
logisticsServiceClient = new LogisticsClient();
|
|
|
269 |
LogisticsService.Client logisticsClient = logisticsServiceClient.getClient();
|
|
|
270 |
|
|
|
271 |
int newdays = (int) logisticsClient.adjustDeliveryDays(now.getTimeInMillis(), days);
|
|
|
272 |
now.add(Calendar.DAY_OF_MONTH, newdays);
|
|
|
273 |
|
|
|
274 |
SimpleDateFormat dateformat = new SimpleDateFormat("EEE dd-MMM-yy");
|
|
|
275 |
if(newdays == 1){
|
|
|
276 |
businessDayToActualDateMap.put(days, "Tomorrow, " + dateformat.format(now.getTime()));
|
|
|
277 |
}else{
|
|
|
278 |
businessDayToActualDateMap.put(days, dateformat.format(now.getTime()));
|
|
|
279 |
}
|
|
|
280 |
return businessDayToActualDateMap.get(days);
|
|
|
281 |
}
|
| 3225 |
vikas |
282 |
|
| 317 |
ashish |
283 |
/**
|
|
|
284 |
*
|
|
|
285 |
* @param id
|
|
|
286 |
*/
|
|
|
287 |
public void setId(String id) {
|
| 4831 |
varun.gupt |
288 |
String[] tokens = id.split("-");
|
|
|
289 |
this.id = tokens[tokens.length - 1];
|
| 974 |
vikas |
290 |
this.productId = Long.parseLong(this.id);
|
| 317 |
ashish |
291 |
}
|
|
|
292 |
|
| 387 |
rajveer |
293 |
public Map<String,String> getHtmlSnippets(){
|
| 388 |
rajveer |
294 |
System.out.println(" getHtmlSnippets is called");
|
| 387 |
rajveer |
295 |
return htmlSnippets;
|
| 375 |
ashish |
296 |
}
|
| 388 |
rajveer |
297 |
|
| 449 |
rajveer |
298 |
public String getSlideGuideSnippet(){
|
| 388 |
rajveer |
299 |
return htmlSnippets.get("SLIDE_GUIDE");
|
|
|
300 |
}
|
|
|
301 |
|
| 2306 |
vikas |
302 |
public String getRedirectUrl(){
|
| 5493 |
rajveer |
303 |
String query = request.getQueryString();
|
|
|
304 |
if(query!=null){
|
|
|
305 |
return redirectUrl + "?" + query;
|
|
|
306 |
}
|
|
|
307 |
return redirectUrl;
|
| 2306 |
vikas |
308 |
}
|
|
|
309 |
|
| 449 |
rajveer |
310 |
public String getProductSummarySnippet(){
|
|
|
311 |
return htmlSnippets.get("PRODUCT_SUMMARY");
|
|
|
312 |
}
|
|
|
313 |
|
| 974 |
vikas |
314 |
public String getPageTitleSnippet(){
|
|
|
315 |
return htmlSnippets.get("PAGE_TITLE");
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
public String getPageMetaDescSnippet(){
|
|
|
319 |
return htmlSnippets.get("PAGE_METADESC");
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
|
| 1197 |
varun.gupt |
323 |
public String getProductName() {
|
|
|
324 |
return htmlSnippets.get("PRODUCT_NAME");
|
|
|
325 |
}
|
| 5347 |
amit.gupta |
326 |
|
| 5930 |
amit.gupta |
327 |
public String getCompareCategory(){
|
|
|
328 |
return htmlSnippets.get("COMPARE_CATEGORY");
|
| 5347 |
amit.gupta |
329 |
}
|
|
|
330 |
|
| 5930 |
amit.gupta |
331 |
public String getCompareCategoryLowerCase(){
|
|
|
332 |
String compareCategory = htmlSnippets.get("COMPARE_CATEGORY");
|
|
|
333 |
return compareCategory.toLowerCase();
|
| 5347 |
amit.gupta |
334 |
}
|
| 1258 |
varun.gupt |
335 |
|
| 3830 |
chandransh |
336 |
public String getCategoryName() {
|
|
|
337 |
return htmlSnippets.get("CATEGORY_NAME");
|
|
|
338 |
}
|
|
|
339 |
|
|
|
340 |
public String getCategoryUrl() {
|
|
|
341 |
return htmlSnippets.get("CATEGORY_URL");
|
|
|
342 |
}
|
|
|
343 |
|
| 1258 |
varun.gupt |
344 |
public String getProductId() {
|
|
|
345 |
return htmlSnippets.get("PRODUCT_ID");
|
|
|
346 |
}
|
|
|
347 |
|
|
|
348 |
public String getProductUrl() {
|
|
|
349 |
return htmlSnippets.get("PRODUCT_URL");
|
|
|
350 |
}
|
| 1364 |
varun.gupt |
351 |
|
|
|
352 |
public String getRootUrl() {
|
|
|
353 |
return htmlSnippets.get("ROOT_URL");
|
|
|
354 |
}
|
| 2867 |
rajveer |
355 |
|
| 3830 |
chandransh |
356 |
public String getBreadCrumb(){
|
|
|
357 |
return htmlSnippets.get("BREADCRUMB");
|
|
|
358 |
}
|
| 10190 |
amit.gupta |
359 |
|
|
|
360 |
public String isComparable(){
|
|
|
361 |
return htmlSnippets.get("IS_COMPARABLE");
|
|
|
362 |
}
|
| 3830 |
chandransh |
363 |
|
| 2867 |
rajveer |
364 |
/**
|
|
|
365 |
* @param isMobile the isMobile to set
|
|
|
366 |
*/
|
|
|
367 |
public void setMobile(boolean isMobile) {
|
|
|
368 |
this.isMobile = isMobile;
|
| 2652 |
rajveer |
369 |
}
|
| 2867 |
rajveer |
370 |
|
|
|
371 |
/**
|
|
|
372 |
* @return the isMobile
|
|
|
373 |
*/
|
|
|
374 |
public boolean isMobile() {
|
|
|
375 |
return isMobile;
|
|
|
376 |
}
|
| 3225 |
vikas |
377 |
|
|
|
378 |
private void setSnippets() {
|
|
|
379 |
EhcacheWrapper<Long, Map<String, String>> productSnippetsCache = new EhcacheWrapper<Long, Map<String, String>>(
|
|
|
380 |
EhcacheWrapper.PRODUCT_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
|
| 3561 |
rajveer |
381 |
if(sourceId == -1){
|
|
|
382 |
snippets = productSnippetsCache.get(productId);
|
|
|
383 |
}
|
| 3225 |
vikas |
384 |
if (snippets == null) {
|
|
|
385 |
log.info("Getting product snippet for :" + productId);
|
|
|
386 |
snippets = new HashMap<String, String>();
|
| 3561 |
rajveer |
387 |
snippets.put(PRODUCT_PROERTIES_SNIPPET_KEY, ContentServingService.getSnippet(SnippetType.PRODUCT_PROPERTIES_SNIPPET, productId+"", sourceId));
|
|
|
388 |
snippets.put(PRODUCT_SUMMARY_SNIPPET_KEY, ContentServingService.getSnippet(SnippetType.PRODUCT_DETAIL_SNIPPET, productId+"", sourceId));
|
|
|
389 |
snippets.put(PRODUCT_SLIDEGUIDE_KEY, ContentServingService.getSnippet(SnippetType.SLIDE_GUIDE_SNIPPET, productId+"", sourceId));
|
| 11964 |
amit.gupta |
390 |
snippets.put(ENTITY_DETAIL_KEY, ContentServingService.getJSON(productId + ""));
|
| 3561 |
rajveer |
391 |
if(sourceId == -1){
|
|
|
392 |
productSnippetsCache.put(productId, snippets);
|
|
|
393 |
}
|
| 3225 |
vikas |
394 |
return;
|
|
|
395 |
}
|
|
|
396 |
log.info("Loaded from cache product snippet for :" + productId);
|
|
|
397 |
}
|
| 4494 |
varun.gupt |
398 |
|
|
|
399 |
public Map<String, Double> getDiscounts() {
|
|
|
400 |
return discounts;
|
|
|
401 |
}
|
| 4934 |
amit.gupta |
402 |
|
| 11672 |
anikendra |
403 |
public void setEntityLogisticsEstimation(){
|
| 9840 |
amit.gupta |
404 |
List<ItemText> itemTexts = null;
|
| 4934 |
amit.gupta |
405 |
try {
|
|
|
406 |
LogisticsClient cl = new LogisticsClient();
|
|
|
407 |
LogisticsService.Client client = cl.getClient();
|
| 9840 |
amit.gupta |
408 |
itemTexts = client.getEntityLogisticsEstimation(productId, DEFAULT_PINCODE, DeliveryType.PREPAID );
|
| 10195 |
amit.gupta |
409 |
if(itemTexts!=null){
|
|
|
410 |
List<Long> items = new ArrayList<Long>();
|
|
|
411 |
for(ItemText itemText : itemTexts) {
|
|
|
412 |
items.add(itemText.getItemId());
|
| 12633 |
amit.gupta |
413 |
ExclusiveAffiliateItemInfo ea = Utils.getExclusiveAffiliateItems().get(itemText.getItemId());
|
|
|
414 |
if(ea!=null){
|
|
|
415 |
entityItemsExclusiveInfo.add(ea);
|
|
|
416 |
}
|
| 10195 |
amit.gupta |
417 |
}
|
| 12089 |
amit.gupta |
418 |
log.info("Items before: " + itemTexts);
|
| 11970 |
amit.gupta |
419 |
if(userinfo.isPrivateDealUser()){
|
| 11973 |
amit.gupta |
420 |
log.info("Private Deal user identified");
|
| 11970 |
amit.gupta |
421 |
try {
|
|
|
422 |
CatalogClient catalogClientService = new CatalogClient();
|
|
|
423 |
in.shop2020.model.v1.catalog.CatalogService.Client client1 = catalogClientService.getClient();
|
|
|
424 |
Set<Long> deals = client1.getAllActivePrivateDeals(items, 0).keySet();
|
|
|
425 |
int lastIndex = 0;
|
|
|
426 |
for(int i=0;i<itemTexts.size();i++) {
|
|
|
427 |
ItemText it = itemTexts.get(i);
|
|
|
428 |
if(it.getDisplayText().equals("NOTIFY ME")) {
|
|
|
429 |
break;
|
|
|
430 |
}
|
| 12087 |
amit.gupta |
431 |
if(deals.contains(it.getItemId()) && lastIndex > 0) {
|
|
|
432 |
itemTexts.add(i-lastIndex,itemTexts.remove(i));
|
| 12088 |
amit.gupta |
433 |
}else if(!deals.contains(it.getItemId())){
|
| 11970 |
amit.gupta |
434 |
lastIndex++;
|
|
|
435 |
}
|
|
|
436 |
}
|
|
|
437 |
} catch (Exception e1) {
|
|
|
438 |
log.warn("Unable to get items by catalog id", e1);
|
|
|
439 |
redirectUrl = "/";
|
|
|
440 |
}
|
| 11972 |
amit.gupta |
441 |
items = new ArrayList<Long>();
|
|
|
442 |
for(ItemText itemText : itemTexts) {
|
|
|
443 |
items.add(itemText.getItemId());
|
|
|
444 |
}
|
| 12089 |
amit.gupta |
445 |
log.info("Items after: " + itemTexts);
|
| 11970 |
amit.gupta |
446 |
}
|
| 11672 |
anikendra |
447 |
firstItem = items.get(0);
|
|
|
448 |
entityLogisticsEstimation = new Gson().toJson(items);
|
|
|
449 |
return;
|
| 10195 |
amit.gupta |
450 |
}
|
| 4934 |
amit.gupta |
451 |
} catch (Exception e1) {
|
| 10190 |
amit.gupta |
452 |
log.error("Unable to get items for productId: "+ productId, e1);
|
| 4934 |
amit.gupta |
453 |
}
|
| 11672 |
anikendra |
454 |
entityLogisticsEstimation = "[]";
|
| 10195 |
amit.gupta |
455 |
|
| 4934 |
amit.gupta |
456 |
}
|
| 5094 |
phani.kuma |
457 |
|
| 11672 |
anikendra |
458 |
public String getEntityLogisticsEstimation() {
|
|
|
459 |
return entityLogisticsEstimation;
|
|
|
460 |
}
|
|
|
461 |
|
| 5094 |
phani.kuma |
462 |
private static void setRetargettingLabel() {
|
|
|
463 |
label.put((long) 1002160, "6EIBCKjf1wMQ6Pua0wM"); //Samsung Galaxy Y S5360
|
|
|
464 |
label.put((long) 1002106, "JFGVCKCt8gMQ6Pua0wM"); //Sony Ericsson Xperia Neo V MT11i
|
|
|
465 |
label.put((long) 1003230, "ArAYCJiu8gMQ6Pua0wM"); //Micromax Funbook Tab P300
|
|
|
466 |
label.put((long) 1002151, "j0c_CJCv8gMQ6Pua0wM"); //HTC Explorer (Pico) A310e
|
|
|
467 |
label.put((long) 1000607, "7H3QCKDh8wMQ6Pua0wM"); //SanDisk MicroSD 8GB
|
|
|
468 |
label.put((long) 1003213, "QtGQCJji8wMQ6Pua0wM"); //Micromax SUPERFONE Gossip A78
|
|
|
469 |
label.put((long) 1002530, "0YNbCJDj8wMQ6Pua0wM"); //Samsung Champ Deluxe Duos C3312
|
|
|
470 |
label.put((long) 1003039, "pQUaCIjk8wMQ6Pua0wM"); //Samsung Star 3 Duos S5222
|
|
|
471 |
label.put((long) 1002575, "zcYTCIDl8wMQ6Pua0wM"); //Samsung Galaxy Y Duos S6102
|
|
|
472 |
}
|
|
|
473 |
|
|
|
474 |
public String getRetargettingLabel() {
|
|
|
475 |
return label.get(this.productId);
|
|
|
476 |
}
|
| 7853 |
amit.gupta |
477 |
|
|
|
478 |
|
|
|
479 |
public String getEmiObject(){
|
|
|
480 |
return ProceedToPayController.getEmiSchemesInJSON();
|
|
|
481 |
}
|
| 5491 |
rajveer |
482 |
|
| 11672 |
anikendra |
483 |
public String getDeliveryEstimate() {
|
|
|
484 |
return new Gson().toJson(this.deliveryEstimate);
|
|
|
485 |
}
|
| 11964 |
amit.gupta |
486 |
|
|
|
487 |
public String getProductJSON(){
|
|
|
488 |
if(userinfo.isPrivateDealUser()){
|
|
|
489 |
return snippets.get(ENTITY_DETAIL_KEY);
|
|
|
490 |
} else {
|
|
|
491 |
return null;
|
|
|
492 |
}
|
|
|
493 |
}
|
| 1197 |
varun.gupt |
494 |
}
|