Subversion Repositories SmartDukaan

Rev

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

Rev 9218 Rev 9280
Line 1... Line 1...
1
package in.shop2020.ui.util;
1
package in.shop2020.ui.util;
2
 
2
 
3
import in.shop2020.metamodel.definitions.Catalog;
3
import in.shop2020.metamodel.definitions.Catalog;
4
import in.shop2020.metamodel.definitions.Category;
4
import in.shop2020.metamodel.definitions.Category;
-
 
5
import in.shop2020.metamodel.util.ItemPojo;
5
import in.shop2020.model.v1.catalog.CatalogService.Client;
6
import in.shop2020.model.v1.catalog.CatalogService.Client;
6
import in.shop2020.model.v1.catalog.CatalogServiceException;
7
import in.shop2020.model.v1.catalog.CatalogServiceException;
7
import in.shop2020.model.v1.catalog.Item;
8
import in.shop2020.model.v1.catalog.Item;
8
import in.shop2020.model.v1.catalog.Source;
9
import in.shop2020.model.v1.catalog.Source;
9
import in.shop2020.model.v1.catalog.SourceItemPricing;
10
import in.shop2020.model.v1.catalog.SourceItemPricing;
Line 110... Line 111...
110
	 * @param exportPath
111
	 * @param exportPath
111
	 * @param source
112
	 * @param source
112
	 * @return
113
	 * @return
113
	 */
114
	 */
