v7.0.0-beta.1 release

This commit is contained in:
HeuJung committed 2026-04-01 10:30:52 +09:00
commit 6595fd0eb5
3967 files changed
+1875383

No files matched your search

@@ -0,0 +1,109 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
/**
* 장바구니 상품 구매불가 예외
*
* 체크아웃 시 재고부족 또는 판매상태 문제가 있는 상품이 있을 때 발생합니다.
*/
class CartUnavailableException extends Exception
{
/**
* @param string $message 예외 메시지
* @param array $unavailableItems 구매불가 상품 목록
*/
public function __construct(
string $message,
private array $unavailableItems = []
) {
parent::__construct($message);
}
/**
* 구매불가 상품 목록 반환
*
* @return array 구매불가 상품 배열
* [
* [
* 'cart_id' => int,
* 'product_id' => int,
* 'product_option_id' => int,
* 'name' => string,
* 'option' => string|null,
* 'thumbnail' => string|null,
* 'quantity' => int,
* 'stock' => int,
* 'reason' => 'stock'|'status', // 재고부족 or 판매상태
* ],
* ...
* ]
*/
public function getUnavailableItems(): array
{
return $this->unavailableItems;
}
/**
* 재고 부족 상품이 있는지 확인
*
* @return bool
*/
public function hasStockIssue(): bool
{
foreach ($this->unavailableItems as $item) {
if (($item['reason'] ?? '') === 'stock') {
return true;
}
}
return false;
}
/**
* 판매상태 문제 상품이 있는지 확인
*
* @return bool
*/
public function hasStatusIssue(): bool
{
foreach ($this->unavailableItems as $item) {
if (($item['reason'] ?? '') === 'status') {
return true;
}
}
return false;
}
/**
* 로깅용 전체 데이터 반환
*
* @return array
*/
public function toArray(): array
{
return [
'message' => $this->getMessage(),
'unavailable_items' => $this->unavailableItems,
'item_count' => count($this->unavailableItems),
'has_stock_issue' => $this->hasStockIssue(),
'has_status_issue' => $this->hasStatusIssue(),
];
}
/**
* 구매불가 상품 목록으로 예외 생성 (팩토리 메서드)
*
* @param array $items 구매불가 상품 목록
* @return static
*/
public static function fromItems(array $items): static
{
$message = __('sirsoft-ecommerce::exceptions.cart_unavailable');
return new static($message, $items);
}
}
@@ -0,0 +1,49 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
/**
* 통화 설정 잠금 예외
*
* 상품이 존재하여 통화 설정 변경이 잠금되어 있을 때 발생합니다.
*/
class CurrencySettingLockedException extends Exception
{
/**
* @param string $settingType 설정 유형 (base_currency, multi_currency 등)
* @param int $productCount 존재하는 상품 수
*/
public function __construct(
private string $settingType,
private int $productCount
) {
parent::__construct(
__('sirsoft-ecommerce::exceptions.currency_setting_locked', [
'setting_type' => $settingType,
'product_count' => $productCount,
])
);
}
/**
* 설정 유형을 반환합니다.
*
* @return string
*/
public function getSettingType(): string
{
return $this->settingType;
}
/**
* 존재하는 상품 수를 반환합니다.
*
* @return int
*/
public function getProductCount(): int
{
return $this->productCount;
}
}
@@ -0,0 +1,83 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
/**
* 재고 부족 예외
*
* 주문 생성 시 재고가 부족할 때 발생합니다.
*/
class InsufficientStockException extends Exception
{
/**
* @param string $message 예외 메시지
* @param array $insufficientItems 재고 부족 상품 목록
*/
public function __construct(
string $message,
private array $insufficientItems = []
) {
parent::__construct($message);
}
/**
* 재고 부족 상품 목록 반환
*
* @return array 재고 부족 상품 배열
* [
* [
* 'product_option_id' => int,
* 'product_name' => string,
* 'option_name' => string|null,
* 'requested_quantity' => int,
* 'available_quantity' => int,
* 'shortage' => int,
* ],
* ...
* ]
*/
public function getInsufficientItems(): array
{
return $this->insufficientItems;
}
/**
* 재고 부족 상품이 있는지 확인
*
* @return bool
*/
public function hasInsufficientItems(): bool
{
return ! empty($this->insufficientItems);
}
/**
* 로깅용 전체 데이터 반환
*
* @return array
*/
public function toArray(): array
{
return [
'message' => $this->getMessage(),
'insufficient_items' => $this->insufficientItems,
'item_count' => count($this->insufficientItems),
];
}
/**
* 재고 부족 상품 목록으로 예외 생성 (팩토리 메서드)
*
* @param array $items 재고 부족 상품 목록
* @return static
*/
public static function fromItems(array $items): static
{
$count = count($items);
$message = __('sirsoft-ecommerce::exceptions.insufficient_stock', ['count' => $count]);
return new static($message, $items);
}
}
@@ -0,0 +1,23 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
/**
* 옵션 주문 이력 존재 예외
*
* 삭제하려는 옵션에 주문 이력이 있을 때 발생합니다.
*/
class OptionHasOrderHistoryException extends Exception
{
/**
* @param string|null $message 예외 메시지
*/
public function __construct(?string $message = null)
{
parent::__construct(
$message ?? __('sirsoft-ecommerce::messages.options.has_order_history')
);
}
}
@@ -0,0 +1,74 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
/**
* 주문 재계산 금액 변동 예외
*
* 체크아웃 시점과 주문 생성 시점 사이에 가격/쿠폰/배송비가 변경되어
* 최종 결제금액이 달라졌을 때 발생합니다.
*/
class OrderAmountChangedException extends Exception
{
/**
* @param int $storedAmount 체크아웃 시점 저장 금액
* @param int $recalculatedAmount 주문 시점 재계산 금액
*/
public function __construct(
private int $storedAmount,
private int $recalculatedAmount
) {
parent::__construct(
__('sirsoft-ecommerce::exceptions.order_amount_changed', [
'stored' => number_format($storedAmount),
'recalculated' => number_format($recalculatedAmount),
])
);
}
/**
* 체크아웃 시점 저장 금액 반환
*
* @return int
*/
public function getStoredAmount(): int
{
return $this->storedAmount;
}
/**
* 주문 시점 재계산 금액 반환
*
* @return int
*/
public function getRecalculatedAmount(): int
{
return $this->recalculatedAmount;
}
/**
* 금액 차이 반환
*
* @return int
*/
public function getDifference(): int
{
return abs($this->storedAmount - $this->recalculatedAmount);
}
/**
* 로깅용 전체 데이터 반환
*
* @return array
*/
public function toArray(): array
{
return [
'stored_amount' => $this->storedAmount,
'recalculated_amount' => $this->recalculatedAmount,
'difference' => $this->getDifference(),
];
}
}
@@ -0,0 +1,86 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
/**
* 결제 금액 불일치 예외
*
* 프론트엔드 결제예정금액과 서버 재계산 금액이 불일치할 때 발생합니다.
*/
class PaymentAmountMismatchException extends Exception
{
/**
* @param float $expectedAmount 프론트엔드 결제예정금액
* @param float $actualAmount 서버 재계산 금액
* @param array $context 추가 컨텍스트 정보 (주문번호, 사용자ID 등)
*/
public function __construct(
private float $expectedAmount,
private float $actualAmount,
private array $context = []
) {
parent::__construct(
__('sirsoft-ecommerce::exceptions.payment_amount_mismatch', [
'expected' => number_format($expectedAmount),
'actual' => number_format($actualAmount),
])
);
}
/**
* 프론트엔드 결제예정금액 반환
*
* @return float
*/
public function getExpectedAmount(): float
{
return $this->expectedAmount;
}
/**
* 서버 재계산 금액 반환
*
* @return float
*/
public function getActualAmount(): float
{
return $this->actualAmount;
}
/**
* 금액 차이 반환
*
* @return float
*/
public function getDifference(): float
{
return abs($this->expectedAmount - $this->actualAmount);
}
/**
* 컨텍스트 정보 반환
*
* @return array
*/
public function getContext(): array
{
return $this->context;
}
/**
* 로깅용 전체 데이터 반환
*
* @return array
*/
public function toArray(): array
{
return [
'expected_amount' => $this->expectedAmount,
'actual_amount' => $this->actualAmount,
'difference' => $this->getDifference(),
'context' => $this->context,
];
}
}
@@ -0,0 +1,30 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
use Modules\Sirsoft\Ecommerce\Enums\SequenceType;
/**
* 시퀀스 코드 중복 예외
*
* 이미 발급된 코드를 재발급하려고 할 때 발생합니다.
*/
class SequenceCodeDuplicateException extends Exception
{
/**
* 시퀀스 코드 중복 예외 생성
*
* @param SequenceType $type 시퀀스 타입
* @param string $code 중복된 코드
*/
public function __construct(SequenceType $type, string $code)
{
parent::__construct(
__('sirsoft-ecommerce::exceptions.sequence_code_duplicate', [
'type' => $type->value,
'code' => $code,
])
);
}
}
@@ -0,0 +1,24 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
use Modules\Sirsoft\Ecommerce\Enums\SequenceType;
/**
* 시퀀스를 찾을 수 없을 때 발생하는 예외
*/
class SequenceNotFoundException extends Exception
{
/**
* 생성자
*
* @param SequenceType $type 시퀀스 타입
*/
public function __construct(SequenceType $type)
{
parent::__construct(
__('sirsoft-ecommerce::exceptions.sequence_not_found', ['type' => $type->value])
);
}
}
@@ -0,0 +1,28 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
use Modules\Sirsoft\Ecommerce\Enums\SequenceType;
/**
* 시퀀스가 최대값에 도달했을 때 발생하는 예외
*/
class SequenceOverflowException extends Exception
{
/**
* 생성자
*
* @param SequenceType $type 시퀀스 타입
* @param int $maxValue 최대값
*/
public function __construct(SequenceType $type, int $maxValue)
{
parent::__construct(
__('sirsoft-ecommerce::exceptions.sequence_overflow', [
'type' => $type->value,
'max_value' => $maxValue,
])
);
}
}
@@ -0,0 +1,62 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
/**
* 재고 불일치 예외
*
* 실제 재고와 입력된 재고가 일치하지 않을 때 발생합니다.
*/
class StockMismatchException extends Exception
{
/**
* @param int $productId 상품 ID
* @param int $expectedStock 예상 재고
* @param int $actualStock 실제 재고
*/
public function __construct(
private int $productId,
private int $expectedStock,
private int $actualStock
) {
parent::__construct(
__('sirsoft-ecommerce::exceptions.stock_mismatch', [
'product_id' => $productId,
'expected' => $expectedStock,
'actual' => $actualStock,
])
);
}
/**
* 상품 ID를 반환합니다.
*
* @return int
*/
public function getProductId(): int
{
return $this->productId;
}
/**
* 예상 재고를 반환합니다.
*
* @return int
*/
public function getExpectedStock(): int
{
return $this->expectedStock;
}
/**
* 실제 재고를 반환합니다.
*
* @return int
*/
public function getActualStock(): int
{
return $this->actualStock;
}
}
@@ -0,0 +1,36 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Exceptions;
use Exception;
/**
* 프리셋 접근 권한 없음 예외
*
* 사용자가 본인 소유가 아닌 프리셋에 접근하려 할 때 발생합니다.
*/
class UnauthorizedPresetAccessException extends Exception
{
/**
* @param int $presetId 프리셋 ID
*/
public function __construct(
private int $presetId
) {
parent::__construct(
__('sirsoft-ecommerce::exceptions.unauthorized_preset_access', [
'preset_id' => $presetId,
])
);
}
/**
* 프리셋 ID를 반환합니다.
*
* @return int
*/
public function getPresetId(): int
{
return $this->presetId;
}
}