From 3b25bf4a91aa227344819bc8ef6e679ba6cdcd30 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Sun, 20 Sep 2020 12:23:02 -0300 Subject: [PATCH 01/17] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20creates=20estrusctur?= =?UTF-8?q?e=20to=20split=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BankAccountMapperInterface.php | 74 ++++++++ .../BankAccountMapperResponseInterface.php | 9 + .../SplitRecipientsMapperInterface.php | 109 +++++++++++ ...SplitRecipientsMapperResponseInterface.php | 20 ++ Api/SplitRecipientsApiInterface.php | 20 ++ Helper/SplitHelper.php | 164 +++++++++++++++++ Model/Api/SplitRecipients.php | 116 ++++++++++++ Model/Request/BankAccount.php | 140 ++++++++++++++ Model/Request/Recipient.php | 174 ++++++++++++++++++ Model/Response/BankAccount.php | 7 + Model/Response/Recipient.php | 29 +++ 11 files changed, 862 insertions(+) create mode 100644 Api/ObjectMapper/SplitRecipients/BankAccountMapperInterface.php create mode 100644 Api/ObjectMapper/SplitRecipients/BankAccountMapperResponseInterface.php create mode 100644 Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperInterface.php create mode 100644 Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperResponseInterface.php create mode 100644 Api/SplitRecipientsApiInterface.php create mode 100644 Helper/SplitHelper.php create mode 100644 Model/Api/SplitRecipients.php create mode 100644 Model/Request/BankAccount.php create mode 100644 Model/Request/Recipient.php create mode 100644 Model/Response/BankAccount.php create mode 100644 Model/Response/Recipient.php diff --git a/Api/ObjectMapper/SplitRecipients/BankAccountMapperInterface.php b/Api/ObjectMapper/SplitRecipients/BankAccountMapperInterface.php new file mode 100644 index 0000000..34c2c37 --- /dev/null +++ b/Api/ObjectMapper/SplitRecipients/BankAccountMapperInterface.php @@ -0,0 +1,74 @@ +getId() !== null) { + $recipientRepository = new RecipientRepository(); + $recipientPrevious = $recipientRepository->find($recipientRequest->getId()); + + $bankAccountCore->setId($recipientPrevious->getBankAccount()->getId()); + $recipientCore->setMundipaggId($recipientPrevious->getMundipaggId()); + $recipientCore->setStatus($recipientPrevious->getStatus()); + $recipientRequest->setDocument($recipientPrevious->getDocument()); + } + + if ($recipientRequest->isMarketPlace()) { + $recipientCore + ->setName($recipientRequest->getName()) + ->setEmail($recipientRequest->getEmail()) + ->setDocument($recipientRequest->getDocument()) + ->setDescription($recipientRequest->getDescription()); + } + + if (!$recipientRequest->isMarketPlace()) { + $objectManager = ObjectManager::getInstance(); + $customer = $objectManager->get(Customer::class)->load( + $recipientRequest->getExternalRecipientId() + ); + + $recipientCore + ->setName($customer->getName()) + ->setEmail($customer->getEmail()) + ->setDescription("testando ver de onde pegar") + ->setDocument($customer->getDataByKey('taxvat')); + } + + $recipientCore + ->setId($recipientRequest->getId()) + ->setIsMarketPlace($recipientRequest->isMarketPlace()) + ->setExternalRecipientId($recipientRequest->getExternalRecipientId()) + ->setType(self::getDocumentType($recipientCore->getDocument())); + + $bankAccountRequest = $recipientRequest->getBankAccount(); + $bankAccountCore + ->setHolderName($recipientCore->getName()) + ->setType(new TypeBankAccount($bankAccountRequest->getType())) + ->setHolderDocument($recipientCore->getDocument()) + ->setBank($bankAccountRequest->getBank()) + ->setBranchNumber($bankAccountRequest->getBranchNumber()) + ->setBranchCheckDigit($bankAccountRequest->getBranchCheckDigit()) + ->setAccountNumber($bankAccountRequest->getAccountNumber()) + ->setAccountCheckDigit($bankAccountRequest->getAccountCheckDigit()) + ->setHolderType($recipientCore->getType()); + + $recipientCore->setBankAccount($bankAccountCore); + + return $recipientCore; + } + + /** + * @param $document + * @return Type + */ + private static function getDocumentType($document) + { + $type = Type::company(); + if (strlen($document) == 11 && ($document !== null)) { + $type = Type::individual(); + } + return $type; + } + + public static function mapperRecipientResponse(RecipientInterface $recipientCore) + { + $recipientResponse = new RecipientResponse(); + + $recipientResponse->setName($recipientCore->getName()); + $recipientResponse->setEmail($recipientCore->getEmail()); + $recipientResponse->setDescription($recipientCore->getDescription()); + $recipientResponse->setDocument($recipientCore->getDocument()); + $recipientResponse->setIsMarketPlace($recipientCore->isMarketPlace()); + // $recipientResponse->setType($recipientCore->getType()->getValue()); + $recipientResponse->setId($recipientCore->getId()); + $recipientResponse->setMundipaggId($recipientCore->getMundipaggId()->getValue()); + $recipientResponse->setExternalRecipientId($recipientCore->getExternalRecipientId()); + $recipientResponse->setStatus($recipientCore->getStatus()->getValue()); + + $bankAccountCore = $recipientCore->getBankAccount(); + + $bankAccountResponse = new BankAccountResponse(); + + // $bankAccountResponse->setHolderName($bankAccountCore->getHolderName()); + // $bankAccountResponse->setHolderType($bankAccountCore->getHolderType()->getValue()); + // $bankAccountResponse->setHolderDocument($bankAccountCore->getHolderDocument()); + $bankAccountResponse->setBank($bankAccountCore->getBank()); + $bankAccountResponse->setBranchNumber($bankAccountCore->getBranchNumber()); + $bankAccountResponse->setBranchCheckDigit($bankAccountCore->getBranchCheckDigit()); + $bankAccountResponse->setAccountNumber($bankAccountCore->getAccountNumber()); + $bankAccountResponse->setAccountCheckDigit($bankAccountCore->getAccountCheckDigit()); + +// $type = Type::company(); +// if (strlen($recipientPrevious->getDocument()) == 11 && ($recipientPrevious->getDocument() !== null)) { +// $type = Type::individual(); +// } + + // $recipientCore->setType($type); + + $bankAccountResponse->setType($bankAccountCore->getType()->getValue()); + + $recipientResponse->setBankAccount($bankAccountResponse); + + return $recipientResponse; + } + + /** + * @param RecipientInterface $recipient + * @throws Exception + */ + public static function validateRecipientRequest(SplitRecipientsMapperInterface $recipient) + { + $objectManager = ObjectManager::getInstance(); + $seller = $objectManager->get(Seller::class)->load( + $recipient->getExternalRecipientId() + ); + + if (!$recipient->isMarketPlace() && !(bool)$seller->getData("is_seller")) { + throw new Exception("it's not a seller"); + } + + if ($recipient->isMarketPlace()) { + // só pode ter um + } + + if ($recipient->isMarketPlace() && $recipient->getExternalRecipientId() !== null) { + // se cair aqui montou o json request errado + throw new Exception("bad request!!!!"); + } + } +} diff --git a/Model/Api/SplitRecipients.php b/Model/Api/SplitRecipients.php new file mode 100644 index 0000000..da4a085 --- /dev/null +++ b/Model/Api/SplitRecipients.php @@ -0,0 +1,116 @@ +request = $request; + Magento2CoreSetup::bootstrap(); + $this->i18n = new LocalizationService(); + $this->moneyService = new MoneyService(); + + $logService = new LogService( + 'RecipientService', + true + ); + + $config = Magento2CoreSetup::getModuleConfiguration(); + + $secretKey = null; + if ($config->getSecretKey() != null) { + $secretKey = $config->getSecretKey()->getValue(); + } + + Configuration::$basicAuthPassword = ''; + + $mundipaggApi = new MundiAPIClient($secretKey, ''); + + $this->recipientService = new RecipientService( + $logService, + new RecipientRepository(), + $mundipaggApi + ); + } + + /** + * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperInterface $splitRecipient + * @param int $id + * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperResponseInterface|array + */ + public function save($splitRecipient, $id = null) + { + try { + SplitHelper::validateRecipientRequest($splitRecipient); + + $splitRecipient = SplitHelper::mapperRecipientRequest($splitRecipient); + + $this->recipientService->save($splitRecipient); + + return SplitHelper::mapperRecipientResponse($splitRecipient); + } catch (Exception $exception) { + return [ + 'code' => 404, + 'message' => $exception->getMessage() + ]; + } catch (Throwable $exception) { + return [ + 'code' => 404, + 'message' => $exception->getMessage() + ]; + } + + return $splitRecipient; + } + + /** + * @param int $id + * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperInterface $splitRecipient + * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperResponseInterface|array + */ + public function update($id, $splitRecipient) + { + $splitRecipient->setId($id); + return $this->save($splitRecipient, $id); + } +} diff --git a/Model/Request/BankAccount.php b/Model/Request/BankAccount.php new file mode 100644 index 0000000..89ef509 --- /dev/null +++ b/Model/Request/BankAccount.php @@ -0,0 +1,140 @@ +bank = $bank; + } + + /** + * @return string + */ + public function getBank() + { + return $this->bank; + } + + /** + * @param string $branchNumber + */ + public function setBranchNumber($branchNumber) + { + $this->branchNumber = $branchNumber; + } + + /** + * @return string + */ + public function getBranchNumber() + { + return $this->branchNumber; + } + + /** + * @param string $branchCheckDigit + */ + public function setBranchCheckDigit($branchCheckDigit) + { + $this->branchCheckDigit = $branchCheckDigit; + } + + /** + * @return string + */ + public function getBranchCheckDigit() + { + return $this->branchCheckDigit; + } + + /** + * @param string + */ + public function setAccountNumber($accountNumber) + { + $this->accountNumber = $accountNumber; + } + + /** + * @return string + */ + public function getAccountNumber() + { + return $this->accountNumber; + } + + /** + * @param string + */ + public function setAccountCheckDigit($accountCheckDigit) + { + $this->accountCheckDigit = $accountCheckDigit; + } + + /** + * @return string + */ + public function getAccountCheckDigit() + { + return $this->accountCheckDigit; + } + + /** + * @param string + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @return mixed|string[] + */ + public function jsonSerialize() + { + return ["testebank" => "bankarray"]; + } +} diff --git a/Model/Request/Recipient.php b/Model/Request/Recipient.php new file mode 100644 index 0000000..b6b58ea --- /dev/null +++ b/Model/Request/Recipient.php @@ -0,0 +1,174 @@ +externalRecipientId; + } + + /** + * @param int $externalRecipientId + */ + public function setExternalRecipientId($externalRecipientId) + { + $this->externalRecipientId = $externalRecipientId; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param string $email + */ + public function setEmail($email) + { + $this->email = $email; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string + */ + public function getDocument() + { + return $this->document; + } + + /** + * @param $document + */ + public function setDocument($document) + { + $this->document = $document; + } + + /** + * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface + */ + public function getBankAccount() + { + return $this->bankAccount; + } + + /** + * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface $bankAccount + */ + public function setBankAccount(\MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface $bankAccount) + { + $this->bankAccount = $bankAccount; + } + + public function getStatus() + { + return $this->status; + } + + public function setStatus($status) + { + $this->status = $status; + } + + /** + * @return bool + */ + public function isMarketPlace() + { + return $this->isMarketPlace; + } + + /** + * @param bool $isMarketPlace + */ + public function setIsMarketPlace($isMarketPlace) + { + $this->isMarketPlace = $isMarketPlace; + } + + public function getId() + { + return $this->id; + } + + public function setId($id) + { + $this->id = $id; + } +} diff --git a/Model/Response/BankAccount.php b/Model/Response/BankAccount.php new file mode 100644 index 0000000..8d0a415 --- /dev/null +++ b/Model/Response/BankAccount.php @@ -0,0 +1,7 @@ +mundipaggId; + } + + /** + * @param string $mundipaggId + */ + public function setMundipaggId($mundipaggId) + { + $this->mundipaggId = $mundipaggId; + } +} From 5f8920f6d64ec55c3b7afee8d18f5f9351086728 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Sun, 20 Sep 2020 12:23:45 -0300 Subject: [PATCH 02/17] adds more two table in decoretator --- Concrete/Magento2DatabaseDecorator.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Concrete/Magento2DatabaseDecorator.php b/Concrete/Magento2DatabaseDecorator.php index 15cefc3..c00ce70 100644 --- a/Concrete/Magento2DatabaseDecorator.php +++ b/Concrete/Magento2DatabaseDecorator.php @@ -49,7 +49,13 @@ protected function setTableArray() $this->db->getTableName('mundipagg_module_core_recurrence_subscription_repetitions'), AbstractDatabaseDecorator::TABLE_RECURRENCE_SUBSCRIPTION_ITEM => - $this->db->getTableName('mundipagg_module_core_recurrence_subscription_items') + $this->db->getTableName('mundipagg_module_core_recurrence_subscription_items'), + + AbstractDatabaseDecorator::TABLE_SPLIT_RECIPIENT => + $this->db->getTableName('mundipagg_module_core_split_recipient'), + + AbstractDatabaseDecorator::TABLE_SPLIT_RECIPIENT_BANK_ACCOUNT => + $this->db->getTableName('mundipagg_module_core_split_recipient_bank_account') ]; } From ffcfe94b80f3e65718a19c8c26fffe6789f334e9 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Sun, 20 Sep 2020 12:24:25 -0300 Subject: [PATCH 03/17] implements preference to split api --- etc/di.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/etc/di.xml b/etc/di.xml index 6f2b08b..8e57cdc 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -607,6 +607,18 @@ + + + + + + + + + + + + From 7372fb1a9741db00cedc6133c7de8dfa32036cf7 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Mon, 21 Sep 2020 20:52:04 -0300 Subject: [PATCH 04/17] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20does=20refactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... => BankAccountMapperRequestInterface.php} | 2 +- .../BankAccountMapperResponseInterface.php | 4 +- ...SplitRecipientsMapperRequestInterface.php} | 12 +-- ...SplitRecipientsMapperResponseInterface.php | 7 +- Api/SplitRecipientsApiInterface.php | 4 +- Helper/SplitHelper.php | 83 +++++++++++++------ Model/Api/SplitRecipients.php | 62 +++++--------- Model/Request/BankAccount.php | 4 +- Model/Request/Recipient.php | 13 +-- Model/Response/BankAccount.php | 4 +- Model/Response/Recipient.php | 2 +- etc/di.xml | 4 +- etc/webapi.xml | 16 ++++ 13 files changed, 124 insertions(+), 93 deletions(-) rename Api/ObjectMapper/SplitRecipients/{BankAccountMapperInterface.php => BankAccountMapperRequestInterface.php} (92%) rename Api/ObjectMapper/SplitRecipients/{SplitRecipientsMapperInterface.php => SplitRecipientsMapperRequestInterface.php} (83%) diff --git a/Api/ObjectMapper/SplitRecipients/BankAccountMapperInterface.php b/Api/ObjectMapper/SplitRecipients/BankAccountMapperRequestInterface.php similarity index 92% rename from Api/ObjectMapper/SplitRecipients/BankAccountMapperInterface.php rename to Api/ObjectMapper/SplitRecipients/BankAccountMapperRequestInterface.php index 34c2c37..c88f8b1 100644 --- a/Api/ObjectMapper/SplitRecipients/BankAccountMapperInterface.php +++ b/Api/ObjectMapper/SplitRecipients/BankAccountMapperRequestInterface.php @@ -4,7 +4,7 @@ use Mundipagg\Core\Split\Interfaces\BankAccountInterface; -interface BankAccountMapperInterface //extends \Mundipagg\Core\Split\Interfaces\BankAccountInterface +interface BankAccountMapperRequestInterface { /** * @param string diff --git a/Api/ObjectMapper/SplitRecipients/BankAccountMapperResponseInterface.php b/Api/ObjectMapper/SplitRecipients/BankAccountMapperResponseInterface.php index a18b888..6b586a1 100644 --- a/Api/ObjectMapper/SplitRecipients/BankAccountMapperResponseInterface.php +++ b/Api/ObjectMapper/SplitRecipients/BankAccountMapperResponseInterface.php @@ -2,8 +2,6 @@ namespace MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients; -use Mundipagg\Core\Split\Interfaces\BankAccountInterface; - -interface BankAccountMapperResponseInterface extends BankAccountMapperInterface +interface BankAccountMapperResponseInterface extends BankAccountMapperRequestInterface { } diff --git a/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperInterface.php b/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperRequestInterface.php similarity index 83% rename from Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperInterface.php rename to Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperRequestInterface.php index 31e5da6..75926af 100644 --- a/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperInterface.php +++ b/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperRequestInterface.php @@ -2,10 +2,9 @@ namespace MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients; -use Mundipagg\Core\Split\Interfaces\BankAccountInterface; use Mundipagg\Core\Split\Interfaces\RecipientInterface; -interface SplitRecipientsMapperInterface // extends \Mundipagg\Core\Split\Interfaces\RecipientInterface +interface SplitRecipientsMapperRequestInterface { /** @@ -86,15 +85,18 @@ public function getStatus(); public function setStatus($status); /** - * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface + * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperRequestInterface */ public function getBankAccount(); /** - * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface $bankAccount + * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperRequestInterface $bankAccount * @return RecipientInterface */ - public function setBankAccount(\MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface $bankAccount); + public function setBankAccount( + \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperRequestInterface + $bankAccount + ); /** * @return bool diff --git a/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperResponseInterface.php b/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperResponseInterface.php index e5dbb47..5caf14e 100644 --- a/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperResponseInterface.php +++ b/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperResponseInterface.php @@ -2,10 +2,7 @@ namespace MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients; -use Mundipagg\Core\Split\Interfaces\BankAccountInterface; -use Mundipagg\Core\Split\Interfaces\RecipientInterface; - -interface SplitRecipientsMapperResponseInterface extends SplitRecipientsMapperInterface +interface SplitRecipientsMapperResponseInterface extends SplitRecipientsMapperRequestInterface { /** * @return string @@ -17,4 +14,4 @@ public function getMundipaggId(); * @return SplitRecipientsMapperResponseInterface */ public function setMundipaggId($mundipaggId); -} \ No newline at end of file +} diff --git a/Api/SplitRecipientsApiInterface.php b/Api/SplitRecipientsApiInterface.php index a13d90e..19fbea1 100644 --- a/Api/SplitRecipientsApiInterface.php +++ b/Api/SplitRecipientsApiInterface.php @@ -5,7 +5,7 @@ interface SplitRecipientsApiInterface { /** - * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperInterface $splitRecipient + * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperRequestInterface $splitRecipient * @param int $id * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperResponseInterface|array */ @@ -13,7 +13,7 @@ public function save($splitRecipient, $id = null); /** * @param int $id - * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperInterface $splitRecipient + * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperRequestInterface $splitRecipient * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperResponseInterface|array */ public function update($id, $splitRecipient); diff --git a/Helper/SplitHelper.php b/Helper/SplitHelper.php index d4147d4..e4472a8 100644 --- a/Helper/SplitHelper.php +++ b/Helper/SplitHelper.php @@ -5,26 +5,33 @@ use Exception; use Magento\Customer\Model\Customer; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\AlreadyExistsException; +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\IntegrationException; +use Magento\Framework\Module\Manager; use Mundipagg\Core\Kernel\ValueObjects\Type; use Mundipagg\Core\Split\Aggregates\BankAccount; use Mundipagg\Core\Split\Aggregates\Recipient; use Mundipagg\Core\Split\Interfaces\RecipientInterface; use Mundipagg\Core\Split\Repositories\RecipientRepository; use Mundipagg\Core\Split\ValueObjects\TypeBankAccount; -use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperInterface; +use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperRequestInterface; use MundiPagg\MundiPagg\Model\Response\BankAccount as BankAccountResponse; use MundiPagg\MundiPagg\Model\Response\Recipient as RecipientResponse; use Webkul\Marketplace\Model\Seller; class SplitHelper { + private const MODULE_MARKETPLACE_NAME = 'Webkul_Marketplace'; + /** - * @param SplitRecipientsMapperInterface $recipientRequest + * @param SplitRecipientsMapperRequestInterface $recipientRequest * @return RecipientInterface * @throws Exception */ - public static function mapperRecipientRequest(SplitRecipientsMapperInterface $recipientRequest) - { + public static function mapperRecipientRequest( + SplitRecipientsMapperRequestInterface $recipientRequest + ) { $recipientCore = new Recipient(); $bankAccountCore = new BankAccount(); @@ -92,9 +99,14 @@ private static function getDocumentType($document) if (strlen($document) == 11 && ($document !== null)) { $type = Type::individual(); } + return $type; } + /** + * @param RecipientInterface $recipientCore + * @return RecipientResponse + */ public static function mapperRecipientResponse(RecipientInterface $recipientCore) { $recipientResponse = new RecipientResponse(); @@ -104,7 +116,6 @@ public static function mapperRecipientResponse(RecipientInterface $recipientCore $recipientResponse->setDescription($recipientCore->getDescription()); $recipientResponse->setDocument($recipientCore->getDocument()); $recipientResponse->setIsMarketPlace($recipientCore->isMarketPlace()); - // $recipientResponse->setType($recipientCore->getType()->getValue()); $recipientResponse->setId($recipientCore->getId()); $recipientResponse->setMundipaggId($recipientCore->getMundipaggId()->getValue()); $recipientResponse->setExternalRecipientId($recipientCore->getExternalRecipientId()); @@ -114,22 +125,10 @@ public static function mapperRecipientResponse(RecipientInterface $recipientCore $bankAccountResponse = new BankAccountResponse(); - // $bankAccountResponse->setHolderName($bankAccountCore->getHolderName()); - // $bankAccountResponse->setHolderType($bankAccountCore->getHolderType()->getValue()); - // $bankAccountResponse->setHolderDocument($bankAccountCore->getHolderDocument()); $bankAccountResponse->setBank($bankAccountCore->getBank()); $bankAccountResponse->setBranchNumber($bankAccountCore->getBranchNumber()); $bankAccountResponse->setBranchCheckDigit($bankAccountCore->getBranchCheckDigit()); $bankAccountResponse->setAccountNumber($bankAccountCore->getAccountNumber()); - $bankAccountResponse->setAccountCheckDigit($bankAccountCore->getAccountCheckDigit()); - -// $type = Type::company(); -// if (strlen($recipientPrevious->getDocument()) == 11 && ($recipientPrevious->getDocument() !== null)) { -// $type = Type::individual(); -// } - - // $recipientCore->setType($type); - $bankAccountResponse->setType($bankAccountCore->getType()->getValue()); $recipientResponse->setBankAccount($bankAccountResponse); @@ -138,27 +137,59 @@ public static function mapperRecipientResponse(RecipientInterface $recipientCore } /** - * @param RecipientInterface $recipient + * @param SplitRecipientsMapperRequestInterface $recipient * @throws Exception */ - public static function validateRecipientRequest(SplitRecipientsMapperInterface $recipient) - { + public static function validateRecipientRequest( + SplitRecipientsMapperRequestInterface $recipient + ) { $objectManager = ObjectManager::getInstance(); + + /** + * @var Manager $moduleManager + */ + $moduleManager = $objectManager->get(Manager::class); + + if (!$moduleManager->isEnabled(self::MODULE_MARKETPLACE_NAME)) { + $moduleName = self::MODULE_MARKETPLACE_NAME; + throw new IntegrationException( + __("Module {$moduleName} not found/enabled"), + null, + null + ); + } + + /** + * @var Seller $seller + */ $seller = $objectManager->get(Seller::class)->load( $recipient->getExternalRecipientId() ); if (!$recipient->isMarketPlace() && !(bool)$seller->getData("is_seller")) { - throw new Exception("it's not a seller"); + throw new IntegrationException(__("It's not a seller"), null, null); + } + + if ($recipient->isMarketPlace() && $recipient->getExternalRecipientId() !== null) { + throw new InputException( + __("It's not possible to pass marketplace and externalRecipientId"), + null, + null + ); } - if ($recipient->isMarketPlace()) { - // só pode ter um + $recipientMKTList = null; + if ($recipient->isMarketPlace() && $recipient->getId() === null) { + $recipientRepository = new RecipientRepository(); + $recipientMKTList = $recipientRepository->getMarketplaceUser(); } - if ($recipient->isMarketPlace() && $recipient->getExternalRecipientId() !== null) { - // se cair aqui montou o json request errado - throw new Exception("bad request!!!!"); + if ($recipientMKTList !== null) { + throw new AlreadyExistsException( + __("It's not possible to have more the one Recipient MKT"), + null, + null + ); } } } diff --git a/Model/Api/SplitRecipients.php b/Model/Api/SplitRecipients.php index da4a085..5b35453 100644 --- a/Model/Api/SplitRecipients.php +++ b/Model/Api/SplitRecipients.php @@ -4,17 +4,19 @@ use Exception; use Magento\Framework\Webapi\Rest\Request; +use MundiAPILib\APIException; use MundiAPILib\Configuration; use MundiAPILib\MundiAPIClient; +use Mundipagg\Core\Kernel\Exceptions\InvalidParamException; use Mundipagg\Core\Kernel\Services\LocalizationService; use Mundipagg\Core\Kernel\Services\LogService; -use Mundipagg\Core\Kernel\Services\MoneyService; use Mundipagg\Core\Split\Repositories\RecipientRepository; use Mundipagg\Core\Split\Services\RecipientService; +use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperRequestInterface; +use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperResponseInterface; use MundiPagg\MundiPagg\Api\SplitRecipientsApiInterface; use MundiPagg\MundiPagg\Concrete\Magento2CoreSetup; use MundiPagg\MundiPagg\Helper\SplitHelper; -use Throwable; class SplitRecipients implements SplitRecipientsApiInterface { @@ -28,11 +30,6 @@ class SplitRecipients implements SplitRecipientsApiInterface */ protected $recipientService; - /** - * @var MoneyService - */ - private $moneyService; - /** * @var LocalizationService */ @@ -45,15 +42,10 @@ class SplitRecipients implements SplitRecipientsApiInterface */ public function __construct(Request $request) { - $this->request = $request; Magento2CoreSetup::bootstrap(); - $this->i18n = new LocalizationService(); - $this->moneyService = new MoneyService(); - $logService = new LogService( - 'RecipientService', - true - ); + $this->request = $request; + $this->i18n = new LocalizationService(); $config = Magento2CoreSetup::getModuleConfiguration(); @@ -64,49 +56,37 @@ public function __construct(Request $request) Configuration::$basicAuthPassword = ''; - $mundipaggApi = new MundiAPIClient($secretKey, ''); - $this->recipientService = new RecipientService( - $logService, + new LogService('RecipientService', true), new RecipientRepository(), - $mundipaggApi + new MundiAPIClient($secretKey, '') ); } /** - * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperInterface $splitRecipient + * @param SplitRecipientsMapperRequestInterface $splitRecipient * @param int $id - * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperResponseInterface|array + * @return SplitRecipientsMapperResponseInterface|array + * @throws APIException + * @throws InvalidParamException + * @throws Exception */ public function save($splitRecipient, $id = null) { - try { - SplitHelper::validateRecipientRequest($splitRecipient); + SplitHelper::validateRecipientRequest($splitRecipient); - $splitRecipient = SplitHelper::mapperRecipientRequest($splitRecipient); - - $this->recipientService->save($splitRecipient); - - return SplitHelper::mapperRecipientResponse($splitRecipient); - } catch (Exception $exception) { - return [ - 'code' => 404, - 'message' => $exception->getMessage() - ]; - } catch (Throwable $exception) { - return [ - 'code' => 404, - 'message' => $exception->getMessage() - ]; - } + $splitRecipient = SplitHelper::mapperRecipientRequest($splitRecipient); + $this->recipientService->save($splitRecipient); - return $splitRecipient; + return SplitHelper::mapperRecipientResponse($splitRecipient); } /** * @param int $id - * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperInterface $splitRecipient - * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperResponseInterface|array + * @param SplitRecipientsMapperRequestInterface $splitRecipient + * @return SplitRecipientsMapperResponseInterface|array + * @throws APIException + * @throws InvalidParamException */ public function update($id, $splitRecipient) { diff --git a/Model/Request/BankAccount.php b/Model/Request/BankAccount.php index 89ef509..5a468ae 100644 --- a/Model/Request/BankAccount.php +++ b/Model/Request/BankAccount.php @@ -2,7 +2,9 @@ namespace MundiPagg\MundiPagg\Model\Request; -class BankAccount implements \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface +use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperRequestInterface; + +class BankAccount implements BankAccountMapperRequestInterface { /** * @var string diff --git a/Model/Request/Recipient.php b/Model/Request/Recipient.php index b6b58ea..abc940b 100644 --- a/Model/Request/Recipient.php +++ b/Model/Request/Recipient.php @@ -2,7 +2,10 @@ namespace MundiPagg\MundiPagg\Model\Request; -class Recipient implements \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperInterface +use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperRequestInterface; +use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperRequestInterface; + +class Recipient implements SplitRecipientsMapperRequestInterface { /** * @var string @@ -20,7 +23,7 @@ class Recipient implements \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients private $description; /** - * @var \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface + * @var BankAccountMapperRequestInterface */ private $bankAccount; @@ -121,7 +124,7 @@ public function setDocument($document) } /** - * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface + * @return BankAccountMapperRequestInterface */ public function getBankAccount() { @@ -129,9 +132,9 @@ public function getBankAccount() } /** - * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface $bankAccount + * @param BankAccountMapperRequestInterface $bankAccount */ - public function setBankAccount(\MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface $bankAccount) + public function setBankAccount(BankAccountMapperRequestInterface $bankAccount) { $this->bankAccount = $bankAccount; } diff --git a/Model/Response/BankAccount.php b/Model/Response/BankAccount.php index 8d0a415..7c92f5c 100644 --- a/Model/Response/BankAccount.php +++ b/Model/Response/BankAccount.php @@ -2,6 +2,8 @@ namespace MundiPagg\MundiPagg\Model\Response; -class BankAccount extends \MundiPagg\MundiPagg\Model\Request\BankAccount implements \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperInterface +use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperRequestInterface; + +class BankAccount extends \MundiPagg\MundiPagg\Model\Request\BankAccount implements BankAccountMapperRequestInterface { } diff --git a/Model/Response/Recipient.php b/Model/Response/Recipient.php index a3b8cc5..04589c0 100644 --- a/Model/Response/Recipient.php +++ b/Model/Response/Recipient.php @@ -4,7 +4,7 @@ use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperResponseInterface; -class Recipient extends \MundiPagg\MundiPagg\Model\Request\Recipient implements \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperResponseInterface +class Recipient extends \MundiPagg\MundiPagg\Model\Request\Recipient implements SplitRecipientsMapperResponseInterface { /** * @var string diff --git a/etc/di.xml b/etc/di.xml index 8e57cdc..cee2eb2 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -610,8 +610,8 @@ - - + + diff --git a/etc/webapi.xml b/etc/webapi.xml index a7ce166..e49d326 100755 --- a/etc/webapi.xml +++ b/etc/webapi.xml @@ -189,4 +189,20 @@ + + + + + + + + + + + + + + From 5a8abe99327b2f30437e39abb3ba7cf66ad503ff Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Tue, 22 Sep 2020 10:12:37 -0300 Subject: [PATCH 05/17] fixes method --- Helper/SplitHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Helper/SplitHelper.php b/Helper/SplitHelper.php index e4472a8..483339a 100644 --- a/Helper/SplitHelper.php +++ b/Helper/SplitHelper.php @@ -62,7 +62,7 @@ public static function mapperRecipientRequest( $recipientCore ->setName($customer->getName()) ->setEmail($customer->getEmail()) - ->setDescription("testando ver de onde pegar") + ->setDescription("description default") ->setDocument($customer->getDataByKey('taxvat')); } From 00e6d35e2686b70d862a2c01f4b8d55d1fd2cf39 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Tue, 22 Sep 2020 10:13:27 -0300 Subject: [PATCH 06/17] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20creates=20migration?= =?UTF-8?q?=20to=20split=20tables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Setup/InstallSchema.php | 282 ++++++++++++++++++++++++++++++++++++++++ Setup/UpgradeSchema.php | 4 + 2 files changed, 286 insertions(+) diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php index e56aff8..d330562 100755 --- a/Setup/InstallSchema.php +++ b/Setup/InstallSchema.php @@ -1360,4 +1360,286 @@ public function installSubscriptionItems(SchemaSetupInterface $installer) } return $installer; } + + public function installSplitRecipient(SchemaSetupInterface $installer) + { + $tableName = $installer->getTable( + 'mundipagg_module_core_split_recipient' + ); + + if (!$installer->getConnection()->isTableExists($tableName)) { + $configTable = $installer->getConnection() + ->newTable($tableName) + ->addColumn( + 'id', + Table::TYPE_INTEGER, + null, + [ + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true + ], + 'ID' + ) + ->addColumn( + 'mundipagg_id', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + 'format: rp_xxxxxxxxxxxxxxxx' + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'external_recipient_id', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'name', + Table::TYPE_TEXT, + 100, + [ + 'nullable' => false, + ], + null + ) + ->addColumn( + 'document', + Table::TYPE_TEXT, + null, + [ + 'unsigned' => true, + 'nullable' => false, + ], + null + ) + ->addColumn( + 'email', + Table::TYPE_TEXT, + null, + [ + 'unsigned' => true, + 'nullable' => false, + ], + null + ) + ->addColumn( + 'status', + Table::TYPE_TEXT, + null, + [ + 'unsigned' => true, + 'nullable' => false, + ], + null + ) + ->addColumn( + 'description', + Table::TYPE_TEXT, + null, + [ + 'unsigned' => true, + 'nullable' => false, + ], + null + ) + ->addColumn( + 'is_marketplace', + Table::TYPE_BOOLEAN, + 11, + [ + 'nullable' => false + ], + "Is Marketplace?" + ) + ->addColumn( + 'meta_data', + Table::TYPE_TEXT, + null, + [ + 'unsigned' => true, + 'nullable' => true, + ], + null + ) + ->addColumn( + 'created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], + 'Created At' + ) + ->addColumn( + 'updated_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], + 'Updated At' + ) + ->setOption('charset', 'utf8'); + + $installer->getConnection()->createTable($configTable); + } + return $installer; + } + + public function installSplitRecipientBankAccount(SchemaSetupInterface $installer) + { + $tableName = $installer->getTable( + 'mundipagg_module_core_split_recipient_bank_account' + ); + + if (!$installer->getConnection()->isTableExists($tableName)) { + $configTable = $installer->getConnection() + ->newTable($tableName) + ->addColumn( + 'id', + Table::TYPE_INTEGER, + null, + [ + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true + ], + 'ID' + ) + ->addColumn( + 'recipient_id', + Table::TYPE_INTEGER, + null, + [ + 'nullable' => false + ], + 'foreign key mundipagg_module_core_split_recipient.id' + ) + ->addColumn( + 'holder_name', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'holder_type', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'holder_document', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'bank', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'branch_number', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'branch_check_digit', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'account_number', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'account_check_digit', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'type', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'meta_data', + Table::TYPE_TEXT, + null, + [ + 'nullable' => true + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], + 'Created At' + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'updated_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], + 'Updated At' + ) + ->setOption('charset', 'utf8'); + + $installer->getConnection()->createTable($configTable); + } + return $installer; + } } diff --git a/Setup/UpgradeSchema.php b/Setup/UpgradeSchema.php index e2dd88c..8a83b53 100644 --- a/Setup/UpgradeSchema.php +++ b/Setup/UpgradeSchema.php @@ -83,6 +83,10 @@ public function upgrade( $setup = $installSchema->installSubscriptionItems($setup); } + /* @TODO depois adicionar qual versão vai instalar as tabelas */ + $setup = $installSchema->installSplitRecipient($setup); + $setup = $installSchema->installSplitRecipientBankAccount($setup); + $setup->endSetup(); } From d8fe4314597887c8a9f08073980c5c9fbf75304b Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Wed, 23 Sep 2020 13:05:04 -0300 Subject: [PATCH 07/17] =?UTF-8?q?=F0=9F=8E=A8=20creates=20interface=20requ?= =?UTF-8?q?est/response=20to=20split=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SplitRecipientsMapperRequestInterface.php | 15 +- ...TransferSettingsMapperRequestInterface.php | 39 ++++ ...ransferSettingsMapperResponseInterface.php | 7 + Model/Request/TransferSetting.php | 196 ++++++++++++++++++ Model/Response/TransferSetting.php | 71 +++++++ 5 files changed, 327 insertions(+), 1 deletion(-) create mode 100644 Api/ObjectMapper/SplitRecipients/TransferSettingsMapperRequestInterface.php create mode 100644 Api/ObjectMapper/SplitRecipients/TransferSettingsMapperResponseInterface.php create mode 100644 Model/Request/TransferSetting.php create mode 100644 Model/Response/TransferSetting.php diff --git a/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperRequestInterface.php b/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperRequestInterface.php index 75926af..96995bd 100644 --- a/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperRequestInterface.php +++ b/Api/ObjectMapper/SplitRecipients/SplitRecipientsMapperRequestInterface.php @@ -6,7 +6,6 @@ interface SplitRecipientsMapperRequestInterface { - /** * @return int */ @@ -98,6 +97,20 @@ public function setBankAccount( $bankAccount ); + /** + * @param \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\TransferSettingsMapperRequestInterface $transferSettings + * @return RecipientInterface + */ + public function setTransferSettings( + \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\TransferSettingsMapperRequestInterface + $transferSettings + ); + + /** + * @return \MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\TransferSettingsMapperRequestInterface + */ + public function getTransferSettings(); + /** * @return bool */ diff --git a/Api/ObjectMapper/SplitRecipients/TransferSettingsMapperRequestInterface.php b/Api/ObjectMapper/SplitRecipients/TransferSettingsMapperRequestInterface.php new file mode 100644 index 0000000..7b87702 --- /dev/null +++ b/Api/ObjectMapper/SplitRecipients/TransferSettingsMapperRequestInterface.php @@ -0,0 +1,39 @@ +externalRecipientId; + } + + /** + * @param int $externalRecipientId + */ + public function setExternalRecipientId($externalRecipientId) + { + $this->externalRecipientId = $externalRecipientId; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param string $email + */ + public function setEmail($email) + { + $this->email = $email; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string + */ + public function getDocument() + { + return $this->document; + } + + /** + * @param $document + */ + public function setDocument($document) + { + $this->document = $document; + } + + /** + * @return BankAccountMapperRequestInterface + */ + public function getBankAccount() + { + return $this->bankAccount; + } + + /** + * @param BankAccountMapperRequestInterface $bankAccount + */ + public function setBankAccount(BankAccountMapperRequestInterface $bankAccount) + { + $this->bankAccount = $bankAccount; + } + + public function getStatus() + { + return $this->status; + } + + public function setStatus($status) + { + $this->status = $status; + } + + /** + * @return bool + */ + public function isMarketPlace() + { + return $this->isMarketPlace; + } + + /** + * @param bool $isMarketPlace + */ + public function setIsMarketPlace($isMarketPlace) + { + $this->isMarketPlace = $isMarketPlace; + } + + public function getId() + { + return $this->id; + } + + public function setId($id) + { + $this->id = $id; + } + + public function setTransferSettings(TransferSettingsMapperRequestInterface $transferSettings) + { + $this->transferSettings = $transferSettings; + } + + public function getTransferSettings() + { + return $this->transferSettings; + } +} diff --git a/Model/Response/TransferSetting.php b/Model/Response/TransferSetting.php new file mode 100644 index 0000000..b039a5d --- /dev/null +++ b/Model/Response/TransferSetting.php @@ -0,0 +1,71 @@ +transferInterval; + } + + /** + * @param string $transferInterval + */ + public function setTransferInterval($transferInterval) + { + $this->transferInterval = $transferInterval; + } + + /** + * @return bool + */ + public function isTransferEnabled() + { + return $this->transferEnabled; + } + + /** + * @param bool $transferEnabled + */ + public function setTransferEnabled($transferEnabled) + { + $this->transferEnabled = $transferEnabled; + } + + /** + * @return int + */ + public function getTransferDay() + { + return $this->transferDay; + } + + /** + * @param int $transferDay + */ + public function setTransferDay($transferDay) + { + $this->transferDay = $transferDay; + } +} From 99ca5a41a44e8c2547aadcdd2121dfe2be2bdbb0 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Wed, 23 Sep 2020 13:06:15 -0300 Subject: [PATCH 08/17] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20removes=20interface?= =?UTF-8?q?=20unnecessary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Response/BankAccount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Response/BankAccount.php b/Model/Response/BankAccount.php index 7c92f5c..fa04b96 100644 --- a/Model/Response/BankAccount.php +++ b/Model/Response/BankAccount.php @@ -4,6 +4,6 @@ use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperRequestInterface; -class BankAccount extends \MundiPagg\MundiPagg\Model\Request\BankAccount implements BankAccountMapperRequestInterface +class BankAccount extends \MundiPagg\MundiPagg\Model\Request\BankAccount { } From 2542dfd50106c97d1de79682596aa2e14bb8dd3f Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Wed, 23 Sep 2020 13:06:59 -0300 Subject: [PATCH 09/17] =?UTF-8?q?=F0=9F=8E=A8=20changes=20the=20way=20how?= =?UTF-8?q?=20return=20recipient=20object?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Api/SplitRecipients.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Api/SplitRecipients.php b/Model/Api/SplitRecipients.php index 5b35453..1e522de 100644 --- a/Model/Api/SplitRecipients.php +++ b/Model/Api/SplitRecipients.php @@ -76,9 +76,9 @@ public function save($splitRecipient, $id = null) SplitHelper::validateRecipientRequest($splitRecipient); $splitRecipient = SplitHelper::mapperRecipientRequest($splitRecipient); - $this->recipientService->save($splitRecipient); + $recipient = $this->recipientService->save($splitRecipient); - return SplitHelper::mapperRecipientResponse($splitRecipient); + return SplitHelper::mapperRecipientResponse($recipient); } /** From 0210f14cc5cd63728c81e2d072e8d8b15900427d Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Wed, 23 Sep 2020 13:07:27 -0300 Subject: [PATCH 10/17] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20removes=20interface?= =?UTF-8?q?=20unnecessary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Response/TransferSetting.php | 68 +----------------------------- 1 file changed, 2 insertions(+), 66 deletions(-) diff --git a/Model/Response/TransferSetting.php b/Model/Response/TransferSetting.php index b039a5d..0670269 100644 --- a/Model/Response/TransferSetting.php +++ b/Model/Response/TransferSetting.php @@ -1,71 +1,7 @@ transferInterval; - } - - /** - * @param string $transferInterval - */ - public function setTransferInterval($transferInterval) - { - $this->transferInterval = $transferInterval; - } - - /** - * @return bool - */ - public function isTransferEnabled() - { - return $this->transferEnabled; - } - - /** - * @param bool $transferEnabled - */ - public function setTransferEnabled($transferEnabled) - { - $this->transferEnabled = $transferEnabled; - } - - /** - * @return int - */ - public function getTransferDay() - { - return $this->transferDay; - } - - /** - * @param int $transferDay - */ - public function setTransferDay($transferDay) - { - $this->transferDay = $transferDay; - } } From e6d405609c61396e9b8fdeb91ee9f965afbbbbd7 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Wed, 23 Sep 2020 13:08:14 -0300 Subject: [PATCH 11/17] creates transferSettings request --- Model/Request/TransferSetting.php | 167 ++++-------------------------- 1 file changed, 21 insertions(+), 146 deletions(-) diff --git a/Model/Request/TransferSetting.php b/Model/Request/TransferSetting.php index 115445f..b039a5d 100644 --- a/Model/Request/TransferSetting.php +++ b/Model/Request/TransferSetting.php @@ -2,195 +2,70 @@ namespace MundiPagg\MundiPagg\Model\Request; -use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperRequestInterface; -use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperRequestInterface; use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\TransferSettingsMapperRequestInterface; -class Recipient implements SplitRecipientsMapperRequestInterface +class TransferSetting implements TransferSettingsMapperRequestInterface { /** * @var string */ - private $name; - - /** - * @var string - */ - private $email; - - /** - * @var string - */ - private $description; - - /** - * @var BankAccountMapperRequestInterface - */ - private $bankAccount; - - /** - * @var int - */ - private $externalRecipientId; - - /** - * @var string - */ - private $status; + private $transferInterval; /** * @var bool */ - private $isMarketPlace = false; - - /** - * @var string - */ - private $document; + private $transferEnabled; /** * @var int */ - private $id; - - /** - * @var TransferSettingsMapperRequestInterface - */ - private $transferSettings; - - /** - * @return int - */ - public function getExternalRecipientId() - { - return $this->externalRecipientId; - } - - /** - * @param int $externalRecipientId - */ - public function setExternalRecipientId($externalRecipientId) - { - $this->externalRecipientId = $externalRecipientId; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * @return string - */ - public function getEmail() - { - return $this->email; - } - - /** - * @param string $email - */ - public function setEmail($email) - { - $this->email = $email; - } - - public function getDescription() - { - return $this->description; - } - - public function setDescription($description) - { - $this->description = $description; - } + private $transferDay; /** * @return string */ - public function getDocument() + public function getTransferInterval() { - return $this->document; + return $this->transferInterval; } /** - * @param $document + * @param string $transferInterval */ - public function setDocument($document) + public function setTransferInterval($transferInterval) { - $this->document = $document; + $this->transferInterval = $transferInterval; } /** - * @return BankAccountMapperRequestInterface + * @return bool */ - public function getBankAccount() + public function isTransferEnabled() { - return $this->bankAccount; + return $this->transferEnabled; } /** - * @param BankAccountMapperRequestInterface $bankAccount + * @param bool $transferEnabled */ - public function setBankAccount(BankAccountMapperRequestInterface $bankAccount) - { - $this->bankAccount = $bankAccount; - } - - public function getStatus() + public function setTransferEnabled($transferEnabled) { - return $this->status; - } - - public function setStatus($status) - { - $this->status = $status; + $this->transferEnabled = $transferEnabled; } /** - * @return bool + * @return int */ - public function isMarketPlace() + public function getTransferDay() { - return $this->isMarketPlace; + return $this->transferDay; } /** - * @param bool $isMarketPlace + * @param int $transferDay */ - public function setIsMarketPlace($isMarketPlace) - { - $this->isMarketPlace = $isMarketPlace; - } - - public function getId() - { - return $this->id; - } - - public function setId($id) - { - $this->id = $id; - } - - public function setTransferSettings(TransferSettingsMapperRequestInterface $transferSettings) - { - $this->transferSettings = $transferSettings; - } - - public function getTransferSettings() + public function setTransferDay($transferDay) { - return $this->transferSettings; + $this->transferDay = $transferDay; } } From 182fc36276ce479ddc7424f5dbe42af68188fb21 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Wed, 23 Sep 2020 13:08:47 -0300 Subject: [PATCH 12/17] =?UTF-8?q?=F0=9F=8E=A8=20adds=20mundipagg=5Fmodule?= =?UTF-8?q?=5Fcore=5Fsplit=5Frecipient=5Ftransfer=5Fsettings=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Concrete/Magento2DatabaseDecorator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Concrete/Magento2DatabaseDecorator.php b/Concrete/Magento2DatabaseDecorator.php index c00ce70..d1b1b12 100644 --- a/Concrete/Magento2DatabaseDecorator.php +++ b/Concrete/Magento2DatabaseDecorator.php @@ -55,7 +55,10 @@ protected function setTableArray() $this->db->getTableName('mundipagg_module_core_split_recipient'), AbstractDatabaseDecorator::TABLE_SPLIT_RECIPIENT_BANK_ACCOUNT => - $this->db->getTableName('mundipagg_module_core_split_recipient_bank_account') + $this->db->getTableName('mundipagg_module_core_split_recipient_bank_account'), + + AbstractDatabaseDecorator::TABLE_SPLIT_TRANSFER_SETTING => + $this->db->getTableName('mundipagg_module_core_split_recipient_transfer_settings') ]; } From 7407012dd3173d2abc3a38d9c3a36148edb0de56 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Wed, 23 Sep 2020 13:09:56 -0300 Subject: [PATCH 13/17] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20make=20check=20field?= =?UTF-8?q?=20pass=20in=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Helper/SplitHelper.php | 65 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/Helper/SplitHelper.php b/Helper/SplitHelper.php index 483339a..a171a61 100644 --- a/Helper/SplitHelper.php +++ b/Helper/SplitHelper.php @@ -9,15 +9,20 @@ use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\IntegrationException; use Magento\Framework\Module\Manager; +use Mundipagg\Core\Kernel\Helper\Hydrator; use Mundipagg\Core\Kernel\ValueObjects\Type; use Mundipagg\Core\Split\Aggregates\BankAccount; use Mundipagg\Core\Split\Aggregates\Recipient; +use Mundipagg\Core\Split\Aggregates\TransferSettings; use Mundipagg\Core\Split\Interfaces\RecipientInterface; use Mundipagg\Core\Split\Repositories\RecipientRepository; +use Mundipagg\Core\Split\ValueObjects\TransferInterval; use Mundipagg\Core\Split\ValueObjects\TypeBankAccount; use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperRequestInterface; use MundiPagg\MundiPagg\Model\Response\BankAccount as BankAccountResponse; use MundiPagg\MundiPagg\Model\Response\Recipient as RecipientResponse; +use MundiPagg\MundiPagg\Model\Response\TransferSetting as TransferSettingResponse; +use ReflectionException; use Webkul\Marketplace\Model\Seller; class SplitHelper @@ -34,6 +39,7 @@ public static function mapperRecipientRequest( ) { $recipientCore = new Recipient(); $bankAccountCore = new BankAccount(); + $transferSettingsCore = new TransferSettings(); if ($recipientRequest->getId() !== null) { $recipientRepository = new RecipientRepository(); @@ -86,6 +92,18 @@ public static function mapperRecipientRequest( $recipientCore->setBankAccount($bankAccountCore); + if ($recipientRequest->getTransferSettings() !== null) { + $transferSettingsRequest = $recipientRequest->getTransferSettings(); + $transferSettingsCore + ->setTransferInterval(new TransferInterval( + $transferSettingsRequest->getTransferInterval() + )) + ->setTransferDay($transferSettingsRequest->getTransferDay()) + ->setTransferEnabled($transferSettingsRequest->isTransferEnabled()); + + $recipientCore->setTransferSettings($transferSettingsCore); + } + return $recipientCore; } @@ -122,7 +140,6 @@ public static function mapperRecipientResponse(RecipientInterface $recipientCore $recipientResponse->setStatus($recipientCore->getStatus()->getValue()); $bankAccountCore = $recipientCore->getBankAccount(); - $bankAccountResponse = new BankAccountResponse(); $bankAccountResponse->setBank($bankAccountCore->getBank()); @@ -133,6 +150,17 @@ public static function mapperRecipientResponse(RecipientInterface $recipientCore $recipientResponse->setBankAccount($bankAccountResponse); + $transferSettingsCore = $recipientCore->getTransferSettings(); + $transferSettingResponse = new TransferSettingResponse(); + + $transferSettingResponse->setTransferInterval( + $transferSettingsCore->getTransferInterval()->getValue() + ); + $transferSettingResponse->setTransferDay($transferSettingsCore->getTransferDay()); + $transferSettingResponse->setTransferEnabled($transferSettingsCore->isTransferEnabled()); + + $recipientResponse->setTransferSettings($transferSettingResponse); + return $recipientResponse; } @@ -191,5 +219,40 @@ public static function validateRecipientRequest( null ); } + + if ($recipient->isMarketPlace()) { + self::checkFieldsRequired($recipient, + ['status', 'externalRecipientId', 'id', 'document', 'transferSettings'] + ); + return; + } + + self::checkFieldsRequired($recipient, + ['status', 'externalRecipientId', 'id', 'document', 'transferSettings', 'name', 'email', 'description'] + ); + } + + /** + * @param SplitRecipientsMapperRequestInterface $recipient + * @throws ReflectionException + */ + private static function checkFieldsRequired( + SplitRecipientsMapperRequestInterface $recipient, + $propertyListDontCheck + ) { + $recipientArray = Hydrator::extractRecursive($recipient); + + array_walk_recursive( + $recipientArray, + function ($leafvalue, $key) use ($propertyListDontCheck) { + if ($leafvalue === null && !in_array($key, $propertyListDontCheck)) { + throw new InputException( + __("The '{$key}' is required"), + null, + null + ); + } + } + ); } } From 54463972789d288ddcb82a5a5559a1b4ae278eda Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Wed, 23 Sep 2020 13:10:25 -0300 Subject: [PATCH 14/17] =?UTF-8?q?=F0=9F=8E=A8=20adds=20property=20transfer?= =?UTF-8?q?=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Request/Recipient.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Model/Request/Recipient.php b/Model/Request/Recipient.php index abc940b..115445f 100644 --- a/Model/Request/Recipient.php +++ b/Model/Request/Recipient.php @@ -4,6 +4,7 @@ use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\BankAccountMapperRequestInterface; use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\SplitRecipientsMapperRequestInterface; +use MundiPagg\MundiPagg\Api\ObjectMapper\SplitRecipients\TransferSettingsMapperRequestInterface; class Recipient implements SplitRecipientsMapperRequestInterface { @@ -47,8 +48,16 @@ class Recipient implements SplitRecipientsMapperRequestInterface */ private $document; + /** + * @var int + */ private $id; + /** + * @var TransferSettingsMapperRequestInterface + */ + private $transferSettings; + /** * @return int */ @@ -174,4 +183,14 @@ public function setId($id) { $this->id = $id; } + + public function setTransferSettings(TransferSettingsMapperRequestInterface $transferSettings) + { + $this->transferSettings = $transferSettings; + } + + public function getTransferSettings() + { + return $this->transferSettings; + } } From 020490ba08bfa8825ee5aa983c9d331132bdbeaf Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Wed, 23 Sep 2020 13:11:01 -0300 Subject: [PATCH 15/17] =?UTF-8?q?=F0=9F=8E=A8=20regiter=20transfer=20setti?= =?UTF-8?q?ngs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etc/di.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/di.xml b/etc/di.xml index cee2eb2..65a3c08 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -617,6 +617,8 @@ + + From 81828ed04316d87ab352dc0f9be4718ab84af82a Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Thu, 24 Sep 2020 10:25:37 -0300 Subject: [PATCH 16/17] =?UTF-8?q?=F0=9F=8E=A8=20creates=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Helper/SplitHelper.php | 24 +++++++++--- Setup/InstallSchema.php | 81 +++++++++++++++++++++++++++++++++++++++++ Setup/UpgradeSchema.php | 1 + 3 files changed, 100 insertions(+), 6 deletions(-) diff --git a/Helper/SplitHelper.php b/Helper/SplitHelper.php index a171a61..b706b68 100644 --- a/Helper/SplitHelper.php +++ b/Helper/SplitHelper.php @@ -221,31 +221,43 @@ public static function validateRecipientRequest( } if ($recipient->isMarketPlace()) { - self::checkFieldsRequired($recipient, + self::checkFieldsRequired( + $recipient, ['status', 'externalRecipientId', 'id', 'document', 'transferSettings'] ); return; } - self::checkFieldsRequired($recipient, - ['status', 'externalRecipientId', 'id', 'document', 'transferSettings', 'name', 'email', 'description'] + self::checkFieldsRequired( + $recipient, + [ + 'status', + 'externalRecipientId', + 'id', + 'document', + 'transferSettings', + 'name', + 'email', + 'description' + ] ); } /** * @param SplitRecipientsMapperRequestInterface $recipient + * @param array $propertyListDontCheck * @throws ReflectionException */ private static function checkFieldsRequired( SplitRecipientsMapperRequestInterface $recipient, - $propertyListDontCheck + array $propertyListDontCheck ) { $recipientArray = Hydrator::extractRecursive($recipient); array_walk_recursive( $recipientArray, - function ($leafvalue, $key) use ($propertyListDontCheck) { - if ($leafvalue === null && !in_array($key, $propertyListDontCheck)) { + function ($value, $key) use ($propertyListDontCheck) { + if ($value === null && !in_array($key, $propertyListDontCheck)) { throw new InputException( __("The '{$key}' is required"), null, diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php index d330562..03c3354 100755 --- a/Setup/InstallSchema.php +++ b/Setup/InstallSchema.php @@ -1642,4 +1642,85 @@ public function installSplitRecipientBankAccount(SchemaSetupInterface $installer } return $installer; } + + public function installSplitRecipientTransferSettings(SchemaSetupInterface $installer) + { + $tableName = $installer->getTable( + 'mundipagg_module_core_split_recipient_transfer_settings' + ); + + if (!$installer->getConnection()->isTableExists($tableName)) { + $configTable = $installer->getConnection() + ->newTable($tableName) + ->addColumn( + 'id', + Table::TYPE_INTEGER, + null, + [ + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true + ], + 'ID' + ) + ->addColumn( + 'recipient_id', + Table::TYPE_INTEGER, + null, + [ + 'nullable' => false + ], + 'foreign key mundipagg_module_core_split_recipient.id' + ) + ->addColumn( + 'transfer_enabled', + Table::TYPE_BOOLEAN, + 11, + [ + 'nullable' => false + ], + null + ) + ->addColumn( + 'transfer_interval', + Table::TYPE_TEXT, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'transfer_day', + Table::TYPE_INTEGER, + null, + [ + 'nullable' => false + ], + null + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], + 'Created At' + ) + ->setOption('charset', 'utf8') + ->addColumn( + 'updated_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], + 'Updated At' + ) + ->setOption('charset', 'utf8'); + + $installer->getConnection()->createTable($configTable); + } + return $installer; + } } diff --git a/Setup/UpgradeSchema.php b/Setup/UpgradeSchema.php index 8a83b53..c5d35e1 100644 --- a/Setup/UpgradeSchema.php +++ b/Setup/UpgradeSchema.php @@ -86,6 +86,7 @@ public function upgrade( /* @TODO depois adicionar qual versão vai instalar as tabelas */ $setup = $installSchema->installSplitRecipient($setup); $setup = $installSchema->installSplitRecipientBankAccount($setup); + $setup = $installSchema->installSplitRecipientTransferSettings($setup); $setup->endSetup(); } From 7d500445bbb744c8c415e1766f9a7cca941d5ae5 Mon Sep 17 00:00:00 2001 From: Wallace Ferreira Date: Thu, 24 Sep 2020 10:45:27 -0300 Subject: [PATCH 17/17] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20removes=20code=20unu?= =?UTF-8?q?sed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etc/di.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/di.xml b/etc/di.xml index 65a3c08..15077aa 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -620,7 +620,6 @@ -