114
	public double insertPriceInHtml(List<Item> items, long catalogId, String domain, String exportPath, Source source){
115
	public double insertPriceInHtml(List<Item> items, long catalogId, String domain, String exportPath, Source source){
115
		List<Map<String, String>> itemDetails = new ArrayList<Map<String,String>>();
116
		ArrayList<Map<String, String>> itemDetails = new ArrayList<Map<String,String>>();
-
 
117
		List<ItemPojo> itemPojos = new ArrayList<ItemPojo>();
116
		String offerText = null;
118
		String offerText = null;
117
		String offerDetailText = null;
119
		String offerDetailText = null;
118
		String offerDetailLink = null;
120
		String offerDetailLink = null;
119
		String afterArrival = null;
121
		String afterArrival = null;
120
		String showPrice = "TRUE";
122
		String showPrice = "TRUE";
121
		Item minPriceItem = null;
123
		Item minPriceItem = null;
122
		for(Item item: items){
124
		for(Item item: items){
123
			Map<String, String> itemDetail = new HashMap<String, String>();
125
			Map<String, String> itemDetail = new HashMap<String, String>();
-
 
126
			ItemPojo itemPojo = new ItemPojo();
124
			boolean showmrp = true;
127
			boolean showmrp = true;
125
			double sellingPrice = item.getSellingPrice();
128
			double sellingPrice = item.getSellingPrice();
126
			double mrp = item.getMrp();
129
			double mrp = item.getMrp();
127
			
130
			
128
			if(source != null){
131
			if(source != null){
Line 143... Line 146...
143
			if(minPriceItem == null || minPriceItem.getSellingPrice() > item.getSellingPrice()){
146
			if(minPriceItem == null || minPriceItem.getSellingPrice() > item.getSellingPrice()){
144
				minPriceItem = item;
147
				minPriceItem = item;
145
			}
148
			}
146
			
149
			
147
			double saving = Math.round((mrp-sellingPrice)/mrp*100);
150
			double saving = Math.round((mrp-sellingPrice)/mrp*100);
148
			itemDetail.put("ITEM_ID", ((int)item.getId())+"");	
151
			itemDetail.put("ITEM_ID", ((int)item.getId())+"");
149
			itemDetail.put("SP", ((int)sellingPrice)+"");
152
			itemDetail.put("SP", ((int)sellingPrice)+"");
150
			itemDetail.put("MRP", ((int)mrp)+"");
153
			itemDetail.put("MRP", ((int)mrp)+"");
151
			itemDetail.put("SAVING", ((int)saving)+"");
154
			itemDetail.put("SAVING", ((int)saving)+"");
152
			itemDetail.put("COLOR", item.getColor());
155
			itemDetail.put("COLOR", item.getColor());
153
			itemDetail.put("CATALOG_ID", ((int)item.getCatalogItemId())+"");
156
			itemDetail.put("CATALOG_ID", ((int)item.getCatalogItemId())+"");
154
			itemDetail.put("SHOWMRP", showmrp +"");
157
			itemDetail.put("SHOWMRP", showmrp +"");
155
			itemDetail.put("IS_SELECTED", item.isDefaultForEntity() ? "SELECTED" : "");
158
			itemDetail.put("IS_SELECTED", item.isDefaultForEntity() ? "SELECTED" : "");
156
			itemDetails.add(itemDetail);
159
			itemDetails.add(itemDetail);
-
 
160
			itemPojo.setId(item.getId());
-
 
161
			itemPojo.setSellingPrice(item.getSellingPrice());
-
 
162
			itemPojo.setMrp(mrp);
-
 
163
			itemPojo.setColor(item.getColor());
-
 
164
			itemPojo.setMinEmi(Double.parseDouble(getEMI(item.getSellingPrice())));
157
			
165
			
158
			if(item.getItemStatus().equals(status.COMING_SOON)){
166
			if(item.getItemStatus().equals(status.COMING_SOON)){
159
				afterArrival = "after arrival";
167
				afterArrival = "after arrival";
160
				if(!item.isShowSellingPrice()){
168
				if(!item.isShowSellingPrice()){
161
					showPrice = "FALSE";
169
					showPrice = "FALSE";
Line 194... Line 202...
194
		// a particular entity are always downloaded from the same location.
202
		// a particular entity are always downloaded from the same location.
195
		String staticurl = "http://static" + catalogId%3 + "." + (domain.contains("store") ? "saholic.com":domain);
203
		String staticurl = "http://static" + catalogId%3 + "." + (domain.contains("store") ? "saholic.com":domain);
196
		
204
		
197
		
205
		
198
		VelocityContext context = new VelocityContext();
206
		VelocityContext context = new VelocityContext();
-
 
207
		String emiString = getEMI(items.get(0).getSellingPrice());
199
		context.put("domain", domain.contains("store") ? "saholic.com":domain);
208
		context.put("domain", domain.contains("store") ? "saholic.com":domain);
200
		context.put("itemDetails", itemDetails);
209
		context.put("itemDetails", itemDetails);
201
		context.put("minPriceItem", minPriceItem);
210
		context.put("minPriceItem", minPriceItem);
202
		context.put("staticurl", staticurl);
211
		context.put("staticurl", staticurl);
203
		context.put("OFFER_TEXT", offerText);
212
		context.put("OFFER_TEXT", offerText);
204
		context.put("OFFER_DETAIL_TEXT", offerDetailText);
213
		context.put("OFFER_DETAIL_TEXT", offerDetailText);
205
		context.put("OFFER_DETAIL_LINK", offerDetailLink);
214
		context.put("OFFER_DETAIL_LINK", offerDetailLink);
206
		context.put("AFTER_ARRIVAL", afterArrival);
215
		context.put("AFTER_ARRIVAL", afterArrival);
207
		context.put("SHOW_PRICE", domain.contains("store")?"FALSE":showPrice);
216
		context.put("SHOW_PRICE", domain.contains("store")?"FALSE":showPrice);
208
		context.put("IS_STORE", domain.contains("store")?"TRUE":"FALSE");
217
		context.put("IS_STORE", domain.contains("store")?"TRUE":"FALSE");
209
		context.put("EMI", getEMI(items.get(0).getSellingPrice()));
218
		context.put("EMI", emiString);
210
		List<String> filenames = new ArrayList<String>();
219
		List<String> filenames = new ArrayList<String>();
211
		if(!domain.contains("store")){		
220
		if(!domain.contains("store")){		
212
			filenames.add("WidgetSnippet");
221
			filenames.add("WidgetSnippet");
213
			filenames.add("ProductPropertiesSnippet");
222
			filenames.add("ProductPropertiesSnippet");
214
			filenames.add("MyResearchSnippet");
223
			filenames.add("MyResearchSnippet");
Line 248... Line 257...
248
        getHtmlFromVelocity(filenames,exportPath,context,catalogId);
257
        getHtmlFromVelocity(filenames,exportPath,context,catalogId);
249
        
258
        
250
        //Update catalogInfo to catalog
259
        //Update catalogInfo to catalog
251
        
260
        
252
        PojoCreator creator = new PojoCreator();
261
        PojoCreator creator = new PojoCreator();
253
        creator.updateCatalogInfo(catalogId, minPriceItem.getSellingPrice(), minPriceItem.getMrp(), offerText, null);
262
        creator.updateCatalogInfo(catalogId, minPriceItem.getSellingPrice(), minPriceItem.getMrp(), offerText, Double.parseDouble(emiString), itemPojos);
254
        return minPriceItem.getSellingPrice();
263
        return minPriceItem.getSellingPrice();
255
    }
264
    }
256
    
265
    
257
    private static String getEMI(double sellingPrice) {
266
    private static String getEMI(double sellingPrice) {
258
        String returnString = null;
267
        String returnString = null;