Przeglądaj źródła

积分接口BUG修复 修改订单支付积分状态

bianjunhui 1 tydzień temu
rodzic
commit
7c57980f3a

+ 3 - 3
packages/Longyi/RewardPoints/src/Http/Controllers/Admin/RuleController.php

@@ -20,10 +20,10 @@ class RuleController extends Controller
      * Transaction type mapping with complete configuration
      */
     private const TRANSACTION_TYPES = [
-        1 => ['name' => 'Order', 'icon' => 'icon-shopping-cart', 'color' => 'blue'],
+        3 => ['name' => 'Order', 'icon' => 'icon-shopping-cart', 'color' => 'blue'],
         2 => ['name' => 'Registration', 'icon' => 'icon-user', 'color' => 'green'],
-        3 => ['name' => 'Product Review', 'icon' => 'icon-star', 'color' => 'yellow'],
-        4 => ['name' => 'Login', 'icon' => 'icon-calendar', 'color' => 'purple'],
+        4 => ['name' => 'Product Review', 'icon' => 'icon-star', 'color' => 'yellow'],
+        9 => ['name' => 'Login', 'icon' => 'icon-calendar', 'color' => 'purple'],
         5 => ['name' => 'Referral', 'icon' => 'icon-share', 'color' => 'indigo'],
         6 => ['name' => 'Birthday', 'icon' => 'icon-gift', 'color' => 'pink'],
         7 => ['name' => 'Share', 'icon' => 'icon-share-alt', 'color' => 'orange'],

+ 5 - 4
packages/Longyi/RewardPoints/src/Http/Controllers/Admin/TransactionController.php

@@ -159,14 +159,15 @@ class TransactionController extends Controller
             ]);
 
             $typeNames = [
-                1 => 'Order',
+                3 => 'Order',
                 2 => 'Registration',
-                3 => 'Product Review',
-                4 => 'Daily Sign In',
+                4 => 'Product Review',
+                1 => 'Daily Sign In',
                 5 => 'Referral',
                 6 => 'Birthday',
+                7 => 'Share',
                 8 => 'Subscribe',
-                0 => 'Admin Adjustment',
+                9 => 'login',
                 99 => 'Admin Action'
             ];
 

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

@@ -2,6 +2,7 @@
 
 namespace Longyi\RewardPoints\Http\Controllers;
 
+use Illuminate\Support\Facades\Log;
 use Longyi\RewardPoints\Models\RewardActiveRule;
 use Longyi\RewardPoints\Repositories\RewardPointRepository;
 use Longyi\RewardPoints\Repositories\RewardPointSettingRepository;
@@ -10,7 +11,7 @@ use Longyi\RewardPoints\Helpers\ApiResponse;
 use Carbon\Carbon;
 use Illuminate\Http\Request;
 use Illuminate\Routing\Controller;
