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();