1
|
|
|
<?php |
2
|
|
|
namespace Padosoft\AffiliateNetwork; |
3
|
|
|
|
4
|
|
|
use Oara\Network\Publisher\Affilinet as AffilinetOara; |
5
|
|
|
|
6
|
|
|
class AffilinetEx extends AffilinetOara |
7
|
|
|
{ |
8
|
|
|
/** |
9
|
|
|
* @param null $merchantList |
10
|
|
|
* @param \DateTime|null $dStartDate |
11
|
|
|
* @param \DateTime|null $dEndDate |
12
|
|
|
* @return array |
13
|
|
|
* @throws Exception |
14
|
|
|
*/ |
15
|
|
|
public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null) |
16
|
|
|
{ |
17
|
|
|
$totalTransactions = array(); |
18
|
|
|
|
19
|
|
|
// Don't need merchant list here |
20
|
|
|
// $merchantIdList = \Oara\Utilities::getMerchantIdMapFromMerchantList($merchantList); |
|
|
|
|
21
|
|
|
|
22
|
|
|
try { |
23
|
|
|
$publisherStatisticsServiceUrl = 'https://api.affili.net/V2.0/PublisherStatistics.svc?wsdl'; |
24
|
|
|
$publisherStatisticsService = new \SoapClient($publisherStatisticsServiceUrl, array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE, 'soap_version' => SOAP_1_1)); |
25
|
|
|
|
26
|
|
|
$params = array( |
27
|
|
|
'StartDate' => \strtotime($dStartDate->format("Y-m-d")), |
|
|
|
|
28
|
|
|
'EndDate' => \strtotime($dEndDate->format("Y-m-d")), |
|
|
|
|
29
|
|
|
'TransactionStatus' => 'All', |
30
|
|
|
'ValuationType' => 'DateOfConfirmation' // Only modified transactions within date range - <PN> - 2017-06-26 |
31
|
|
|
); |
32
|
|
|
$currentPage = 1; |
33
|
|
|
$transactionList = self::affilinetCall('transaction', $publisherStatisticsService, $params, 0, $currentPage); |
34
|
|
|
|
35
|
|
|
while (isset($transactionList->TotalRecords) && $transactionList->TotalRecords > 0 && isset($transactionList->TransactionCollection->Transaction)) { |
36
|
|
|
$transactionCollection = array(); |
37
|
|
|
if (!\is_array($transactionList->TransactionCollection->Transaction)) { |
38
|
|
|
$transactionCollection[] = $transactionList->TransactionCollection->Transaction; |
39
|
|
|
} else { |
40
|
|
|
$transactionCollection = $transactionList->TransactionCollection->Transaction; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
foreach ($transactionCollection as $transactionObject) { |
44
|
|
|
|
45
|
|
|
$transaction = array(); |
46
|
|
|
$transaction["status"] = $transactionObject->TransactionStatus; |
47
|
|
|
$transaction["unique_id"] = $transactionObject->TransactionId; |
48
|
|
|
$transaction["commission"] = $transactionObject->PublisherCommission; |
49
|
|
|
$transaction["amount"] = $transactionObject->NetPrice; |
50
|
|
|
$transaction["date"] = $transactionObject->RegistrationDate; |
51
|
|
|
$transaction["click_date"] = $transactionObject->ClickDate; // Future use - <PN> |
52
|
|
|
$transaction["udpate_date"] = $transactionObject->CheckDate; // Future use - <PN> |
53
|
|
|
$transaction["merchantId"] = $transactionObject->ProgramId; |
54
|
|
|
$transaction["custom_id"] = $transactionObject->SubId; |
55
|
|
View Code Duplication |
if ($transaction['status'] == 'Confirmed') { |
|
|
|
|
56
|
|
|
$transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED; |
57
|
|
|
} else |
58
|
|
|
if ($transaction['status'] == 'Open') { |
59
|
|
|
$transaction['status'] = \Oara\Utilities::STATUS_PENDING; |
60
|
|
|
} else |
61
|
|
|
if ($transaction['status'] == 'Cancelled') { |
62
|
|
|
$transaction['status'] = \Oara\Utilities::STATUS_DECLINED; |
63
|
|
|
} |
64
|
|
|
$totalTransactions[] = $transaction; |
65
|
|
|
} |
66
|
|
|
$currentPage++; |
67
|
|
|
$transactionList = self::affilinetCall('transaction', $publisherStatisticsService, $params, 0, $currentPage); |
68
|
|
|
} |
69
|
|
|
} catch (\Exception $e) { |
70
|
|
|
// Avoid lost of transactions if one call failed |
71
|
|
|
echo PHP_EOL . "AffilinetEx - getTransactionList err: ".$e->getMessage().PHP_EOL; |
72
|
|
|
throw new \Exception($e); |
73
|
|
|
} |
74
|
|
|
echo (New \DateTime())->format("d/m/Y H:i:s") . " - AffilinetEx getTransactionList - return " . count($totalTransactions) . " transactions" . PHP_EOL; |
75
|
|
|
return $totalTransactions; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.