Subversion Repositories SmartDukaan

Rev

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

Rev 8528 Rev 8727
Line 1... Line 1...
1
package com.amazonaws.mws.samples;
1
package com.amazonaws.mws.samples;
2
 
2
 
3
import in.shop2020.thrift.clients.HelperClient;
3
import in.shop2020.thrift.clients.HelperClient;
4
import in.shop2020.thrift.clients.TransactionClient;
-
 
5
 
4
 
6
import java.io.FileNotFoundException;
5
import java.io.FileNotFoundException;
7
import java.io.FileOutputStream;
6
import java.io.FileOutputStream;
8
import java.io.FileReader;
7
import java.io.FileReader;
9
import java.io.IOException;
8
import java.io.IOException;
Line 33... Line 32...
33
import com.amazonaws.mws.model.IdList;
32
import com.amazonaws.mws.model.IdList;
34
import com.amazonaws.mws.model.RequestReportRequest;
33
import com.amazonaws.mws.model.RequestReportRequest;
35
import com.amazonaws.mws.samples.GetReportSample;
34
import com.amazonaws.mws.samples.GetReportSample;
36
 
35
 
37
public class FeedbackRequestEmailSender {
36
public class FeedbackRequestEmailSender {
38
 
-
 
39
	protected static Logger log = Logger.getLogger(FeedbackRequestEmailSender.class);
37
	protected static Logger log = Logger.getLogger(FeedbackRequestEmailSender.class);
-
 
38
 
-
 
39
	public RequestReportRequest getReportRequest(String merchantId, IdList marketplaces, String reporttype, String reportOptions, XMLGregorianCalendar startDate, XMLGregorianCalendar endDate){
-
 
40
		System.out.println("In method of getting Report Request");
-
 
41
		RequestReportRequest reqReportRequest = new RequestReportRequest()
-
 
42
		.withMerchant(merchantId)
-
 
43
		.withMarketplaceIdList(marketplaces)
-
 
44
		.withReportType(reporttype)
-
 
45
		.withReportOptions(reportOptions);
-
 
46
		reqReportRequest.setStartDate(startDate);
-
 
47
		reqReportRequest.setEndDate(endDate);
-
 
48
		System.out.println("Got Report Request");
-
 
49
		return reqReportRequest;
-
 
50
	}
-
 
51
	
-
 
52
	public String getReportRequestId(MarketplaceWebService webservice, RequestReportRequest reqReportRequest){
-
 
53
		System.out.println("In method of getting Report Request Id");
-
 
54
		String requestReportRequestId = null;
-
 
55
		while(true){
-
 
56
			try {
-
 
57
				requestReportRequestId = RequestReportSample.invokeRequestReport(webservice, reqReportRequest);
-
 
58
				break;
-
 
59
			} catch (MarketplaceWebServiceException e1) {
-
 
60
				// TODO Auto-generated catch block
-
 
61
				e1.printStackTrace();
-
 
62
			}
-
 
63
		}
-
 
64
		System.out.println("Got Report Request Id");
-
 
65
		System.out.println(requestReportRequestId);
-
 
66
		System.out.println("requestReportRequestId success");
-
 
67
		return requestReportRequestId;
-
 
68
	}
-
 
69
	
-
 
70
	
-
 
71
	 public Map<String,String> getrequestReportIdmap(String merchantId, MarketplaceWebService webservice, String requestReportRequestId){
-
 
72
		 System.out.println("In method of getting Report Request Id Map");
-
 
73
		 Map<String,String> requestReportIdmap;
-
 
74
	whileLoop:while(true){
-
 
75
		     GetReportListRequest requestShipmentReportList = new GetReportListRequest();
-
 
76
			 requestShipmentReportList.setMerchant( merchantId );
-
 
77
	
-
 
78
			 final IdList shipmentReportRequestIdList = new IdList(Arrays.asList(requestReportRequestId));        
-
 
79
			 requestShipmentReportList.setReportRequestIdList(shipmentReportRequestIdList);
-
 
80
			 
-
 
81
			 requestReportIdmap = GetReportListSample.invokeGetReportList(webservice, requestShipmentReportList);
-
 
82
			
-
 
83
			 if(requestReportIdmap.get(requestReportRequestId)!=null){
-
 
84
				 break whileLoop;
-
 
85
			 }
-
 
86
			 else{ 
-
 
87
				log.info("Report not ready\n");
-
 
88
				try {
-
 
89
					Thread.sleep(5*60*1000);
-
 
90
				} catch (InterruptedException e) {
-
 
91
					System.out.println("Error During getting Map Response");
-
 
92
					log.error("Error During getting Response :- ", e);
-
 
93
				}
-
 
94
			 }
-
 
95
		 }
-
 
96
		 System.out.println("Got Report Request Id Map");
-
 
97
		 return requestReportIdmap;
-
 
98
	 }
-
 
99
	
-
 
100
	public void writeReportLocally(MarketplaceWebService webservice, String merchantId, String reportId, String filePath, String reportType){
-
 
101
		System.out.println("In method of writting Report");
-
 
102
		GetReportRequest requestReport = new GetReportRequest();
-
 
103
		requestReport.setMerchant( merchantId );		
-
 
104
 
-
 
105
		requestReport.setReportId(reportId);
-
 
106
		OutputStream report=null;
-
 
107
		try {
-
 
108
			report = new FileOutputStream(filePath);
-
 
109
		} catch (FileNotFoundException e) {
-
 
110
			log.error("Error Getting Shipment Report :- ", e);
-
 
111
		}
-
 
112
		requestReport.setReportOutputStream( report );
-
 
113
		GetReportSample.invokeGetReport(webservice, requestReport);
-
 
114
 
-
 
115
		System.out.println(reportType +" Report ready please check");
-
 
116
	}
-
 
117
	
-
 
118
	public CSVReader getReportReader(String filePath, String reportType){
-
 
119
		System.out.println("In method of getting report reader");
-
 
120
		CSVReader reportReader = null; 
-
 
121
		try {
-
 
122
			reportReader = new CSVReader(new FileReader(filePath),'\t');
-
 
123
		} catch (FileNotFoundException e) {
-
 
124
			System.out.println("Error Reading "+reportType+" Report ");
-
 
125
			log.error("Error Reading Shipment Report :- ", e);
-
 
126
		}
-
 
127
		System.out.println("Got Report reader");
-
 
128
		return reportReader;
-
 
129
	}
-
 
130
	
-
 
131
	public List<String> getFBACustomerEmails(CSVReader shpmntReportReader, CSVReader rtrnsReportReader, DatatypeFactory df){
-
 
132
		
-
 
133
		List<String> fbaCustomersEmails  = new ArrayList<String>();
-
 
134
		
-
 
135
		String [] shipmentReportData;
-
 
136
		String [] returnsReportData;
-
 
137
 
-
 
138
		boolean matchFoundInReturns= false;
-
 
139
		System.out.println("In method of getting email ids");
-
 
140
		try {
-
 
141
			while ((shipmentReportData = shpmntReportReader.readNext()) != null) {
-
 
142
				if(!shipmentReportData[0].equalsIgnoreCase("amazon-order-id")){
-
 
143
					returnReportWhile:while((returnsReportData = rtrnsReportReader.readNext()) != null){
-
 
144
						if(!returnsReportData[1].equalsIgnoreCase("amazon-order-id")){
-
 
145
							if(shipmentReportData[0].equalsIgnoreCase(returnsReportData[1])){
-
 
146
								matchFoundInReturns= true;
-
 
147
								break returnReportWhile;
-
 
148
							}
-
 
149
							else{
-
 
150
								XMLGregorianCalendar shipmentDate= df.newXMLGregorianCalendar(shipmentReportData[8].substring(0, shipmentReportData[8].indexOf("T")));
-
 
151
								XMLGregorianCalendar estimatedDate= df.newXMLGregorianCalendar(shipmentReportData[44].substring(0, shipmentReportData[44].indexOf("T")));
-
 
152
								if(shipmentDate.compare(estimatedDate)==-1)
-
 
153
									matchFoundInReturns= false;
-
 
154
							}
-
 
155
						}
-
 
156
					}
-
 
157
 
-
 
158
				if(!matchFoundInReturns){
-
 
159
					fbaCustomersEmails.add(shipmentReportData[10]);
-
 
160
				}
-
 
161
				}
-
 
162
 
-
 
163
			}
-
 
164
		} catch (IOException e) {
-
 
165
			log.error("Error Reading IO operations :- ", e);
-
 
166
		}
-
 
167
		System.out.println("Got email ids");
-
 
168
		return fbaCustomersEmails;
-
 
169
	}
-
 
170
	
40
	public static void main(String... args){
171
	public static void main(String... args){
-
 
172
		
41
		/************************************************************************
173
		/************************************************************************
42
		 * Access Key ID and Secret Access Key ID, obtained from:
174
		 * Access Key ID and Secret Access Key ID, obtained from:
43
		 * http://aws.amazon.com
175
		 * http://aws.amazon.com
44
		 ***********************************************************************/
176
		 ***********************************************************************/
-
 
177
		
45
		final String accessKeyId = "AKIAII3SGRXBJDPCHSGQ";
178
		final String accessKeyId = "AKIAII3SGRXBJDPCHSGQ";
46
		final String secretAccessKey = "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";
179
		final String secretAccessKey = "B92xTbNBTYygbGs98w01nFQUhbec1pNCkCsKVfpg";
47
 
180
 
48
		final String appName = "Test";
181
		final String appName = "Test";
49
		final String appVersion = "1.0";
182
		final String appVersion = "1.0";
50
		final String merchantId = "AF6E3O0VE0X4D";
183
		final String merchantId = "AF6E3O0VE0X4D";
51
 
-
 
52
		MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
-
 
53
 
-
 
54
		/************************************************************************
184
		/************************************************************************
55
		 * Uncomment to set the appropriate MWS endpoint.
185
		 * Uncomment to set the appropriate MWS endpoint.
56
		 ************************************************************************/
186
		 ************************************************************************/
57
		// US
187
		// US
58
		// config.setServiceURL("https://mws.amazonservices.com");
188
		// config.setServiceURL("https://mws.amazonservices.com");
Line 69... Line 199...
69
		// China
199
		// China
70
		// config.setServiceURL("https://mws.amazonservices.com.cn");
200
		// config.setServiceURL("https://mws.amazonservices.com.cn");
71
		// Canada
201
		// Canada
72
		// config.setServiceURL("https://mws.amazonservices.ca");
202
		// config.setServiceURL("https://mws.amazonservices.ca");
73
		// India
203
		// India
74
		config.setServiceURL("https://mws.amazonservices.in");
-
 
-
 
204
		
75
 
205
		
76
		/************************************************************************
206
		/************************************************************************
77
		 * You can also try advanced configuration options. Available options are:
207
		 * You can also try advanced configuration options. Available options are:
78
		 *
208
		 *
79
		 *  - Signature Version
209
		 *  - Signature Version
80
		 *  - Proxy Host and Proxy Port
210
		 *  - Proxy Host and Proxy Port
Line 83... Line 213...
83
		 ***********************************************************************/
213
		 ***********************************************************************/
84
 
214
 
85
		/************************************************************************
215
		/************************************************************************
86
		 * Instantiate Http Client Implementation of Marketplace Web Service        
216
		 * Instantiate Http Client Implementation of Marketplace Web Service        
87
		 ***********************************************************************/
217
		 ***********************************************************************/
-
 
218
		
88
 
219
 
-
 
220
		MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
-
 
221
		config.setServiceURL("https://mws.amazonservices.in");
89
		MarketplaceWebService service = new MarketplaceWebServiceClient(
222
		MarketplaceWebService service = new MarketplaceWebServiceClient(
90
				accessKeyId, secretAccessKey, appName, appVersion, config);
223
				accessKeyId, secretAccessKey, appName, appVersion, config);
91
 
224
 
92
		/************************************************************************
225
		/************************************************************************
93
		 * Uncomment to try out Mock Service that simulates Marketplace Web Service 
226
		 * Uncomment to try out Mock Service that simulates Marketplace Web Service 
Line 113... Line 246...
113
		// marketplaces from which data should be included in the report; look at the
246
		// marketplaces from which data should be included in the report; look at the
114
		// API reference document on the MWS website to see which marketplaces are
247
		// API reference document on the MWS website to see which marketplaces are
115
		// included if you do not specify the list yourself
248
		// included if you do not specify the list yourself
116
		final IdList marketplaces = new IdList(Arrays.asList(
249
		final IdList marketplaces = new IdList(Arrays.asList(
117
		"A21TJRUUN4KGV"));        
250
		"A21TJRUUN4KGV"));        
118
		RequestReportRequest fullfilledShipmentReportRequest = new RequestReportRequest()
-
 
119
		.withMerchant(merchantId)
-
 
120
		.withMarketplaceIdList(marketplaces)
-
 
121
		.withReportType("_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_")
-
 
122
		.withReportOptions("ShowSalesChannel=true");
-
 
123
 
-
 
124
		RequestReportRequest returnsReportRequest = new RequestReportRequest()
251
		FeedbackRequestEmailSender feedbackRequestEmailSender = new FeedbackRequestEmailSender();
125
		.withMerchant(merchantId)
-
 
126
		.withMarketplaceIdList(marketplaces)
-
 
127
		.withReportType("_GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA_")
-
 
128
		.withReportOptions("ShowSalesChannel=true");
-
 
129
 
252
		
130
		// demonstrates how to set the date range
253
		// demonstrates how to set the date range
131
		DatatypeFactory df = null;
254
		DatatypeFactory df = null;
132
		try {
255
		try {
133
			df = DatatypeFactory.newInstance();
256
			df = DatatypeFactory.newInstance();
134
		} catch (DatatypeConfigurationException e) {
257
		} catch (DatatypeConfigurationException e) {
135
			e.printStackTrace();
258
			e.printStackTrace();
136
			throw new RuntimeException(e);
259
			throw new RuntimeException(e);
137
		}
260
		}
138
		Calendar start_Date= new GregorianCalendar();
261
		Calendar current_Date= new GregorianCalendar();
139
 
262
 
140
		XMLGregorianCalendar endDate2 = df.newXMLGregorianCalendar(new GregorianCalendar(start_Date.get(Calendar.YEAR),start_Date.get(Calendar.MONTH),start_Date.get(Calendar.DAY_OF_MONTH)));
263
		XMLGregorianCalendar endDateReturnReport = df.newXMLGregorianCalendar(new GregorianCalendar(current_Date.get(Calendar.YEAR),current_Date.get(Calendar.MONTH),current_Date.get(Calendar.DAY_OF_MONTH)));
141
 
264
 
142
		start_Date.add(Calendar.DAY_OF_MONTH, -21);
265
		current_Date.add(Calendar.DAY_OF_MONTH, -21);
143
 
266
 
144
		XMLGregorianCalendar startDate = df.newXMLGregorianCalendar(new GregorianCalendar(start_Date.get(Calendar.YEAR),start_Date.get(Calendar.MONTH),start_Date.get(Calendar.DAY_OF_MONTH)));
267
		XMLGregorianCalendar startDateBoth = df.newXMLGregorianCalendar(new GregorianCalendar(current_Date.get(Calendar.YEAR),current_Date.get(Calendar.MONTH),current_Date.get(Calendar.DAY_OF_MONTH)));
145
		start_Date.add(Calendar.DAY_OF_MONTH, 1);
268
		current_Date.add(Calendar.DAY_OF_MONTH, 1);
146
 
269
 
147
		XMLGregorianCalendar endDate1 = df.newXMLGregorianCalendar(new GregorianCalendar(start_Date.get(Calendar.YEAR),start_Date.get(Calendar.MONTH),start_Date.get(Calendar.DAY_OF_MONTH)));
270
		XMLGregorianCalendar endDateFullFilledReport = df.newXMLGregorianCalendar(new GregorianCalendar(current_Date.get(Calendar.YEAR),current_Date.get(Calendar.MONTH),current_Date.get(Calendar.DAY_OF_MONTH)));
148
 
271
 
-
 
272
		RequestReportRequest fullfilledShipmentReportRequest = feedbackRequestEmailSender.getReportRequest(merchantId, marketplaces, "_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_", "ShowSalesChannel=true", startDateBoth, endDateFullFilledReport);
-
 
273
		
-
 
274
		RequestReportRequest returnsReportRequest = feedbackRequestEmailSender.getReportRequest(merchantId, marketplaces, "_GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA_", "ShowSalesChannel=true", startDateBoth, endDateReturnReport);
-
 
275
		
149
		fullfilledShipmentReportRequest.setStartDate(startDate);
276
		String shipmentReportRequestId = feedbackRequestEmailSender.getReportRequestId(service, fullfilledShipmentReportRequest);
-
 
277
		
150
		fullfilledShipmentReportRequest.setEndDate(endDate1);
278
		String returnsReportRequestId = feedbackRequestEmailSender.getReportRequestId(service, returnsReportRequest);
-
 
279
		
-
 
280
		Map<String,String> requestIdShipmentReportIdmap = feedbackRequestEmailSender.getrequestReportIdmap(merchantId, service, shipmentReportRequestId);
151
 
281
 
152
		// @TODO: set additional request parameters here
-
 
153
		Map<String,String> requestIdShipmentReportIdmap;
-
 
154
 
282
 
155
		returnsReportRequest.setStartDate(startDate);
283
		Map<String,String> requestIdReturnsReportIdmap = feedbackRequestEmailSender.getrequestReportIdmap(merchantId, service, returnsReportRequestId);
156
		returnsReportRequest.setEndDate(endDate2);
-
 
157
 
284
 
158
		Map<String,String> requestIdReturnsReportIdmap;
-
 
159
 
285
		
160
		List<String> fbaCustomersEmails  = new ArrayList<String>();
-
 
161
		///Request report
286
		///Request report
162
 
287
 
163
		String emailBody= "Dear Customer, <br><br>" +
288
		String emailBody= "Dear Customer, <br><br>" +
164
		"Thank you very much for shopping with Saholic at Amazon.in .<br><br>"+
289
		"Thank you very much for shopping with Saholic at Amazon.in .<br><br>"+
165
		"We hope that you are happy with your purchase and if you are, please spare some time to leave positive feedback for us.<br><br>" +
290
		"We hope that you are happy with your purchase and if you are, please spare some time to leave positive feedback for us.<br><br>" +
Line 171... Line 296...
171
		"Please do not leave any negative feedback. If you have any problems or concerns about your recent purchase, please get in touch with our customer service as soon as possible and we will do everything we can to help.<br><br>" +
296
		"Please do not leave any negative feedback. If you have any problems or concerns about your recent purchase, please get in touch with our customer service as soon as possible and we will do everything we can to help.<br><br>" +
172
		"Yours Sincerely,<br>" +
297
		"Yours Sincerely,<br>" +
173
		"Saholic Team<br>";
298
		"Saholic Team<br>";
174
 
299
 
175
		String emailIdFrom= "help@saholic.com";
300
		String emailIdFrom= "help@saholic.com";
176
 
-
 
177
		String shipmentReportRequestId = null;		
-
 
178
		while(true){
-
 
179
 
-
 
180
			try {
-
 
181
				shipmentReportRequestId = RequestReportSample.invokeRequestReport(service, fullfilledShipmentReportRequest);
-
 
182
				break;
-
 
183
			} catch (MarketplaceWebServiceException e1) {
-
 
184
				// TODO Auto-generated catch block
-
 
185
				e1.printStackTrace();
-
 
186
			}
-
 
187
		}
-
 
188
		String returnsReportRequestId = null;
-
 
189
		while(true){
-
 
190
			try {
-
 
191
				returnsReportRequestId = RequestReportSample.invokeRequestReport(service, returnsReportRequest);
-
 
192
				break;
-
 
193
			} catch (MarketplaceWebServiceException e1) {
-
 
194
				// TODO Auto-generated catch block
-
 
195
				e1.printStackTrace();
-
 
196
			}
-
 
197
		}
-
 
198
		while(true){
-
 
199
			GetReportListRequest requestShipmentReportList = new GetReportListRequest();
-
 
200
			requestShipmentReportList.setMerchant( merchantId );
-
 
201
 
-
 
202
			GetReportListRequest requestReturnsReportList = new GetReportListRequest();
-
 
203
			requestReturnsReportList.setMerchant( merchantId );
-
 
204
 
-
 
205
			final IdList shipmentReportRequestIdList = new IdList(Arrays.asList(shipmentReportRequestId));        
-
 
206
			requestShipmentReportList.setReportRequestIdList(shipmentReportRequestIdList);
-
 
207
			///Request report status
-
 
208
			requestIdShipmentReportIdmap = GetReportListSample.invokeGetReportList(service, requestShipmentReportList);
-
 
209
 
-
 
210
			final IdList returnsReportRequestIdList = new IdList(Arrays.asList(returnsReportRequestId));        
-
 
211
			requestReturnsReportList.setReportRequestIdList(returnsReportRequestIdList);
-
 
212
 
-
 
213
			requestIdReturnsReportIdmap= GetReportListSample.invokeGetReportList(service, requestReturnsReportList);
-
 
214
 
-
 
215
			///Fetch report only if it is ready
301
			//Fetch report only if it is ready
216
			if(requestIdShipmentReportIdmap.get(shipmentReportRequestId)!=null && requestIdReturnsReportIdmap.get(returnsReportRequestId)!=null){
302
		feedbackRequestEmailSender.writeReportLocally(service, merchantId, requestIdShipmentReportIdmap.get(shipmentReportRequestId), "/tmp/AmazonFullFilledShipmentReport.txt", "Fullfilled Shipment");
217
				GetReportRequest requestShipmentReport = new GetReportRequest();
-
 
218
				requestShipmentReport.setMerchant( merchantId );
-
 
219
 
-
 
220
				GetReportRequest requestReturnsReport = new GetReportRequest();
-
 
221
				requestReturnsReport.setMerchant( merchantId );
-
 
222
 
-
 
223
				requestShipmentReport.setReportId( requestIdShipmentReportIdmap.get(shipmentReportRequestId) );
303
		feedbackRequestEmailSender.writeReportLocally(service, merchantId, requestIdReturnsReportIdmap.get(returnsReportRequestId), "/tmp/AmazonReturnsReport.txt", "Returns");	
224
				OutputStream shipmentReport=null;
-
 
225
				try {
-
 
226
					shipmentReport = new FileOutputStream( "/tmp/AmazonFullFilledShipmentReport.txt" );
-
 
227
				} catch (FileNotFoundException e) {
-
 
228
					log.error("Error Getting Shipment Report :- ", e);
-
 
229
				}
304
		
230
				requestShipmentReport.setReportOutputStream( shipmentReport );
-
 
231
				GetReportSample.invokeGetReport(service, requestShipmentReport);
-
 
232
 
-
 
233
				System.out.println("Shipment Report ready please check\n");
-
 
234
				CSVReader shipmentReportReader = null; 
-
 
235
				try {
-
 
236
					shipmentReportReader = new CSVReader(new FileReader("/tmp/AmazonFullFilledShipmentReport.txt"),'\t');
305
		CSVReader shipmentReportReader = feedbackRequestEmailSender.getReportReader("/tmp/AmazonFullFilledShipmentReport.txt", "Fullfilled Shipment") ;
237
				} catch (FileNotFoundException e) {
-
 
238
					log.error("Error Reading Shipment Report :- ", e);
-
 
239
				}
-
 
240
 
-
 
241
				requestReturnsReport.setReportId( requestIdReturnsReportIdmap.get(returnsReportRequestId) );
-
 
242
				OutputStream returnsReport=null;
-
 
243
				try {
-
 
244
					returnsReport = new FileOutputStream( "/tmp/AmazonReturnsReport.txt" );
-
 
245
				} catch (FileNotFoundException e) {
-
 
246
					log.error("Error Getting Returns Report :- ", e);
-
 
247
				}
-
 
248
				requestReturnsReport.setReportOutputStream( returnsReport );
-
 
249
				GetReportSample.invokeGetReport(service, requestReturnsReport);
-
 
250
 
-
 
251
				System.out.println("Return Report ready please check\n");
-
 
252
				CSVReader returnsReportReader = null; 
-
 
253
				try {
-
 
254
					returnsReportReader = new CSVReader(new FileReader("/tmp/AmazonReturnsReport.txt"),'\t');
306
		CSVReader returnsReportReader = feedbackRequestEmailSender.getReportReader("/tmp/AmazonReturnsReport.txt", "Returns") ; 
255
				} catch (FileNotFoundException e) {
-
 
256
					log.error("Error Reading Returns Report :- ", e);
-
 
257
				}
307
				
258
 
-
 
259
 
-
 
260
				String [] shipmentReportData;
-
 
261
				String [] returnsReportData;
-
 
262
 
-
 
263
				boolean matchFoundInReturns= false;
-
 
264
 
-
 
265
				try {
-
 
266
					while ((shipmentReportData = shipmentReportReader.readNext()) != null) {
-
 
267
						if(!shipmentReportData[0].equalsIgnoreCase("amazon-order-id")){
-
 
268
							returnReportWhile:while((returnsReportData = returnsReportReader.readNext()) != null){
-
 
269
								if(!returnsReportData[1].equalsIgnoreCase("amazon-order-id")){
-
 
270
									if(shipmentReportData[0].equalsIgnoreCase(returnsReportData[1])){
-
 
271
										matchFoundInReturns= true;
-
 
272
										break returnReportWhile;
-
 
273
									}
-
 
274
									else{
-
 
275
										XMLGregorianCalendar shipmentDate= df.newXMLGregorianCalendar(shipmentReportData[8].substring(0, shipmentReportData[8].indexOf("T")));
-
 
276
										XMLGregorianCalendar estimatedDate= df.newXMLGregorianCalendar(shipmentReportData[44].substring(0, shipmentReportData[44].indexOf("T")));
308
		List<String> fbaCustomersEmails  = feedbackRequestEmailSender.getFBACustomerEmails(shipmentReportReader, returnsReportReader, df);
277
										if(shipmentDate.compare(estimatedDate)==-1)
-
 
278
											matchFoundInReturns= false;
-
 
279
									}
-
 
280
								}
-
 
281
							}
-
 
282
 
-
 
283
						if(!matchFoundInReturns){
-
 
284
							fbaCustomersEmails.add(shipmentReportData[10]);
-
 
285
						}
-
 
286
						}
-
 
287
 
-
 
288
					}
-
 
289
				} catch (IOException e) {
-
 
290
					log.error("Error Reading IO operations :- ", e);
-
 
291
				} 
-
 
292
 
-
 
293
				break;
-
 
294
			}
-
 
295
			else{ 
-
 
296
				log.info("Report not ready\n");
-
 
297
				try {
-
 
298
					Thread.sleep(5*60*1000);
-
 
299
				} catch (InterruptedException e) {
-
 
300
					log.error("Error During getting Response :- ", e);
-
 
301
				}
-
 
302
			}
-
 
303
		}
-
 
304
 
309
 
305
		HelperClient helperServiceClient;
310
		HelperClient helperServiceClient;
306
		try {
311
		try {
307
			helperServiceClient = new HelperClient("helper_service_server_host_prod", "helper_service_server_port_prod");
312
			helperServiceClient = new HelperClient("helper_service_server_host_prod", "helper_service_server_port_prod");
308
			in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
313
			in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
Line 320... Line 325...
320
		// Note that depending on the type of report being downloaded, a report can reach 
325
		// Note that depending on the type of report being downloaded, a report can reach 
321
		// sizes greater than 1GB. For this reason we recommend that you _always_ program to
326
		// sizes greater than 1GB. For this reason we recommend that you _always_ program to
322
		// MWS in a streaming fashion. Otherwise, as your business grows you may silently reach
327
		// MWS in a streaming fashion. Otherwise, as your business grows you may silently reach
323
		// the in-memory size limit and have to re-work your solution.
328
		// the in-memory size limit and have to re-work your solution.
324
		//
329
		//
325
		System.exit(1);
330
		System.exit(0);
326
 
331
 
327
	}
332
	}
328
 
333
 
329
}
334
}