param; $token = AcquisitionTicketToken::whereToken($param->token)->first(); if ($token === null) { logger(sprintf("トークン無 (%d) %s", $param->customerId, $param->token)); return $this->failedResponse(); } if ($param->ticketId) { $ticket = AcquisitionTicket::find($param->ticketId); if ($ticket === null || !$ticket->canUse()) { $ticket = CreateLogic::create($param->token); } } else { $ticket = CreateLogic::create($param->token); } $res = [ 'ticket_id' => $ticket->id, 'data' => $this->convertToQrStr($ticket), ]; return $this->successResponse($res); } private function convertToQrStr(AcquisitionTicket $ticket): string { $body = sprintf( "%02d%s%06d%02d%02d", "01", $ticket->publishing_date->format('Ymd'), $ticket->publishing_no, $ticket->shop_no, $ticket->discount_ticket_code, ); return sprintf( "HT004%s", QRCryptoLogic::encrypt($body) ); } }