Subversion Repositories SmartDukaan

Rev

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