public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null)
{
$totalTransactions = array();
$merchantIdArray = \array_keys(\Oara\Utilities::getMerchantIdMapFromMerchantList($merchantList));
$iteration = self::calculeIterationNumber(\count($merchantIdArray), '20');
for ($it = 0; $it < $iteration; $it++) {
//echo "iteration $it of $iteration \n\n";
$merchantSlice = \array_slice($merchantIdArray, $it * 20, 20);
try {
$transactionDateEnd = clone $dEndDate;
$transactionDateEnd->add(new \DateInterval('P1D'));
$restUrl = 'https://commission-detail.api.cj.com/v3/commissions?cids=' . \implode(',', $merchantSlice) . '&date-type=posting&start-date=' . $dStartDate->format("Y-m-d") . '&end-date=' . $transactionDateEnd->format("Y-m-d");
$totalTransactions = \array_merge($totalTransactions, self::getTransactionsXml($restUrl, $merchantList));
} catch (\Exception $e) {
$amountDays = $dStartDate->diff($dEndDate)->days;
$auxDate = clone $dStartDate;
for ($j = 0; $j <= $amountDays; $j++) {
$transactionDateEnd = clone $auxDate;
$transactionDateEnd->add(new \DateInterval('P1D'));
$restUrl = 'https://commission-detail.api.cj.com/v3/commissions?cids=' . \implode(',', $merchantSlice) . '&date-type=posting&start-date=' . $auxDate->format("Y-m-d") . '&end-date=' . $transactionDateEnd->format("Y-m-d");
try {
$totalTransactions = \array_merge($totalTransactions, self::getTransactionsXml($restUrl, $merchantList));
} catch (\Exception $e) {
$try = 0;
$done = false;
while (!$done && $try < 5) {
try {
$totalTransactions = \array_merge($totalTransactions, self::transactionsByType(\implode(',', $merchantSlice), $auxDate, $transactionDateEnd, $merchantList));
$done = true;
} catch (\Exception $e) {
$try++;
//echo "try again $try\n\n";
}
}
if ($try == 5) {
throw new \Exception("Couldn't get data from the Transaction");
}
}
$auxDate->add(new \DateInterval('P1D'));
}
}
}
return $totalTransactions;
}