-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from rarus/dev
Сделать пример по запросу для роли организация метода getSalesHistory
- Loading branch information
Showing
12 changed files
with
345 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
src/Rarus/BonusServer/Transactions/DTO/Points/PointTransactionCollection.php
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
src/Rarus/BonusServer/Transactions/DTO/Points/Transactions/Fabric.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Rarus\BonusServer\Transactions\DTO\Points\Transactions; | ||
|
||
use Money\Currency; | ||
use Money\Currencies\ISOCurrencies; | ||
use Money\Parser\DecimalMoneyParser; | ||
|
||
use Rarus\BonusServer\Cards\DTO\CardId; | ||
use Rarus\BonusServer\Discounts\DTO\DiscountId; | ||
use Rarus\BonusServer\Shops\DTO\ShopId; | ||
use Rarus\BonusServer\Transactions\DTO\CashRegister\CashRegisterId; | ||
use Rarus\BonusServer\Transactions\DTO\Document\DocumentId; | ||
use Rarus\BonusServer\Transactions\DTO\Type; | ||
use Rarus\BonusServer\Transactions\DTO\Points\PointId; | ||
|
||
use Rarus\BonusServer\Util\DateTimeParser; | ||
|
||
/** | ||
* Class Fabric | ||
* | ||
* @package Rarus\BonusServer\Transactions\DTO\Points | ||
*/ | ||
class Fabric | ||
{ | ||
/** | ||
* @param Currency $currency | ||
* @param array $arPointTransaction | ||
* @param \DateTimeZone $dateTimeZone | ||
* | ||
* @return Transaction | ||
* @throws \Rarus\BonusServer\Exceptions\ApiClientException | ||
*/ | ||
public static function initPointTransactionFromServerResponse(Currency $currency, array $arPointTransaction, \DateTimeZone $dateTimeZone): Transaction | ||
{ | ||
$currencies = new ISOCurrencies(); | ||
$moneyParser = new DecimalMoneyParser($currencies); | ||
|
||
$pointTrx = new Transaction(); | ||
$pointTrx | ||
->setRowNumber((int)$arPointTransaction['row_number']) | ||
->setPointId(new PointId((string)$arPointTransaction['id'])) | ||
->setCardId(new CardId((string)$arPointTransaction['card_id'])) | ||
->setMastercardId(new CardId((string)$arPointTransaction['mastercard_id'])) | ||
->setTime(DateTimeParser::parseTimestampFromServerResponse((string)$arPointTransaction['time'], $dateTimeZone)) | ||
->setSum($moneyParser->parse((string)$arPointTransaction['sum'], $currency->getCode())) | ||
->setType($arPointTransaction['type'] === 0 ? Type\Fabric::getRefund() : Type\Fabric::getSale()) | ||
->setAuthor((string)$arPointTransaction['author']) | ||
->setDescription((string)$arPointTransaction['description']) | ||
->setDocumentId(new DocumentId((string)$arPointTransaction['doc_id'])) | ||
->setCashRegisterId(new CashRegisterId((string)$arPointTransaction['kkm_id'])) | ||
->setShopId(new ShopId((string)$arPointTransaction['shop_id'])) | ||
->setDocumentTypeId((string)$arPointTransaction['doc_type']) | ||
->setInvalidatePeriod(DateTimeParser::parseTimestampFromServerResponse((string)$arPointTransaction['invalidate_period'], $dateTimeZone)) | ||
->setActivationPeriod(DateTimeParser::parseTimestampFromServerResponse((string)$arPointTransaction['activation_period'], $dateTimeZone)) | ||
->setDiscountId(new DiscountId((string)$arPointTransaction['discount_id'])); | ||
|
||
return $pointTrx; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/Rarus/BonusServer/Transactions/DTO/Points/Transactions/PaginationResponse.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Rarus\BonusServer\Transactions\DTO\Points\Transactions; | ||
|
||
use Rarus\BonusServer\Transport\DTO\Pagination; | ||
|
||
/** | ||
* Class PaginationResponse | ||
* | ||
* @package Rarus\BonusServer\Transactions\DTO\Points\Transactions | ||
*/ | ||
class PaginationResponse extends \Rarus\BonusServer\Transport\DTO\PaginationResponse | ||
{ | ||
/** | ||
* @var TransactionCollection | ||
*/ | ||
private $transactionCollection; | ||
|
||
/** | ||
* PaginationResponse constructor. | ||
* | ||
* @param TransactionCollection $transactionCollection | ||
* @param Pagination $pagination | ||
*/ | ||
public function __construct(TransactionCollection $transactionCollection, Pagination $pagination) | ||
{ | ||
$this->transactionCollection = $transactionCollection; | ||
$this->pagination = $pagination; | ||
} | ||
|
||
/** | ||
* @return TransactionCollection | ||
*/ | ||
public function getTransactionCollection(): TransactionCollection | ||
{ | ||
return $this->transactionCollection; | ||
} | ||
} |
Oops, something went wrong.