| Line 124... |
Line 124... |
| 124 |
else{
|
124 |
else{
|
| 125 |
break;
|
125 |
break;
|
| 126 |
}
|
126 |
}
|
| 127 |
i++;
|
127 |
i++;
|
| 128 |
}
|
128 |
}
|
| 129 |
/*for(Order order:orders){
|
129 |
for(Order order:orders){
|
| 130 |
System.out.println("Order " + order.getExternalId() +" "+order.getOrderItemId() + " : "+ order.getStatus());
|
130 |
System.out.println("Order " + order.getExternalId() +" "+order.getOrderItemId() + " : "+ order.getStatus() + " "+order.getStatusDateMessage() + " "
|
| - |
|
131 |
+ order.getStatusLabel() + " " + order.getPickup_by_date() + " "+ order.getTrackingId());
|
| 131 |
}*/
|
132 |
}
|
| 132 |
processOrders(orders);
|
133 |
//processOrders(orders);
|
| 133 |
} catch (IOException e) {
|
134 |
} catch (IOException e) {
|
| 134 |
e.printStackTrace();
|
135 |
e.printStackTrace();
|
| 135 |
}
|
136 |
}
|
| 136 |
}
|
137 |
}
|
| 137 |
|
138 |
|
| Line 160... |
Line 161... |
| 160 |
logger.error("Unable to establish connection to the User service ", e);
|
161 |
logger.error("Unable to establish connection to the User service ", e);
|
| 161 |
}
|
162 |
}
|
| 162 |
logger.info("Before iterating orders in file");
|
163 |
logger.info("Before iterating orders in file");
|
| 163 |
for(Order order : orders){
|
164 |
for(Order order : orders){
|
| 164 |
|
165 |
|
| 165 |
String orderId,subOrderId,create_date;
|
166 |
String orderId,subOrderId,create_date,ship_date = null;
|
| 166 |
long sku;
|
167 |
long sku;
|
| 167 |
|
168 |
|
| 168 |
if(order.getExternalId().length()==0 || order.getOrderItemId().length()==0 ){
|
169 |
if(order.getExternalId().length()==0 || order.getOrderItemId().length()==0 ){
|
| 169 |
sb.append(" Could not parse order id " + order.getExternalId()+ " " + order.getExternalId() + "\n");
|
170 |
sb.append(" Could not parse order id " + order.getExternalId()+ " " + order.getExternalId() + "\n");
|
| 170 |
continue;
|
171 |
continue;
|
| Line 181... |
Line 182... |
| 181 |
else{
|
182 |
else{
|
| 182 |
sb.append(orderId+" "+subOrderId + " Could not parse order date" +"\n");
|
183 |
sb.append(orderId+" "+subOrderId + " Could not parse order date" +"\n");
|
| 183 |
logger.info(orderId+" "+subOrderId + " Could not parse order date");
|
184 |
logger.info(orderId+" "+subOrderId + " Could not parse order date");
|
| 184 |
continue;
|
185 |
continue;
|
| 185 |
}
|
186 |
}
|
| - |
|
187 |
if(order.getPickup_by_date()!=null){
|
| - |
|
188 |
ship_date = order.getPickup_by_date();
|
| - |
|
189 |
}
|
| 186 |
if(order.getSku()==0L){
|
190 |
if(order.getSku()==0L){
|
| 187 |
sb.append(orderId+" "+subOrderId + " Could not parse sku" +"\n");
|
191 |
sb.append(orderId+" "+subOrderId + " Could not parse sku" +"\n");
|
| 188 |
logger.info(orderId+" "+subOrderId + " Could not parse sku");
|
192 |
logger.info(orderId+" "+subOrderId + " Could not parse sku");
|
| 189 |
continue;
|
193 |
continue;
|
| 190 |
}
|
194 |
}
|
| 191 |
else{
|
195 |
else{
|
| 192 |
sku = order.getSku();
|
196 |
sku = order.getSku();
|
| 193 |
logger.info(orderId+" "+subOrderId + " Processing sku " + sku);
|
197 |
logger.info(orderId+" "+subOrderId + " Processing sku " + sku);
|
| 194 |
}
|
198 |
}
|
| 195 |
if(order.getStatus().length()!=0 && (order.getStatus().equalsIgnoreCase("Approved") || order.getStatus().equalsIgnoreCase("confirmed"))){
|
199 |
if(order.getStatusLabel().length()!=0 && (order.getStatusLabel().equalsIgnoreCase("Approved") || order.getStatusLabel().equalsIgnoreCase("confirmed"))){
|
| 196 |
String status = order.getStatus();
|
200 |
String status = order.getStatus();
|
| 197 |
}
|
201 |
}
|
| 198 |
else{
|
202 |
else{
|
| 199 |
if(order.getStatus().length()==0){
|
203 |
if(order.getStatus().length()==0){
|
| 200 |
sb.append(orderId+" "+subOrderId + " Could not parse status " + "\n");
|
204 |
sb.append(orderId+" "+subOrderId + " Could not parse status " + "\n");
|
| Line 349... |
Line 353... |
| 349 |
sb.append(orderId+" "+subOrderId + " Ship to date not available " +"\n");
|
353 |
sb.append(orderId+" "+subOrderId + " Ship to date not available " +"\n");
|
| 350 |
logger.info(orderId+" "+subOrderId + " Ship to date not available " +"\n");
|
354 |
logger.info(orderId+" "+subOrderId + " Ship to date not available " +"\n");
|
| 351 |
continue;
|
355 |
continue;
|
| 352 |
}
|
356 |
}
|
| 353 |
//String shipByDate = nextLine[26];
|
357 |
//String shipByDate = nextLine[26];
|
| - |
|
358 |
SimpleDateFormat createDateFormatter = new SimpleDateFormat("MMM dd, yyyy hh:mm aaa");
|
| - |
|
359 |
SimpleDateFormat shipDateFormatter = new SimpleDateFormat("MMM dd, yyyy");
|
| - |
|
360 |
Date flipkartTxnDate = null;
|
| - |
|
361 |
Date shipByDate = null;
|
| - |
|
362 |
try {
|
| - |
|
363 |
flipkartTxnDate = createDateFormatter.parse(create_date);
|
| - |
|
364 |
} catch (ParseException e) {
|
| - |
|
365 |
logger.error(orderId+" "+subOrderId + " Could not parse flipkart order date from file " , e);
|
| - |
|
366 |
sb.append(orderId+" "+subOrderId + " Could not parse order date" +"\n");
|
| - |
|
367 |
continue;
|
| - |
|
368 |
}
|
| - |
|
369 |
if(ship_date!=null){
|
| - |
|
370 |
try {
|
| - |
|
371 |
shipByDate = shipDateFormatter.parse(ship_date);
|
| - |
|
372 |
} catch (ParseException e) {
|
| - |
|
373 |
logger.error(orderId+" "+subOrderId + " ship date " , e);
|
| - |
|
374 |
sb.append(orderId+" "+subOrderId + " ship date" +"\n");
|
| - |
|
375 |
continue;
|
| - |
|
376 |
}
|
| - |
|
377 |
}
|
| 354 |
Client transaction_client = null;
|
378 |
Client transaction_client = null;
|
| 355 |
try {
|
379 |
try {
|
| 356 |
transaction_client = new TransactionClient().getClient();
|
380 |
transaction_client = new TransactionClient().getClient();
|
| 357 |
if(transaction_client.flipkartOrderExists(orderId,subOrderId)) {
|
381 |
if(transaction_client.flipkartOrderExists(orderId,subOrderId)) {
|
| 358 |
logger.error("Flipkart order exists " + "id : " + orderId + " suborder id : " + subOrderId);
|
382 |
logger.error("Flipkart order exists " + "id : " + orderId + " suborder id : " + subOrderId);
|
| 359 |
sb.append("Flipkart order exists " + orderId+" "+subOrderId+"\n");
|
383 |
sb.append("Flipkart order exists " + orderId+" "+subOrderId+"\n");
|
| - |
|
384 |
if(shipByDate!=null && order.getTrackingId()!=null){
|
| - |
|
385 |
transaction_client.updateFlipkartOrderDatesAndAWB(orderId, subOrderId, shipByDate.getTime(), order.getTrackingId());
|
| - |
|
386 |
}
|
| 360 |
continue;
|
387 |
continue;
|
| 361 |
}
|
388 |
}
|
| 362 |
|
389 |
|
| 363 |
} catch (TTransportException e1) {
|
390 |
} catch (TTransportException e1) {
|
| 364 |
logger.error("Problem with Transaction service " , e1);
|
391 |
logger.error("Problem with Transaction service " , e1);
|
| 365 |
e1.printStackTrace();
|
392 |
e1.printStackTrace();
|
| 366 |
} catch (TException e) {
|
393 |
} catch (TException e) {
|
| 367 |
logger.error("Problem.. thrift exception with Transaction service " , e);
|
394 |
logger.error("Problem.. thrift exception with Transaction service " , e);
|
| 368 |
e.printStackTrace();
|
395 |
e.printStackTrace();
|
| 369 |
}
|
396 |
}
|
| 370 |
SimpleDateFormat istFormatter = new SimpleDateFormat("MMM dd, yyyy hh:mm aaa");
|
- |
|
| 371 |
Date flipkartTxnDate = null;
|
- |
|
| 372 |
try {
|
- |
|
| 373 |
flipkartTxnDate = istFormatter.parse(create_date);
|
- |
|
| 374 |
} catch (ParseException e) {
|
- |
|
| 375 |
logger.error(orderId+" "+subOrderId + " Could not parse flipkart order date from file " , e);
|
- |
|
| 376 |
sb.append(orderId+" "+subOrderId + " Could not parse order date" +"\n");
|
- |
|
| 377 |
continue;
|
- |
|
| 378 |
}
|
- |
|
| 379 |
Transaction txn = new Transaction();
|
397 |
Transaction txn = new Transaction();
|
| 380 |
txn.setShoppingCartid(user.getActiveCartId());
|
398 |
txn.setShoppingCartid(user.getActiveCartId());
|
| 381 |
txn.setCustomer_id(user.getUserId());
|
399 |
txn.setCustomer_id(user.getUserId());
|
| 382 |
System.out.println("User Id is " + user.getUserId());
|
400 |
System.out.println("User Id is " + user.getUserId());
|
| 383 |
txn.setCreatedOn(new Date().getTime());
|
401 |
txn.setCreatedOn(new Date().getTime());
|
| Line 408... |
Line 426... |
| 408 |
t_order.setStatus(OrderStatus.PAYMENT_PENDING);
|
426 |
t_order.setStatus(OrderStatus.PAYMENT_PENDING);
|
| 409 |
t_order.setStatusDescription("In Process");
|
427 |
t_order.setStatusDescription("In Process");
|
| 410 |
t_order.setCreated_timestamp(new Date().getTime());
|
428 |
t_order.setCreated_timestamp(new Date().getTime());
|
| 411 |
t_order.setOrderType(OrderType.B2C);
|
429 |
t_order.setOrderType(OrderType.B2C);
|
| 412 |
t_order.setCod(false);
|
430 |
t_order.setCod(false);
|
| - |
|
431 |
if(shipByDate!=null){
|
| - |
|
432 |
t_order.setPromised_shipping_time(shipByDate.getTime());
|
| - |
|
433 |
t_order.setExpected_shipping_time(shipByDate.getTime());
|
| - |
|
434 |
t_order.setPromised_delivery_time(shipByDate.getTime()+ 4*24*60*60);
|
| - |
|
435 |
t_order.setExpected_delivery_time(shipByDate.getTime()+ 4*24*60*60);
|
| - |
|
436 |
}
|
| - |
|
437 |
else{
|
| 413 |
try {
|
438 |
try {
|
| 414 |
Date shipDate = new Date();
|
439 |
Date shipDate = new Date();
|
| 415 |
shipDate.setTime( flipkartTxnDate.getTime() + sla*24*60*60*1000);
|
440 |
shipDate.setTime( flipkartTxnDate.getTime() + sla*24*60*60*1000);
|
| 416 |
Calendar time = Calendar.getInstance();
|
441 |
Calendar time = Calendar.getInstance();
|
| 417 |
t_order.setPromised_shipping_time(shipDate.getTime());
|
442 |
t_order.setPromised_shipping_time(shipDate.getTime());
|
| 418 |
t_order.setExpected_shipping_time(shipDate.getTime());
|
443 |
t_order.setExpected_shipping_time(shipDate.getTime());
|
| 419 |
time.add(Calendar.DAY_OF_MONTH, 4);
|
444 |
time.add(Calendar.DAY_OF_MONTH, 4);
|
| 420 |
t_order.setPromised_delivery_time(time.getTimeInMillis());
|
445 |
t_order.setPromised_delivery_time(time.getTimeInMillis());
|
| 421 |
t_order.setExpected_delivery_time(time.getTimeInMillis());
|
446 |
t_order.setExpected_delivery_time(time.getTimeInMillis());
|
| 422 |
} catch(Exception e) {
|
447 |
} catch(Exception e) {
|
| 423 |
logger.error("Error in updating Shipping or Delivery Time for suborderid " + subOrderId);
|
448 |
logger.error("Error in updating Shipping or Delivery Time for suborderid " + subOrderId);
|
| 424 |
sb.append(orderId + " "+ subOrderId + " Could not update delivery time" + " " + "\n");
|
449 |
sb.append(orderId + " "+ subOrderId + " Could not update delivery time" + " " + "\n");
|
| 425 |
exit = true;
|
450 |
exit = true;
|
| 426 |
continue;
|
451 |
continue;
|
| - |
|
452 |
}
|
| 427 |
}
|
453 |
}
|
| 428 |
SnapdealItem snapdealItem = new CatalogClient().getClient().getSnapdealItem(sku);
|
454 |
SnapdealItem snapdealItem = new CatalogClient().getClient().getSnapdealItem(sku);
|
| 429 |
inventoryClient = new InventoryClient().getClient();
|
455 |
inventoryClient = new InventoryClient().getClient();
|
| 430 |
try {
|
456 |
try {
|
| 431 |
logger.info("Snapdeal Item id is " + snapdealItem.getItem_id());
|
457 |
logger.info("Snapdeal Item id is " + snapdealItem.getItem_id());
|