SellingManagerSoldOrderType[] sellingManagerSoldOrders = sellingManagerSoldListings.getReturnedSaleRecord();
if (UtilValidate.isNotEmpty(sellingManagerSoldOrders)) {
int soldOrderLength = sellingManagerSoldOrders.length;
for (int i = 0; i < soldOrderLength; i++) {
SellingManagerSoldOrderType sellingManagerSoldOrder = sellingManagerSoldOrders[i];
if (sellingManagerSoldOrder != null) {
SellingManagerSoldTransactionType[] sellingManagerSoldTransactions = sellingManagerSoldOrder.getSellingManagerSoldTransaction();
int sellingManagerSoldTransactionLength = sellingManagerSoldTransactions.length;
for (int j = 0; j < sellingManagerSoldTransactionLength; j++) {
Map<String, Object> entry = FastMap.newInstance();
SellingManagerSoldTransactionType sellingManagerSoldTransaction = sellingManagerSoldTransactions[j];
entry.put("itemId", sellingManagerSoldTransaction.getItemID());
entry.put("title", sellingManagerSoldTransaction.getItemTitle());
entry.put("transactionId", sellingManagerSoldTransaction.getTransactionID().toString());
entry.put("quantity", sellingManagerSoldTransaction.getQuantitySold());
entry.put("listingType", sellingManagerSoldTransaction.getListingType().value());
String buyer = null;
if (sellingManagerSoldOrder.getBuyerID() != null) {
buyer = sellingManagerSoldOrder.getBuyerID();
}
entry.put("buyer", buyer);
String buyerEmail = null;
if (sellingManagerSoldOrder.getBuyerID() != null) {
buyerEmail = sellingManagerSoldOrder.getBuyerEmail();
}
entry.put("buyerEmail", buyerEmail);
GetItemCall api = new GetItemCall(apiContext);
api.setItemID(sellingManagerSoldTransaction.getItemID());
DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
DetailLevelCodeType.RETURN_ALL,
DetailLevelCodeType.ITEM_RETURN_ATTRIBUTES,
DetailLevelCodeType.ITEM_RETURN_DESCRIPTION
};
api.setDetailLevel(detailLevels);
ItemType itemType = api.getItem();
String itemUrl = null;
entry.put("SKU", itemType.getSKU());
if (UtilValidate.isNotEmpty(itemType.getReservePrice())) reservPrice = itemType.getReservePrice().getValue();
entry.put("reservePrice", reservPrice);
entry.put("hitCount", itemType.getHitCount() != null ? itemType.getHitCount() : 0);
if (itemType.getListingDetails() != null) {
itemUrl = itemType.getListingDetails().getViewItemURL();
}
entry.put("itemUrl", itemUrl);
String itemUrlNatural = null;
if (itemType.getListingDetails() != null) {
itemUrlNatural = itemType.getListingDetails().getViewItemURLForNaturalSearch();
}
entry.put("itemUrlNatural", itemUrlNatural);
String unpaidItemStatus = null;
if (sellingManagerSoldOrder.getUnpaidItemStatus() != null) {
unpaidItemStatus = sellingManagerSoldOrder.getUnpaidItemStatus().value();
}
entry.put("unpaidItemStatus", unpaidItemStatus);
Date creationTime = null;
if (sellingManagerSoldOrder.getCreationTime() != null) {
creationTime = sellingManagerSoldOrder.getCreationTime().getTime();
}
entry.put("creationTime", creationTime);
double totalAmount = 0;
if (sellingManagerSoldOrder.getTotalAmount() != null) {
totalAmount = sellingManagerSoldOrder.getTotalAmount().getValue();
}
entry.put("totalAmount", totalAmount);
if (sellingManagerSoldOrder.getSalePrice() != null) {
entry.put("salePrice", sellingManagerSoldOrder.getSalePrice().getValue());
}
Date paidTime = null;
String checkoutStatus = null;
String shippedStatus = null;
Date shippedTime = null;
if (sellingManagerSoldOrder.getOrderStatus() != null) {
if (sellingManagerSoldOrder.getOrderStatus().getPaidTime() != null) {
paidTime = sellingManagerSoldOrder.getOrderStatus().getPaidTime().getTime();
}
if (sellingManagerSoldOrder.getOrderStatus().getCheckoutStatus() != null) {
checkoutStatus = sellingManagerSoldOrder.getOrderStatus().getCheckoutStatus().value();
}
if (sellingManagerSoldOrder.getOrderStatus().getShippedStatus() != null) {
shippedStatus = sellingManagerSoldOrder.getOrderStatus().getShippedStatus().value();
}
if (sellingManagerSoldOrder.getOrderStatus().getShippedTime() != null) {
shippedTime = sellingManagerSoldOrder.getOrderStatus().getShippedTime().getTime();
}
}
entry.put("paidTime", paidTime);
entry.put("checkoutStatus", checkoutStatus);
entry.put("shippedStatus", shippedStatus);