OrderType order = new OrderType();
order.setCreatingUserRole(TradingRoleCodeType.SELLER);
BuyerPaymentMethodCodeType[] buyerPayment = new BuyerPaymentMethodCodeType[1];
buyerPayment[0] = BuyerPaymentMethodCodeType.CASH_ON_PICKUP;
order.setPaymentMethods(buyerPayment);
TransactionArrayType transactionArr = new TransactionArrayType();
List translist = FastList.newInstance();
AmountType total = new AmountType();
double totalAmt = 0.0;
CurrencyCodeType currencyId = null;
int totalQty = 0;
for (int j = 0; j < soldGroupList.size(); j++) {
Map<String, Object> myMap = (Map<String, Object>) soldGroupList.get(j);
if (UtilValidate.isNotEmpty(myMap.get("group"))) {
if (x == Integer.parseInt(myMap.get("group").toString())) {
SellingManagerSoldOrderType sellingManagerSoldOrder = (SellingManagerSoldOrderType) myMap.get("soldorder");
String buyerId = sellingManagerSoldOrder.getBuyerID().toString();
int qty = sellingManagerSoldOrder.getTotalQuantity();
totalQty = totalQty + qty;
if (key.equals(buyerId) && (UtilValidate.isEmpty(sellingManagerSoldOrder.getOrderStatus().getPaidTime()))) {
double totalAmount = 0.0;
if (UtilValidate.isNotEmpty(sellingManagerSoldOrder.getTotalAmount())) {
totalAmount = sellingManagerSoldOrder.getTotalAmount().getValue();
currencyId = sellingManagerSoldOrder.getTotalAmount().getCurrencyID();
} else {
totalAmount = sellingManagerSoldOrder.getSalePrice().getValue();
currencyId = sellingManagerSoldOrder.getSalePrice().getCurrencyID();
}
//Combine
totalAmt = totalAmt + totalAmount;
SellingManagerSoldTransactionType[] sellingManagerSoldTransactions = sellingManagerSoldOrder.getSellingManagerSoldTransaction();
//set transaction
for (int count = 0; count < sellingManagerSoldTransactions.length; count++) {
SellingManagerSoldTransactionType sellingManagerSoldTransaction = sellingManagerSoldTransactions[count];
TransactionType transtype = new TransactionType();
ItemType itemtype = new ItemType();
if (UtilValidate.isNotEmpty(sellingManagerSoldTransaction.getItemID())) {
itemtype.setItemID(sellingManagerSoldTransaction.getItemID());
transtype.setItem(itemtype);
transtype.setTransactionID(sellingManagerSoldTransaction.getTransactionID().toString());
translist.add(transtype);
}
}
}
}
}
}
if (totalQty < maxItems) {
total.setValue(totalAmt);
total.setCurrencyID(currencyId);
TransactionType[] transArr = new TransactionType[translist.size()];
for (int counter = 0; counter < translist.size(); counter++) {
transArr[counter] = (TransactionType) translist.get(counter);
}
transactionArr.setTransaction(transArr);
if (transactionArr.getTransactionLength() > 1) {
order.setTotal(total);
order.setTransactionArray(transactionArr);
AddOrderCall call = new AddOrderCall(apiContext);
AddOrderRequestType req = new AddOrderRequestType();
AddOrderResponseType resp = null;