From a9d9d536ece2f24139b677d6bdcefe6362351f2e Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Wed, 3 Apr 2024 10:54:14 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=81=E3=83=A3=E3=83=BC=E3=82=B8=E5=8F=96?= =?UTF-8?q?=E6=B6=88=20=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Codes/DepositTransferReason.php | 1 + app/Http/Controllers/Web/BaseParam.php | 4 +++- app/Http/Controllers/Web/Shop/DepositChargeParam.php | 3 ++- app/Logics/QRService/ChargeLogic.php | 7 ++++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Codes/DepositTransferReason.php b/app/Codes/DepositTransferReason.php index 21087a7..7106fff 100644 --- a/app/Codes/DepositTransferReason.php +++ b/app/Codes/DepositTransferReason.php @@ -5,6 +5,7 @@ namespace App\Codes; enum DepositTransferReason: string { case チャージ = "チャージ"; + case チャージ_取消 = "チャージ_取消"; case 駐車料金割引_認証 = "駐車料金割引_認証"; case 駐車料金割引_印字 = "駐車料金割引_印字"; case 駐車料金割引_取得 = "駐車料金割引_取得"; diff --git a/app/Http/Controllers/Web/BaseParam.php b/app/Http/Controllers/Web/BaseParam.php index c35b9b2..090aa0c 100644 --- a/app/Http/Controllers/Web/BaseParam.php +++ b/app/Http/Controllers/Web/BaseParam.php @@ -17,6 +17,7 @@ abstract class BaseParam implements IParam const NULLABLE = 'nullable'; const STR = 'string'; const NUMERIC = 'numeric'; + const INTEGER = 'integer'; const DATE = 'date'; const BOOLEAN_ = 'boolean'; const IMAGE = 'image'; @@ -178,7 +179,8 @@ abstract class BaseParam implements IParam { return array_merge([ $this->isNullable($condition, $nullable) ? self::NULLABLE : self::REQUIRED, - self::NUMERIC + self::NUMERIC, + self::INTEGER, ], is_array($condition) ? $condition : []); } protected function boolean(array|bool $condition = [], $nullable = false): array diff --git a/app/Http/Controllers/Web/Shop/DepositChargeParam.php b/app/Http/Controllers/Web/Shop/DepositChargeParam.php index 79e2a5d..2e192d7 100644 --- a/app/Http/Controllers/Web/Shop/DepositChargeParam.php +++ b/app/Http/Controllers/Web/Shop/DepositChargeParam.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Web\Shop; use App\Http\Controllers\Web\BaseParam; use App\Models\HtpmsCustomer\Deposit\Deposit; +use Illuminate\Validation\Rule; /** * @property string shopId @@ -15,7 +16,7 @@ class DepositChargeParam extends BaseParam { return [ Deposit::COL_NAME_SHOP_ID => $this->str(), - "amount" => $this->numeric(), + "amount" => $this->numeric(["between:-100000,100000", Rule::notIn("0")]), ]; } } diff --git a/app/Logics/QRService/ChargeLogic.php b/app/Logics/QRService/ChargeLogic.php index f487813..7237722 100644 --- a/app/Logics/QRService/ChargeLogic.php +++ b/app/Logics/QRService/ChargeLogic.php @@ -22,7 +22,12 @@ class ChargeLogic $history = self::makeTransferHistory($shopId, $amount); $deposit->deposit += $amount; - $history->transfer_reason = DepositTransferReason::チャージ; + + if (0 < $amount) { + $history->transfer_reason = DepositTransferReason::チャージ; + } else { + $history->transfer_reason = DepositTransferReason::チャージ_取消; + } $deposit->save(); $history->save();