/** * @param CommandInterface $command * @return bool */ public function execute(CommandInterface $command) { if (!$command instanceof CreateMemberCommand) { throw new \DomainException("Internal error, silahkan hubungi CS kami"); } $command->setRepository($this->member_repo); $violation = $this->validator->validate($command); if ($violation->count() > 0) { $message = $violation->get(0)->getMessage(); throw new \DomainException($message); } $member = new Member(); $member->setAccountId($command->getAccountId()); $member->setEmail($command->getEmail()); $member->setAccountNumber($command->getAccountNumber()); $member->setAccountHolder($command->getAccountHolder()); $member->setBankName($command->getBankName()); $member->setFullName($command->getFullname()); $member->setAddress($command->getAddress()); $member->setPhone($command->getPhone()); $this->member_repo->save($member); $data = ["account_id" => $member->getAccountId(), "email" => $member->getEmail(), "phone" => $member->getPhone(), "fullname" => $member->getFullName(), "bank_name" => $member->getBankName(), "account_number" => $member->getAccountNumber(), "account_holder" => $member->getAccountHolder(), "address" => $member->getAddress(), "date" => date("Y-m-d H:i:s")]; $this->event_emitter->emit("validation.created", [$data]); return true; }
public function execute(CommandInterface $command) { if (!$command instanceof ClaimRebateCommand) { throw new \DomainException("Internal error, silahkan hubungi CS kami"); } $command->setRepository($this->member_repo); $violation = $this->validator->validate($command); if ($violation->count() > 0) { $message = $violation->get(0)->getMessage(); throw new \DomainException($message); } $member = $this->member_repo->findOneBy(["account_id" => $command->getAccountId()]); $claim_rebate = new ClaimRebate(); $claim_rebate->setMember($member); $claim_rebate->setMt4Account($command->getMt4Account()); $claim_rebate->setType($command->getType()); $this->claim_rebate_repo->save($claim_rebate); $data = ["email" => $member->getEmail(), "account_id" => $member->getAccountId(), "fullname" => $member->getFullName(), "type" => $claim_rebate->getType(), "mt4_account" => $claim_rebate->getMt4Account(), "bank_name" => $member->getBankName(), "account_number" => $member->getAccountNumber(), "account_holder" => $member->getAccountHolder(), "date" => date("Y-m-d H:i:s")]; $this->event_emitter->emit("claim.rebate.created", [$data]); return true; }