-
+use Longyi\RewardPoints\Models\RewardPointHistory;
 class RewardPointsController extends Controller
 {
     protected $rewardPointRepository;
@@ -141,7 +142,7 @@ class RewardPointsController extends Controller
         if (!$customer) {
             return ApiResponse::unauthorized();
         }
-
+        Log::info('Customer login event triggered');
         $today = Carbon::now()->format('Y-m-d');
         $signedToday = RewardPointCustomerSign::where('customer_id', $customer->id)
             ->where('sign_date', $today)
@@ -150,7 +151,8 @@ class RewardPointsController extends Controller
         $lastSign = RewardPointCustomerSign::where('customer_id', $customer->id)
             ->orderBy('sign_date', 'desc')
             ->first();
-
+        /*$currentGroup = 'sign_in';
+        $settings = $this->settingRepository->getSettingsByGroup($currentGroup);*/
         return ApiResponse::success([
             'signed_today' => $signedToday,
             'current_streak' => $lastSign ? $lastSign->count_date : 0,
@@ -242,14 +244,12 @@ class RewardPointsController extends Controller
         $currentStreak = $lastSign ? $lastSign->count_date : 0;
 
         // Get total earned points (all time)
-        $totalEarned = $this->model
-            ->where('customer_id', $customer->id)
+        $totalEarned = RewardPointHistory::where('customer_id', $customer->id)
             ->where('amount', '>', 0)
             ->sum('amount');
 
         // Get total used points (all time)
-        $totalUsed = $this->model
-                ->where('customer_id', $customer->id)
+        $totalUsed = RewardPointHistory::where('customer_id', $customer->id)
                 ->where('amount', '<', 0)
                 ->sum('amount') * -1;
 
@@ -343,10 +343,10 @@ class RewardPointsController extends Controller
     protected function getStatusText($status)
     {
         $statuses = [
-            0 => 'Completed',
-            1 => 'Pending',
-            2 => 'Expired',
-            3 => 'Cancelled'
+            1 => 'Completed',
+            0 => 'Pending',
+            3 => 'Expired',
+            2 => 'Cancelled'
         ];
 
         return $statuses[$status] ?? 'Unknown';

+ 91 - 4
packages/Longyi/RewardPoints/src/Listeners/CustomerEvents.php

@@ -2,11 +2,12 @@
 
 namespace Longyi\RewardPoints\Listeners;
 
+use Longyi\RewardPoints\Models\RewardPointHistory;
 use Longyi\RewardPoints\Repositories\RewardPointRepository;
 use Longyi\RewardPoints\Models\RewardActiveRule;
 use Webkul\Customer\Models\Customer;
 use Illuminate\Support\Facades\Log;
-
+use Illuminate\Support\Facades\Cache;
 class CustomerEvents
 {
     protected $rewardPointRepository;
@@ -18,7 +19,7 @@ class CustomerEvents
 
     public function handleCustomerRegistration($event)
     {
-        Log::info('Points added for customer registration');
+
         // 检查事件参数类型
         if (is_object($event) && method_exists($event, 'getAttribute')) {
             $customer = $event;
@@ -96,13 +97,99 @@ class CustomerEvents
         if (!empty($pointsList)) {
             $histories = $this->rewardPointRepository->addPointsBatch($customer->id, $pointsList);
 
-            Log::info('Points added for customer registration', [
+            /*Log::info('Points added for customer registration', [
                 'customer_id' => $customer->id,
                 'points_count' => count($pointsList),
                 'points_breakdown' => array_column($pointsList, 'amount'),
                 'total_points' => array_sum(array_column($pointsList, 'amount'))
-            ]);
+            ]);*/
+        }
+    }
+
+    /**
+     * 处理客户登录事件,赠送登录积分
+     */
+    public function handleCustomerLogin($event)
+    {
+        // 检查事件参数类型
+        if (is_object($event) && method_exists($event, 'getAttribute')) {
+            $customer = $event;
+        } elseif (is_array($event) && isset($event['customer'])) {
+            $customer = $event['customer'];
+        } elseif (is_array($event) && isset($event['id'])) {
+            $customer = Customer::find($event['id']);
+        } elseif (is_int($event) || is_string($event)) {
+            $customer = Customer::find($event);
+        } else {
+            $customer = $event;
+        }
+
+        if (!$customer) {
+            Log::warning('Customer not found in login event');
+            return;
+        }
+
+        Log::info('Customer identified', [
+            'customer_id' => $customer->id,
+            'customer_email' => $customer->email ?? 'N/A'
+        ]);
+
+        // 检查今天是否已经获得过登录积分(使用 Redis/Cache 标记)
+        $today = \Carbon\Carbon::now()->format('Y-m-d');
+        $cacheKey = "reward_points:login_received:{$customer->id}:{$today}";
+
+        // 尝试从缓存获取标记
+        $alreadyReceivedToday = Cache::has($cacheKey);
+        // 尝试从数据库获取登陆状态
+        if(empty($alreadyReceivedToday)){
+            $alreadyReceivedToday = RewardPointHistory::where('customer_id', $customer->id)
+                ->where('type_of_transaction', RewardActiveRule::TYPE_LOGIN)
+                ->whereDate('transaction_time', $today)
+                ->where('status', RewardPointHistory::STATUS_COMPLETED)
+                ->exists();
         }
+
+        if ($alreadyReceivedToday) {
+            /*Log::info('Customer already received login points today (from cache), skipping', [
+                'customer_id' => $customer->id,
+                'date' => $today,
+                'cache_store' => config('cache.default')
+            ]);*/
+            return;
+        }
+
+
+        // 查询登录规则
+        $loginRule = RewardActiveRule::where('type_of_transaction', RewardActiveRule::TYPE_LOGIN)
+            ->where('status', 1)
+            ->first();
+
+        if (!$loginRule) {
+            Log::info('No active login rule found, skipping login points');
+            return;
+        }
+
+        // 获取登录积分
+        $loginPoints = (int) $loginRule->reward_point;
+        if ($loginPoints <= 0) {
+            Log::info('Login points is 0 or negative, skipping login points');
+            return;
+        }
+
+        // 添加登录积分
+        $history = $this->rewardPointRepository->addPoints(
+            $customer->id,
+            RewardActiveRule::TYPE_LOGIN,
+            $loginPoints,
+            null,
+            'Login bonus'
+        );
+
+        /*Log::info('Login points added successfully', [
+            'customer_id' => $customer->id,
+            'points' => $loginPoints,
+            'history_id' => $history->history_id ?? null
+        ]);*/
     }
 
     /**

+ 58 - 14
packages/Longyi/RewardPoints/src/Listeners/OrderEvents.php

@@ -36,13 +36,21 @@ class OrderEvents
         $points = $this->calculateOrderPoints($order, $rule);
 
         if ($points > 0) {
+            // 支付订单后,积分状态为 PENDING(待确认),不计入用户总积分
             $this->rewardPointRepository->addPoints(
                 $order->customer_id,
                 RewardActiveRule::TYPE_ORDER,
                 $points,
                 $order->id,
-                "Points earned from order #{$order->increment_id}"
+                "Points earned from order #{$order->increment_id} (Pending)",
+                $rule
             );
+
+            Log::info('Order points added as PENDING (not counted in balance yet)', [
+                'order_id' => $order->id,
+                'customer_id' => $order->customer_id,
+                'points' => $points
+            ]);
         }
     }
 
@@ -53,11 +61,14 @@ class OrderEvents
         }
 
         \DB::transaction(function () use ($order) {
+            // 查找该订单相关的所有积分记录(包括 PENDING 和 COMPLETED)
             $histories = $this->rewardPointRepository->findWhere([
                 'customer_id' => $order->customer_id,
                 'history_order_id' => $order->id,
-                'type_of_transaction' => RewardActiveRule::TYPE_ORDER,
-                'status' => RewardPointHistory::STATUS_COMPLETED
+                'type_of_transaction' => RewardActiveRule::TYPE_ORDER
+            ])->whereIn('status', [
+                RewardPointHistory::STATUS_PENDING,
+                RewardPointHistory::STATUS_COMPLETED
             ])->get();
 
             if ($histories->isEmpty()) {
@@ -66,18 +77,35 @@ class OrderEvents
 
             foreach ($histories as $history) {
                 if ($history->amount > 0 && $history->point_remaining > 0) {
-                    $result = $this->rewardPointRepository->deductPoints(
-                        $order->customer_id,
-                        $history->point_remaining,
-                        $order->id,
-                        "Points deducted due to order cancellation #{$order->increment_id}"
-                    );
-
-                    if ($result) {
-                        $history->status = RewardPointHistory::STATUS_CANCELLED;
-                        $history->point_remaining = 0;
-                        $history->save();
+                    // 只有 COMPLETED 状态的积分需要从用户余额中扣减
+                    if ($history->status === RewardPointHistory::STATUS_COMPLETED) {
+                        $result = $this->rewardPointRepository->deductPoints(
+                            $order->customer_id,
+                            $history->point_remaining,
+                            $order->id,
+                            "Points deducted due to order cancellation #{$order->increment_id}"
+                        );
+
+                        if ($result) {
+                            Log::info('Completed points deducted on cancellation', [
+                                'history_id' => $history->history_id,
+                                'order_id' => $order->id,
+                                'points_deducted' => $history->point_remaining
+                            ]);
+                        }
+                    } else {
+                        // PENDING 状态的积分只需更新状态,不需要扣减(因为从未计入余额)
+                        Log::info('Pending points cancelled (no deduction needed)', [
+                            'history_id' => $history->history_id,
+                            'order_id' => $order->id,
+                            'points' => $history->point_remaining
+                        ]);
                     }
+
+                    // 更新历史记录状态
+                    $history->status = RewardPointHistory::STATUS_CANCELLED;
+                    $history->point_remaining = 0;
+                    $history->save();
                 }
             }
         });
@@ -93,6 +121,21 @@ class OrderEvents
             return;
         }
 
+        // 将该订单的 PENDING 积分确认为 COMPLETED,并计入用户总积分
+        $confirmedPoints = $this->rewardPointRepository->confirmPendingPoints(
+            $order->customer_id,
+            $order->id
+        );
+
+       /* if ($confirmedPoints > 0) {
+            Log::info('Order completed, pending points confirmed', [
+                'order_id' => $order->id,
+                'customer_id' => $order->customer_id,
+                'confirmed_points' => $confirmedPoints
+            ]);
+        }*/
+
+        // 处理成长值
         $this->growthValueService->handleOrderCompleted($order);
     }
 
@@ -101,5 +144,6 @@ class OrderEvents
         $pointsPerCurrency = 10;
         return floor($order->grand_total * $pointsPerCurrency);
     }
+
 }
 

+ 3 - 0
packages/Longyi/RewardPoints/src/Providers/EventServiceProvider.php

@@ -10,6 +10,9 @@ class EventServiceProvider extends ServiceProvider
         'customer.registration.after' => [
             'Longyi\RewardPoints\Listeners\CustomerEvents@handleCustomerRegistration'
         ],
+        'customer.after.login' => [
+            'Longyi\RewardPoints\Listeners\CustomerEvents@handleCustomerLogin'
+        ],
         'checkout.order.save.after' => [
             'Longyi\RewardPoints\Listeners\OrderEvents@handleOrderPlacement'
         ],

+ 102 - 33
packages/Longyi/RewardPoints/src/Repositories/RewardPointRepository.php

@@ -46,38 +46,40 @@ class RewardPointRepository extends Repository
                         'last_checkout' => Carbon::now()
                     ]
                 );
-                
-                // 2. 使用 increment 方法增加积分
-                $customerPoints->increment('mw_reward_point', $amount);
-                
+
+                // 2. 确定积分状态
+                // 订单类型的积分初始状态为 PENDING,其他类型直接 COMPLETED
+                $status = ($type === RewardActiveRule::TYPE_ORDER)
+                    ? RewardPointHistory::STATUS_PENDING
+                    : RewardPointHistory::STATUS_COMPLETED;
+
+                // 3. 只有 COMPLETED 状态的积分才计入用户总积分
+                if ($status === RewardPointHistory::STATUS_COMPLETED) {
+                    $customerPoints->increment('mw_reward_point', $amount);
+                }
+
                 // 3. 更新最后检查时间
                 $customerPoints->last_checkout = Carbon::now();
                 $customerPoints->save();
-                
+
                 // 4. 重新查询获取最新的余额
                 $customerPoints = RewardPointCustomer::where('customer_id', $customerId)->first();
                 $newBalance = $customerPoints ? (int) $customerPoints->mw_reward_point : $amount;
 
-                Log::info('Points added', [
+               /* Log::info('Points added', [
                     'customer_id' => $customerId,
                     'type' => $type,
                     'amount' => $amount,
                     'new_balance' => $newBalance
-                ]);
+                ]);*/
 
                 // 5. 获取过期信息(如果没有传入规则,则查询)
-                $expiredDay = 0;
-                $expiredTime = null;
-                
+
                 if ($rule) {
                     $expiredDay = $rule->expired_day ?? 0;
                     $expiredTime = $expiredDay > 0 ? Carbon::now()->addDays($expiredDay) : null;
                 } else {
-                    // 兼容旧代码,如果没有传入规则则查询
-                    $rule = RewardActiveRule::where('type_of_transaction', $type)
-                        ->where('status', 1)
-                        ->first();
-                    $expiredDay = $rule ? $rule->expired_day : 0;
+                    $expiredDay = 365;
                     $expiredTime = $expiredDay > 0 ? Carbon::now()->addDays($expiredDay) : null;
                 }
 
@@ -94,7 +96,7 @@ class RewardPointRepository extends Repository
                     'expired_time' => $expiredTime,
                     'point_remaining' => $amount,
                     'check_time' => 1,
-                    'status' => RewardPointHistory::STATUS_COMPLETED
+                    'status' => $status
                 ]);
 
                 return $history;
@@ -128,17 +130,17 @@ class RewardPointRepository extends Repository
                         'last_checkout' => Carbon::now()
                     ]
                 );
-                
+
                 // 确保 $customerPoints 存在
                 if (!$customerPoints) {
                     throw new \Exception('Failed to create or retrieve customer points record');
                 }
-                
+
                 // 2. 获取当前余额
                 $currentBalance = (int) $customerPoints->mw_reward_point;
                 $histories = [];
-                $totalAmount = 0;                                
-                
+                $totalAmount = 0;
+
                 // 3. 逐条创建历史记录(每条记录使用累加后的余额)
                 foreach ($pointsList as $index => $pointData) {
                     $amount = (int) $pointData['amount'];
@@ -146,22 +148,22 @@ class RewardPointRepository extends Repository
                     $detail = $pointData['detail'] ?? null;
                     $orderId = $pointData['order_id'] ?? null;
                     $rule = $pointData['rule'] ?? null;
-                    
+
                     // 累加总积分
                     $totalAmount += $amount;
-                    
+
                     // 计算当前这条记录后的余额(累加后的余额)
                     $newBalance = $currentBalance + $totalAmount;
-                    
+
                     // 获取过期信息
                     $expiredDay = 0;
                     $expiredTime = null;
-                    
+
                     if ($rule) {
                         $expiredDay = $rule->expired_day ?? 0;
                         $expiredTime = $expiredDay > 0 ? Carbon::now()->addDays($expiredDay) : null;
                     }
-                    
+
                     // 创建历史记录(每条记录独立)
                     $history = $this->create([
                         'customer_id' => $customerId,
@@ -177,11 +179,11 @@ class RewardPointRepository extends Repository
                         'check_time' => 1,
                         'status' => RewardPointHistory::STATUS_COMPLETED
                     ]);
-                    
+
                     $histories[] = $history;
-        
+
                 }
-                
+
                  // 4. 最后一次性更新用户总积分
                 $updated = DB::table('mw_reward_point_customer')
                         ->where('customer_id', $customerId)
@@ -189,7 +191,7 @@ class RewardPointRepository extends Repository
                             'mw_reward_point' => DB::raw('mw_reward_point + ' . (float)$totalAmount),
                             'last_checkout' => Carbon::now()
                         ]);
