Subversion Repositories SmartDukaan

Rev

Rev 14638 | Rev 14641 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
9651 manish.sha 1
package in.shop2020;
2
 
3
import in.shop2020.model.v1.order.OrderSource;
10178 manish.sha 4
import in.shop2020.model.v1.order.OrderStatus;
9651 manish.sha 5
import in.shop2020.thrift.clients.TransactionClient;
12428 manish.sha 6
import in.shop2020.utils.GmailUtils;
10178 manish.sha 7
 
9651 manish.sha 8
import java.io.BufferedReader;
10565 manish.sha 9
import java.io.IOException;
9651 manish.sha 10
import java.io.InputStreamReader;
10178 manish.sha 11
import java.io.UnsupportedEncodingException;
9651 manish.sha 12
import java.text.SimpleDateFormat;
13
import java.util.ArrayList;
11518 manish.sha 14
import java.util.Calendar;
9651 manish.sha 15
import java.util.Date;
9883 manish.sha 16
import java.util.HashMap;
9651 manish.sha 17
import java.util.List;
9883 manish.sha 18
import java.util.Map;
10178 manish.sha 19
 
12428 manish.sha 20
import javax.mail.MessagingException;
21
 
10178 manish.sha 22
import org.apache.http.HttpResponse;
23
import org.apache.http.NameValuePair;
10565 manish.sha 24
import org.apache.http.client.ClientProtocolException;
10178 manish.sha 25
import org.apache.http.client.HttpClient;
26
import org.apache.http.client.entity.UrlEncodedFormEntity;
27
import org.apache.http.client.methods.HttpGet;
28
import org.apache.http.client.methods.HttpPost;
14639 manish.sha 29
import org.apache.http.entity.StringEntity;
10178 manish.sha 30
import org.apache.http.impl.client.DefaultHttpClient;
31
import org.apache.http.message.BasicNameValuePair;
9651 manish.sha 32
import org.json.JSONArray;
33
import org.json.JSONObject;
10178 manish.sha 34
import org.slf4j.LoggerFactory;
9651 manish.sha 35
import org.slf4j.Logger;
36
 
10178 manish.sha 37
 
38
 
