| Line 151... |
Line 151... |
| 151 |
} catch (Exception e) {
|
151 |
} catch (Exception e) {
|
| 152 |
logger.error("Unable to establish connection to the User service ", e);
|
152 |
logger.error("Unable to establish connection to the User service ", e);
|
| 153 |
}
|
153 |
}
|
| 154 |
logger.info("Before iterating orders in file");
|
154 |
logger.info("Before iterating orders in file");
|
| 155 |
while ((nextLine = orderfilereader.readNext()) != null && nextLine.length!=0) {
|
155 |
while ((nextLine = orderfilereader.readNext()) != null && nextLine.length!=0) {
|
| 156 |
logger.info("Order file entry " + nextLine);
|
156 |
logger.info("Order file entry " + nextLine + " Length " + nextLine.length);
|
| 157 |
String orderId,subOrderId,create_date;
|
157 |
String orderId,subOrderId,create_date;
|
| 158 |
long sku;
|
158 |
long sku;
|
| 159 |
logger.info("Processing order " + nextLine[3]+ " " + nextLine[4]);
|
159 |
logger.info("Processing order " + nextLine[3]+ " " + nextLine[4]);
|
| 160 |
if(nextLine[3].length()==0 || nextLine[4].length()==0 ){
|
160 |
if(nextLine[3].length()==0 || nextLine[4].length()==0 ){
|
| 161 |
sb.append(" Could not parse order id " + nextLine[3]+ " " + nextLine[4] + "\n");
|
161 |
sb.append(" Could not parse order id " + nextLine[3]+ " " + nextLine[4] + "\n");
|
| Line 268... |
Line 268... |
| 268 |
else{
|
268 |
else{
|
| 269 |
sb.append(orderId+" "+subOrderId + " Total Selling Price not set " +"\n");
|
269 |
sb.append(orderId+" "+subOrderId + " Total Selling Price not set " +"\n");
|
| 270 |
logger.info(orderId+" "+subOrderId + " Total Selling Price not set " +"\n");
|
270 |
logger.info(orderId+" "+subOrderId + " Total Selling Price not set " +"\n");
|
| 271 |
continue;
|
271 |
continue;
|
| 272 |
}
|
272 |
}
|
| - |
|
273 |
|
| - |
|
274 |
String shipToName,addressLine1,addressLine2,city,state,pincode,buyerName="unknown";
|
| - |
|
275 |
if(nextLine[17].length()>0){
|
| 273 |
//String buyerName = nextLine[17];
|
276 |
buyerName = nextLine[17];
|
| - |
|
277 |
}
|
| - |
|
278 |
else{
|
| - |
|
279 |
sb.append(orderId+" "+subOrderId + " Buyer Name not set " +"\n");
|
| 274 |
String shipToName,addressLine1,addressLine2,city,state,pincode;
|
280 |
logger.info(orderId+" "+subOrderId + " Buyer Name not set " +"\n");
|
| - |
|
281 |
}
|
| 275 |
if(nextLine[18].length()>0){
|
282 |
if(nextLine[18].length()>0){
|
| 276 |
shipToName = nextLine[18];
|
283 |
shipToName = nextLine[18];
|
| 277 |
}
|
284 |
}
|
| 278 |
else{
|
285 |
else{
|
| 279 |
sb.append(orderId+" "+subOrderId + " Ship to Name not set " +"\n");
|
286 |
sb.append(orderId+" "+subOrderId + " Ship to Name not set " +"\n");
|
| 280 |
logger.info(orderId+" "+subOrderId + " Ship to Name not set " +"\n");
|
287 |
logger.info(orderId+" "+subOrderId + " Ship to Name not set " +"\n");
|
| 281 |
continue;
|
288 |
continue;
|
| 282 |
}
|
289 |
}
|
| - |
|
290 |
if(buyerName.contains("unknown")){
|
| - |
|
291 |
buyerName = shipToName;
|
| - |
|
292 |
}
|
| 283 |
if(nextLine[19].length()>0){
|
293 |
if(nextLine[19].length()>0){
|
| 284 |
addressLine1 = nextLine[19];
|
294 |
addressLine1 = nextLine[19];
|
| 285 |
}
|
295 |
}
|
| 286 |
else{
|
296 |
else{
|
| 287 |
addressLine1 ="";
|
297 |
addressLine1 ="";
|
| Line 515... |
Line 525... |
| 515 |
continue;
|
525 |
continue;
|
| 516 |
}
|
526 |
}
|
| 517 |
List<in.shop2020.model.v1.order.Order> flipkartorders = transaction.getOrders();
|
527 |
List<in.shop2020.model.v1.order.Order> flipkartorders = transaction.getOrders();
|
| 518 |
for(in.shop2020.model.v1.order.Order flipkartorder:flipkartorders){
|
528 |
for(in.shop2020.model.v1.order.Order flipkartorder:flipkartorders){
|
| 519 |
try {
|
529 |
try {
|
| - |
|
530 |
List<in.shop2020.model.v1.order.Attribute> attributeList = new ArrayList<in.shop2020.model.v1.order.Attribute>();
|
| 520 |
inventoryClient.reserveItemInWarehouse(flipkartorder.getLineitems().get(0).getItem_id(), fulfillmentWarehouse.getId(), 1,
|
531 |
inventoryClient.reserveItemInWarehouse(flipkartorder.getLineitems().get(0).getItem_id(), fulfillmentWarehouse.getId(), 1,
|
| 521 |
flipkartorder.getId(), flipkartorder.getCreated_timestamp(), flipkartorder.getPromised_shipping_time(), flipkartorder.getLineitems().get(0).getQuantity());
|
532 |
flipkartorder.getId(), flipkartorder.getCreated_timestamp(), flipkartorder.getPromised_shipping_time(), flipkartorder.getLineitems().get(0).getQuantity());
|
| 522 |
FlipkartOrder flipkartOrder = new FlipkartOrder();
|
533 |
FlipkartOrder flipkartOrder = new FlipkartOrder();
|
| 523 |
flipkartOrder.setOrderId(flipkartorder.getId());
|
534 |
flipkartOrder.setOrderId(flipkartorder.getId());
|
| 524 |
flipkartOrder.setFlipkartOrderId(orderId);
|
535 |
flipkartOrder.setFlipkartOrderId(orderId);
|
| 525 |
flipkartOrder.setFlipkartSubOrderId(subOrderId);
|
536 |
flipkartOrder.setFlipkartSubOrderId(subOrderId);
|
| 526 |
flipkartOrder.setFlipkartTxnDate(flipkartTxnDate.getTime());
|
537 |
flipkartOrder.setFlipkartTxnDate(flipkartTxnDate.getTime());
|
| 527 |
flipkartOrder.setEmiFee(emiFee);
|
538 |
flipkartOrder.setEmiFee(emiFee);
|
| 528 |
flipkartOrder.setOctroiFee(octroiFee);
|
539 |
flipkartOrder.setOctroiFee(octroiFee);
|
| 529 |
flipkartOrder.setShippingPrice(shippingPrice);
|
540 |
flipkartOrder.setShippingPrice(shippingPrice);
|
| - |
|
541 |
in.shop2020.model.v1.order.Attribute attribute = new in.shop2020.model.v1.order.Attribute();
|
| - |
|
542 |
attribute.setName("Buyer Name");
|
| - |
|
543 |
attribute.setValue(buyerName);
|
| - |
|
544 |
attributeList.add(attribute);
|
| 530 |
try {
|
545 |
try {
|
| 531 |
transaction_client.createFlipkartOrder(flipkartOrder);
|
546 |
transaction_client.createFlipkartOrder(flipkartOrder);
|
| - |
|
547 |
transaction_client.setOrderAttributes(flipkartOrder.getOrderId(),attributeList);
|
| 532 |
} catch (TException e) {
|
548 |
} catch (TException e) {
|
| 533 |
logger.error("Could not create flipkart order");
|
549 |
logger.error("Could not create flipkart order");
|
| 534 |
sb.append(orderId+" "+subOrderId + " Could not create flipkart order"+"\n");
|
550 |
sb.append(orderId+" "+subOrderId + " Could not create flipkart order"+"\n");
|
| 535 |
continue;
|
551 |
continue;
|
| 536 |
}
|
552 |
}
|
| Line 553... |
Line 569... |
| 553 |
sos = response.getOutputStream();
|
569 |
sos = response.getOutputStream();
|
| 554 |
if(sb!=null){
|
570 |
if(sb!=null){
|
| 555 |
sos.write(sb.toString().getBytes());
|
571 |
sos.write(sb.toString().getBytes());
|
| 556 |
}
|
572 |
}
|
| 557 |
else{
|
573 |
else{
|
| 558 |
sos.write("Orders uploaded successfully".toString().getBytes());
|
574 |
sos.write("Orders Created Successfully".toString().getBytes());
|
| 559 |
}
|
575 |
}
|
| 560 |
sos.flush();
|
576 |
sos.flush();
|
| 561 |
} catch (IOException e) {
|
577 |
} catch (IOException e) {
|
| 562 |
System.out.println("Unable to stream the manifest file");
|
578 |
System.out.println("Unable to stream the manifest file");
|
| 563 |
}
|
579 |
}
|