-                                              
+
                 return $histories;
             });
         } catch (\Exception $e) {
@@ -214,7 +216,7 @@ class RewardPointRepository extends Repository
                     Log::warning('Customer points record not found', ['customer_id' => $customerId]);
                     return false;
                 }
-                
+
                 if ($customerPoints->mw_reward_point < $amount) {
                     Log::warning('Insufficient points', [
                         'customer_id' => $customerId,
@@ -275,6 +277,8 @@ class RewardPointRepository extends Repository
 
     public function checkExpiredPoints()
     {
+        // 只检查已过期的、状态为 COMPLETED 的、还有剩余积分的记录
+        // PENDING 状态的积分不会过期(因为订单还未完成)
         $expiredHistories = $this->where('expired_time', '<', Carbon::now())
             ->where('status', RewardPointHistory::STATUS_COMPLETED)
             ->where('point_remaining', '>', 0)
@@ -294,11 +298,11 @@ class RewardPointRepository extends Repository
                         $history->status = RewardPointHistory::STATUS_EXPIRED;
                         $history->point_remaining = 0;
                         $history->save();
-                        
+
                         Log::info('Expired points processed', [
                             'history_id' => $history->history_id,
                             'customer_id' => $history->customer_id,
-                            'points' => $history->point_remaining
+                            'points_expired' => $history->getOriginal('point_remaining')
                         ]);
                     }
                 });
@@ -310,4 +314,69 @@ class RewardPointRepository extends Repository
             }
         }
     }
