getMerchantNameMapFromMerchantList() публичный статический Метод

public static getMerchantNameMapFromMerchantList ( $merchantList ) : array
$merchantList
Результат array
Пример #1
0
 /**
  * @param null $merchantList
  * @param \DateTime|null $dStartDate
  * @param \DateTime|null $dEndDate
  * @return array
  */
 public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null)
 {
     $merchantNameMap = \Oara\Utilities::getMerchantNameMapFromMerchantList($merchantList);
     $totalTransactions = array();
     $valuesFromExport = array();
     $valuesFromExport[] = new \Oara\Curl\Parameter('period', '-1');
     $valuesFromExport[] = new \Oara\Curl\Parameter('subPeriod', '0');
     $valuesFromExport[] = new \Oara\Curl\Parameter('websiteId', '-1');
     $valuesFromExport[] = new \Oara\Curl\Parameter('hdnMerchantProgram', '');
     $valuesFromExport[] = new \Oara\Curl\Parameter('searchType', '1');
     $valuesFromExport[] = new \Oara\Curl\Parameter('merchantId', '-1');
     $valuesFromExport[] = new \Oara\Curl\Parameter('subId', '');
     $valuesFromExport[] = new \Oara\Curl\Parameter('approvalStatus', '-1');
     $valuesFromExport[] = new \Oara\Curl\Parameter('records', '20');
     $valuesFromExport[] = new \Oara\Curl\Parameter('sortField', 'transactionDateTime');
     $valuesFromExport[] = new \Oara\Curl\Parameter('time', '1');
     $valuesFromExport[] = new \Oara\Curl\Parameter('p', '1');
     $valuesFromExport[] = new \Oara\Curl\Parameter('changePage', '1');
     $valuesFromExport[] = new \Oara\Curl\Parameter('oldColumn', 'transactionDateTime');
     $valuesFromExport[] = new \Oara\Curl\Parameter('order', 'down');
     $valuesFromExport[] = new \Oara\Curl\Parameter('mId', '-1');
     $valuesFromExport[] = new \Oara\Curl\Parameter('submittedPeriod', -1);
     $valuesFromExport[] = new \Oara\Curl\Parameter('submittedSubId', '');
     $valuesFromExport[] = new \Oara\Curl\Parameter('exportType', 'csv');
     $valuesFromExport[] = new \Oara\Curl\Parameter('reportTitle', 'report');
     $valuesFromExport[] = new \Oara\Curl\Parameter('reportId', '');
     $valuesFromExport[] = new \Oara\Curl\Parameter('startDate', $dStartDate->format("d/m/Y"));
     $valuesFromExport[] = new \Oara\Curl\Parameter('endDate', $dEndDate->format("d/m/Y"));
     $urls = array();
     $urls[] = new \Oara\Curl\Request("{$this->_extension}/affiliate_statistic_transaction.html?", $valuesFromExport);
     $exportReport = $this->_client->post($urls);
     $exportData = \str_getcsv($exportReport[0], "\n");
     $num = \count($exportData);
     for ($i = 2; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ",");
         if (isset($merchantNameMap[$transactionExportArray[2]])) {
             $merchantId = $merchantNameMap[$transactionExportArray[2]];
             $transaction = array();
             $transaction['merchantId'] = $merchantId;
             $transactionDate = \DateTime::createFromFormat("d/m/Y H:i:s", $transactionExportArray[4]);
             $transaction['date'] = $transactionDate->format("Y-m-d H:i:s");
             $transaction['unique_id'] = $transactionExportArray[0];
             if ($transactionExportArray[12] != null && \trim($transactionExportArray[12]) != null) {
                 $transaction['custom_id'] = $transactionExportArray[12];
             }
             if ($transactionExportArray[15] == "Approved" || $transactionExportArray[15] == "Approve") {
                 $transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED;
             } else {
                 if ($transactionExportArray[15] == "Pending") {
                     $transaction['status'] = \Oara\Utilities::STATUS_PENDING;
                 } else {
                     if ($transactionExportArray[15] == "Declined" || $transactionExportArray[15] == "Rejected") {
                         $transaction['status'] = \Oara\Utilities::STATUS_DECLINED;
                     } else {
                         throw new \Exception("No Status found " . $transactionExportArray[15]);
                     }
                 }
             }
             $transaction['amount'] = \Oara\Utilities::parseDouble($transactionExportArray[7]);
             $transaction['commission'] = \Oara\Utilities::parseDouble($transactionExportArray[9]);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Пример #2
0
 /**
  * @param null $merchantList
  * @param \DateTime|null $dStartDate
  * @param \DateTime|null $dEndDate
  * @return array
  */
 public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null)
 {
     $totalTransactions = array();
     $merchantIdList = \Oara\Utilities::getMerchantIdMapFromMerchantList($merchantList);
     $merchantMap = \Oara\Utilities::getMerchantNameMapFromMerchantList($merchantList);
     $valuesFromExport = array();
     $valuesFromExport[] = new \Oara\Curl\Parameter('api_key', $this->_apiPassword);
     $valuesFromExport[] = new \Oara\Curl\Parameter('start_date', $dStartDate->format("Y-m-d"));
     $valuesFromExport[] = new \Oara\Curl\Parameter('end_date', $dEndDate->format("Y-m-d"));
     $valuesFromExport[] = new \Oara\Curl\Parameter('filter[Stat.offer_id]', \implode(",", $merchantIdList));
     $urls = array();
     $urls[] = new \Oara\Curl\Request('http://p.wowtrk.com/stats/lead_report.xml?', $valuesFromExport);
     $exportReport = $this->_exportClient->get($urls);
     $exportData = self::loadXml($exportReport[0]);
     foreach ($exportData->stats->stat as $transaction) {
         if (isset($merchantMap[(string) $transaction->offer])) {
             $obj = array();
             $obj['merchantId'] = $merchantMap[(string) $transaction->offer];
             $obj['date'] = (string) $transaction->date_time;
             $obj['status'] = \Oara\Utilities::STATUS_CONFIRMED;
             $obj['customId'] = (string) $transaction->sub_id;
             $obj['amount'] = \Oara\Utilities::parseDouble((string) $transaction->payout);
             $obj['commission'] = \Oara\Utilities::parseDouble((string) $transaction->payout);
             if ($obj['amount'] != 0 || $obj['commission'] != 0) {
                 $totalTransactions[] = $obj;
             }
         }
     }
     return $totalTransactions;
 }
Пример #3
0
 /**
  * @param null $merchantList
  * @param \DateTime|null $dStartDate
  * @param \DateTime|null $dEndDate
  * @return array
  */
 public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null)
 {
     $totalTransactions = array();
     $merchantMap = \Oara\Utilities::getMerchantNameMapFromMerchantList($merchantList);
     $statusArray = array(0, 1, 2);
     foreach ($statusArray as $status) {
         $valuesFromExport = array(new \Oara\Curl\Parameter('AfID', '0'), new \Oara\Curl\Parameter('S', ''), new \Oara\Curl\Parameter('ST', '2'), new \Oara\Curl\Parameter('Period', '6'), new \Oara\Curl\Parameter('AdID', '0'), new \Oara\Curl\Parameter('B', '2'));
         $valuesFromExport[] = new \Oara\Curl\Parameter('SD', $dStartDate->format("Y-m-d"));
         $valuesFromExport[] = new \Oara\Curl\Parameter('ED', $dEndDate->format("Y-m-d"));
         $valuesFromExport[] = new \Oara\Curl\Parameter('Status', $status);
         $urls = array();
         $urls[] = new \Oara\Curl\Request('http://www.clixgalore.co.uk/AffiliateTransactionSentReport_Excel.aspx?', $valuesFromExport);
         $exportReport = $this->_client->get($urls);
         $exportData = \Oara\Utilities::htmlToCsv($exportReport[0]);
         $num = \count($exportData);
         for ($i = 1; $i < $num; $i++) {
             $transactionExportArray = \str_getcsv($exportData[$i], ";");
             if (isset($merchantMap[$transactionExportArray[2]])) {
                 $transaction = array();
                 $merchantId = (int) $merchantMap[$transactionExportArray[2]];
                 $transaction['merchantId'] = $merchantId;
                 $transactionDate = \DateTime::createFromFormat("d M Y H:m", $transactionExportArray[0]);
                 $transaction['date'] = $transactionDate->format("Y-m-d H:i:s");
                 if ($transactionExportArray[6] != null) {
                     $transaction['custom_id'] = $transactionExportArray[6];
                 }
                 if ($status == 1) {
                     $transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED;
                 } else {
                     if ($status == 2) {
                         $transaction['status'] = \Oara\Utilities::STATUS_PENDING;
                     } else {
                         if ($status == 0) {
                             $transaction['status'] = \Oara\Utilities::STATUS_DECLINED;
                         }
                     }
                 }
                 $transaction['amount'] = \Oara\Utilities::parseDouble($transactionExportArray[4]);
                 $transaction['commission'] = \Oara\Utilities::parseDouble($transactionExportArray[5]);
                 $totalTransactions[] = $transaction;
             }
         }
     }
     return $totalTransactions;
 }
