Subversion Repositories SmartDukaan

Rev

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

Rev 10673 Rev 10763
Line 4... Line 4...
4
import in.shop2020.metamodel.util.ProductPojo;
4
import in.shop2020.metamodel.util.ProductPojo;
5
import in.shop2020.mobileapi.serving.pojos.CartLinePojo;
5
import in.shop2020.mobileapi.serving.pojos.CartLinePojo;
6
import in.shop2020.mobileapi.serving.pojos.CartPojo;
6
import in.shop2020.mobileapi.serving.pojos.CartPojo;
7
import in.shop2020.mobileapi.serving.pojos.MenuPojo;
7
import in.shop2020.mobileapi.serving.pojos.MenuPojo;
8
import in.shop2020.mobileapi.serving.pojos.RechargeAmountPojo;
8
import in.shop2020.mobileapi.serving.pojos.RechargeAmountPojo;
-
 
9
import in.shop2020.model.v1.catalog.CatalogService;
-
 
10
import in.shop2020.model.v1.catalog.InsurerType;
9
import in.shop2020.model.v1.catalog.Item;
11
import in.shop2020.model.v1.catalog.Item;
10
import in.shop2020.model.v1.user.Cart;
12
import in.shop2020.model.v1.user.Cart;
11
import in.shop2020.model.v1.user.Line;
13
import in.shop2020.model.v1.user.Line;
12
import in.shop2020.storage.mongo.StorageManager;
14
import in.shop2020.storage.mongo.StorageManager;
13
import in.shop2020.thrift.clients.CatalogClient;
15
import in.shop2020.thrift.clients.CatalogClient;
Line 115... Line 117...
115
		ContentPojo cp = StorageManager.getById(StorageManager.views.siteContent, entityId, ContentPojo.class);
117
		ContentPojo cp = StorageManager.getById(StorageManager.views.siteContent, entityId, ContentPojo.class);
116
		ProductPojo pp = null;
118
		ProductPojo pp = null;
117
		if(cp!=null){
119
		if(cp!=null){
118
			try {
120
			try {
119
			pp = new ProductPojo();
121
			pp = new ProductPojo();
-
 
122
			pp.setId(cp.getId());
120
			pp.setOfferText(cp.getOfferText());
123
			pp.setOfferText(cp.getOfferText());
121
			pp.setDescription(StringUtils.join(cp.getKeySpecs().subList(0, 3),", "));
124
			pp.setDescription(StringUtils.join(cp.getKeySpecs().subList(0, 3),", "));
122
			pp.setImageUrl(cp.getIconImageUrl());
125
			pp.setImageUrl(cp.getIconImageUrl());
123
			pp.setUrl(cp.getUrl());
126
			pp.setUrl(cp.getUrl());
124
			pp.setMrp(cp.getItems().get(0).getMrp());
127
			pp.setMrp(cp.getItems().get(0).getMrp());
Line 132... Line 135...
132
			}
135
			}
133
		}
136
		}
134
		return pp;
137
		return pp;
135
	}
138
	}
136
	
139
	
137
	public static CartPojo getCartPojo(Cart cart, String errorMsg, String pincode, Boolean needInsuranceInfo) {
140
	public static CartPojo getCartPojo (Cart cart, String errorMsg, String pincode, Boolean needInsuranceInfo) throws Exception{
138
	    CartPojo cartPojo = new CartPojo();
141
	    CartPojo cartPojo = new CartPojo();
139
	    cartPojo.setCouponCode(cart.getCouponCode());
142
	    cartPojo.setCouponCode(cart.getCouponCode());
140
	    cartPojo.setDiscountedPrice(cart.getDiscountedPrice());
143
	    cartPojo.setDiscountedPrice(cart.getDiscountedPrice());
141
	    cartPojo.setId(cart.getId());
144
	    cartPojo.setId(cart.getId());
142
	    cartPojo.setMessage(errorMsg);
145
	    cartPojo.setMessage(errorMsg);
143
	    cartPojo.setPickupStoreId(cart.getPickupStoreId());
146
	    cartPojo.setPickupStoreId(cart.getPickupStoreId());
144
	    cartPojo.setTotalPrice(cart.getTotalPrice());
147
	    cartPojo.setTotalPrice(cart.getTotalPrice());
145
	    cartPojo.setNeedInsuranceInfo(needInsuranceInfo);
148
	    cartPojo.setNeedInsuranceInfo(needInsuranceInfo);
146
	    
149
	    
147
	    List<CartLinePojo> linepojos = new ArrayList<CartLinePojo>();
150
	    List<CartLinePojo> linepojos = new ArrayList<CartLinePojo>();
148
	    
-
 
-
 
151
	    CatalogService.Client catalogClient = new CatalogClient().getClient();
149
	    for(Line line : cart.getLines()) {
152
	    for(Line line : cart.getLines()) {
150
	        CartLinePojo linepojo = new CartLinePojo();
153
	        CartLinePojo linepojo = new CartLinePojo();
151
	        linepojo.setItemId(line.getItemId());
154
	        linepojo.setItemId(line.getItemId());
152
	        linepojo.setActualPrice(line.getActualPrice());
155
	        linepojo.setActualPrice(line.getActualPrice());
153
	        linepojo.setDataProtectionAmount(line.getDataProtectionAmount());
156
	        linepojo.setDataProtectionAmount(line.getDataProtectionAmount());
154
	        linepojo.setDataProtectionInsurer(line.getDataProtectionInsurer());
157
	        linepojo.setDataProtectionInsurer(line.getDataProtectionInsurer());
155
	        linepojo.setDataProtectionAvailable(true); //TODO
158
	        linepojo.setDataProtectionAvailable(catalogClient.getPrefferedInsurerForItem(line.getItemId(), InsurerType.DATA)>0);
156
	        linepojo.setDiscountedPrice(line.getDiscountedPrice());
159
	        linepojo.setDiscountedPrice(line.getDiscountedPrice());
157
	        linepojo.setInsuranceAmount(line.getInsuranceAmount());
160
	        linepojo.setInsuranceAmount(line.getInsuranceAmount());
158
	        linepojo.setInsurer(line.getInsurer());
161
	        linepojo.setInsurer(line.getInsurer());
159
	        linepojo.setTheftInsuranceAvailable(true);//TODO
162
	        linepojo.setTheftInsuranceAvailable(catalogClient.getPrefferedInsurerForItem(line.getItemId(), InsurerType.DEVICE)>0);
160
	        linepojo.setQuantity(line.getQuantity());
163
	        linepojo.setQuantity(line.getQuantity());
161
	        linepojo.setLogisticsInfo(in.shop2020.mobileapi.serving.services.LogisticsService.getLogisticsInfo(line.getItemId(), pincode));
164
	        linepojo.setLogisticsInfo(in.shop2020.mobileapi.serving.services.LogisticsService.getLogisticsInfo(line.getItemId(), pincode));
162
	        
165
	        
163
	        try {
166
	        try {
164
	            CatalogClient csc = new CatalogClient();
167
	            CatalogClient csc = new CatalogClient();