-}
+
+    /**
+     * 确认待处理的积分(将 PENDING 状态改为 COMPLETED 并计入用户余额)
+     */
+    public function confirmPendingPoints($customerId, $orderId)
+    {
+        try {
+            return DB::transaction(function () use ($customerId, $orderId) {
+                // 查找所有 PENDING 状态的订单积分记录
+                $pendingHistories = $this->where('customer_id', $customerId)
+                    ->where('history_order_id', $orderId)
+                    ->where('type_of_transaction', RewardActiveRule::TYPE_ORDER)
+                    ->where('status', RewardPointHistory::STATUS_PENDING)
+                    ->get();
+
+                if ($pendingHistories->isEmpty()) {
+                    Log::info('No pending points to confirm', [
+                        'customer_id' => $customerId,
+                        'order_id' => $orderId
+                    ]);
+                    return 0;
+                }
+
+                $totalConfirmedPoints = 0;
+
+                foreach ($pendingHistories as $history) {
+                    // 增加用户总积分
+                    $customerPoints = RewardPointCustomer::where('customer_id', $customerId)
+                        ->lockForUpdate()
+                        ->first();
+
+                    if ($customerPoints) {
+                        $customerPoints->increment('mw_reward_point', $history->point_remaining);
+                        $customerPoints->save();
+
+                        // 更新历史记录状态
+                        $history->status = RewardPointHistory::STATUS_COMPLETED;
+                        $history->balance = (int) $customerPoints->mw_reward_point;
+                        $history->save();
+
+                        $totalConfirmedPoints += $history->point_remaining;
+
+                        Log::info('Pending points confirmed', [
+                            'history_id' => $history->history_id,
+                            'customer_id' => $customerId,
+                            'order_id' => $orderId,
+                            'points' => $history->point_remaining,
+                            'new_balance' => $customerPoints->mw_reward_point
+                        ]);
+                    }
+                }
+
+                return $totalConfirmedPoints;
+            });
+        } catch (\Exception $e) {
+            Log::error('Error confirming pending points', [
+                'customer_id' => $customerId,
+                'order_id' => $orderId,
+                'error' => $e->getMessage(),
+                'trace' => $e->getTraceAsString()
+            ]);
+            throw $e;
+        }
+    }
+
+}

