rewardPointRepository = $rewardPointRepository; } public function handle() { $email = $this->argument('email'); if (!$email) { // 获取最后一个注册的客户 $customer = Customer::orderBy('id', 'desc')->first(); } else { $customer = Customer::where('email', $email)->first(); } if (!$customer) { $this->error('Customer not found!'); return 1; } $this->info("Testing registration points for customer: {$customer->name} ({$customer->email})"); $this->info("Customer ID: {$customer->id}"); // 检查是否有注册规则 $registrationRule = RewardActiveRule::where('type_of_transaction', RewardActiveRule::TYPE_REGISTRATION) ->where('status', 1) ->first(); if ($registrationRule) { $this->info("Found registration rule:"); $this->table( ['ID', 'Name', 'Points', 'Status'], [[ $registrationRule->id, $registrationRule->name, $registrationRule->reward_point, $registrationRule->status ? 'Active' : 'Inactive' ]] ); } else { $this->warn("No active registration rule found. Using config value."); $pointsFromConfig = config('rewardpoints.registration.points_per_registration', 100); $this->info("Points from config: {$pointsFromConfig}"); } // 手动触发注册积分 $this->info("\nManually adding registration points..."); try { $event = new \stdClass(); $event->id = $customer->id; $listener = new \Longyi\RewardPoints\Listeners\CustomerEvents($this->rewardPointRepository); $listener->handleCustomerRegistration($customer); $this->info("✓ Points added successfully!"); // 显示当前积分 $currentPoints = $this->rewardPointRepository->getCustomerPoints($customer->id); $this->info("Current points balance: {$currentPoints}"); } catch (\Exception $e) { $this->error("Error: " . $e->getMessage()); $this->error($e->getTraceAsString()); return 1; } return 0; } }