Просмотр исходного кода

Merge branch 'dev-rewardPoints' into dev

bianjunhui 1 неделя назад
Родитель
Сommit
185e36cd90

+ 24 - 0
packages/Longyi/RewardPoints/src/Config/TransactionType.php

@@ -75,6 +75,16 @@ class TransactionType
      */
     const ORDER_CANCEL_REFUND = 12;
 
+    /**
+     * 浏览产品
+     */
+    const BROWSE_PRODUCT = 13;
+
+    /**
+     * 关注
+     */
+    const FOLLOW = 14;
+
     /**
      * 获取所有类型配置
      *
@@ -174,6 +184,20 @@ class TransactionType
                 'icon' => 'icon-undo',
                 'color' => 'cyan',
             ],
+            self::BROWSE_PRODUCT => [
+                'code' => 'browse_product',
+                'name' => '浏览产品',
+                'description' => '浏览产品赠送积分',
+                'icon' => 'icon-eye',
+                'color' => 'blue',
+            ],
+            self::FOLLOW => [
+                'code' => 'follow',
+                'name' => '关注',
+                'description' => '关注赠送积分',
+                'icon' => 'icon-heart',
+                'color' => 'red',
+            ],
         ];
     }
 

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

@@ -200,12 +200,12 @@ class RewardPointsController extends Controller
         // Get pagination parameters
         $page = $request->input('page', 1);
         $limit = $request->input('per_page', 20);
-
+        $amountType= $request->input('amountType');
         // Validate limit
         $limit = min(max($limit, 1), 100); // Limit between 1 and 100
 
         // Get paginated history
-        $history = $this->rewardPointRepository->getHistory($customer->id, $limit,$page);
+        $history = $this->rewardPointRepository->getHistory($customer->id, $limit,$page,$amountType);
 
         // Transform history data
         $transformedHistory = collect($history->items())->map(function ($item) {

+ 7 - 2
packages/Longyi/RewardPoints/src/Repositories/RewardPointRepository.php

@@ -267,7 +267,7 @@ class RewardPointRepository extends Repository
             throw $e;
         }
     }
-    public function getHistory($customerId, $limit = 20, $page = null)
+    public function getHistory($customerId, $limit = 20, $page = null,$amountType = '')
     {
         $query = $this->where('customer_id', $customerId)
             ->orderBy('transaction_time', 'desc');
@@ -275,7 +275,12 @@ class RewardPointRepository extends Repository
         if ($page) {
             return $query->paginate($limit, ['*'], 'page', $page);
         }
-
+// 根据视图类型筛选(仅获取或全部)
+       if ($amountType === 'earned') {
+            $query->where('amount', '>', 0)->where('status',1);
+        } elseif ($amountType === 'redeemed') {
+            $query->where('amount', '<', 0);
+        }
         return $query->paginate($limit);
     }