소스 검색

fix: :bug: fix #901

Ferks-FK 1 년 전
부모
커밋
a471cb4021
2개의 변경된 파일9개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 3
      app/Http/Controllers/Admin/PaymentController.php
  2. 1 1
      app/Listeners/UserPayment.php

+ 8 - 3
app/Http/Controllers/Admin/PaymentController.php

@@ -143,14 +143,19 @@ class PaymentController extends Controller
             $subtotal = $shopProduct->price;
 
             // Apply Coupon
-            $isCouponValid = $this->isCouponValid($couponCode, $user, $shopProduct->id);
-            if ($isCouponValid) {
-                $subtotal = $this->applyCoupon($couponCode, $subtotal);
+            if ($couponCode) {
+                if ($this->isCouponValid($couponCode, $user, $shopProduct->id)) {
+                    $subtotal = $this->applyCoupon($couponCode, $subtotal);
+                }
             }
 
             // Apply Partner Discount
             $subtotal = $subtotal - ($subtotal * $discount / 100);
             if ($subtotal <= 0) {
+                if ($couponCode) {
+                    event(new CouponUsedEvent($couponCode));
+                }
+
                 return $this->handleFreeProduct($shopProduct);
             }
 

+ 1 - 1
app/Listeners/UserPayment.php

@@ -49,7 +49,7 @@ class UserPayment
         $shopProduct = $event->shopProduct;
 
         // only update user if payment is paid
-        if ($event->payment->status != PaymentStatus::PAID) {
+        if ($event->payment->status != PaymentStatus::PAID->value) {
             return;
         }