Subversion Repositories SmartDukaan

Rev

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

Rev 9477 Rev 9573
Line 143... Line 143...
143
			txn.setTransactionStatus(TransactionStatus.INIT);
143
			txn.setTransactionStatus(TransactionStatus.INIT);
144
			txn.setStatusDescription("Order for Snapdeal ");
144
			txn.setStatusDescription("Order for Snapdeal ");
145
			List<in.shop2020.model.v1.order.Order> orderlist = new ArrayList<in.shop2020.model.v1.order.Order>();
145
			List<in.shop2020.model.v1.order.Order> orderlist = new ArrayList<in.shop2020.model.v1.order.Order>();
146
			try {
146
			try {
147
				catalogClient =  new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
147
				catalogClient =  new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
148
				try{
-
 
149
					sku = Long.parseLong(order.getSKUCode());
148
				snapdealItem = catalogClient.getSnapdealItembySkuAtSnapdeal(order.getSKUCode());
-
 
149
				if(snapdealItem.getItem_id()!=0){
150
					snapdealItem = catalogClient.getSnapdealItem(Long.parseLong(order.getSKUCode()));
150
					sku = snapdealItem.getItem_id();
151
				}
151
				}
152
				catch(NumberFormatException e){
-
 
153
					snapdealItem = catalogClient.getSnapdealItembySkuAtSnapdeal(order.getSKUCode());
-
 
154
					if(snapdealItem.getItem_id()!=0){
-
 
155
						sku = snapdealItem.getItem_id();
-
 
156
					}
-
 
157
					else{
152
				else{
158
						sb.append(order.getSuborderId() +" "+"SKU not found "+"\n");
153
					sb.append(order.getSuborderId() +" "+"SKU not found "+"\n");
159
						continue;
154
					continue;
160
					}
-
 
161
				}
155
				}
162
				if(snapdealItem.getExceptionPrice()!=0 && snapdealItem.getItem_id()!=0 && (order.getSellingPricePerItem() <  snapdealItem.getExceptionPrice())){
156
				if(snapdealItem.getExceptionPrice()!=0 && snapdealItem.getItem_id()!=0 && (order.getSellingPricePerItem() <  snapdealItem.getExceptionPrice())){
163
					SellingPrice = snapdealItem.getExceptionPrice();
157
					SellingPrice = snapdealItem.getExceptionPrice();
164
				}
158
				}
165
				else{
159
				else{
Line 243... Line 237...
243
					inventoryClient = new InventoryClient().getClient();
237
					inventoryClient = new InventoryClient().getClient();
244
					List<Warehouse> warehouses = inventoryClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, fulfillmentWarehouse.getVendor().getId(), 0, 0);
238
					List<Warehouse> warehouses = inventoryClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, fulfillmentWarehouse.getVendor().getId(), 0, 0);
245
					for(Warehouse warehouse : warehouses) {
239
					for(Warehouse warehouse : warehouses) {
246
						if(warehouse.getBillingWarehouseId()!=0) {
240
						if(warehouse.getBillingWarehouseId()!=0) {
247
							billingWarehouseId = warehouse.getBillingWarehouseId();
241
							billingWarehouseId = warehouse.getBillingWarehouseId();
248
			                break;
242
							break;
249
						}
243
						}
250
					}
244
					}
251
				}else {
245
				}else {
252
					billingWarehouseId = fulfillmentWarehouse.getBillingWarehouseId();
246
					billingWarehouseId = fulfillmentWarehouse.getBillingWarehouseId();
253
				}
247
				}
254
			        
248
 
255
				//logger.info("Billing warehouse id for suborderid  " + order.getSuborderId() + " is " + fulfillmentWarehouse.getBillingWarehouseId());
249
				//logger.info("Billing warehouse id for suborderid  " + order.getSuborderId() + " is " + fulfillmentWarehouse.getBillingWarehouseId());
256
				t_order.setWarehouse_id(billingWarehouseId);
250
				t_order.setWarehouse_id(billingWarehouseId);
257
				VendorItemPricing vendorItemPricing = new VendorItemPricing();
251
				VendorItemPricing vendorItemPricing = new VendorItemPricing();
