Przeglądaj źródła

サービス券文字列の復号化コマンドを作成

develop
sosuke.iwabuchi 6 miesięcy temu
rodzic
commit
fde40b0499
1 zmienionych plików z 79 dodań i 0 usunięć
  1. +79
    -0
      app/Console/Commands/QRCode/サービス券復号化.php

+ 79
- 0
app/Console/Commands/QRCode/サービス券復号化.php Wyświetl plik

@@ -0,0 +1,79 @@
<?php

namespace App\Console\Commands\QRCode;

use App\Console\Commands\BaseCommand;
use App\Logics\QRService\QRCryptoLogic;
use Str;

class サービス券復号化 extends BaseCommand
{

const COMMAND = "qrcode:decrypto {input}";


/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = self::COMMAND;

/**
* The console command description.
*
* @var string
*/
protected $description = 'QRサービス券(取得)を復号化する。';

static public function getCommand()
{
return self::COMMAND;
}



/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return int
*/
public function service(): int
{
$input = $this->argument("input");
if (!$input) {
$this->outputError("入力エラー");
return self::RESULTCODE_FAILED;
}

$origin = Str::substr($input, 5);

$result = QRCryptoLogic::decrypt($origin);
$this->outputInfo(sprintf("復号化:[%s]->[%s]", $origin, $result));

$this->qrParse($result);

return self::RESULTCODE_SUCCESS;
}

private function qrParse(string $input)
{
$発行端末 = Str::substr($input, 0, 2);
$発行日 = Str::substr($input, 2, 8);
$発行連番 = Str::substr($input, 10, 6);
$店舗番号 = Str::substr($input, 16, 2);
$券コード = Str::substr($input, 18, 2);

$this->outputInfo(sprintf("発行端末[%s] 発行日[%s] 発行連番[%s] 店舗番号[%s] 券コード[%s]", $発行端末, $発行日, $発行連番, $店舗番号, $券コード));
}
}

Ładowanie…
Anuluj
Zapisz