| Line 1... |
Line 1... |
| 1 |
package com.amazonaws.mws.samples;
|
1 |
package com.amazonaws.mws.samples;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.model.v1.catalog.Amazonlisted;
|
3 |
import in.shop2020.model.v1.catalog.Amazonlisted;
|
| 4 |
import in.shop2020.model.v1.inventory.AmazonFbaInventorySnapshot;
|
4 |
import in.shop2020.model.v1.inventory.AmazonFbaInventorySnapshot;
|
| - |
|
5 |
import in.shop2020.model.v1.order.AmazonFCWarehouseLocation;
|
| 5 |
import in.shop2020.model.v1.order.AmazonFbaSalesSnapshot;
|
6 |
import in.shop2020.model.v1.order.AmazonFbaSalesSnapshot;
|
| 6 |
import in.shop2020.thrift.clients.CatalogClient;
|
7 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 7 |
import in.shop2020.thrift.clients.InventoryClient;
|
8 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 8 |
import in.shop2020.thrift.clients.TransactionClient;
|
9 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 9 |
import in.shop2020.utils.GmailUtils;
|
10 |
import in.shop2020.utils.GmailUtils;
|
| Line 277... |
Line 278... |
| 277 |
e.printStackTrace();
|
278 |
e.printStackTrace();
|
| 278 |
}
|
279 |
}
|
| 279 |
String [] nextLine;
|
280 |
String [] nextLine;
|
| 280 |
try {
|
281 |
try {
|
| 281 |
int count =1;
|
282 |
int count =1;
|
| 282 |
Map<Date,Map<Long,FbaSalesSnapshot>> orderDateItemIdFbaSaleSnapshotMap = new HashMap<Date,Map<Long,FbaSalesSnapshot>>();
|
283 |
Map<Date,Map<String,FbaSalesSnapshot>> orderDateItemIdFbaSaleSnapshotMap = new HashMap<Date,Map<String,FbaSalesSnapshot>>();
|
| 283 |
|
284 |
|
| 284 |
if(amazonOrderData!=null){
|
285 |
if(amazonOrderData!=null){
|
| 285 |
List<Message> orderMessageList = amazonOrderData.getMessage();
|
286 |
List<Message> orderMessageList = amazonOrderData.getMessage();
|
| 286 |
System.out.println("Amazon Order List ... "+orderMessageList.size());
|
287 |
System.out.println("Amazon Order List ... "+orderMessageList.size());
|
| 287 |
for(Message orderMessage : orderMessageList){
|
288 |
for(Message orderMessage : orderMessageList){
|
| Line 293... |
Line 294... |
| 293 |
TimeZone zone= TimeZone.getTimeZone("GMT");
|
294 |
TimeZone zone= TimeZone.getTimeZone("GMT");
|
| 294 |
istFormatter.setTimeZone(zone);
|
295 |
istFormatter.setTimeZone(zone);
|
| 295 |
Date date = istFormatter.parse(amazonOrder.getPurchaseDate().toString());
|
296 |
Date date = istFormatter.parse(amazonOrder.getPurchaseDate().toString());
|
| 296 |
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
297 |
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
| 297 |
Date date_key = dateFormat.parse(dateFormat.format(date));
|
298 |
Date date_key = dateFormat.parse(dateFormat.format(date));
|
| 298 |
System.out.println("Order Details " + amazonOrder.getAmazonOrderID()+" "+date_key+" "+ amazonOrder.getOrderItem().get(0).getSKU() +" " + amazonOrder.getOrderItem().get(0).getItemStatus() + " " + amazonOrder.getOrderItem().get(0).getQuantity());
|
299 |
//System.out.println("Order Details " + amazonOrder.getAmazonOrderID()+" "+date_key+" "+ amazonOrder.getOrderItem().get(0).getSKU() +" " + amazonOrder.getOrderItem().get(0).getItemStatus() + " " + amazonOrder.getOrderItem().get(0).getQuantity());
|
| - |
|
300 |
Long itemid;
|
| - |
|
301 |
AmazonFCWarehouseLocation fcLocation;
|
| - |
|
302 |
if(amazonOrder.getOrderItem().get(0).getSKU().startsWith("FBA")){
|
| 299 |
Long itemid = Long.parseLong(amazonOrder.getOrderItem().get(0).getSKU().replaceAll("FBA",""));
|
303 |
itemid = Long.parseLong(amazonOrder.getOrderItem().get(0).getSKU().replaceAll("FBA",""));
|
| - |
|
304 |
fcLocation = AmazonFCWarehouseLocation.Mumbai;
|
| - |
|
305 |
}
|
| - |
|
306 |
else if(amazonOrder.getOrderItem().get(0).getSKU().startsWith("FBB")){
|
| - |
|
307 |
itemid = Long.parseLong(amazonOrder.getOrderItem().get(0).getSKU().replaceAll("FBB",""));
|
| - |
|
308 |
fcLocation = AmazonFCWarehouseLocation.Bangalore;
|
| - |
|
309 |
}
|
| - |
|
310 |
else{
|
| - |
|
311 |
continue;
|
| - |
|
312 |
}
|
| 300 |
Integer qty=0;
|
313 |
Integer qty=0;
|
| 301 |
if(amazonOrder.getOrderItem().get(0).getQuantity()!=0){
|
314 |
if(amazonOrder.getOrderItem().get(0).getQuantity()!=0){
|
| 302 |
qty = new Integer(amazonOrder.getOrderItem().get(0).getQuantity());
|
315 |
qty = new Integer(amazonOrder.getOrderItem().get(0).getQuantity());
|
| 303 |
}
|
316 |
}
|
| 304 |
Float itemSale = null;
|
317 |
Float itemSale = null;
|
| Line 332... |
Line 345... |
| 332 |
itemSale = (float) 0;
|
345 |
itemSale = (float) 0;
|
| 333 |
itemDiscount = (float) 0;
|
346 |
itemDiscount = (float) 0;
|
| 334 |
qty = 0;
|
347 |
qty = 0;
|
| 335 |
}
|
348 |
}
|
| 336 |
if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date_key)){
|
349 |
if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date_key)){
|
| - |
|
350 |
FbaSalesSnapshot fbaSalesSnapshot;
|
| 337 |
if(orderDateItemIdFbaSaleSnapshotMap.get(date_key).containsKey(itemid)){
|
351 |
if(orderDateItemIdFbaSaleSnapshotMap.get(date_key).containsKey(amazonOrder.getOrderItem().get(0).getSKU())){
|
| 338 |
FbaSalesSnapshot fbaSalesSnapshot = orderDateItemIdFbaSaleSnapshotMap.get(date_key).get(itemid);
|
352 |
fbaSalesSnapshot = orderDateItemIdFbaSaleSnapshotMap.get(date_key).get(amazonOrder.getOrderItem().get(0).getSKU());
|
| 339 |
if(itemDiscount!=0){
|
353 |
if(itemDiscount!=0){
|
| 340 |
fbaSalesSnapshot.setPromotionOrderCount(fbaSalesSnapshot.getPromotionOrderCount()+qty);
|
354 |
fbaSalesSnapshot.setPromotionOrderCount(fbaSalesSnapshot.getPromotionOrderCount()+qty);
|
| 341 |
fbaSalesSnapshot.setTotalPromotionSale(fbaSalesSnapshot.getTotalPromotionSale() + (itemSale - itemDiscount));
|
355 |
fbaSalesSnapshot.setTotalPromotionSale(fbaSalesSnapshot.getTotalPromotionSale() + (itemSale - itemDiscount));
|
| 342 |
}
|
356 |
}
|
| 343 |
else{
|
- |
|
| 344 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
357 |
fbaSalesSnapshot.setFcLocation(fcLocation);
|
| 345 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
- |
|
| 346 |
}
|
- |
|
| 347 |
fbaSalesSnapshot.setTotalOrderCount(fbaSalesSnapshot.getTotalOrderCount() + qty);
|
358 |
fbaSalesSnapshot.setTotalOrderCount(fbaSalesSnapshot.getTotalOrderCount() + qty);
|
| 348 |
fbaSalesSnapshot.setTotalSale(fbaSalesSnapshot.getTotalSale() + itemSale - itemDiscount);
|
359 |
fbaSalesSnapshot.setTotalSale(fbaSalesSnapshot.getTotalSale() + itemSale - itemDiscount);
|
| 349 |
orderDateItemIdFbaSaleSnapshotMap.get(date_key).put(itemid,fbaSalesSnapshot);
|
- |
|
| 350 |
}
|
360 |
}
|
| 351 |
else{
|
361 |
else{
|
| 352 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
362 |
fbaSalesSnapshot = new FbaSalesSnapshot();
|
| - |
|
363 |
fbaSalesSnapshot.setFcLocation(fcLocation);
|
| 353 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
364 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
| 354 |
fbaSalesSnapshot.setTotalSale(itemSale - itemDiscount);
|
365 |
fbaSalesSnapshot.setTotalSale(itemSale - itemDiscount);
|
| 355 |
if(itemDiscount!=0){
|
366 |
if(itemDiscount!=0){
|
| 356 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
367 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
| 357 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
368 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
| 358 |
}
|
369 |
}
|
| 359 |
else{
|
370 |
else{
|
| 360 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
371 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
| 361 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
372 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
| 362 |
}
|
373 |
}
|
| 363 |
orderDateItemIdFbaSaleSnapshotMap.get(date_key).put(itemid,fbaSalesSnapshot);
|
- |
|
| 364 |
}
|
374 |
}
|
| - |
|
375 |
orderDateItemIdFbaSaleSnapshotMap.get(date_key).put(amazonOrder.getOrderItem().get(0).getSKU(),fbaSalesSnapshot);
|
| 365 |
}
|
376 |
}
|
| 366 |
else{
|
377 |
else{
|
| 367 |
Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
|
378 |
Map<String,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<String,FbaSalesSnapshot>();
|
| 368 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
379 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
| - |
|
380 |
fbaSalesSnapshot.setFcLocation(fcLocation);
|
| 369 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
381 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
| 370 |
fbaSalesSnapshot.setTotalSale(itemSale);
|
382 |
fbaSalesSnapshot.setTotalSale(itemSale);
|
| 371 |
if(itemDiscount!=0){
|
383 |
if(itemDiscount!=0){
|
| 372 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
384 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
| 373 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
385 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
| 374 |
}
|
386 |
}
|
| 375 |
else{
|
387 |
else{
|
| 376 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
388 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
| 377 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
389 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
| 378 |
}
|
390 |
}
|
| 379 |
ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
|
391 |
ItemIdFbaSaleSnapshotMap.put(amazonOrder.getOrderItem().get(0).getSKU(),fbaSalesSnapshot);
|
| 380 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
392 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
| 381 |
}
|
393 |
}
|
| 382 |
}
|
394 |
}
|
| 383 |
}
|
395 |
}
|
| 384 |
}
|
396 |
}
|
| 385 |
|
397 |
|
| 386 |
/*while ((nextLine = orderreportreader.readNext()) != null) {
|
- |
|
| 387 |
try{
|
- |
|
| 388 |
if(count!=1 && nextLine[5].equalsIgnoreCase("Amazon") && nextLine[6].equalsIgnoreCase("Amazon.in")){
|
- |
|
| 389 |
SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
- |
|
| 390 |
istFormatter .setLenient(false);
|
- |
|
| 391 |
TimeZone zone= TimeZone.getTimeZone("GMT");
|
- |
|
| 392 |
istFormatter.setTimeZone(zone);
|
- |
|
| 393 |
Date date = istFormatter.parse(nextLine[2]);
|
- |
|
| 394 |
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
- |
|
| 395 |
Date date_key = dateFormat.parse(dateFormat.format(date));
|
- |
|
| 396 |
System.out.println("Order Details " + nextLine[0]+" "+date_key+" "+ nextLine[11] +" " + nextLine[13] + " " + nextLine[14]);
|
- |
|
| 397 |
// 0- amazon-order-id 11- sku 13- item-status 14 - quantity
|
- |
|
| 398 |
Long itemid = Long.parseLong(nextLine[11].replaceAll("FBA",""));
|
- |
|
| 399 |
Integer qty=0;
|
- |
|
| 400 |
if(nextLine[14].length()!=0){
|
- |
|
| 401 |
qty = new Integer(nextLine[14]);
|
- |
|
| 402 |
}
|
- |
|
| 403 |
Float itemSale = null;
|
- |
|
| 404 |
if(nextLine[16].length()!=0){
|
- |
|
| 405 |
itemSale = new Float(nextLine[16]);
|
- |
|
| 406 |
}
|
- |
|
| 407 |
else{
|
- |
|
| 408 |
continue;
|
- |
|
| 409 |
}
|
- |
|
| 410 |
Float itemDiscount;
|
- |
|
| 411 |
if(nextLine[22].length()!=0){
|
- |
|
| 412 |
itemDiscount = new Float(nextLine[22]);
|
- |
|
| 413 |
}
|
- |
|
| 414 |
else{
|
- |
|
| 415 |
itemDiscount = new Float(0);
|
- |
|
| 416 |
}
|
- |
|
| 417 |
if(nextLine[4].equalsIgnoreCase("Cancelled") || nextLine[13].equalsIgnoreCase("Cancelled")){
|
- |
|
| 418 |
itemSale = (float) 0;
|
- |
|
| 419 |
itemDiscount = (float) 0;
|
- |
|
| 420 |
qty = 0;
|
- |
|
| 421 |
}
|
- |
|
| 422 |
if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date_key)){
|
- |
|
| 423 |
if(orderDateItemIdFbaSaleSnapshotMap.get(date_key).containsKey(itemid)){
|
- |
|
| 424 |
FbaSalesSnapshot fbaSalesSnapshot = orderDateItemIdFbaSaleSnapshotMap.get(date_key).get(itemid);
|
- |
|
| 425 |
if(itemDiscount!=0){
|
- |
|
| 426 |
fbaSalesSnapshot.setPromotionOrderCount(fbaSalesSnapshot.getPromotionOrderCount()+qty);
|
- |
|
| 427 |
fbaSalesSnapshot.setTotalPromotionSale(fbaSalesSnapshot.getTotalPromotionSale() + (itemSale - itemDiscount));
|
- |
|
| 428 |
}
|
- |
|
| 429 |
else{
|
- |
|
| 430 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
- |
|
| 431 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
- |
|
| 432 |
}
|
- |
|
| 433 |
fbaSalesSnapshot.setTotalOrderCount(fbaSalesSnapshot.getTotalOrderCount() + qty);
|
- |
|
| 434 |
fbaSalesSnapshot.setTotalSale(fbaSalesSnapshot.getTotalSale() + itemSale - itemDiscount);
|
- |
|
| 435 |
orderDateItemIdFbaSaleSnapshotMap.get(date_key).put(itemid,fbaSalesSnapshot);
|
- |
|
| 436 |
}
|
- |
|
| 437 |
else{
|
- |
|
| 438 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
- |
|
| 439 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
- |
|
| 440 |
fbaSalesSnapshot.setTotalSale(itemSale - itemDiscount);
|
- |
|
| 441 |
if(itemDiscount!=0){
|
- |
|
| 442 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
- |
|
| 443 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
- |
|
| 444 |
}
|
- |
|
| 445 |
else{
|
- |
|
| 446 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
- |
|
| 447 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
- |
|
| 448 |
}
|
- |
|
| 449 |
orderDateItemIdFbaSaleSnapshotMap.get(date_key).put(itemid,fbaSalesSnapshot);
|
- |
|
| 450 |
}
|
- |
|
| 451 |
}
|
- |
|
| 452 |
else{
|
- |
|
| 453 |
Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
|
- |
|
| 454 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
- |
|
| 455 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
- |
|
| 456 |
fbaSalesSnapshot.setTotalSale(itemSale);
|
- |
|
| 457 |
if(itemDiscount!=0){
|
- |
|
| 458 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
- |
|
| 459 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
- |
|
| 460 |
}
|
- |
|
| 461 |
else{
|
- |
|
| 462 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
- |
|
| 463 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
- |
|
| 464 |
}
|
- |
|
| 465 |
ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
|
- |
|
| 466 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
- |
|
| 467 |
}
|
- |
|
| 468 |
}
|
- |
|
| 469 |
}
|
- |
|
| 470 |
catch(Exception e){
|
- |
|
| 471 |
e.printStackTrace();
|
- |
|
| 472 |
}
|
- |
|
| 473 |
count++;
|
- |
|
| 474 |
}*/
|
- |
|
| 475 |
InventoryClient inventoryServiceClient = null;
|
398 |
InventoryClient inventoryServiceClient = null;
|
| 476 |
TransactionClient transactionServiceClient = null;
|
399 |
TransactionClient transactionServiceClient = null;
|
| 477 |
CatalogClient catalogServiceClient = null;
|
400 |
CatalogClient catalogServiceClient = null;
|
| 478 |
try {
|
401 |
try {
|
| 479 |
inventoryServiceClient = new InventoryClient();
|
402 |
inventoryServiceClient = new InventoryClient();
|
| Line 500... |
Line 423... |
| 500 |
cal.setTime(d);
|
423 |
cal.setTime(d);
|
| 501 |
cal.add(Calendar.DATE,1);
|
424 |
cal.add(Calendar.DATE,1);
|
| 502 |
d = cal.getTime();
|
425 |
d = cal.getTime();
|
| 503 |
dates.add(d);
|
426 |
dates.add(d);
|
| 504 |
}
|
427 |
}
|
| 505 |
List<AmazonFbaInventorySnapshot> nonzeroFbaInventorySnapshotlist = inventoryClient.getAllAmazonFbaItemInventory();
|
428 |
List<AmazonFbaInventorySnapshot> fbaInventorySnapshotlist = inventoryClient.getAllAmazonFbaItemInventory();
|
| - |
|
429 |
String prefix;
|
| 506 |
for(Date date:dates){
|
430 |
for(Date date:dates){
|
| 507 |
if(nonzeroFbaInventorySnapshotlist!=null){
|
431 |
if(fbaInventorySnapshotlist!=null){
|
| 508 |
for(AmazonFbaInventorySnapshot amazonFbaInventory:nonzeroFbaInventorySnapshotlist){
|
432 |
for(AmazonFbaInventorySnapshot amazonFbaInventory:fbaInventorySnapshotlist){
|
| - |
|
433 |
if(amazonFbaInventory.getLocation().name().equals(AmazonFCWarehouseLocation.Bangalore.name())){
|
| - |
|
434 |
prefix = "FBB";
|
| - |
|
435 |
}
|
| - |
|
436 |
else if(amazonFbaInventory.getLocation().name().equals(AmazonFCWarehouseLocation.Mumbai.name())){
|
| - |
|
437 |
prefix = "FBA";
|
| - |
|
438 |
}
|
| - |
|
439 |
else{
|
| - |
|
440 |
continue;
|
| - |
|
441 |
}
|
| 509 |
if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date) ){
|
442 |
if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date) ){
|
| 510 |
if(!orderDateItemIdFbaSaleSnapshotMap.get(date).containsKey(amazonFbaInventory.getItem_id())){
|
443 |
if(!orderDateItemIdFbaSaleSnapshotMap.get(date).containsKey(prefix+String.valueOf(amazonFbaInventory.getItem_id()))){
|
| 511 |
Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
|
444 |
Map<String,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date);
|
| 512 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
445 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
| 513 |
fbaSalesSnapshot.setTotalOrderCount(0);
|
446 |
fbaSalesSnapshot.setTotalOrderCount(0);
|
| 514 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
447 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
| 515 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
448 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
| 516 |
fbaSalesSnapshot.setTotalSale((float) 0);
|
449 |
fbaSalesSnapshot.setTotalSale((float) 0);
|
| 517 |
ItemIdFbaSaleSnapshotMap.put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
|
450 |
ItemIdFbaSaleSnapshotMap.put(prefix+String.valueOf(amazonFbaInventory.getItem_id()),fbaSalesSnapshot);
|
| 518 |
orderDateItemIdFbaSaleSnapshotMap.get(date).put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
|
451 |
orderDateItemIdFbaSaleSnapshotMap.put(date,ItemIdFbaSaleSnapshotMap);
|
| 519 |
}
|
452 |
}
|
| 520 |
|
- |
|
| 521 |
}
|
453 |
}
|
| 522 |
else{
|
454 |
else{
|
| 523 |
Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
|
455 |
Map<String,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<String,FbaSalesSnapshot>();
|
| 524 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
456 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
| 525 |
fbaSalesSnapshot.setTotalOrderCount(0);
|
457 |
fbaSalesSnapshot.setTotalOrderCount(0);
|
| 526 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
458 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
| 527 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
459 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
| 528 |
fbaSalesSnapshot.setTotalSale((float) 0);
|
460 |
fbaSalesSnapshot.setTotalSale((float) 0);
|
| 529 |
ItemIdFbaSaleSnapshotMap.put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
|
461 |
ItemIdFbaSaleSnapshotMap.put(prefix+String.valueOf(amazonFbaInventory.getItem_id()),fbaSalesSnapshot);
|
| 530 |
orderDateItemIdFbaSaleSnapshotMap.put(date,ItemIdFbaSaleSnapshotMap);
|
462 |
orderDateItemIdFbaSaleSnapshotMap.put(date,ItemIdFbaSaleSnapshotMap);
|
| 531 |
}
|
463 |
}
|
| 532 |
}
|
464 |
}
|
| 533 |
}
|
465 |
}
|
| 534 |
else{
|
466 |
else{
|
| 535 |
System.out.println("No inventory in FBA");
|
467 |
System.out.println("No inventory at Amazon FC");
|
| 536 |
}
|
468 |
}
|
| 537 |
}
|
469 |
}
|
| 538 |
Map<Long,PriceAtDate> itemIdOurPriceMap = new HashMap<Long,PriceAtDate>();
|
470 |
Map<Long,PriceAtDate> itemIdOurPriceMap = new HashMap<Long,PriceAtDate>();
|
| 539 |
Map<Long,PriceAtDate> itemIdSalePriceMap = new HashMap<Long,PriceAtDate>();
|
471 |
Map<Long,PriceAtDate> itemIdSalePriceMap = new HashMap<Long,PriceAtDate>();
|
| 540 |
Map<Long,PriceAtDate> itemIdminFBAPriceMap = new HashMap<Long,PriceAtDate>();
|
472 |
Map<Long,PriceAtDate> itemIdminFBAPriceMap = new HashMap<Long,PriceAtDate>();
|
| Line 547... |
Line 479... |
| 547 |
SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
479 |
SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
| 548 |
istFormatter .setLenient(false);
|
480 |
istFormatter .setLenient(false);
|
| 549 |
TimeZone zone= TimeZone.getTimeZone("GMT");
|
481 |
TimeZone zone= TimeZone.getTimeZone("GMT");
|
| 550 |
istFormatter.setTimeZone(zone);
|
482 |
istFormatter.setTimeZone(zone);
|
| 551 |
Date date = istFormatter.parse(nextLine[0]);
|
483 |
Date date = istFormatter.parse(nextLine[0]);
|
| - |
|
484 |
if(nextLine[1].length()> 0 && (nextLine[1].startsWith("FBA") || nextLine[1].startsWith("FBB"))){
|
| - |
|
485 |
nextLine[1] = nextLine[1].replaceAll("FBA","");
|
| - |
|
486 |
nextLine[1] = nextLine[1].replaceAll("FBB","");
|
| - |
|
487 |
}
|
| - |
|
488 |
else{
|
| - |
|
489 |
continue;
|
| - |
|
490 |
}
|
| 552 |
Long item_id = Long.parseLong(nextLine[1].replaceAll("FBA",""));
|
491 |
Long item_id = Long.parseLong(nextLine[1]);
|
| 553 |
Double ourPrice = null;
|
492 |
Double ourPrice = null;
|
| 554 |
Double minFBAPrice= null;
|
493 |
Double minFBAPrice= null;
|
| 555 |
Double minMFNPrice= null;
|
494 |
Double minMFNPrice= null;
|
| 556 |
Double salePrice= null;
|
495 |
Double salePrice= null;
|
| 557 |
if(nextLine[30].length() >0){
|
496 |
if(nextLine[30].length() >0){
|
| Line 629... |
Line 568... |
| 629 |
}
|
568 |
}
|
| 630 |
count++;
|
569 |
count++;
|
| 631 |
}
|
570 |
}
|
| 632 |
boolean oos;
|
571 |
boolean oos;
|
| 633 |
List<AmazonFbaSalesSnapshot> fbaSalesSnapShotList = new ArrayList<AmazonFbaSalesSnapshot>();
|
572 |
List<AmazonFbaSalesSnapshot> fbaSalesSnapShotList = new ArrayList<AmazonFbaSalesSnapshot>();
|
| 634 |
for (Entry<Date, Map<Long, FbaSalesSnapshot>> entry : orderDateItemIdFbaSaleSnapshotMap.entrySet()){
|
573 |
for (Entry<Date, Map<String, FbaSalesSnapshot>> entry : orderDateItemIdFbaSaleSnapshotMap.entrySet()){
|
| 635 |
Date orderDate = entry.getKey();
|
574 |
Date orderDate = entry.getKey();
|
| - |
|
575 |
AmazonFCWarehouseLocation location;
|
| - |
|
576 |
Long item_id;
|
| 636 |
for(Entry<Long, FbaSalesSnapshot> entry1 :entry.getValue().entrySet()){
|
577 |
for(Entry<String, FbaSalesSnapshot> entry1 :entry.getValue().entrySet()){
|
| - |
|
578 |
if(entry1.getKey().startsWith("FBA")){
|
| - |
|
579 |
location = AmazonFCWarehouseLocation.Mumbai;
|
| - |
|
580 |
item_id = Long.parseLong(entry1.getKey().replaceAll("FBA",""));
|
| - |
|
581 |
}
|
| - |
|
582 |
else if(entry1.getKey().startsWith("FBB")){
|
| - |
|
583 |
location = AmazonFCWarehouseLocation.Bangalore;
|
| - |
|
584 |
item_id = Long.parseLong(entry1.getKey().replaceAll("FBB",""));
|
| - |
|
585 |
}
|
| - |
|
586 |
else{
|
| - |
|
587 |
continue;
|
| - |
|
588 |
}
|
| 637 |
System.out.println("Item ID is " + entry1.getKey());
|
589 |
// System.out.println("Item ID is " + item_id);
|
| - |
|
590 |
List<AmazonFbaInventorySnapshot> iteminventory;
|
| 638 |
Long inventory;
|
591 |
Long inventory = 0L;
|
| 639 |
try{
|
592 |
try{
|
| 640 |
inventory = inventoryClient.getAmazonFbaItemInventory(entry1.getKey());
|
593 |
iteminventory = inventoryClient.getAmazonFbaItemInventory(item_id);
|
| 641 |
}
|
594 |
}
|
| 642 |
catch(TTransportException e){
|
595 |
catch(TTransportException e){
|
| 643 |
inventoryClient = inventoryServiceClient.getClient();
|
596 |
inventoryClient = inventoryServiceClient.getClient();
|
| 644 |
inventory = inventoryClient.getAmazonFbaItemInventory(entry1.getKey());
|
597 |
iteminventory = inventoryClient.getAmazonFbaItemInventory(item_id);
|
| - |
|
598 |
}
|
| - |
|
599 |
for(AmazonFbaInventorySnapshot inv:iteminventory){
|
| - |
|
600 |
if(inv.getLocation().equals(location)){
|
| - |
|
601 |
inventory = inv.getAvailability();
|
| - |
|
602 |
}
|
| 645 |
}
|
603 |
}
|
| 646 |
if(inventory==0 && entry1.getValue().getTotalOrderCount()==0){
|
604 |
if(inventory==0 && entry1.getValue().getTotalOrderCount()==0){
|
| 647 |
oos=true;
|
605 |
oos=true;
|
| 648 |
}
|
606 |
}
|
| 649 |
else{
|
607 |
else{
|
| 650 |
oos=false;
|
608 |
oos=false;
|
| 651 |
}
|
609 |
}
|
| 652 |
Long item_id = entry1.getKey();
|
- |
|
| 653 |
Amazonlisted amazon_item;
|
610 |
Amazonlisted amazon_item;
|
| 654 |
try{
|
611 |
try{
|
| 655 |
amazon_item=catalogClient.getAmazonItemDetails(item_id);
|
612 |
amazon_item=catalogClient.getAmazonItemDetails(item_id);
|
| 656 |
}
|
613 |
}
|
| 657 |
catch(TTransportException e){
|
614 |
catch(TTransportException e){
|
| Line 659... |
Line 616... |
| 659 |
amazon_item=catalogClient.getAmazonItemDetails(item_id);
|
616 |
amazon_item=catalogClient.getAmazonItemDetails(item_id);
|
| 660 |
}
|
617 |
}
|
| 661 |
if(amazon_item.getItemid()==0){
|
618 |
if(amazon_item.getItemid()==0){
|
| 662 |
continue;
|
619 |
continue;
|
| 663 |
}
|
620 |
}
|
| 664 |
System.out.println(orderDate +","+entry1.getKey()+","+entry1.getValue()+","+ inventory +","+ oos+","+itemIdSalePriceMap.get(item_id)+","+itemIdminFBAPriceMap.get(item_id)+","+itemIdminMFNPriceMap.get(item_id));
|
621 |
//System.out.println(orderDate +","+entry1.getKey()+","+entry1.getValue()+","+ inventory +","+ oos+","+itemIdSalePriceMap.get(item_id)+","+itemIdminFBAPriceMap.get(item_id)+","+itemIdminMFNPriceMap.get(item_id));
|
| 665 |
AmazonFbaSalesSnapshot amazonfbasalessnapshot = new AmazonFbaSalesSnapshot();
|
622 |
AmazonFbaSalesSnapshot amazonfbasalessnapshot = new AmazonFbaSalesSnapshot();
|
| 666 |
amazonfbasalessnapshot.setDateOfSale(orderDate.getTime());
|
623 |
amazonfbasalessnapshot.setDateOfSale(orderDate.getTime());
|
| 667 |
amazonfbasalessnapshot.setItem_id(entry1.getKey());
|
624 |
amazonfbasalessnapshot.setItem_id(item_id);
|
| 668 |
amazonfbasalessnapshot.setTotalOrderCount(entry1.getValue().getPromotionOrderCount());
|
625 |
amazonfbasalessnapshot.setTotalOrderCount(entry1.getValue().getPromotionOrderCount());
|
| 669 |
amazonfbasalessnapshot.setTotalOrderCount(entry1.getValue().getTotalOrderCount());
|
626 |
amazonfbasalessnapshot.setTotalOrderCount(entry1.getValue().getTotalOrderCount());
|
| 670 |
amazonfbasalessnapshot.setTotalSale(entry1.getValue().getTotalSale());
|
627 |
amazonfbasalessnapshot.setTotalSale(entry1.getValue().getTotalSale());
|
| 671 |
amazonfbasalessnapshot.setPromotionSale(entry1.getValue().getTotalPromotionSale());
|
628 |
amazonfbasalessnapshot.setPromotionSale(entry1.getValue().getTotalPromotionSale());
|
| 672 |
amazonfbasalessnapshot.setIsOutOfStock(oos);
|
629 |
amazonfbasalessnapshot.setIsOutOfStock(oos);
|
| Line 701... |
Line 658... |
| 701 |
else{
|
658 |
else{
|
| 702 |
amazonfbasalessnapshot.setOurPrice(amazon_item.getFbaPrice());
|
659 |
amazonfbasalessnapshot.setOurPrice(amazon_item.getFbaPrice());
|
| 703 |
amazonfbasalessnapshot.setOurPriceSnapshotDate(0);
|
660 |
amazonfbasalessnapshot.setOurPriceSnapshotDate(0);
|
| 704 |
}
|
661 |
}
|
| 705 |
amazonfbasalessnapshot.setAmazonFbaInventory(inventory);
|
662 |
amazonfbasalessnapshot.setAmazonFbaInventory(inventory);
|
| - |
|
663 |
amazonfbasalessnapshot.setFcLocation(location);
|
| 706 |
fbaSalesSnapShotList.add(amazonfbasalessnapshot);
|
664 |
fbaSalesSnapShotList.add(amazonfbasalessnapshot);
|
| 707 |
}
|
665 |
}
|
| 708 |
}
|
666 |
}
|
| 709 |
System.out.println("Order Details to be Updated Size... "+fbaSalesSnapShotList.size());
|
667 |
System.out.println("Order Details to be Updated Size... "+fbaSalesSnapShotList.size());
|
| 710 |
try{
|
668 |
try{
|