From 6ae5b73a84539a71337be3f155a4cc00a9014a4f Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Thu, 4 Apr 2024 10:32:15 +0900 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E8=88=97=E7=95=AA=E5=8F=B7=E7=B4=90?= =?UTF-8?q?=E3=81=A5=E3=81=91=E3=81=ABQR=E3=82=B5=E3=83=BC=E3=83=93?= =?UTF-8?q?=E3=82=B9=E5=88=B8=E5=88=A9=E7=94=A8=E6=96=B9=E6=B3=95=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Codes/Model/QRServiceUsage.php | 13 ++++ .../CheckDataFormatController.php | 8 ++- .../Config/Certification/DeleteController.php | 9 ++- .../Certification/RegisterController.php | 2 + .../Config/Certification/UpdateController.php | 8 ++- app/Logics/QRService/CertificateLogic.php | 8 ++- .../HtpmsCustomer/Mst/ShopNoRelation.php | 13 ++++ ...ertificationAvailableSettingRepository.php | 4 +- ..._add_column_tbl3_mst_shop_no_relations.php | 65 +++++++++++++++++++ 9 files changed, 120 insertions(+), 10 deletions(-) create mode 100644 app/Codes/Model/QRServiceUsage.php create mode 100644 database/migrations/2024_04_04_085800_add_column_tbl3_mst_shop_no_relations.php diff --git a/app/Codes/Model/QRServiceUsage.php b/app/Codes/Model/QRServiceUsage.php new file mode 100644 index 0000000..8d10962 --- /dev/null +++ b/app/Codes/Model/QRServiceUsage.php @@ -0,0 +1,13 @@ +data); // 対象の駐車場か判定 - $relation = ShopNoRelation::whereShopId($this->sessionUser->shopId()) - ->whereParkingManagementCode($data->駐車場管理コード) + $relation = ShopNoRelation::byKey( + $this->sessionUser->shopId(), + $data->駐車場管理コード, + QRServiceUsage::認証方式 + ) ->first(); if ($relation === null) { diff --git a/app/Http/Controllers/Web/Shop/Config/Certification/DeleteController.php b/app/Http/Controllers/Web/Shop/Config/Certification/DeleteController.php index 6363e14..a734171 100644 --- a/app/Http/Controllers/Web/Shop/Config/Certification/DeleteController.php +++ b/app/Http/Controllers/Web/Shop/Config/Certification/DeleteController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Web\Shop\Config\Certification; +use App\Codes\Model\QRServiceUsage; use App\Http\Controllers\Web\WebController; use App\Models\HtpmsCustomer\Mst\ShopNoRelation; use App\Models\HtpmsCustomer\QRService\CertificationAvailableSetting; @@ -36,11 +37,13 @@ class DeleteController extends WebController ->whereParkingManagementCode($param->parkingManagementCode) ->get(); - $relation = ShopNoRelation::whereShopId($param->shopId) - ->whereParkingManagementCode($param->parkingManagementCode) + $relation = ShopNoRelation::byKey( + $param->shopId, + $param->parkingManagementCode, + RServiceUsage::認証方式 + ) ->firstOrFail(); - foreach ($settings as $setting) { $setting->delete(); } diff --git a/app/Http/Controllers/Web/Shop/Config/Certification/RegisterController.php b/app/Http/Controllers/Web/Shop/Config/Certification/RegisterController.php index 931282a..7dfc6f6 100644 --- a/app/Http/Controllers/Web/Shop/Config/Certification/RegisterController.php +++ b/app/Http/Controllers/Web/Shop/Config/Certification/RegisterController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Web\Shop\Config\Certification; +use App\Codes\Model\QRServiceUsage; use App\Exceptions\ParamException; use App\Http\Controllers\Web\WebController; use App\Models\ColumnName; @@ -44,6 +45,7 @@ class RegisterController extends WebController $relation->shop_id = $param->shopId; $relation->parking_management_code = $param->parkingManagementCode; $relation->shop_no = $param->shopNo; + $relation->qr_service_useage = QRServiceUsage::認証方式; $relation->save(); diff --git a/app/Http/Controllers/Web/Shop/Config/Certification/UpdateController.php b/app/Http/Controllers/Web/Shop/Config/Certification/UpdateController.php index 7b49c61..41abbff 100644 --- a/app/Http/Controllers/Web/Shop/Config/Certification/UpdateController.php +++ b/app/Http/Controllers/Web/Shop/Config/Certification/UpdateController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Web\Shop\Config\Certification; +use App\Codes\Model\QRServiceUsage; use App\Http\Controllers\Web\WebController; use App\Models\HtpmsCustomer\Mst\ShopNoRelation; use Illuminate\Http\JsonResponse; @@ -30,8 +31,11 @@ class UpdateController extends WebController { $param = $this->param; - $relation = ShopNoRelation::whereShopId($param->shopId) - ->whereParkingManagementCode($param->parkingManagementCode) + $relation = ShopNoRelation::byKey( + $param->shopId, + $param->parkingManagementCode, + QRServiceUsage::認証方式 + ) ->firstOrFail(); $relation->shop_no = $param->shopNo; diff --git a/app/Logics/QRService/CertificateLogic.php b/app/Logics/QRService/CertificateLogic.php index 43182f6..bdee200 100644 --- a/app/Logics/QRService/CertificateLogic.php +++ b/app/Logics/QRService/CertificateLogic.php @@ -3,6 +3,7 @@ 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\CertificationAvailableSetting; @@ -52,8 +53,11 @@ class CertificateLogic $qr->discount_ticket_code = $discountTicketCode; // 店舗番号の解決 - $relation = ShopNoRelation::whereShopId($shopId) - ->whereParkingManagementCode($parkingManagementCode) + $relation = ShopNoRelation::byKey( + $shopId, + $parkingManagementCode, + QRServiceUsage::認証方式 + ) ->first(); if ($relation instanceof ShopNoRelation === false) { throw new AppCommonException("店舗番号紐づけ未設定"); diff --git a/app/Models/HtpmsCustomer/Mst/ShopNoRelation.php b/app/Models/HtpmsCustomer/Mst/ShopNoRelation.php index 0fe3a5d..3bd4d50 100644 --- a/app/Models/HtpmsCustomer/Mst/ShopNoRelation.php +++ b/app/Models/HtpmsCustomer/Mst/ShopNoRelation.php @@ -2,6 +2,7 @@ namespace App\Models\HtpmsCustomer\Mst; +use App\Codes\Model\QRServiceUsage; use App\Models\ColumnName; use App\Models\HtpmsCustomer\HtpmsCustomerAppModel; @@ -13,11 +14,23 @@ class ShopNoRelation extends HtpmsCustomerAppModel const COL_NAME_SHOP_ID = ColumnName::SHOP_ID; const COL_NAME_PARKING_MANAGEMENT_CODE = ColumnName::PARKING_MANAGEMENT_CODE; const COL_NAME_SHOP_NO = ColumnName::SHOP_NO; + const COL_NAME_QR_SERVICE_USEAGE = "qr_service_useage"; protected $table = "tbl3_mst_shop_no_relations"; + protected $casts = [ + self::COL_NAME_QR_SERVICE_USEAGE => QRServiceUsage::class, + ]; + public function getModelName(): string { return "店舗番号紐づけ"; } + + public static function byKey(string $shopId, string $parkingManagementCode, QRServiceUsage $qrServiceUsage) + { + return static::whereShopId($shopId) + ->whereParkingManagementCode($parkingManagementCode) + ->whereQrServiceUseage($qrServiceUsage); + } } diff --git a/app/Repositories/CertificationAvailableSettingRepository.php b/app/Repositories/CertificationAvailableSettingRepository.php index 1442911..32fe345 100644 --- a/app/Repositories/CertificationAvailableSettingRepository.php +++ b/app/Repositories/CertificationAvailableSettingRepository.php @@ -2,6 +2,7 @@ namespace App\Repositories; +use App\Codes\Model\QRServiceUsage; use App\Models\ColumnName; use App\Models\HtpmsCustomer\Existing\Parking; use App\Models\HtpmsCustomer\Mst\ShopNoRelation; @@ -30,7 +31,8 @@ class CertificationAvailableSettingRepository extends BaseRepository public function get(array $condition): Collection { - $table = ShopNoRelation::getBuilder(static::TABLE_RELATION); + $table = ShopNoRelation::getBuilder(static::TABLE_RELATION) + ->where(ShopNoRelation::COL_NAME_QR_SERVICE_USEAGE, QRServiceUsage::認証方式->value); $table->leftJoinSub(CertificationAvailableSetting::getBuilder(), static::TABLE_SETTING, function (JoinClause $join) { $join->on( diff --git a/database/migrations/2024_04_04_085800_add_column_tbl3_mst_shop_no_relations.php b/database/migrations/2024_04_04_085800_add_column_tbl3_mst_shop_no_relations.php new file mode 100644 index 0000000..08170e7 --- /dev/null +++ b/database/migrations/2024_04_04_085800_add_column_tbl3_mst_shop_no_relations.php @@ -0,0 +1,65 @@ +connection)->table("tbl3_mst_shop_no_relations")->get(); + + // テーブル削除 + Schema::drop("tbl3_mst_shop_no_relations"); + Schema::drop("tbl3_mst_shop_no_relation_histories"); + + + + // テーブル作成 + $schema = function (Blueprint $table, MigrationHelper $helper) { + $helper->baseColumn() + ->shopId() + ->parkinManagementCode() + ->shopNo(); + $table->string("qr_service_useage")->comment("QRサービス券利用方法"); + $helper->index(1, [ColumnName::PARKING_MANAGEMENT_CODE]); + }; + MigrationHelper::createTable("tbl3_mst_shop_no_relations", $schema, "HTD 店舗コード紐づけ"); + MigrationHelper::createTable("tbl3_mst_shop_no_relation_histories", $schema, "HTD 店舗コード紐づけ履歴"); + + // ユニーク制約作成 + MigrationHelper::addUnique("tbl3_mst_shop_no_relations", 1, [ + ColumnName::SHOP_ID, + ColumnName::PARKING_MANAGEMENT_CODE, + "qr_service_useage", + ]); + + // データ移行 + foreach ($backup as $data) { + DB::connection($this->connection)->table("tbl3_mst_shop_no_relations")->insert( + [ + ...json_decode(json_encode($data), true), + "qr_service_useage" => QRServiceUsage::認証方式->value, + ] + ); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + } +};