targetType === 'product_amount'; } /** * 주문금액 할인 쿠폰인지 확인합니다. */ public function isOrderCoupon(): bool { return $this->targetType === 'order_amount'; } /** * 배송비 할인 쿠폰인지 확인합니다. */ public function isShippingCoupon(): bool { return $this->targetType === 'shipping_fee'; } /** * 정액 할인인지 확인합니다. */ public function isFixedDiscount(): bool { return $this->discountType === 'fixed'; } /** * 정률 할인인지 확인합니다. */ public function isRateDiscount(): bool { return $this->discountType === 'rate'; } /** * 중복 불가 쿠폰인지 확인합니다. */ public function isExclusiveCoupon(): bool { return $this->isExclusive; } /** * 배열로 변환합니다. */ public function toArray(): array { return [ 'coupon_id' => $this->couponId, 'coupon_issue_id' => $this->couponIssueId, 'name' => $this->name, 'target_type' => $this->targetType, 'target_scope' => $this->targetScope, 'discount_type' => $this->discountType, 'discount_value' => $this->discountValue, 'total_discount' => $this->totalDiscount, 'total_discount_formatted' => $this->totalDiscountFormatted, 'applied_items' => $this->appliedItems, 'is_exclusive' => $this->isExclusive, 'min_order_amount' => $this->minOrderAmount, 'max_discount_amount' => $this->maxDiscountAmount, ]; } /** * 배열에서 DTO를 생성합니다. * * @param array $data 배열 데이터 */ public static function fromArray(array $data): self { return new self( couponId: $data['coupon_id'] ?? 0, couponIssueId: $data['coupon_issue_id'] ?? 0, name: $data['name'] ?? '', targetType: $data['target_type'] ?? '', targetScope: $data['target_scope'] ?? null, discountType: $data['discount_type'] ?? '', discountValue: $data['discount_value'] ?? 0, totalDiscount: $data['total_discount'] ?? 0, totalDiscountFormatted: $data['total_discount_formatted'] ?? '', appliedItems: $data['applied_items'] ?? null, isExclusive: $data['is_exclusive'] ?? false, minOrderAmount: $data['min_order_amount'] ?? 0, maxDiscountAmount: $data['max_discount_amount'] ?? 0, ); } }