Jelajahi Sumber

积分历史记录分页

bianjunhui 1 Minggu lalu
induk
melakukan
ffe67bfb14

+ 1 - 1
packages/Longyi/RewardPoints/src/Http/Controllers/RewardPointsController.php

@@ -182,7 +182,7 @@ class RewardPointsController extends Controller
         $limit = min(max($limit, 1), 100); // Limit between 1 and 100
 
         // Get paginated history
-        $history = $this->rewardPointRepository->getHistory($customer->id, $limit);
+        $history = $this->rewardPointRepository->getHistory($customer->id, $limit,$page);
 
         // Transform history data
         $transformedHistory = collect($history->items())->map(function ($item) {

+ 1 - 1
packages/Longyi/RewardPoints/src/Listeners/OrderEvents.php

@@ -142,7 +142,7 @@ class OrderEvents
     protected function calculateOrderPoints($order, $rule)
     {
         $pointsPerCurrency = 10;
-        return floor($order->grand_total * $pointsPerCurrency);
+        return floor($order->base_grand_total * $pointsPerCurrency);
     }
 
 }

+ 9 - 5
packages/Longyi/RewardPoints/src/Repositories/RewardPointRepository.php

@@ -267,12 +267,16 @@ class RewardPointRepository extends Repository
             return false;
         }
     }
-
-    public function getHistory($customerId, $limit = 20)
+    public function getHistory($customerId, $limit = 20, $page = null)
     {
-        return $this->where('customer_id', $customerId)
-            ->orderBy('transaction_time', 'desc')
-            ->paginate($limit);
+        $query = $this->where('customer_id', $customerId)
+            ->orderBy('transaction_time', 'desc');
+
+        if ($page) {
+            return $query->paginate($limit, ['*'], 'page', $page);
+        }
+
+        return $query->paginate($limit);
     }
 
     public function checkExpiredPoints()