|
- <?php
-
- namespace App\Logics\QRService;
-
- use App\Codes\DepositTransferReason;
-
- class ChargeLogic
- {
- use DepositCheck;
-
- /**
- * デポジットをチャージする
- */
- public static function charge(
- string $shopId,
- int $amount,
- ) {
-
-
- [$shop, $deposit] = self::getData($shopId);
-
-
- $history = self::makeTransferHistory($shopId, $amount);
- $deposit->deposit += $amount;
-
- if (0 < $amount) {
- $history->transfer_reason = DepositTransferReason::チャージ;
- } else {
- $history->transfer_reason = DepositTransferReason::チャージ_取消;
- }
-
- $deposit->save();
- $history->save();
-
- return $deposit;
- }
- }
|