SortedMap<String, Object> acceptBestOfferIDs = new TreeMap<String, Object>();
//Loop for get data best offer from buyer
RespondToBestOfferCall respondToBestOfferCall = new RespondToBestOfferCall(apiContext);
respondToBestOfferCall.setItemID(itemID);
for (int offerCount = 0; offerCount < bestOffers.length; offerCount++) {
BestOfferType bestOfferType = bestOffers[offerCount];
BestOfferStatusCodeType bestOfferStatusCodeType = bestOfferType.getStatus();
//Check status of best offer
if (bestOfferStatusCodeType == BestOfferStatusCodeType.PENDING) {
String bestOfferID = bestOfferType.getBestOfferID();
UserType buyer = bestOfferType.getBuyer();
String buyerUserID = buyer.getUserID();
AmountType price = bestOfferType.getPrice();
String offerPrice = new Double(price.getValue()).toString();
Double doCerrentPrice = Double.parseDouble(offerPrice);
int offerQuantity = bestOfferType.getQuantity();
String[] bestOfferIDs = { bestOfferID };
respondToBestOfferCall.setBestOfferIDs(bestOfferIDs);
if (rejectOffer.equals("Y")) {
if (offerQuantity > inventoryQuantityItem) {
respondToBestOfferCall.setSellerResponse("Your order is more than inventory item's Buy-It-Now price.");
respondToBestOfferCall.setBestOfferAction(BestOfferActionCodeType.DECLINE);
respondToBestOfferCall.respondToBestOffer();
continue;
}
}
String buyerMessage = bestOfferType.getBuyerMessage();
if (ignoreOfferMessage.equals("Y") && UtilValidate.isNotEmpty(buyerMessage)) {
GenericValue userOfferCheck = delegator.findByPrimaryKey("EbayUserBestOffer", UtilMisc.toMap("itemId", itemID, "userId", buyerUserID));
if (UtilValidate.isEmpty(userOfferCheck)) {
GenericValue ebayUserBestOffer = delegator.makeValue("EbayUserBestOffer");
ebayUserBestOffer.put("productStoreId", productStoreId);