258
				if(fulfillmentWarehouse.getId()==7) {
252
				if(fulfillmentWarehouse.getId()==7) {
259
					Item item = new CatalogClient().getClient().getItem(lineItem.getItem_id());
253
					Item item = new CatalogClient().getClient().getItem(lineItem.getItem_id());
260
					vendorItemPricing = inventoryClient.getItemPricing(lineItem.getItem_id(), item.getPreferredVendor());
254
					vendorItemPricing = inventoryClient.getItemPricing(lineItem.getItem_id(), item.getPreferredVendor());
261
				} else {
255
				} else {
262
					vendorItemPricing = inventoryClient.getItemPricing(lineItem.getItem_id(), fulfillmentWarehouse.getVendor().getId());
256
					vendorItemPricing = inventoryClient.getItemPricing(lineItem.getItem_id(), fulfillmentWarehouse.getVendor().getId());
263
				}
257
				}
264
				
258
 
265
				t_order.getLineitems().get(0).setTransfer_price(vendorItemPricing.getTransferPrice());
259
				t_order.getLineitems().get(0).setTransfer_price(vendorItemPricing.getTransferPrice());
266
				t_order.getLineitems().get(0).setNlc(vendorItemPricing.getNlc());
260
				t_order.getLineitems().get(0).setNlc(vendorItemPricing.getNlc());
267
			} catch (InventoryServiceException e) {
261
			} catch (InventoryServiceException e) {
268
				logger.error("Error connecting inventory service for suborderid  " + order.getSuborderId() , e);
262
				logger.error("Error connecting inventory service for suborderid  " + order.getSuborderId() , e);
269
				sb.append(order.getSuborderId() + " Inventory Service Exception" + " " + "\n");
263
				sb.append(order.getSuborderId() + " Inventory Service Exception" + " " + "\n");
Line 449... Line 443...
449
			snapdealOrder.setListingPrice(order.getSellingPricePerItem());
443
			snapdealOrder.setListingPrice(order.getSellingPricePerItem());
450
			snapdealOrder.setMaxNlc(snapdealItem.getMaxNlc());
444
			snapdealOrder.setMaxNlc(snapdealItem.getMaxNlc());
451
			try {
445
			try {
452
				transaction_client.createSnapdealOrder(snapdealOrder);
446
				transaction_client.createSnapdealOrder(snapdealOrder);
453
				new PaymentClient().getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, Long.toString(subOrderId), null, PaymentStatus.SUCCESS, null, null);
447
				new PaymentClient().getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, Long.toString(subOrderId), null, PaymentStatus.SUCCESS, null, null);
454
				
448
 
455
			} catch (TException e) {
449
			} catch (TException e) {
456
				logger.error("Could not create Snapdeal Order");
450
				logger.error("Could not create Snapdeal Order");
457
				sb.append(order.getSuborderId() + " Could not create snapdeal order"+"\n");
451
				sb.append(order.getSuborderId() + " Could not create snapdeal order"+"\n");
458
			} catch (PaymentException e) {
452
			} catch (PaymentException e) {
459
				logger.error("Could not update payment for Snapdeal Order");
453
				logger.error("Could not update payment for Snapdeal Order");
Line 512... Line 506...
512
 
506
 
513
 
507
 
514
	}
508
	}
515
 
509
 
516
	public static long createPayment(User user, String subOrderId, double amount) throws NumberFormatException, PaymentException, TException {
510
	public static long createPayment(User user, String subOrderId, double amount) throws NumberFormatException, PaymentException, TException {
517
	    in.shop2020.payments.PaymentService.Client client = new PaymentClient().getClient();
511
		in.shop2020.payments.PaymentService.Client client = new PaymentClient().getClient();
518
        return client.createPayment(user.getUserId(), amount, SNAPDEAL_GATEWAY_ID, Long.valueOf(transactionId), false);
512
		return client.createPayment(user.getUserId(), amount, SNAPDEAL_GATEWAY_ID, Long.valueOf(transactionId), false);
519
        
513
 
520
	}   
514
	}   
521
 
515
 
522
	public static LineItem createLineItem(long itemId, double amount) throws CatalogServiceException, TException {
516
	public static LineItem createLineItem(long itemId, double amount) throws CatalogServiceException, TException {
523
		LineItem lineItem = new LineItem();
517
		LineItem lineItem = new LineItem();
524
		CatalogService.Client catalogClient = new CatalogClient().getClient();
518
		CatalogService.Client catalogClient = new CatalogClient().getClient();