Subversion Repositories SmartDukaan

Rev

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

Rev 9414 Rev 9667
Line 1... Line 1...
1
package in.shop2020.mobileapi.serving.utils;
1
package in.shop2020.mobileapi.serving.utils;
2
 
2
 
3
import in.shop2020.metamodel.util.ContentPojo;
3
import in.shop2020.metamodel.util.ContentPojo;
4
import in.shop2020.storage.mongo.StorageManager;
4
import in.shop2020.storage.mongo.StorageManager;
-
 
5
import in.shop2020.thrift.clients.CatalogClient;
5
import in.shop2020.metamodel.util.ProductPojo;
6
import in.shop2020.metamodel.util.ProductPojo;
6
import in.shop2020.mobileapi.serving.controllers.CategoryController;
7
import in.shop2020.mobileapi.serving.controllers.CategoryController;
-
 
8
import in.shop2020.mobileapi.serving.pojos.CartLinePojo;
-
 
9
import in.shop2020.mobileapi.serving.pojos.CartPojo;
7
import in.shop2020.mobileapi.serving.pojos.MenuPojo;
10
import in.shop2020.mobileapi.serving.pojos.MenuPojo;
-
 
11
import in.shop2020.model.v1.catalog.Item;
-
 
12
import in.shop2020.model.v1.user.Cart;
-
 
13
import in.shop2020.model.v1.user.Line;
8
 
14
 
9
import java.util.ArrayList;
15
import java.util.ArrayList;
10
import java.util.List;
16
import java.util.List;
11
 
17
 
12
import org.apache.commons.lang.StringUtils;
18
import org.apache.commons.lang.StringUtils;
Line 121... Line 127...
121
				pp = null;
127
				pp = null;
122
			}
128
			}
123
		}
129
		}
124
		return pp;
130
		return pp;
125
	}
131
	}
-
 
132
	
-
 
133
	public static CartPojo getCartPojo(Cart cart, String errorMsg) {
-
 
134
	    CartPojo cartPojo = new CartPojo();
-
 
135
	    cartPojo.setCouponCode(cart.getCouponCode());
-
 
136
	    cartPojo.setDiscountedPrice(cart.getDiscountedPrice());
-
 
137
	    cartPojo.setId(cart.getId());
-
 
138
	    cartPojo.setMessage(errorMsg);
-
 
139
	    cartPojo.setPickupStoreId(cart.getPickupStoreId());
-
 
140
	    cartPojo.setTotalPrice(cart.getTotalPrice());
-
 
141
	    
-
 
142
	    List<CartLinePojo> linepojos = new ArrayList<CartLinePojo>();
-
 
143
	    
-
 
144
	    for(Line line : cart.getLines()) {
-
 
145
	        CartLinePojo linepojo = new CartLinePojo();
-
 
146
	        linepojo.setActualPrice(line.getActualPrice());
-
 
147
	        linepojo.setDataProtectionAmount(line.getDataProtectionAmount());
-
 
148
	        linepojo.setDataProtectionInsurer(line.getDataProtectionInsurer());
-
 
149
	        linepojo.setDataProtectionAvailable(true); //TODO
-
 
150
	        linepojo.setDiscountedPrice(line.getDiscountedPrice());
-
 
151
	        linepojo.setInsuranceAmount(line.getInsuranceAmount());
-
 
152
	        linepojo.setInsurer(line.getInsurer());
-
 
153
	        linepojo.setTheftInsuranceAvailable(true);//TODO
-
 
154
	        linepojo.setQuantity(line.getQuantity());
-
 
155
	        
-
 
156
	        try {
-
 
157
	            CatalogClient csc = new CatalogClient();
-
 
158
	            Item item = csc.getClient().getItem(line.getItemId());
-
 
159
	            linepojo.setName(item.getBrand() + " " + item.getModelName() + " " + item.getModelNumber());
-
 
160
	            linepojo.setColor(item.getColor());
-
 
161
	            
-
 
162
	            linepojos.add(linepojo);
-
 
163
	            
-
 
164
	        } catch(Exception e) {
-
 
165
	            log.error("Error in getting item with id : " + line.getItemId(), e);
-
 
166
	        }
-
 
167
	    }
-
 
168
	    cartPojo.setLines(linepojos);
-
 
169
        return cartPojo;
-
 
170
	    
-
 
171
	}
126
    
172
    
127
}
173
}
-
 
174