Пример #4
0
 /**
  * @param null $merchantList
  * @param \DateTime|null $dStartDate
  * @param \DateTime|null $dEndDate
  * @return array
  */
 public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null)
 {
     $totalTransactions = array();
     $merchantMap = \Oara\Utilities::getMerchantNameMapFromMerchantList($merchantList);
     $valuesFromExport = array();
     $valuesFromExport[] = new \Oara\Curl\Parameter('c', 'stats');
     $valuesFromExport[] = new \Oara\Curl\Parameter('id_shop', '');
     $valuesFromExport[] = new \Oara\Curl\Parameter('a', 'listMonthDayOrder');
     $valuesFromExport[] = new \Oara\Curl\Parameter('month', $dEndDate->fromat("Y-m"));
     $valuesFromExport[] = new \Oara\Curl\Parameter('export', 'csv');
     $urls = array();
     $urls[] = new \Oara\Curl\Request('http://www.afiliant.com/publisher/index.php?', $valuesFromExport);
     $exportData = null;
     try {
         $exportReport = $this->_client->get($urls);
         $exportData = \str_getcsv($exportReport[0], "\r\n");
     } catch (\Exception $e) {
         echo "No data \n";
     }
     if ($exportData != null) {
         $num = \count($exportData);
         for ($i = 0; $i < $num; $i++) {
             $transactionExportArray = \str_getcsv($exportData[$i], ";");
             if (isset($merchantMap[$transactionExportArray[1]])) {
                 $transaction = array();
                 $merchantId = (int) $merchantMap[$transactionExportArray[1]];
                 $transaction['merchantId'] = $merchantId;
                 $transaction['date'] = $transactionExportArray[0] . " 00:00:00";
                 $transaction['unique_id'] = $transactionExportArray[3];
                 if (isset($transactionExportArray[8]) && $transactionExportArray[8] != null) {
                     $transaction['custom_id'] = $transactionExportArray[8];
                 }
                 if ($transactionExportArray[6] == 'zaakceptowana') {
                     $transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED;
                 } else {
                     if ($transactionExportArray[6] == 'oczekuje') {
                         $transaction['status'] = \Oara\Utilities::STATUS_PENDING;
                     } else {
                         if ($transactionExportArray[6] == 'odrzucona') {
                             $transaction['status'] = \Oara\Utilities::STATUS_DECLINED;
                         }
                     }
                 }
                 $transaction['amount'] = \Oara\Utilities::parseDouble($transactionExportArray[4]);
                 $transaction['commission'] = \Oara\Utilities::parseDouble($transactionExportArray[5]);
                 $totalTransactions[] = $transaction;
             }
         }
     }
     return $totalTransactions;
 }