|
|
@@ -8,6 +8,7 @@ use App\Http\helper\NumConfig;
|
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
+use App\Services\VipService;
|
|
|
|
|
|
/**
|
|
|
* Superball Activity: recharge + turnover task, balls, lucky number, prize pool.
|
|
|
@@ -35,6 +36,10 @@ class SuperballActivityService
|
|
|
$userTask = $this->getUserTask($userId, $today);
|
|
|
$multiplierRow = $this->getUserMultiplier($userId);
|
|
|
|
|
|
+ // VIP 等级与每日免费球数(赠送球数 = VIP 等级)
|
|
|
+ $vipLevel = $this->getUserVipLevel($userId);
|
|
|
+ $vipFreeBalls = $vipLevel > 0 ? $vipLevel : 0;
|
|
|
+
|
|
|
$rechargeToday = $this->getUserRechargeForDate($userId, $today);
|
|
|
$turnoverToday = $this->getUserTotalBetForDate($userId, $today);
|
|
|
$turnoverProgress = (int) $turnoverToday;
|
|
|
@@ -99,7 +104,7 @@ class SuperballActivityService
|
|
|
|
|
|
$last7Lucky = $this->getLast7DaysLuckyNumbersPrivate();
|
|
|
|
|
|
- return [
|
|
|
+ $data = [
|
|
|
'yesterday' => [
|
|
|
'pool_amount' => (int) $yesterdayDaily->pool_amount,
|
|
|
'pool_amount_display' => (int) $yesterdayDaily->pool_amount / NumConfig::NUM_VALUE,
|
|
|
@@ -149,9 +154,32 @@ class SuperballActivityService
|
|
|
'max' => self::MULTIPLIER_MAX,
|
|
|
'step' => self::MULTIPLIER_STEP,
|
|
|
],
|
|
|
+ 'vip' => [
|
|
|
+ 'level' => $vipLevel,
|
|
|
+ 'daily_free_balls' => $vipFreeBalls,
|
|
|
+ ],
|
|
|
'lucky_reward_per_ball' => self::LUCKY_REWARD_PER_BALL,
|
|
|
'lucky_numbers_7_days' => $last7Lucky,
|
|
|
];
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户 VIP 等级(用于每日赠送球数计算)
|
|
|
+ */
|
|
|
+ protected function getUserVipLevel(int $userId): int
|
|
|
+ {
|
|
|
+ if ($userId <= 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从 YN_VIPAccount 读取累计充值金额,交由 VipService 计算 VIP 等级
|
|
|
+ $userRecharge = (int) DB::table('QPAccountsDB.dbo.YN_VIPAccount')
|
|
|
+ ->where('UserID', $userId)
|
|
|
+ ->value('Recharge');
|
|
|
+
|
|
|
+ return (int) VipService::calculateVipLevel($userId, $userRecharge);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -250,7 +278,11 @@ class SuperballActivityService
|
|
|
return ['success' => false, 'message' => ['web.superball.task_not_completed', 'Task not completed']];
|
|
|
}
|
|
|
|
|
|
- $ballCount = (int) $tierConfig->ball_count;
|
|
|
+ // 基础任务球数 + 每日 VIP 免费球数(赠送球 = VIP 等级)
|
|
|
+ $baseBallCount = (int) $tierConfig->ball_count;
|
|
|
+ $vipLevel = $this->getUserVipLevel($userId);
|
|
|
+ $vipFreeBalls = $vipLevel > 0 ? $vipLevel : 0;
|
|
|
+ $ballCount = $baseBallCount + $vipFreeBalls;
|
|
|
|
|
|
DB::connection('write')->transaction(function () use ($userId, $today, $task, $ballCount) {
|
|
|
DB::connection('write')->table(TableName::agent() . 'superball_user_task')
|
|
|
@@ -277,6 +309,8 @@ class SuperballActivityService
|
|
|
|
|
|
return [
|
|
|
'ball_count' => $ballCount,
|
|
|
+ 'base_ball_count' => $baseBallCount,
|
|
|
+ 'vip_free_balls' => $vipFreeBalls,
|
|
|
'message' => 'Claim success, please select numbers for your balls',
|
|
|
];
|
|
|
}
|
|
|
@@ -297,7 +331,11 @@ class SuperballActivityService
|
|
|
if (!$tierConfig) {
|
|
|
return ['success' => false, 'message' => ['web.superball.activity_not_found', 'Activity not found']];
|
|
|
}
|
|
|
- $ballCount = (int) $tierConfig->ball_count;
|
|
|
+ // 与领取时保持一致:基础任务球数 + 每日 VIP 免费球数
|
|
|
+ $baseBallCount = (int) $tierConfig->ball_count;
|
|
|
+ $vipLevel = $this->getUserVipLevel($userId);
|
|
|
+ $vipFreeBalls = $vipLevel > 0 ? $vipLevel : 0;
|
|
|
+ $ballCount = $baseBallCount + $vipFreeBalls;
|
|
|
if (count($numbers) !== $ballCount) {
|
|
|
return ['success' => false, 'message' => ['web.superball.number_count_mismatch', 'Number count mismatch']];
|
|
|
}
|