Дипломная работа: Автоматизация и обеспечение информационной безопасности обработки заявок в ПАО "СКБ Банк"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
112
$smsManager->setSource($this->formManager->getBank());
if ($smsManager->requestNewCode()) {
$response = ['sent' => 1];
} else {
$this->errorManager->setError(ErrorManager::STATE_API_SMS_NOT_SENT);
}
return $this->getAnswer($response);
}
}
Исходный текст модуля «Отправка заявки в банковские системы»
<?php
namespace app\modules\landings\components\rabbit;
class CreditSiebel extends RabbitTransporter
{
public function init()
{
parent::init();
$this->on(self::EVENT_CLAIM_COMMUNICATION_PRELIMINARY_DECISION, function ($event) {
$claim = Yii::$app->db->useMaster(function ($db) use ($event) {
return Claims::find()
->with('info')
->byId($event->claim->id);
});
if ($this->isLastStep($event->claim->id) && $this->isOfferedClaim($event->claim->id)) {
/** @var CreditFrontCommunicate $communication */
$communication = new CreditFrontCommunicate();
$communication->actionPreliminaryDecision($claim);
}
});
$this->on(self::EVENT_CLAIM_COMMUNICATION_READY_TO_ISSUE, function ($event) {
$claim = Yii::$app->db->useMaster(function ($db) use ($event) {
return Claims::find()
->with('info')
->byId($event->claim->id);
});
if ($this->isLastStep($event->claim->id) && $this->isOfferedClaim($event->claim->id)) {
/** @var CreditFrontCommunicate $communication */
$communication = new CreditFrontCommunicate();
$communication->actionReadyToIssue($claim);
}
});
113
$this->on(self::EVENT_CLAIM_COMMUNICATION_FAILURE, function ($event) {
if ($this->isLastStep($event->claim->id) && $this->isDeclinedClaim($event->claim->id)) {
/** @var CreditFrontCommunicate $communication */
$communication = new CreditFrontCommunicate();
$communication->actionFailure($event->claim);
}
});
}
private function isOfferedClaim($claimId)
{
$offered = false;
$claimState = ClaimsState::find()->byClaimId($claimId);
if ($claimState->is_offered == ClaimsState::CLAIM_IS_OFFERED) $offered = true;
return $offered;
}
private function isDeclinedClaim($claimId)
{
$declined = false;
$claimState = ClaimsState::find()->byClaimId($claimId);
if ($claimState->is_declined == ClaimsState::CLAIM_IS_DECLINED) $declined = true;
return $declined;
}
/**
* checks for last step of claim for communication start
*
* @param $claimId
* @return bool
*/
private function isLastStep($claimId)
{
$lastStep = false;
$rabbit = RabbitQueue::find()
->outgoing()
->byClaimId($claimId)
->byAddType(self::REQUEST_TYPE_UPDATE)
->byType(RabbitQueue::TYPE_CREDIT_FRONT)
->limit(1)
->addOrderBy(['id' => SORT_DESC])
->one();
if (count($rabbit) > 0) {
$_message = $rabbit->message;
$message = Json::decode($_message);
114
$step = ArrayHelper::getValue($message, 'WS.BODY.CLAIM_STEP');
if ($step === 6) {
$lastStep = true;
}
}
return $lastStep;
}
/**
* Pushing new message into rabbit queue
*
* @return bool
* @throws ErrorException
*/
public function push(): bool
{
if (!$this->getRequestForPassage()) {
return false;
}
if (!isset($this->claim)) {
$this->setClaim($this->claim);
}
if (!$this->getRqUid()) {
$this->setRqUid();
}
$message = $this->getOuterMessage();
$claimId = $this->claim->id;
$addType = $this->getAddType();
$rabbitQueue = new RabbitQueue(RabbitQueue::STATUS_NEW);
$rabbitQueue->type = RabbitQueue::TYPE_CREDIT_FRONT;
$rabbitQueue->message = $message;
$rabbitQueue->claim_id = $claimId;
$rabbitQueue->rq_uid = $this->getRqUid();
$rabbitQueue->direction = RabbitQueue::DIRECTION_OUT;
$rabbitQueue->add_type = $addType;
if ($rabbitQueue->save(false)) {
$this->runTheWolf();
if ($addType == self::REQUEST_TYPE_UPDATE) {
if (ArrayHelper::getValue($this->claim->info->dataArray, 'step') == 6 && $this-
>isOfferedClaim($claimId)) {
$event = new ClaimCommunicationEvent();
115
$event->claim = $this->claim;
/** ----==== EVENT_CLAIM_COMMUNICATION_READY_TO_ISSUE ====---- */
$this->trigger(self::EVENT_CLAIM_COMMUNICATION_PRELIMINARY_DECISION, $event);
//} elseif ($this->claim->info->dataArray['step'] == 6 && $this->isDeclinedClaim($claimId))
{
} elseif (ArrayHelper::getValue($this->claim->info->dataArray, 'step') == 6 && $this-
>isDeclinedClaim($claimId)) {
$event = new ClaimCommunicationEvent();
$event->claim = $this->claim;
/** ----==== EVENT_CLAIM_COMMUNICATION_FAILURE ====---- */
$this->trigger(self::EVENT_CLAIM_COMMUNICATION_FAILURE, $event);
}
}
return true;
}
return false;
}
private function getOuterMessage(): string
{
if (!$result = Json::encode(['WS' => array_merge($this->getHeader(), $this->getBody())])) {
throw new ErrorException('Не удалось сформировать исходящее сообщение.');
}
return $result;
}
/**
* Getting header of outgoing message for rabbit queue
*
* @return array
*/
private function getHeader(): array
{
$passage = $this->getPassage();
switch ($passage) {
case self::TRANSPORTER_PASSAGE_CREATE_CASH_RQ:
case self::TRANSPORTER_PASSAGE_UPDATE_CASH_RQ:
$bp = self::BP_STEP_SYNC_CHANNEL_SIEBEL_APPL_RQ;
$docTypeInMsg = self::DOC_TYPE_IN_MSG_SYNC_CHANNEL_SIEBEL_APPL_RQ;
break;
case self::TRANSPORTER_PASSAGE_ACCEPT_CASH_RQ:
case self::TRANSPORTER_PASSAGE_DECLINE_ALL_CASH_RQ:
$bp = self::BP_STEP_ASYNC_CHANNEL_SIEBEL_APPL_DECISION_RQ;
$docTypeInMsg = self::DOC_TYPE_IN_MSG_ASYNC_CHANNEL_SIEBEL_APPL_DECISION_RQ;
break;
default:
$bp = self::BP_STEP_SYNC_CHANNEL_SIEBEL_APPL_RQ;
$docTypeInMsg = self::DOC_TYPE_IN_MSG_SYNC_CHANNEL_SIEBEL_APPL_RQ;
}
$header = [
116
'ID' => $this->getRqUid(),
'SENDER' => 'SDP',
'RECEIVER' => $this->receiver,
'BANK' => self::BANK_SKB,
'ROLEMSG' => 'Request',
'TYPEMSG' => 'Application',
'SENDTIME' => DateTimeHelper::dateFormatModification(self::MESSAGE_TIME_FORMAT, 'Y-
m-d H:i:s', date('Y-m-d H:i:s'), false),
'PRIORITY' => '4',
'DOCTYPEINMSG' => $docTypeInMsg,
'BP' => $bp,
];
return ['HEADER' => $header];
}
/**
* @return array
* @throws ErrorException
* @see
getCreateNewRequestMessage,getUpdateRequestMessage,getAcceptRequestMessage,getDeclineAll
OffersMessage,getCloseRequestMessage,getOkMessage
*/
private function getBody(): array
{
$requestMethod = 'get' . $this->getRequestForPassage() . 'Message';
if (!method_exists($this, $requestMethod)) {
throw new ErrorException('Incorrect request method');
}
$result = $this->{$requestMethod}();
ksort($result);
return [
'BODY' => $result
];
}
/**
* Getting code of citizenship
*
* @param $value
* @return string|null
*/
public function getCitizenshipCode($value)
{
$result = null;
if ($value == 'Yes') {
$result = '643';
}
return $result;
}
Источник: https://baza.diplomsite.ru/previewfile/1778