+ 16 - 15
packages/Longyi/RewardPoints/src/Resources/views/admin/transactions/index.blade.php

@@ -103,14 +103,15 @@
                     class="flex w-full min-h-[39px] py-2 px-3 border border-gray-300 dark:border-gray-800 rounded-md text-sm text-gray-600 dark:text-gray-300 transition-all hover:border-gray-400 dark:hover:border-gray-400 focus:border-gray-400 dark:focus:border-gray-400"
                 >
                     <option value="">@lang('All Types')</option>
-                    <option value="1" {{ $transactionType == '1' ? 'selected' : '' }}>@lang('Order')</option>
+                    <option value="3" {{ $transactionType == '3' ? 'selected' : '' }}>@lang('Order')</option>
                     <option value="2" {{ $transactionType == '2' ? 'selected' : '' }}>@lang('Registration')</option>
-                    <option value="3" {{ $transactionType == '3' ? 'selected' : '' }}>@lang('Product Review')</option>
-                    <option value="4" {{ $transactionType == '4' ? 'selected' : '' }}>@lang('Daily Sign In')</option>
+                    <option value="4" {{ $transactionType == '4' ? 'selected' : '' }}>@lang('Product Review')</option>
+                    <option value="1" {{ $transactionType == '1' ? 'selected' : '' }}>@lang('Daily Sign In')</option>
                     <option value="5" {{ $transactionType == '5' ? 'selected' : '' }}>@lang('Referral')</option>
                     <option value="6" {{ $transactionType == '6' ? 'selected' : '' }}>@lang('Birthday')</option>
