| @@ -1,14 +0,0 @@ | |||||
| <?php | |||||
| namespace App\Events\ReceiptIssuingOrder; | |||||
| /** | |||||
| * 依頼完了イベント | |||||
| */ | |||||
| class CompletedEvent extends ReceiptIssuingOrderEvent | |||||
| { | |||||
| public function getEventName(): string | |||||
| { | |||||
| return "完了"; | |||||
| } | |||||
| } | |||||
| @@ -9,6 +9,6 @@ class DownloadedEvent extends ReceiptIssuingOrderEvent | |||||
| { | { | ||||
| public function getEventName(): string | public function getEventName(): string | ||||
| { | { | ||||
| return "ダウンロード"; | |||||
| return "ダウンロード完了"; | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,14 @@ | |||||
| <?php | |||||
| namespace App\Events\ReceiptIssuingOrder; | |||||
| /** | |||||
| * Email送付完了イベント | |||||
| */ | |||||
| class EmailSendEvent extends ReceiptIssuingOrderEvent | |||||
| { | |||||
| public function getEventName(): string | |||||
| { | |||||
| return "Email送付完了"; | |||||
| } | |||||
| } | |||||
| @@ -3,9 +3,11 @@ | |||||
| namespace App\Events\ReceiptIssuingOrder; | namespace App\Events\ReceiptIssuingOrder; | ||||
| use App\Models\ReceiptIssuingOrder; | use App\Models\ReceiptIssuingOrder; | ||||
| use App\Util\DateUtil; | |||||
| use Illuminate\Broadcasting\InteractsWithSockets; | use Illuminate\Broadcasting\InteractsWithSockets; | ||||
| use Illuminate\Foundation\Events\Dispatchable; | use Illuminate\Foundation\Events\Dispatchable; | ||||
| use Illuminate\Queue\SerializesModels; | use Illuminate\Queue\SerializesModels; | ||||
| use Illuminate\Support\Carbon; | |||||
| /** | /** | ||||
| * 領収証発行依頼の基底イベントクラス | * 領収証発行依頼の基底イベントクラス | ||||
| @@ -14,9 +16,12 @@ abstract class ReceiptIssuingOrderEvent | |||||
| { | { | ||||
| use Dispatchable, InteractsWithSockets, SerializesModels; | use Dispatchable, InteractsWithSockets, SerializesModels; | ||||
| public Carbon $eventDatetime; | |||||
| public function __construct( | public function __construct( | ||||
| public ReceiptIssuingOrder $order | public ReceiptIssuingOrder $order | ||||
| ) { | ) { | ||||
| $this->eventDatetime = DateUtil::now(); | |||||
| } | } | ||||
| abstract public function getEventName(): string; | abstract public function getEventName(): string; | ||||
| @@ -6,7 +6,9 @@ use App\Codes\QueueName; | |||||
| use App\Jobs\BaseJob; | use App\Jobs\BaseJob; | ||||
| use App\Models\ReceiptIssuingHTParkingCustomOrder; | use App\Models\ReceiptIssuingHTParkingCustomOrder; | ||||
| use App\Models\ReceiptIssuingOrder; | use App\Models\ReceiptIssuingOrder; | ||||
| use App\Models\ReceiptIssuingOrderTax; | |||||
| use App\Util\Custom\HelloTechno\API; | use App\Util\Custom\HelloTechno\API; | ||||
| use Illuminate\Support\Carbon; | |||||
| class NoticeReceiptIssuingOrder extends BaseJob | class NoticeReceiptIssuingOrder extends BaseJob | ||||
| { | { | ||||
| @@ -18,7 +20,9 @@ class NoticeReceiptIssuingOrder extends BaseJob | |||||
| public function __construct( | public function __construct( | ||||
| private ReceiptIssuingOrder $order, | private ReceiptIssuingOrder $order, | ||||
| private ReceiptIssuingHTParkingCustomOrder $custom, | private ReceiptIssuingHTParkingCustomOrder $custom, | ||||
| private string $eventName = "", | |||||
| private ReceiptIssuingOrderTax $tax, | |||||
| private string $eventName, | |||||
| private Carbon $eventDatetime, | |||||
| ) { | ) { | ||||
| $this->onQueue(QueueName::JOB->value); | $this->onQueue(QueueName::JOB->value); | ||||
| } | } | ||||
| @@ -31,7 +35,7 @@ class NoticeReceiptIssuingOrder extends BaseJob | |||||
| public function handle() | public function handle() | ||||
| { | { | ||||
| try { | try { | ||||
| API::sendReceiptIssuingOrder($this->order, $this->custom); | |||||
| API::sendReceiptIssuingOrder($this->order, $this->custom, $this->tax, $this->eventName, $this->eventDatetime); | |||||
| } catch (Exception $e) { | } catch (Exception $e) { | ||||
| $this->log(false); | $this->log(false); | ||||
| throw $e; | throw $e; | ||||
| @@ -3,6 +3,7 @@ | |||||
| namespace App\Jobs\ReceiptIssuingOrder; | namespace App\Jobs\ReceiptIssuingOrder; | ||||
| use App\Codes\QueueName; | use App\Codes\QueueName; | ||||
| use App\Events\ReceiptIssuingOrder\EmailSendEvent; | |||||
| use App\Jobs\BaseJob; | use App\Jobs\BaseJob; | ||||
| use App\Models\Email; | use App\Models\Email; | ||||
| use App\Models\ReceiptIssuingOrder; | use App\Models\ReceiptIssuingOrder; | ||||
| @@ -61,6 +62,7 @@ class PollEmailSendStatus extends BaseJob | |||||
| { | { | ||||
| $this->order->status_receipt_email_send_datetime = $sendDatetime; | $this->order->status_receipt_email_send_datetime = $sendDatetime; | ||||
| $this->order->save(); | $this->order->save(); | ||||
| EmailSendEvent::dispatch($this->order); | |||||
| info("領収証Emailポーリング完了:" . $this->order->receipt_pdf_email_id); | info("領収証Emailポーリング完了:" . $this->order->receipt_pdf_email_id); | ||||
| } | } | ||||
| @@ -2,10 +2,12 @@ | |||||
| namespace App\Listeners\ReceiptIssuingOrder\Custom\HelloTechno; | namespace App\Listeners\ReceiptIssuingOrder\Custom\HelloTechno; | ||||
| use App\Events\ReceiptIssuingOrder\CompletedEvent; | |||||
| use App\Codes\EnvironmentName; | |||||
| use App\Events\ReceiptIssuingOrder\ConfirmedEvent; | use App\Events\ReceiptIssuingOrder\ConfirmedEvent; | ||||
| use App\Events\ReceiptIssuingOrder\CreatedEvent; | use App\Events\ReceiptIssuingOrder\CreatedEvent; | ||||
| use App\Events\ReceiptIssuingOrder\DownloadedEvent; | use App\Events\ReceiptIssuingOrder\DownloadedEvent; | ||||
| use App\Events\ReceiptIssuingOrder\EmailOrderEvent; | |||||
| use App\Events\ReceiptIssuingOrder\EmailSendEvent; | |||||
| use App\Events\ReceiptIssuingOrder\MailOrderEvent; | use App\Events\ReceiptIssuingOrder\MailOrderEvent; | ||||
| use App\Events\ReceiptIssuingOrder\MailPostedEvent; | use App\Events\ReceiptIssuingOrder\MailPostedEvent; | ||||
| use App\Events\ReceiptIssuingOrder\ReceiptIssuingOrderEvent; | use App\Events\ReceiptIssuingOrder\ReceiptIssuingOrderEvent; | ||||
| @@ -16,11 +18,12 @@ class NoticeListener | |||||
| { | { | ||||
| public function handle( | public function handle( | ||||
| CompletedEvent| | |||||
| ConfirmedEvent| | ConfirmedEvent| | ||||
| CreatedEvent| | CreatedEvent| | ||||
| MailOrderEvent| | MailOrderEvent| | ||||
| MailPostedEvent| | MailPostedEvent| | ||||
| EmailOrderEvent| | |||||
| EmailSendEvent| | |||||
| DownloadedEvent $event | DownloadedEvent $event | ||||
| ): void { | ): void { | ||||
| $this->notice($event->order, $event); | $this->notice($event->order, $event); | ||||
| @@ -31,10 +34,10 @@ class NoticeListener | |||||
| */ | */ | ||||
| private function notice(ReceiptIssuingOrder $order, ReceiptIssuingOrderEvent $event) | private function notice(ReceiptIssuingOrder $order, ReceiptIssuingOrderEvent $event) | ||||
| { | { | ||||
| $htCustom = $order->htCustomOrder; | $htCustom = $order->htCustomOrder; | ||||
| if ($htCustom !== null) { | if ($htCustom !== null) { | ||||
| NoticeReceiptIssuingOrder::dispatch($order, $htCustom, $event->getEventName()); | |||||
| $tax = $order->receiptIssuingOrderTaxes->firstOrFail(); | |||||
| NoticeReceiptIssuingOrder::dispatch($order, $htCustom, $tax, $event->getEventName(), $event->eventDatetime); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -2,9 +2,11 @@ | |||||
| namespace App\Util\Custom\HelloTechno; | namespace App\Util\Custom\HelloTechno; | ||||
| use App\Codes\EnvironmentName; | |||||
| use App\Exceptions\AppCommonException; | use App\Exceptions\AppCommonException; | ||||
| use App\Models\ReceiptIssuingHTParkingCustomOrder; | use App\Models\ReceiptIssuingHTParkingCustomOrder; | ||||
| use App\Models\ReceiptIssuingOrder; | use App\Models\ReceiptIssuingOrder; | ||||
| use App\Models\ReceiptIssuingOrderTax; | |||||
| use Exception; | use Exception; | ||||
| use Illuminate\Support\Arr; | use Illuminate\Support\Arr; | ||||
| use Illuminate\Support\Carbon; | use Illuminate\Support\Carbon; | ||||
| @@ -58,9 +60,20 @@ class API | |||||
| return static::get(static::getAdjustDataUrl(), $query); | return static::get(static::getAdjustDataUrl(), $query); | ||||
| } | } | ||||
| public static function sendReceiptIssuingOrder(ReceiptIssuingOrder $order, ReceiptIssuingHTParkingCustomOrder $customOrder) | |||||
| { | |||||
| $param = static::makeReceiptIssuingOrderParams($order, $customOrder); | |||||
| public static function sendReceiptIssuingOrder( | |||||
| ReceiptIssuingOrder $order, | |||||
| ReceiptIssuingHTParkingCustomOrder $customOrder, | |||||
| ReceiptIssuingOrderTax $tax, | |||||
| string $eventName, | |||||
| Carbon $eventDatetime | |||||
| ) { | |||||
| $param = static::makeReceiptIssuingOrderParams($order, $customOrder, $tax, $eventName, $eventDatetime); | |||||
| if (app()->environment([EnvironmentName::LOCAL->value])) { | |||||
| logger("HT通知 ローカル環境のため送信しない", ['SEND' => $param]); | |||||
| return []; | |||||
| } | |||||
| return static::post(static::getReceiptIssuingOrderUrl(), $param); | return static::post(static::getReceiptIssuingOrderUrl(), $param); | ||||
| } | } | ||||
| @@ -93,10 +106,17 @@ class API | |||||
| } | } | ||||
| public static function makeReceiptIssuingOrderParams(ReceiptIssuingOrder $order, ReceiptIssuingHTParkingCustomOrder $customOrder): array | |||||
| { | |||||
| public static function makeReceiptIssuingOrderParams( | |||||
| ReceiptIssuingOrder $order, | |||||
| ReceiptIssuingHTParkingCustomOrder $customOrder, | |||||
| ReceiptIssuingOrderTax $tax, | |||||
| string $eventName, | |||||
| Carbon $eventDatetime | |||||
| ): array { | |||||
| $param = []; | $param = []; | ||||
| $param['id'] = $order->id; | $param['id'] = $order->id; | ||||
| $param['event_name'] = $eventName; | |||||
| $param['event_datetime'] = static::formatDateTimeStr($eventDatetime); | |||||
| $param['customer_code'] = $customOrder->customer_code; | $param['customer_code'] = $customOrder->customer_code; | ||||
| $param['parking_management_code'] = $customOrder->parking_management_code; | $param['parking_management_code'] = $customOrder->parking_management_code; | ||||
| $param['adjust_seq_no'] = $customOrder->adjust_seq_no; | $param['adjust_seq_no'] = $customOrder->adjust_seq_no; | ||||
| @@ -121,8 +141,10 @@ class API | |||||
| $param['receipt_name'] = $order->receipt_name; | $param['receipt_name'] = $order->receipt_name; | ||||
| $param['receipt_invoice_no'] = $order->receipt_invoice_no; | $param['receipt_invoice_no'] = $order->receipt_invoice_no; | ||||
| $param['receipt_amount'] = $order->receipt_amount; | $param['receipt_amount'] = $order->receipt_amount; | ||||
| $param['tax_rate'] = $tax->tax_rate; | |||||
| $param['tax_amount'] = $tax->tax_amount; | |||||
| $param['email'] = $order->email; | $param['email'] = $order->email; | ||||
| $param['mail_pref_code'] = $order->mail_pref_code; | |||||
| $param['mail_pref_code'] = $order->mail_pref_code !== null ? $order->mail_pref_code->value : null; | |||||
| $param['mail_zip_code'] = $order->mail_zip_code; | $param['mail_zip_code'] = $order->mail_zip_code; | ||||
| $param['mail_address1'] = $order->mail_address1; | $param['mail_address1'] = $order->mail_address1; | ||||
| $param['mail_address2'] = $order->mail_address2; | $param['mail_address2'] = $order->mail_address2; | ||||