9651 manish.sha 39
public class SnapdealOrderStatusReconciliation{
40
	private static Logger logger;
12428 manish.sha 41
 
42
	static String emailFromAddress;
43
	static String password;
44
	static GmailUtils mailer;
45
	static String sendTo[];
46
 
47
	static {
48
		emailFromAddress = "build-staging@shop2020.in";
49
		password = "shop2020";
50
		mailer = new GmailUtils();
51
		sendTo = new String[] { "kshitij.sood@shop2020.in", "manish.sharma@shop2020.in", "amit.gupta@shop2020.in" };
52
	}
9651 manish.sha 53
 
12428 manish.sha 54
	public static void main(String[] args) throws UnsupportedEncodingException, MessagingException{
55
		try{
56
			logger = LoggerFactory.getLogger(SnapdealOrderStatusReconciliation.class);
57
			/*List<OrderStatus> statuses = new ArrayList<OrderStatus>();
58
			statuses.add(OrderStatus.SHIPPED_FROM_WH);
59
			statuses.add(OrderStatus.SHIPPED_TO_LOGST);*/
10178 manish.sha 60
 
12428 manish.sha 61
			Map<String,List<List<String>>> orderDataMap = new HashMap<String,List<List<String>>>();
62
			List<List<String>> deliveredOrderDataList = new ArrayList<List<String>>();
63
			List<List<String>> cancelledOrderDataList = new ArrayList<List<String>>();
64
			long minCreationDate = 0l;
65
			long currentTime = System.currentTimeMillis();
9651 manish.sha 66
 
12428 manish.sha 67
			Calendar cal = Calendar.getInstance();
68
			cal.add(Calendar.DAY_OF_MONTH, -60);
69
			minCreationDate = cal.getTimeInMillis();
70
			/*TransactionClient tsc = null;
71
			try {
72
				tsc = new TransactionClient();
73
				minCreationDate = tsc.getClient().getMinCreatedTimeStampUndeliveredOrdersForSource(OrderSource.SNAPDEAL.getValue());
74
				minCreationDate = 1393612200000l;
75
			} catch (Exception e) {
76
				logger.error("Unable to establish connection to the transaction service while getting Minimum Order Created Timstamp for Undelivered Orders ", e);
77
			}//Dec 14, 2013 12:00:00 AM  1383291412000l
78
			 */
14636 manish.sha 79
			SimpleDateFormat snapdealDateFormat = new SimpleDateFormat("yyyy/MM/dd");
12428 manish.sha 80
			SimpleDateFormat gotSnapdealDateFormat = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss aaa");
81
			SimpleDateFormat ourDBDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
82
			String startDate= "";
83
			Date start_date = new Date(minCreationDate);
84
			Date end_date = new Date(currentTime);
85
			if(minCreationDate > 0l){
86
				startDate = snapdealDateFormat.format(new Date(minCreationDate));
10565 manish.sha 87
			}
12428 manish.sha 88
			else{
89
				startDate = snapdealDateFormat.format(new Date(currentTime));
10565 manish.sha 90
			}
12428 manish.sha 91
			logger.info("Snapdeal Order Recon Start Date .. "+startDate);
92
			//startDate = startDate.replace("-", "%2F");
9731 manish.sha 93
 
12428 manish.sha 94
			String endDate = snapdealDateFormat.format(new Date(System.currentTimeMillis()));
95
			logger.info("Snapdeal Order Recon End Date .. "+endDate);
96
			//endDate = endDate.replace("-", "%2F");
10178 manish.sha 97
 
98
 
12428 manish.sha 99
			HttpClient client = new DefaultHttpClient();
10178 manish.sha 100
 
12428 manish.sha 101
			HttpGet get = new HttpGet("http://selleraccounts.snapdeal.com/keymaker/login");
102
			HttpResponse response = null;
9931 manish.sha 103
			try {
10178 manish.sha 104
				response = client.execute(get);
9931 manish.sha 105
			} catch (Exception e) {
12428 manish.sha 106
				e.printStackTrace();
107
				throw new Exception("Excption while login to snapdeal panel");
9931 manish.sha 108
			} 
12428 manish.sha 109
			BufferedReader rd = null;
9931 manish.sha 110
			try {
10178 manish.sha 111
				rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
12428 manish.sha 112
			} catch (Exception e1) {
113
				e1.printStackTrace();
114
				throw new Exception("Excption while reading login response");
9931 manish.sha 115
			} 
12428 manish.sha 116
			String line = "";
117
			StringBuffer sb = new StringBuffer();
9931 manish.sha 118
			try {
12428 manish.sha 119
				while ((line = rd.readLine()) != null) {
120
					sb.append(line);
121
					//System.out.println(line);
122
				}
123
			} catch (IOException e) {
124
				e.printStackTrace();
125
				throw new Exception("Excption while reading login response");
126
			}
127
			int i= sb.toString().indexOf("name=\"lt\" value=");
128
			char[] charArray = sb.toString().toCharArray();
129
			String lt = "";
130
			int j=0;
131
			for(j=i+16;j<=charArray.length;j++){
9651 manish.sha 132
 
12428 manish.sha 133
				if(charArray[j]==' '){
134
					break;
135
				}
136
			}
137
			lt = sb.substring(i+17,j-1);
138
			System.out.println("LT VALUE " + lt);
139
			i= sb.toString().indexOf("name=\"execution\" value=");
140
			charArray = sb.toString().toCharArray();
9651 manish.sha 141
 
12428 manish.sha 142
			String ex = "";
143
			j=0;
144
			for(j=i+24;j<=charArray.length;j++){
145
				if(charArray[j]==' '){
146
					break;
9651 manish.sha 147
				}
148
			}
12428 manish.sha 149
			ex = sb.substring(i+24,j-1);
150
			System.out.println("EXECUTION VALUE " + ex);	
10178 manish.sha 151
 
152
 
12428 manish.sha 153
 
154
			HttpPost post = new HttpPost("http://selleraccounts.snapdeal.com/login?service=http%3A%2F%2Fshipping.snapdeal.com%2Fj_spring_cas_security_check");
155
			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
156
			//nameValuePairs.add(new BasicNameValuePair("username",
157
			//"khushal.bhatia@saholic.com"));
158
			nameValuePairs.add(new BasicNameValuePair("username",
159
			"saholic-snapdeal@saholic.com"));
160
			//nameValuePairs.add(new BasicNameValuePair("password",
161
			//"sonline"));
162
			nameValuePairs.add(new BasicNameValuePair("password",
163
			"snapsaholic"));
164
			nameValuePairs.add(new BasicNameValuePair("_eventId","submit"));
165
			nameValuePairs.add(new BasicNameValuePair("execution",ex));
166
			nameValuePairs.add(new BasicNameValuePair("lt",lt));
167
			nameValuePairs.add(new BasicNameValuePair("submit","LOGIN"));
168
			post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
169
			//response = null;
9931 manish.sha 170
			try {
12428 manish.sha 171
				response = client.execute(post);
9931 manish.sha 172
			} catch (Exception e) {
12428 manish.sha 173
				logger.error("Unable to get Http Response for snapdeal seller portal login", e);
174
			}
175
			try {
176
				rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
177
			} catch (Exception e1) {
178
				logger.error("Unable to read Http Response for snapdeal seller portal login", e1);
179
				throw new Exception("Unable to read Http Response for snapdeal seller portal login");
9931 manish.sha 180
			} 
9651 manish.sha 181
 
12428 manish.sha 182
			//Striline = "";
9931 manish.sha 183
			try {
12428 manish.sha 184
				while ((line = rd.readLine()) != null) {
185
					System.out.println(line);
186
				}
9931 manish.sha 187
			} catch (Exception e) {
12428 manish.sha 188
				logger.error("Unable to extract Http Response for snapdeal seller portal login", e);
189
				throw new Exception("Unable to extract Http Response for snapdeal seller portal login");
10178 manish.sha 190
			}
14606 manish.sha 191
 
192
			get = new HttpGet("http://shipping.snapdeal.com/vendor/ONESHIP/product-shipment/pendingOrders/40?fulfillmentModelCode=ONESHIP");
193
			try {
194
				response = client.execute(get);
195
			} catch (ClientProtocolException e) {
196
				e.printStackTrace();
197
			} catch (IOException e) {
198
				e.printStackTrace();
199
			}
9651 manish.sha 200
 
14606 manish.sha 201
			rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
202
 
203
			while((line=rd.readLine())!=null){
204
			}
205
 
206
 
207
 
12428 manish.sha 208
			JSONArray jsonDataObj = null;
209
			JSONArray jsonDataShip = null;
210
			String line1 = "";
9651 manish.sha 211
 
12428 manish.sha 212
			for(long start = start_date.getTime(); start < end_date.getTime();){
213
				long end = start + 604800000l;
214
				if(end > end_date.getTime()){
215
					end = end_date.getTime();
216
				}
217
				startDate = snapdealDateFormat.format(new Date(start));
218
				endDate = snapdealDateFormat.format(new Date(end));
219
 
220
				logger.info("==== Start Date.."+startDate+"\n");
221
				logger.info("==== End Date.."+endDate+"\n");
222
 
223
 
224
				/*logger.info("Getting Delivery Information for DropShip Snapdeal Orders");
225
				//http://shipping.snapdeal.com/vendor/ONESHIP/product-shipment/shippedData/fetch?statusCode=COURIER_DELIVERED&dispatchCategoryId=0&startDate=2014%2F04%2F01&endDate=2014%2F04%2F07&statusColumn=deliveredOn
226
				String dropshipUrl = "http://shipping.snapdeal.com/vendor/DROPSHIP/product-shipment/shippedData/fetch/?startDate="+startDate+"&endDate="+endDate+"&statusCode=COURIER_DELIVERED&statusColumn=deliveredOn&dispatchCategoryId=0";
227
				logger.info("Drop Ship Url "+dropshipUrl);
228
 
229
				get = new HttpGet(dropshipUrl);
230
 
231
				try {
232
					response = client.execute(get);
233
				} catch (Exception e) {
234
					logger.error("Unable to get Http Response for snapdeal dropship delivered orders", e);
235
				} 
236
 
237
				try {
238
					rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
239
				} catch (Exception e) {
240
					logger.error("Unable to read Http Response for snapdeal dropship delivered orders", e);
241
				} 
242
 
243
 
244
				try {
245
 
246
					String resP = rd.readLine();
247
					jsonDataObj = new JSONArray("["+resP+"]");
248
					JSONObject j1 = (JSONObject)jsonDataObj.get(0);
249
					jsonDataShip = new JSONArray(j1.get("jsonDataString").toString());
250
				} catch (Exception e) {
251
					logger.error("Unable to extract Http Response for snapdeal dropship delivered orders", e);
252
				} 
253
 
254
 
255
				if(jsonDataShip!=null && jsonDataShip.length()>0){
256
					for(i=0; i< jsonDataShip.length(); i++){
257
						JSONObject jsonObj = null;
258
						try {
259
							jsonObj = jsonDataShip.getJSONObject(i);
260
 
261
							if(jsonObj!=null){
262
								String subOrderCode =(String) jsonObj.get("suborderCode");
263
								String referenceNumber =(String) jsonObj.get("referenceCode");
264
								String deliveryDate =(String) jsonObj.get("deliveredOn");
265
								logger.info("Snapdeal Dropship Order Details...suborderCode... "+subOrderCode+" ...referenceNumber... "+ referenceNumber+ " ...deliveryDate... "+ deliveryDate);
266
								deliveryDate = ourDBDateFormat.format(gotSnapdealDateFormat.parse(deliveryDate).getTime());
267
								List<String> deliveredOrdelList = new ArrayList<String>();
268
								deliveredOrdelList.add(referenceNumber);
269
								deliveredOrdelList.add(subOrderCode);
270
								deliveredOrdelList.add(deliveryDate);
271
								deliveredOrderDataList.add(deliveredOrdelList);
272
							}
273
						} catch (Exception e) {
274
							logger.error("Unable to add delivered order details for updation regarding snapdeal dropship delivered orders", e);
9931 manish.sha 275
						}
276
					}
12428 manish.sha 277
				}*/
278
 
279
				logger.info("Getting Delivery Information for OneShip Snapdeal Orders");
280
				//statusCode=CLD&dispatchCategoryId=0&startDate=2013%2F11%2F01&endDate=2013%2F11%2F07&statusColumn=cancelledOn
14636 manish.sha 281
 
282
				post = new HttpPost("http://shipping.snapdeal.com/vendor/ONESHIP/product-shipment/shippedData/fetch");
14639 manish.sha 283
				/*nameValuePairs = new ArrayList<NameValuePair>();
14636 manish.sha 284
				nameValuePairs.add(new BasicNameValuePair("startDate",startDate));
285
				nameValuePairs.add(new BasicNameValuePair("endDate",endDate));
286
				nameValuePairs.add(new BasicNameValuePair("statusColumn","deliveredOn"));
14639 manish.sha 287
				nameValuePairs.add(new BasicNameValuePair("queryType","CREATED"));*/
288
				String paramVal = "startDate="+startDate+"&endDate="+endDate+"&statusColumn=deliveredOn&queryType=CREATED";
289
				System.out.println(paramVal);
290
				StringEntity entity = new StringEntity(paramVal, "utf-8");
12428 manish.sha 291
 
14639 manish.sha 292
				post.setEntity(entity);
293
 
12428 manish.sha 294
				try {
14636 manish.sha 295
					response = client.execute(post);
12428 manish.sha 296
				} catch (Exception e) {
297
					logger.error("Unable to get Http Response for snapdeal oneship delivered orders", e);
298
					throw new Exception("Unable to get Http Response for snapdeal oneship delivered orders");
299
				} 
300
 
301
				try {
302
					rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
303
				} catch (Exception e) {
304
					logger.error("Unable to read Http Response for snapdeal oneship delivered orders", e);
305
					throw new Exception("Unable to read Http Response for snapdeal oneship delivered orders");
9651 manish.sha 306
				}
9731 manish.sha 307
 
12428 manish.sha 308
				try {
14637 manish.sha 309
					String resP;
310
					while((resP=rd.readLine())!=null){
311
						if(resP!=null && !resP.isEmpty()){
14638 manish.sha 312
							System.out.println("Response... "+resP);
14637 manish.sha 313
							jsonDataObj = new JSONArray("["+resP+"]");
314
							JSONObject j1 = (JSONObject)jsonDataObj.get(0);
315
							jsonDataShip = new JSONArray(j1.get("jsonDataString").toString());
316
						}
12446 manish.sha 317
					}
12428 manish.sha 318
				} catch (Exception e) {
319
					logger.error("Unable to extract Http Response for snapdeal oneship delivered orders", e);
320
					throw new Exception("Unable to extract Http Response for snapdeal oneship delivered orders");
321
				}
9651 manish.sha 322
 
12428 manish.sha 323
				if(jsonDataShip!=null && jsonDataShip.length()>0){
324
					for(i=0; i< jsonDataShip.length(); i++){
325
						JSONObject jsonObj = null;
326
						try {
327
							jsonObj = jsonDataShip.getJSONObject(i);
9731 manish.sha 328
 
12428 manish.sha 329
							if(jsonObj!=null){
330
								String subOrderCode =(String) jsonObj.get("suborderCode");
331
								String referenceNumber =(String) jsonObj.get("referenceCode");
332
								String deliveryDate =(String) jsonObj.get("deliveredOn");
333
								logger.info("Snapdeal Oneship Order Details...suborderCode... "+subOrderCode+" ...referenceNumber... "+ referenceNumber+ " ...deliveryDate... "+ deliveryDate);
334
								deliveryDate = ourDBDateFormat.format(gotSnapdealDateFormat.parse(deliveryDate).getTime());
335
								List<String> deliveredOrdelList = new ArrayList<String>();
336
								deliveredOrdelList.add(referenceNumber);
337
								deliveredOrdelList.add(subOrderCode);
338
								deliveredOrdelList.add(deliveryDate);
9883 manish.sha 339
 
12428 manish.sha 340
								deliveredOrderDataList.add(deliveredOrdelList);
341
							}
342
						} catch (Exception e) {
343
							logger.error("Unable to add delivered order details for updation regarding snapdeal oneship delivered orders", e);
344
							throw new Exception("Unable to add delivered order details for updation regarding snapdeal oneship delivered orders");
9931 manish.sha 345
						}
346
					}
9883 manish.sha 347
				}
9931 manish.sha 348
 
349
 
12428 manish.sha 350
				/*logger.info("Getting Information for Cancelled DropShip Snapdeal Orders");
351
				String dropshipCancelUrl = "http://shipping.snapdeal.com/vendor/DROPSHIP/product-shipment/shippedData/fetch/?statusCode=CLD&dispatchCategoryId=0&startDate="+startDate+"&endDate="+endDate+"&statusColumn=cancelledOn";
352
				logger.info("Drop Ship Cancel Url "+dropshipCancelUrl);
353
 
354
				get = new HttpGet(dropshipCancelUrl);
355
 
356
				try {
357
					response = client.execute(get);
358
				} catch (Exception e) {
359
					logger.error("Unable to get Http Response for snapdeal dropship cancelled orders", e);
360
				} 
361
 
362
				try {
363
					rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
364
				} catch (Exception e) {
365
					logger.error("Unable to read Http Response for snapdeal dropship cancelled orders", e);
366
				}
367
 
368
				try {
369
					String resP = rd.readLine();
370
					jsonDataObj = new JSONArray("["+resP+"]");
371
					JSONObject j1 = (JSONObject)jsonDataObj.get(0);
372
					jsonDataShip = new JSONArray(j1.get("jsonDataString").toString());
373
				} catch (Exception e) {
374
					logger.error("Unable to extract Http Response for snapdeal dropship cancelled orders", e);
375
				} 
376
 
377
				if(jsonDataShip!=null && jsonDataShip.length()>0){
378
					for(i=0; i< jsonDataShip.length(); i++){
379
						JSONObject jsonObj = null;
380
						try {
381
							jsonObj = jsonDataShip.getJSONObject(i);
382
 
383
							if(jsonObj!=null){
384
								String subOrderCode =(String) jsonObj.get("suborderCode");
385
								String referenceNumber =(String) jsonObj.get("referenceCode");
386
								logger.info("Snapdeal Dropship Order Details...suborderCode... "+subOrderCode+" ...referenceNumber... "+ referenceNumber);
387
								List<String> cancelledOrdelList = new ArrayList<String>();
388
								cancelledOrdelList.add(referenceNumber);
389
								cancelledOrdelList.add(subOrderCode);
390
								cancelledOrderDataList.add(cancelledOrdelList);
391
							}
392
						} catch (Exception e) {
393
							logger.error("Unable to add cancelled order details for updation regarding snapdeal dropship orders", e);
9931 manish.sha 394
						}
9883 manish.sha 395
					}
12428 manish.sha 396
				}*/
397
 
398
				logger.info("Getting Information for OneShip Snapdeal Cancelled Orders");
399
				String oneShipCancelUrl = "http://shipping.snapdeal.com/vendor/ONESHIP/product-shipment/shippedData/fetch/?statusCode=CLD&dispatchCategoryId=0&startDate="+startDate+"&endDate="+endDate+"&statusColumn=cancelledOn";
400
				logger.info("One Ship Cancel Url "+oneShipCancelUrl);
401
 
14636 manish.sha 402
				post = new HttpPost("http://shipping.snapdeal.com/vendor/ONESHIP/product-shipment/shippedData/fetch");
403
				nameValuePairs = new ArrayList<NameValuePair>();
404
				nameValuePairs.add(new BasicNameValuePair("startDate",startDate));
405
				nameValuePairs.add(new BasicNameValuePair("endDate",endDate));
406
				nameValuePairs.add(new BasicNameValuePair("statusColumn","cancelledOn"));
407
				nameValuePairs.add(new BasicNameValuePair("queryType","CREATED"));
408
				post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
12428 manish.sha 409
 
410
				try {
14636 manish.sha 411
					response = client.execute(post);
12428 manish.sha 412
				} catch (Exception e) {
413
					logger.error("Unable to get Http Response for snapdeal oneship cancelled orders", e);
414
					throw new Exception("Unable to get Http Response for snapdeal oneship cancelled orders");
415
				} 
416
 
417
				try {
418
					rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
419
				} catch (Exception e) {
420
					logger.error("Unable to read Http Response for snapdeal oneship cancelled orders", e);
421
					throw new Exception("Unable to read Http Response for snapdeal oneship cancelled orders");
9883 manish.sha 422
				}
12428 manish.sha 423
 
424
				try {
14637 manish.sha 425
					String resP;
426
					while((resP=rd.readLine())!=null){
427
						if(resP!=null && !resP.isEmpty()){
428
							jsonDataObj = new JSONArray("["+resP+"]");
429
							JSONObject j1 = (JSONObject)jsonDataObj.get(0);
430
							jsonDataShip = new JSONArray(j1.get("jsonDataString").toString());
431
						}
12446 manish.sha 432
					}
12428 manish.sha 433
				} catch (Exception e) {
434
					logger.error("Unable to extract Http Response for snapdeal oneship cancelled orders", e);
435
					throw new Exception("Unable to extract Http Response for snapdeal oneship cancelled orders");
436
				} 
437
 
438
				if(jsonDataShip!=null && jsonDataShip.length()>0){
439
					for(i=0; i< jsonDataShip.length(); i++){
440
						JSONObject jsonObj = null;
441
						try {
442
							jsonObj = jsonDataShip.getJSONObject(i);
443
 
444
							if(jsonObj!=null){
445
								String subOrderCode =(String) jsonObj.get("suborderCode");
446
								String referenceNumber =(String) jsonObj.get("referenceCode");
447
								logger.info("Snapdeal OneShip Order Details...suborderCode... "+subOrderCode+" ...referenceNumber... "+ referenceNumber);
448
								List<String> cancelledOrdelList = new ArrayList<String>();
449
								cancelledOrdelList.add(referenceNumber);
450
								cancelledOrdelList.add(subOrderCode);
451
								cancelledOrderDataList.add(cancelledOrdelList);
452
							}
453
						} catch (Exception e) {
454
							logger.error("Unable to add cancelled order details for updation regarding snapdeal oneship orders", e);
455
							throw new Exception("Unable to add cancelled order details for updation regarding snapdeal oneship orders");
456
						}
457
					}
458
				}
459
 
460
 
461
				start = end + 86400000l;
9883 manish.sha 462
			}
12428 manish.sha 463
 
464
			if(deliveredOrderDataList!=null && deliveredOrderDataList.size()>0){
465
				logger.info("Delivered Orders Size .. "+deliveredOrderDataList.size());
466
				orderDataMap.put("Delivered", deliveredOrderDataList);
467
			}
468
 
469
			if(cancelledOrderDataList!=null && cancelledOrderDataList.size()>0){
470
				logger.info("Cancelled Orders Size .. "+cancelledOrderDataList.size());
471
				orderDataMap.put("Cancelled", cancelledOrderDataList);
472
			}
473
 
474
			if(orderDataMap!=null && orderDataMap.size()>0){
475
				try{
476
					new TransactionClient().getClient().updateSnapdealOrdersStatus(orderDataMap);
477
				} catch(Exception e){
478
					logger.error("Unable to update delivery information for snapdeal orders", e);
479
					throw new Exception("Unable to update delivery information for snapdeal orders");
480
				}
481
			}
482
 
9883 manish.sha 483
		}
12428 manish.sha 484
		catch(Exception e){
485
			e.printStackTrace();
486
			mailer.sendSSLMessage(sendTo, "Error in Snapdeal Order Status Recon", emailFromAddress, password, "<html><body><p>Please check log</p></body></html>");
9883 manish.sha 487
		}
9651 manish.sha 488
	}
489
}