Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

38 lines
730B

  1. <?php
  2. namespace App\Logics\QRService;
  3. use App\Codes\DepositTransferReason;
  4. class ChargeLogic
  5. {
  6. use DepositCheck;
  7. /**
  8. * デポジットをチャージする
  9. */
  10. public static function charge(
  11. string $shopId,
  12. int $amount,
  13. ) {
  14. [$shop, $deposit] = self::getData($shopId);
  15. $history = self::makeTransferHistory($shopId, $amount);
  16. $deposit->deposit += $amount;
  17. if (0 < $amount) {
  18. $history->transfer_reason = DepositTransferReason::チャージ;
  19. } else {
  20. $history->transfer_reason = DepositTransferReason::チャージ_取消;
  21. }
  22. $deposit->save();
  23. $history->save();
  24. return $deposit;
  25. }
  26. }