| @@ -43,6 +43,7 @@ class GetAcquisitionTokenController extends WebController | |||||
| $res = [ | $res = [ | ||||
| "token" => $token->token, | "token" => $token->token, | ||||
| "customer_id" => $this->sessionUser->customerId(), | |||||
| ]; | ]; | ||||
| return $this->successResponse($res); | return $this->successResponse($res); | ||||
| @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Web\QRService; | |||||
| use App\Http\Controllers\Web\WebController; | use App\Http\Controllers\Web\WebController; | ||||
| use App\Logics\QRService\CreateLogic; | use App\Logics\QRService\CreateLogic; | ||||
| use App\Logics\QRService\QRCryptoLogic; | use App\Logics\QRService\QRCryptoLogic; | ||||
| use App\Models\HtpmsCustomer\HtpmsCustomerConnectionSwitch; | |||||
| use App\Models\HtpmsCustomer\QRService\AcquisitionTicket; | use App\Models\HtpmsCustomer\QRService\AcquisitionTicket; | ||||
| use App\Models\HtpmsCustomer\QRService\AcquisitionTicketToken; | use App\Models\HtpmsCustomer\QRService\AcquisitionTicketToken; | ||||
| use Illuminate\Http\JsonResponse; | use Illuminate\Http\JsonResponse; | ||||
| @@ -33,8 +34,9 @@ class CreateTicketController extends WebController | |||||
| { | { | ||||
| $param = $this->param; | $param = $this->param; | ||||
| $token = AcquisitionTicketToken::whereToken($param->token)->first(); | |||||
| $token = AcquisitionTicketToken::whereToken($param->token)->first(); | |||||
| if ($token === null) { | if ($token === null) { | ||||
| logger(sprintf("トークン無 (%d) %s", $param->customerId, $param->token)); | |||||
| return $this->failedResponse(); | return $this->failedResponse(); | ||||
| } | } | ||||
| @@ -3,8 +3,10 @@ | |||||
| namespace App\Http\Controllers\Web\QRService; | namespace App\Http\Controllers\Web\QRService; | ||||
| use App\Http\Controllers\Web\BaseParam; | use App\Http\Controllers\Web\BaseParam; | ||||
| use App\Models\ColumnName; | |||||
| /** | /** | ||||
| * @property int $customerId | |||||
| * @property string $token | * @property string $token | ||||
| * @property string|null $ticketId | * @property string|null $ticketId | ||||
| */ | */ | ||||
| @@ -13,6 +15,7 @@ class CreateTicketParam extends BaseParam | |||||
| public function rules(): array | public function rules(): array | ||||
| { | { | ||||
| return [ | return [ | ||||
| 'customer_id' => $this->numeric(), | |||||
| 'token' => $this->str(), | 'token' => $this->str(), | ||||
| 'ticket_id' => $this->str(true), | 'ticket_id' => $this->str(true), | ||||
| ]; | ]; | ||||
| @@ -173,7 +173,7 @@ abstract class WebController extends BaseController | |||||
| $this->validated = $validator->validated(); | $this->validated = $validator->validated(); | ||||
| $this->getParam()->setData($this->validated); | $this->getParam()->setData($this->validated); | ||||
| $this->sessionUser->init(); | |||||
| $this->sessionUser->init($this->validated); | |||||
| $this->transaction->beginTransaction(); | $this->transaction->beginTransaction(); | ||||
| $ret = $this->run($request); | $ret = $this->run($request); | ||||
| @@ -22,23 +22,26 @@ class SessionUser | |||||
| private bool $isSwtiched = false; | private bool $isSwtiched = false; | ||||
| private bool $isInit = false; | private bool $isInit = false; | ||||
| public function init() | |||||
| public function init(array $param = []) | |||||
| { | { | ||||
| if ($this->isInit === true) { | if ($this->isInit === true) { | ||||
| return; | return; | ||||
| } | } | ||||
| $this->initSessionUser(); | |||||
| $this->initSessionUser($param); | |||||
| $this->isInit = true; | $this->isInit = true; | ||||
| } | } | ||||
| private function initSessionUser() | |||||
| private function initSessionUser(array $param) | |||||
| { | { | ||||
| // 認証していない場合はスキップ | // 認証していない場合はスキップ | ||||
| $this->user = Auth::user(); | $this->user = Auth::user(); | ||||
| if ($this->user instanceof User && $this->user->customer_id) { | if ($this->user instanceof User && $this->user->customer_id) { | ||||
| HtpmsCustomerConnectionSwitch::switch($this->user->customer_id); | HtpmsCustomerConnectionSwitch::switch($this->user->customer_id); | ||||
| } else if (!!data_get($param, "customer_id")) { | |||||
| HtpmsCustomerConnectionSwitch::switch(data_get($param, "customer_id")); | |||||
| } | } | ||||
| $user = Auth::user(); | $user = Auth::user(); | ||||
| $ckeck = Auth::check(); | $ckeck = Auth::check(); | ||||
| if ($this->user === null) { | if ($this->user === null) { | ||||
| @@ -123,6 +126,12 @@ class SessionUser | |||||
| if ($this->user->customer_code === null) throw new LogicException(); | if ($this->user->customer_code === null) throw new LogicException(); | ||||
| return $this->user->customer_code; | return $this->user->customer_code; | ||||
| } | } | ||||
| public function customerId(): int | |||||
| { | |||||
| if ($this->user === null) throw new LogicException(); | |||||
| if ($this->user->customer_id === null) throw new LogicException(); | |||||
| return $this->user->customer_id; | |||||
| } | |||||
| private function getStoreKey(string $key): string | private function getStoreKey(string $key): string | ||||
| { | { | ||||