| @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Server; | |||||
| use App\Exceptions\AppCommonException; | use App\Exceptions\AppCommonException; | ||||
| use App\Logics\QRService\CertificateLogic; | use App\Logics\QRService\CertificateLogic; | ||||
| use App\Logics\QRService\CreateLogic; | use App\Logics\QRService\CreateLogic; | ||||
| use App\Logics\QRService\PrintingLogic; | |||||
| use App\Transmission\Layouts\Code\QRTypeCode; | use App\Transmission\Layouts\Code\QRTypeCode; | ||||
| use App\Transmission\Layouts\IF24_02Request; | use App\Transmission\Layouts\IF24_02Request; | ||||
| use Exception; | use Exception; | ||||
| @@ -53,7 +54,15 @@ class IF24_02Controller extends IFController | |||||
| $request->discountAmount, | $request->discountAmount, | ||||
| ); | ); | ||||
| } else if ($request->qrTypeCode === QRTypeCode::方式2_印字方式) { | } else if ($request->qrTypeCode === QRTypeCode::方式2_印字方式) { | ||||
| throw new NotImplementedException("方式2未実装"); | |||||
| PrintingLogic::use( | |||||
| $request->shopNo, | |||||
| $request->header->parkingManagementCode, | |||||
| $request->publishingTerminalCode, | |||||
| $request->publishingDate, | |||||
| $request->publishingNo, | |||||
| $request->adjustDatetime, | |||||
| $request->discountAmount, | |||||
| ); | |||||
| } else if ($request->qrTypeCode === QRTypeCode::方式3_取得方式) { | } else if ($request->qrTypeCode === QRTypeCode::方式3_取得方式) { | ||||
| CreateLogic::use( | CreateLogic::use( | ||||
| $request->shopNo, | $request->shopNo, | ||||
| @@ -0,0 +1,68 @@ | |||||
| <?php | |||||
| namespace App\Logics\QRService; | |||||
| use App\Codes\DepositTransferReason; | |||||
| use App\Codes\Model\QRServiceUsage; | |||||
| use App\Exceptions\AppCommonException; | |||||
| use App\Models\HtpmsCustomer\Mst\ShopNoRelation; | |||||
| use App\Models\HtpmsCustomer\QRService\PrintTicket; | |||||
| use Illuminate\Support\Carbon; | |||||
| class PrintingLogic | |||||
| { | |||||
| use DepositCheck; | |||||
| /** | |||||
| * サービス券を使用する | |||||
| * | |||||
| * @param integer $shopNo | |||||
| * @param string $parkingManagementCode | |||||
| * @param string $adjusterTerminalCode | |||||
| * @param Carbon $publishingDate | |||||
| * @param integer $seqNo | |||||
| * @param Carbon $adjustDatetime | |||||
| * @param integer $discountAmount | |||||
| * @return void | |||||
| */ | |||||
| public static function use( | |||||
| int $shopNo, | |||||
| string $parkingManagementCode, | |||||
| string $adjusterTerminalCode, | |||||
| Carbon $publishingDate, | |||||
| int $seqNo, | |||||
| Carbon $adjustDatetime, | |||||
| int $discountAmount, | |||||
| ) { | |||||
| // 重複利用チェック | |||||
| if (PrintTicket::wherePublishingTerminalCode($adjusterTerminalCode) | |||||
| ->wherePublishingDate($publishingDate) | |||||
| ->wherePublishingNo($seqNo) | |||||
| ->exists() | |||||
| ) { | |||||
| throw new AppCommonException("利用済み"); | |||||
| } | |||||
| // 店舗特定 | |||||
| $relation = ShopNoRelation::whereShopNo($shopNo) | |||||
| ->whereParkingManagementCode($parkingManagementCode) | |||||
| ->whereQrServiceUseage(QRServiceUsage::印字方式) | |||||
| ->firstOrFail(); | |||||
| $qr = new PrintTicket(); | |||||
| $qr->publishing_terminal_code = $adjusterTerminalCode; | |||||
| $qr->publishing_date = $publishingDate; | |||||
| $qr->publishing_no = $seqNo; | |||||
| $qr->shop_id = $relation->shop_id; | |||||
| $qr->parking_management_code = $parkingManagementCode; | |||||
| $qr->used_at = $adjustDatetime; | |||||
| $qr->discount_amount = $discountAmount; | |||||
| // デポジット処理 | |||||
| self::useDeposit($qr->shop_id, $discountAmount, DepositTransferReason::駐車料金割引_印字); | |||||
| $qr->save(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,50 @@ | |||||
| <?php | |||||
| namespace App\Models\HtpmsCustomer\QRService; | |||||
| use App\Models\Cast; | |||||
| use App\Models\ColumnName; | |||||
| use App\Models\HistoryModel; | |||||
| use App\Models\HtpmsCustomer\HtpmsCustomerAppModel; | |||||
| /** | |||||
| * 利用済み印字QRサービス券 | |||||
| */ | |||||
| class PrintTicket extends HtpmsCustomerAppModel | |||||
| { | |||||
| const COL_NAME_PARKING_MANAGEMENT_CODE = ColumnName::PARKING_MANAGEMENT_CODE; // 駐車場管理コード | |||||
| const COL_NAME_DISCOUNT_TICKET_CODE = ColumnName::DISCOUNT_TICKET_CODE; // サービス券コード | |||||
| const COL_NAME_PUBLISHING_TERMINAL_CODE = ColumnName::PUBLISHING_TERMINAL_CODE; | |||||
| const COL_NAME_PUBLISHING_DATE = ColumnName::PUBLISHING_DATE; | |||||
| const COL_NAME_PUBLISHING_NO = ColumnName::PUBLISHING_NO; | |||||
| const COL_NAME_SHOP_ID = ColumnName::SHOP_ID; // 店舗ID | |||||
| const COL_NAME_USED_AT = "used_at"; // 利用日時 | |||||
| const COL_NAME_DISCOUNT_AMOUNT = "discount_amount"; // 割引金額 | |||||
| protected $table = "tbl3_qrs_print_tickets"; | |||||
| protected $casts = [ | |||||
| self::COL_NAME_PUBLISHING_DATE => Cast::DATE, | |||||
| self::COL_NAME_USED_AT => Cast::DATETIME, | |||||
| ]; | |||||
| public function getHistory(): ?HistoryModel | |||||
| { | |||||
| return null; | |||||
| } | |||||
| public function getModelName(): string | |||||
| { | |||||
| return "利用済み印字QRサービス券"; | |||||
| } | |||||
| /** | |||||
| * 使用済み判定 使用済みの場合trueを返却 | |||||
| * | |||||
| * @return boolean | |||||
| */ | |||||
| public function isUsed(): bool | |||||
| { | |||||
| return $this->used_at !== null; | |||||
| } | |||||
| } | |||||
| @@ -47,6 +47,11 @@ return new class extends Migration | |||||
| ColumnName::PARKING_MANAGEMENT_CODE, | ColumnName::PARKING_MANAGEMENT_CODE, | ||||
| "qr_service_useage", | "qr_service_useage", | ||||
| ]); | ]); | ||||
| MigrationHelper::addUnique("tbl3_mst_shop_no_relations", 2, [ | |||||
| ColumnName::SHOP_NO, | |||||
| "qr_service_useage", | |||||
| ColumnName::PARKING_MANAGEMENT_CODE, | |||||
| ]); | |||||
| // データ移行 | // データ移行 | ||||
| foreach ($backup as $data) { | foreach ($backup as $data) { | ||||
| @@ -0,0 +1,57 @@ | |||||
| <?php | |||||
| use App\Models\ColumnName; | |||||
| use App\Util\MigrationHelper; | |||||
| use Illuminate\Database\Migrations\Migration; | |||||
| use Illuminate\Database\Schema\Blueprint; | |||||
| use Illuminate\Support\Facades\DB; | |||||
| use Illuminate\Support\Facades\Schema; | |||||
| return new class extends Migration | |||||
| { | |||||
| protected $connection = "htpms_customer"; | |||||
| /** | |||||
| * Run the migrations. | |||||
| */ | |||||
| public function up(): void | |||||
| { | |||||
| $schema = function (Blueprint $table, MigrationHelper $helper) { | |||||
| $helper->baseColumn() | |||||
| ->publishingTerminalCode() | |||||
| ->publishingDate() | |||||
| ->publishingNo() | |||||
| ->shopId() | |||||
| ->parkinManagementCode(); | |||||
| $table->datetime("expires_at")->nullable()->comment("有効期限"); | |||||
| $table->datetime("used_at")->comment("利用日時"); | |||||
| $table->unsignedInteger("discount_amount")->comment("割引金額"); | |||||
| $helper->index(1, [ColumnName::PARKING_MANAGEMENT_CODE]); | |||||
| $helper->index(2, [ColumnName::SHOP_ID]); | |||||
| $helper->index(3, ['used_at']); | |||||
| }; | |||||
| Schema::dropIfExists("tbl3_qrs_print_tickets"); | |||||
| MigrationHelper::createTable("tbl3_qrs_print_tickets", $schema, "HTD 利用済み印字QRサービス券"); | |||||
| MigrationHelper::addUnique( | |||||
| "tbl3_qrs_print_tickets", | |||||
| 1, | |||||
| [ | |||||
| ColumnName::PUBLISHING_TERMINAL_CODE, | |||||
| ColumnName::PUBLISHING_DATE, | |||||
| ColumnName::PUBLISHING_NO, | |||||
| ] | |||||
| ); | |||||
| } | |||||
| /** | |||||
| * Reverse the migrations. | |||||
| */ | |||||
| public function down(): void | |||||
| { | |||||
| } | |||||
| }; | |||||
| @@ -0,0 +1,43 @@ | |||||
| <?php | |||||
| use App\Models\ColumnName; | |||||
| use App\Util\MigrationHelper; | |||||
| use Illuminate\Database\Migrations\Migration; | |||||
| use Illuminate\Database\Schema\Blueprint; | |||||
| use Illuminate\Support\Facades\Schema; | |||||
| return new class extends Migration | |||||
| { | |||||
| protected $connection = "htpms_customer"; | |||||
| /** | |||||
| * Run the migrations. | |||||
| */ | |||||
| public function up(): void | |||||
| { | |||||
| $schema = function (Blueprint $table, MigrationHelper $helper) { | |||||
| $helper->baseColumn() | |||||
| ->shopId(); | |||||
| $table->dateTime("transfer_datetime")->comment("異動日時"); | |||||
| $table->integer("transfer_amount")->comment("異動金額"); | |||||
| $table->integer("before_amount")->comment("異動前デポジット"); | |||||
| $table->integer("after_amount")->comment("異動金額"); | |||||
| $table->string("transfer_reason")->nullable()->comment("異動理由"); | |||||
| $helper->index(1, [ColumnName::SHOP_ID]); | |||||
| $helper->index(2, ["transfer_datetime"]); | |||||
| }; | |||||
| Schema::dropIfExists("tbl3_dep_deposit_transfers"); | |||||
| MigrationHelper::createTable("tbl3_dep_deposit_transfers", $schema, "HTD デポジット異動履歴"); | |||||
| } | |||||
| /** | |||||
| * Reverse the migrations. | |||||
| */ | |||||
| public function down(): void | |||||
| { | |||||
| } | |||||
| }; | |||||