Subversion Repositories SmartDukaan

Rev

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

Rev 8428 Rev 8940
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
3
import in.shop2020.datalogger.EventType;
3
import in.shop2020.datalogger.EventType;
-
 
4
import in.shop2020.model.v1.order.Attribute;
4
import in.shop2020.model.v1.order.Order;
5
import in.shop2020.model.v1.order.Order;
5
import in.shop2020.model.v1.order.TransactionServiceException;
6
import in.shop2020.model.v1.order.TransactionServiceException;
6
import in.shop2020.model.v1.user.Address;
7
import in.shop2020.model.v1.user.Address;
7
import in.shop2020.model.v1.user.Cart;
8
import in.shop2020.model.v1.user.Cart;
8
import in.shop2020.model.v1.user.ShoppingCartException;
9
import in.shop2020.model.v1.user.ShoppingCartException;
Line 34... Line 35...
34
import org.apache.struts2.convention.annotation.Results;
35
import org.apache.struts2.convention.annotation.Results;
35
import org.apache.thrift.TException;
36
import org.apache.thrift.TException;
36
import org.apache.thrift.transport.TTransportException;
37
import org.apache.thrift.transport.TTransportException;
37
 
38
 
38
import com.ShipWebServiceClient;
39
import com.ShipWebServiceClient;
-
 
40
import com.fedex.ship.stub.AssociatedShipmentDetail;
39
import com.fedex.ship.stub.CompletedPackageDetail;
41
import com.fedex.ship.stub.CompletedPackageDetail;
40
import com.fedex.ship.stub.CompletedShipmentDetail;
42
import com.fedex.ship.stub.CompletedShipmentDetail;
-
 
43
import com.fedex.ship.stub.OperationalInstruction;
-
 
44
import com.fedex.ship.stub.PackageOperationalDetail;
41
import com.fedex.ship.stub.ProcessShipmentReply;
45
import com.fedex.ship.stub.ProcessShipmentReply;
-
 
46
import com.fedex.ship.stub.StringBarcode;
42
import com.fedex.ship.stub.TrackingId;
47
import com.fedex.ship.stub.TrackingId;
43
 
48
 
44
import nl.captcha.Captcha;
49
import nl.captcha.Captcha;
45
 
50
 
46
@SuppressWarnings("serial")
51
@SuppressWarnings("serial")
Line 455... Line 460...
455
				ProcessShipmentReply  processShipmentReply = ShipWebServiceClient.getShipmentCreationReply(t_order,fedexAccountInfo.getClientDetail(),fedexAccountInfo.getWad(),fedexAccountInfo.getEndPointAddress());
460
				ProcessShipmentReply  processShipmentReply = ShipWebServiceClient.getShipmentCreationReply(t_order,fedexAccountInfo.getClientDetail(),fedexAccountInfo.getWad(),fedexAccountInfo.getEndPointAddress());
456
				CompletedShipmentDetail completedShipmentDetails = processShipmentReply.getCompletedShipmentDetail();
461
				CompletedShipmentDetail completedShipmentDetails = processShipmentReply.getCompletedShipmentDetail();
457
				CompletedPackageDetail completedPackageDetails =  completedShipmentDetails.getCompletedPackageDetails(0);
462
				CompletedPackageDetail completedPackageDetails =  completedShipmentDetails.getCompletedPackageDetails(0);
458
				TrackingId  trackId= completedPackageDetails.getTrackingIds(0);
463
				TrackingId  trackId= completedPackageDetails.getTrackingIds(0);
459
				t_order = transactionClient.updateOrderAWB(t_order.getId(), trackId.getTrackingNumber());
464
				t_order = transactionClient.updateOrderAWB(t_order.getId(), trackId.getTrackingNumber());
-
 
465
				//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
-
 
466
				CompletedPackageDetail[] cpd= completedShipmentDetails.getCompletedPackageDetails();
-
 
467
				AssociatedShipmentDetail[] asdetails = completedShipmentDetails.getAssociatedShipments();
-
 
468
				List<Attribute> attrList = new ArrayList<Attribute>();
-
 
469
				if(t_order.isCod()){
-
 
470
					if(asdetails!=null){
-
 
471
						for(AssociatedShipmentDetail as : asdetails){
-
 
472
							if(as.getType().getValue().equalsIgnoreCase("COD_RETURN")){
-
 
473
								PackageOperationalDetail pod = as.getPackageOperationalDetail();
-
 
474
								StringBarcode[] barcodes = pod.getBarcodes().getStringBarcodes();
-
 
475
								for(StringBarcode bc : barcodes){
-
 
476
									Attribute attr3 = new Attribute();
-
 
477
									attr3.setName("FedEx_COD_Return_BarCode");
-
 
478
									attr3.setValue(bc.getValue());
-
 
479
									attrList.add(attr3);
-
 
480
								}
-
 
481
								
-
 
482
								String codReturnTrackingNo= as.getTrackingId().getTrackingNumber();
-
 
483
								Attribute attr4 = new Attribute();
-
 
484
								attr4.setName("FedEx_COD_Return_Tracking_No");
-
 
485
								attr4.setValue(codReturnTrackingNo);
-
 
486
								attrList.add(attr4);
-
 
487
							}
-
 
488
						}
-
 
489
					}
-
 
490
				}
-
 
491
				for(CompletedPackageDetail cd : cpd){
-
 
492
					PackageOperationalDetail pod = cd.getOperationalDetail();
-
 
493
					StringBarcode[] barcodes = pod.getBarcodes().getStringBarcodes();
-
 
494
					for(StringBarcode bc : barcodes){
-
 
495
						Attribute attr1 = new Attribute();
-
 
496
						attr1.setName("FedEx_Package_BarCode");
-
 
497
						attr1.setValue(bc.getValue());
-
 
498
						attrList.add(attr1);
-
 
499
					}
-
 
500
					OperationalInstruction[] ois = pod.getOperationalInstructions();
-
 
501
					Attribute attr2 = new Attribute();
-
 
502
					for(OperationalInstruction oi : ois){
-
 
503
						if(oi.getNumber().intValue()==5){
-
 
504
							attr2.setName("FedEx_Location_Code");
-
 
505
							attr2.setValue(oi.getContent());
-
 
506
							attrList.add(attr2);
-
 
507
						}
-
 
508
					}						
-
 
509
				}
-
 
510
				transactionClient.setOrderAttributes(t_order.getId(), attrList);
-
 
511
				//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
-
 
512
				
460
			}
513
			}
461
		} catch (TTransportException e) {
514
		} catch (TTransportException e) {
462
		    log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
515
		    log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
463
		} catch (NumberFormatException e) {
516
		} catch (NumberFormatException e) {
464
		    log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
517
		    log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);