+                    <option value="7" {{ $transactionType == '7' ? 'selected' : '' }}>@lang('Share')</option>
                     <option value="8" {{ $transactionType == '8' ? 'selected' : '' }}>@lang('Subscribe')</option>
-                    <option value="0" {{ $transactionType == '0' ? 'selected' : '' }}>@lang('Admin Adjustment')</option>
+                    <option value="9" {{ $transactionType == '9' ? 'selected' : '' }}>@lang('Login')</option>
                     <option value="99" {{ $transactionType == '99' ? 'selected' : '' }}>@lang('Admin Action')</option>
                 </select>
             </div>
@@ -259,17 +260,17 @@
                         <td class="px-6 py-4 whitespace-nowrap">
                             @php
                                 $typeNames = [
-                                    1 => 'rewardpoints::rewardpoints.admin.transaction-types.order',
-                                    2 => 'rewardpoints::rewardpoints.admin.transaction-types.registration',
-                                    3 => 'rewardpoints::rewardpoints.admin.transaction-types.review',
-                                    4 => 'rewardpoints::rewardpoints.admin.transaction-types.sign-in',
-                                    5 => 'rewardpoints::rewardpoints.admin.transaction-types.referral',
-                                    6 => 'rewardpoints::rewardpoints.admin.transaction-types.birthday',
-                                    7 => 'rewardpoints::rewardpoints.admin.transaction-types.share',
-                                    8 => 'rewardpoints::rewardpoints.admin.transaction-types.subscribe',
-                                    0 => 'rewardpoints::rewardpoints.admin.admin-adjustment',
-                                    99 => 'rewardpoints::rewardpoints.admin.admin-action',
-                                ];
+                                        3 => 'Order',
+                                        2 => 'Registration',
+                                        4 => 'Product Review',
+                                        1 => 'Daily Sign In',
+                                        5 => 'Referral',
+                                        6 => 'Birthday',
+                                        7 => 'Share',
+                                        8 => 'Subscribe',
+                                        9 => 'login',
+                                        99 => 'Admin Action'
+                                    ];
                             @endphp
                             <span class="px-2 py-1 inline-flex text-xs leading-5 font-semibold rounded-full
             @if($transaction->amount > 0)

+ 2 - 0
packages/Webkul/BagistoApi/src/State/LoginProcessor.php

@@ -60,6 +60,8 @@ class LoginProcessor implements ProcessorInterface
                         'deviceToken' => $deviceToken,
                     ]);
                 }
+                // Dispatch customer login event for reward points and other listeners
+                Event::dispatch('customer.after.login', $customer);
 
                 $token = $customer->createToken('customer-login')->plainTextToken;