| @@ -5,6 +5,7 @@ namespace App\Codes; | |||||
| enum DepositTransferReason: string | enum DepositTransferReason: string | ||||
| { | { | ||||
| case チャージ = "チャージ"; | case チャージ = "チャージ"; | ||||
| case チャージ_取消 = "チャージ_取消"; | |||||
| case 駐車料金割引_認証 = "駐車料金割引_認証"; | case 駐車料金割引_認証 = "駐車料金割引_認証"; | ||||
| case 駐車料金割引_印字 = "駐車料金割引_印字"; | case 駐車料金割引_印字 = "駐車料金割引_印字"; | ||||
| case 駐車料金割引_取得 = "駐車料金割引_取得"; | case 駐車料金割引_取得 = "駐車料金割引_取得"; | ||||
| @@ -17,6 +17,7 @@ abstract class BaseParam implements IParam | |||||
| const NULLABLE = 'nullable'; | const NULLABLE = 'nullable'; | ||||
| const STR = 'string'; | const STR = 'string'; | ||||
| const NUMERIC = 'numeric'; | const NUMERIC = 'numeric'; | ||||
| const INTEGER = 'integer'; | |||||
| const DATE = 'date'; | const DATE = 'date'; | ||||
| const BOOLEAN_ = 'boolean'; | const BOOLEAN_ = 'boolean'; | ||||
| const IMAGE = 'image'; | const IMAGE = 'image'; | ||||
| @@ -178,7 +179,8 @@ abstract class BaseParam implements IParam | |||||
| { | { | ||||
| return array_merge([ | return array_merge([ | ||||
| $this->isNullable($condition, $nullable) ? self::NULLABLE : self::REQUIRED, | $this->isNullable($condition, $nullable) ? self::NULLABLE : self::REQUIRED, | ||||
| self::NUMERIC | |||||
| self::NUMERIC, | |||||
| self::INTEGER, | |||||
| ], is_array($condition) ? $condition : []); | ], is_array($condition) ? $condition : []); | ||||
| } | } | ||||
| protected function boolean(array|bool $condition = [], $nullable = false): array | protected function boolean(array|bool $condition = [], $nullable = false): array | ||||
| @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Web\Shop; | |||||
| use App\Http\Controllers\Web\BaseParam; | use App\Http\Controllers\Web\BaseParam; | ||||
| use App\Models\HtpmsCustomer\Deposit\Deposit; | use App\Models\HtpmsCustomer\Deposit\Deposit; | ||||
| use Illuminate\Validation\Rule; | |||||
| /** | /** | ||||
| * @property string shopId | * @property string shopId | ||||
| @@ -15,7 +16,7 @@ class DepositChargeParam extends BaseParam | |||||
| { | { | ||||
| return [ | return [ | ||||
| Deposit::COL_NAME_SHOP_ID => $this->str(), | Deposit::COL_NAME_SHOP_ID => $this->str(), | ||||
| "amount" => $this->numeric(), | |||||
| "amount" => $this->numeric(["between:-100000,100000", Rule::notIn("0")]), | |||||
| ]; | ]; | ||||
| } | } | ||||
| } | } | ||||
| @@ -22,7 +22,12 @@ class ChargeLogic | |||||
| $history = self::makeTransferHistory($shopId, $amount); | $history = self::makeTransferHistory($shopId, $amount); | ||||
| $deposit->deposit += $amount; | $deposit->deposit += $amount; | ||||
| $history->transfer_reason = DepositTransferReason::チャージ; | |||||
| if (0 < $amount) { | |||||
| $history->transfer_reason = DepositTransferReason::チャージ; | |||||
| } else { | |||||
| $history->transfer_reason = DepositTransferReason::チャージ_取消; | |||||
| } | |||||
| $deposit->save(); | $deposit->save(); | ||||
| $history->save(); | $history->save(); | ||||