Subversion Repositories SmartDukaan

Rev

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

Rev 5347 Rev 5350
Line 141... Line 141...
141
	 * @param irDataXMLSnippets
141
	 * @param irDataXMLSnippets
142
	 * @throws Exception
142
	 * @throws Exception
143
	 */
143
	 */
144
	private void getProductsXML(ArrayList<String> irDataXMLSnippets) throws Exception{
144
	private void getProductsXML(ArrayList<String> irDataXMLSnippets) throws Exception{
145
		LogisticsService.Client prod_client = null;
145
		LogisticsService.Client prod_client = null;
-
 
146
		Map<Long, ItemCouponDiscount> couponsAndDiscounts = new HashMap<Long, ItemCouponDiscount>();
-
 
147
		
146
		try {
148
		try {
147
			LogisticsClient logistics_prod = new LogisticsClient("logistics_service_prod_server_host","logistics_service_prod_server_port");
149
			LogisticsClient logistics_prod = new LogisticsClient("logistics_service_prod_server_host","logistics_service_prod_server_port");
148
			prod_client = logistics_prod.getClient();
150
			prod_client = logistics_prod.getClient();
-
 
151
			
-
 
152
			List<Long> itemIds = new ArrayList<Long>();
-
 
153
			
-
 
154
			for(Long entityId: entityIdItemMap.keySet()){
-
 
155
				
-
 
156
				List<Item> items = entityIdItemMap.get(entityId);
-
 
157
				Item firstItem = items.get(0);
-
 
158
				
-
 
159
				if(isMobile(firstItem) || isLaptop(firstItem)) {
-
 
160
					itemIds.add(firstItem.getId());
-
 
161
				}
-
 
162
			}
-
 
163
			
-
 
164
			PromotionClient promotionClient = new PromotionClient();
-
 
165
			in.shop2020.model.v1.user.PromotionService.Client promotionServiceClient = promotionClient.getClient();
-
 
166
			
-
 
167
			List<ItemCouponDiscount> itemsCouponsAndDiscounts = promotionServiceClient.getItemDiscountMap(itemIds);
-
 
168
			
-
 
169
			for (ItemCouponDiscount itemCouponDiscount: itemsCouponsAndDiscounts) {
-
 
170
				couponsAndDiscounts.put(itemCouponDiscount.getItemId(), itemCouponDiscount);
-
 
171
			}
-
 
172
			
149
		} catch (Exception e) {
173
		} catch (Exception e) {
150
			prod_client = null;
174
			prod_client = null;
151
			Utils.info("Logistics estimations can't be fetched as Logistics Service is inaccessible"
175
			Utils.info("Logistics estimations can't be fetched as Logistics Service is inaccessible" + e);
152
					+ e);
-
 
153
		}
176
		}
-
 
177
		
154
		for(Long entityId: entityIdItemMap.keySet()){
178
		for(Long entityId: entityIdItemMap.keySet()){
155
			List<Item> items = entityIdItemMap.get(entityId);
179
			List<Item> items = entityIdItemMap.get(entityId);
156
			Item firstItem = items.get(0);
180
			Item firstItem = items.get(0);
157
			
181
			
158
			if(!isMobile(firstItem) && !isTablet(firstItem))	{
182
			if(!isMobile(firstItem) && !isTablet(firstItem))	{
Line 170... Line 194...
170
						
194
						
171
			String imageUrl = "http://static" + ((entityId+1)%3) + ".saholic.com" + File.separator + "images" + File.separator +
195
			String imageUrl = "http://static" + ((entityId+1)%3) + ".saholic.com" + File.separator + "images" + File.separator +
172
			                  "website" + File.separator + entityId + File.separator + "icon.jpg";
196
			                  "website" + File.separator + entityId + File.separator + "icon.jpg";
173
 
197
 
174
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductURL>" + url + "</ProductURL>");
198
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductURL>" + url + "</ProductURL>");
175
 
-
 
176
			
199
			
-
 
200
			double minPrice = getMinPrice(items);
-
 
201
			
-
 
202
			if(couponsAndDiscounts.containsKey(firstItem.getId()))	{
-
 
203
				
-
 
204
				int discountedPrice = (int)(minPrice - couponsAndDiscounts.get(firstItem.getId()).getDiscount());
-
 
205
				irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductPrice>" + discountedPrice + "</ProductPrice>");
-
 
206
				
-
 
207
			} else	{
177
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductPrice>" + getMinPrice(items) + "</ProductPrice>");
208
				irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductPrice>" + minPrice + "</ProductPrice>");
-
 
209
			}
178
			
210
			
179
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + getMinMRP(items) + "</ProductMRP>");
211
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + getMinMRP(items) + "</ProductMRP>");
180
			
212
			
181
			LogisticsInfo logisticsInfo = null;
213
			LogisticsInfo logisticsInfo = null;
182
			if(prod_client != null){
214
			if(prod_client != null){
Line 499... Line 531...
499
//		items.addAll(cl.getClient().getAllItemsByStatus(status.PAUSED_BY_RISK));
531
//		items.addAll(cl.getClient().getAllItemsByStatus(status.PAUSED_BY_RISK));
500
 
532
 
501
		Map<Long, List<Item>> entityIdItemMap1 = new HashMap<Long, List<Item>>();
533
		Map<Long, List<Item>> entityIdItemMap1 = new HashMap<Long, List<Item>>();
502
		ProductListGenerator pl = new ProductListGenerator(entityIdItemMap1);
534
		ProductListGenerator pl = new ProductListGenerator(entityIdItemMap1);
503
		pl.populateEntityIdItemMap(items);
535
		pl.populateEntityIdItemMap(items);
504
		pl.generateXMLFeedForMobileSite();
536
		pl.generateProductsListXML();
505
	}
537
	}
506
}
538
}
507
539