|
|
@@ -340,7 +340,12 @@ class PayRechargeController extends Controller
|
|
|
'claimed_days' => $claimedDays,
|
|
|
'progress' => $claimedDays . '/' . $bonusDay,
|
|
|
'status' => $dayRewardStatus, // 0=不可领取, 1=可领取, 2=已领取, 3=过期
|
|
|
- 'status_text' => ['不可领取', '可领取', '已领取', '过期'][$dayRewardStatus] ?? '未知'
|
|
|
+ 'status_text' => [
|
|
|
+ __('web.gift.status_cannot_claim'),
|
|
|
+ __('web.gift.status_can_claim'),
|
|
|
+ __('web.gift.status_claimed'),
|
|
|
+ __('web.gift.status_expired')
|
|
|
+ ][$dayRewardStatus] ?? __('web.gift.status_unknown')
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -405,7 +410,12 @@ class PayRechargeController extends Controller
|
|
|
'next_claim_bet' => max(0, $nextClaimBet), // 下次领取还需下注次数
|
|
|
'progress' => round($currentBetCount, 0) . '/' . round($claimedTimes * $perBet + $perBet, 0), // 当前进度/下次领取目标(次数)
|
|
|
'status' => $bettingBonusStatus, // 0=不可领取, 1=可领取, 2=已领取, 3=过期
|
|
|
- 'status_text' => ['不可领取', '可领取', '已领取', '过期'][$bettingBonusStatus] ?? '未知'
|
|
|
+ 'status_text' => [
|
|
|
+ __('web.gift.status_cannot_claim'),
|
|
|
+ __('web.gift.status_can_claim'),
|
|
|
+ __('web.gift.status_claimed'),
|
|
|
+ __('web.gift.status_expired')
|
|
|
+ ][$bettingBonusStatus] ?? __('web.gift.status_unknown')
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -439,7 +449,12 @@ class PayRechargeController extends Controller
|
|
|
'current_bet' => (float)$currentProgress, // 当前累计下注
|
|
|
'progress' => round($currentProgress, 2) . '/' . $requiredBet,
|
|
|
'status' => $bettingTaskStatus, // 0=不可领取, 1=可领取, 2=已领取, 3=过期
|
|
|
- 'status_text' => ['不可领取', '可领取', '已领取', '过期'][$bettingTaskStatus] ?? '未知'
|
|
|
+ 'status_text' => [
|
|
|
+ __('web.gift.status_cannot_claim'),
|
|
|
+ __('web.gift.status_can_claim'),
|
|
|
+ __('web.gift.status_claimed'),
|
|
|
+ __('web.gift.status_expired')
|
|
|
+ ][$bettingTaskStatus] ?? __('web.gift.status_unknown')
|
|
|
];
|
|
|
}
|
|
|
$giftInfo['expired'] = strtotime($giftRecord->created_at)+86400*7;
|
|
|
@@ -1106,6 +1121,471 @@ class PayRechargeController extends Controller
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 连续未充值 VIP 礼包(gift_id=305)—— 检查条件和返回档位
|
|
|
+ */
|
|
|
+ public function vipInactiveGift(Request $request)
|
|
|
+ {
|
|
|
+ $user = $request->user();
|
|
|
+ $this->setUserLocale($request);
|
|
|
+ $userId = $user->UserID;
|
|
|
+
|
|
|
+ // 1. VIP 判断:是否有过充值(YN_VIPAccount.Recharge > 0)
|
|
|
+ $userRecharge = DB::table(TableName::QPAccountsDB() . 'YN_VIPAccount')
|
|
|
+ ->where('UserID', $userId)
|
|
|
+ ->value('Recharge') ?: 0;
|
|
|
+
|
|
|
+ if ($userRecharge <= 0) {
|
|
|
+ // 不满足条件:不是 VIP 用户
|
|
|
+ return apiReturnSuc([
|
|
|
+ 'status' => 0,
|
|
|
+ 'message' => __('web.gift.vip_inactive_not_vip')
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 检查最近一次充值时间,计算连续未充值天数
|
|
|
+ $lastOrder = DB::table('agent.dbo.order')
|
|
|
+ ->where('user_id', $userId)
|
|
|
+ ->where('pay_status', 1)
|
|
|
+ ->where('GiftsID','<>', 305)
|
|
|
+ ->orderBy('pay_at', 'desc')
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if (!$lastOrder) {
|
|
|
+ return apiReturnSuc([
|
|
|
+ 'status' => 0,
|
|
|
+ 'message' => __('web.gift.vip_inactive_not_vip')
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $lastDate = date('Y-m-d', strtotime($lastOrder->pay_at));
|
|
|
+ $today = date('Y-m-d');
|
|
|
+ $diffDays = (strtotime($today) - strtotime($lastDate)) / 86400;
|
|
|
+ // 连续未充值天数:如果最后一次充值是昨天,则未充值天数为0;如果是前天,则为1;以此类推
|
|
|
+ // 需要 >= 3 天,即最后一次充值至少是3天前
|
|
|
+ $inactiveDays = max(0, (int)$diffDays - 1);
|
|
|
+
|
|
|
+ if ($inactiveDays < 3) {
|
|
|
+ // 不满足条件:连续未充值天数不足
|
|
|
+ return apiReturnSuc([
|
|
|
+ 'status' => 0,
|
|
|
+ 'message' => __('web.gift.vip_inactive_days_insufficient'),
|
|
|
+ 'inactive_days' => $inactiveDays
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 计算总充值与平均单笔(从 RecordUserTotalStatistics)
|
|
|
+ $stat = DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')
|
|
|
+ ->where('UserID', $userId)
|
|
|
+ ->select('Recharge', 'RechargeTimes')
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ $totalRecharge = (float)($stat->Recharge ?? 0) / NumConfig::NUM_VALUE; // 转换为元
|
|
|
+ $rechargeTimes = (int)($stat->RechargeTimes ?? 0);
|
|
|
+
|
|
|
+ if ($totalRecharge <= 0 || $rechargeTimes <= 0) {
|
|
|
+ return apiReturnSuc([
|
|
|
+ 'status' => 0,
|
|
|
+ 'message' => __('web.gift.vip_inactive_not_vip')
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $avgRecharge = $totalRecharge / $rechargeTimes;
|
|
|
+
|
|
|
+ // 4. 按规则选择礼包金额
|
|
|
+ $amount = null;
|
|
|
+ if ($totalRecharge < 50) {
|
|
|
+ $amount = $avgRecharge < 15 ? 9.99 : 19.99;
|
|
|
+ } else {
|
|
|
+ if ($avgRecharge < 15) {
|
|
|
+ $amount = 19.99;
|
|
|
+ } elseif ($avgRecharge >= 15 && $avgRecharge < 20) {
|
|
|
+ $amount = 29.99;
|
|
|
+ } else {
|
|
|
+ $amount = 39.99;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 检查是否已经买过 305 礼包
|
|
|
+ $hasBought = DB::table('agent.dbo.order')
|
|
|
+ ->where('user_id', $userId)
|
|
|
+ ->where('GiftsID', 305)
|
|
|
+ ->where('pay_status', 1)
|
|
|
+ ->exists();
|
|
|
+
|
|
|
+ // 6. 查询 7 日礼包记录状态
|
|
|
+ $record = DB::table('agent.dbo.inactive_vip_gift_records')
|
|
|
+ ->where('user_id', $userId)
|
|
|
+ ->where('gift_id', 305)
|
|
|
+ ->orderBy('id', 'desc')
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ /*
|
|
|
+ * status 定义:
|
|
|
+ * 0 不满足条件
|
|
|
+ * 1 满足条件未充值
|
|
|
+ * 2 满足条件已充值,奖励未全部领取
|
|
|
+ * 3 满足条件已充值,奖励全部领取
|
|
|
+ * 4 满足条件已充值,7天礼包已过期
|
|
|
+ */
|
|
|
+ $status = 1;
|
|
|
+ $timeLeft = 0; // 倒计时剩余秒数
|
|
|
+
|
|
|
+ if ($hasBought) {
|
|
|
+ if (!$record) {
|
|
|
+ $status = 2;
|
|
|
+ } else {
|
|
|
+ // 检查 7 天礼包是否已过期
|
|
|
+ if (strtotime($record->expired_at) < time()) {
|
|
|
+ $status = 4; // 7天礼包已过期
|
|
|
+ } else {
|
|
|
+ // 检查 7 天是否全部领完:claimed_days_mask 的低 7 位全部为 1
|
|
|
+ $allClaimedMask = (1 << 7) - 1; // 0b1111111
|
|
|
+ $status = (($record->claimed_days_mask & $allClaimedMask) == $allClaimedMask) ? 3 : 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 满足条件但未充值:检查24小时倒计时(每天重置)
|
|
|
+ $today = date('Y-m-d');
|
|
|
+ $timerKey = "vip_inactive_gift_timer_{$userId}_{$today}";
|
|
|
+ $timerData = Redis::get($timerKey);
|
|
|
+
|
|
|
+ if ($timerData) {
|
|
|
+ $timerData = json_decode($timerData, true);
|
|
|
+ $expireTime = $timerData['expire_time'] ?? 0;
|
|
|
+ $timeLeft = max(0, $expireTime - time());
|
|
|
+
|
|
|
+ if ($timeLeft <= 0) {
|
|
|
+ // 今天的倒计时已结束,不再显示礼包
|
|
|
+ $status = 0;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 今天首次检测到满足条件,初始化24小时倒计时
|
|
|
+ // 从当前时间开始,24小时后过期
|
|
|
+ $expireTime = time() + 86400; // 24小时后
|
|
|
+ $ttl = 86400 + 3600; // Redis过期时间设为25小时,确保跨天也能获取
|
|
|
+
|
|
|
+ Redis::setex($timerKey, $ttl, json_encode([
|
|
|
+ 'expire_time' => $expireTime,
|
|
|
+ 'created_at' => time(),
|
|
|
+ 'date' => $today
|
|
|
+ ]));
|
|
|
+ $timeLeft = 86400;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $payload = [
|
|
|
+ 'status' => $status,
|
|
|
+ 'inactive_days' => $inactiveDays,
|
|
|
+// 'total_recharge' => $totalRecharge,
|
|
|
+// 'avg_recharge' => round($avgRecharge, 2),
|
|
|
+ 'time_left' => $timeLeft,
|
|
|
+ 'expire_at' => $timeLeft > 0 ? (time() + $timeLeft) : null,
|
|
|
+ 'message' => $status == 1 ? __('web.gift.vip_inactive_can_recharge') :
|
|
|
+ ($status == 2 ? __('web.gift.vip_inactive_claimed_partial') :
|
|
|
+ ($status == 3 ? __('web.gift.vip_inactive_claimed_all') :
|
|
|
+ __('web.gift.vip_inactive_seven_days_expired')))
|
|
|
+ ];
|
|
|
+
|
|
|
+ // status=1 时返回充值档位信息(参考 bankruptcyGift),gift_id 固定 305,加总奖励百分比
|
|
|
+ if ($status == 1 && $amount !== null) {
|
|
|
+ $sevenPercent = 140 + max(0, $inactiveDays - 3) * 10;
|
|
|
+ $sevenPercent = min($sevenPercent, 200);
|
|
|
+ $totalRewardPercent = 120 + $sevenPercent; // 120% 立即 + 7日礼包%
|
|
|
+
|
|
|
+ $gear = DB::table('agent.dbo.recharge_gear')
|
|
|
+ ->select('money', 'favorable_price', 'gear', 'give')
|
|
|
+ ->where('money', $amount)
|
|
|
+ ->where('status', 1)
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ $favorablePrice = round($amount * 120 / 100, 2); // 305 固定 120% 立即到账
|
|
|
+ $give = $favorablePrice - $amount;
|
|
|
+
|
|
|
+ if ($gear) {
|
|
|
+ $gear->gift_id = 305;
|
|
|
+ $gear->favorable_price = $favorablePrice;
|
|
|
+ $gear->give = $give;
|
|
|
+ $gear->total_bonus = $totalRewardPercent;
|
|
|
+ $gear->bonus = $totalRewardPercent;
|
|
|
+ $gear->total_reward_percent = $totalRewardPercent;
|
|
|
+ $gear->recommend = 1;
|
|
|
+ if (!empty($gear->gear)) {
|
|
|
+ $gear->gear = Util::filterGearByDevice($gear->gear);
|
|
|
+ }
|
|
|
+ $payload['list'] = [$gear];
|
|
|
+ } else {
|
|
|
+ $payload['list'] = [(object)[
|
|
|
+ 'money' => $amount,
|
|
|
+ 'favorable_price' => $favorablePrice,
|
|
|
+ 'give' => $give,
|
|
|
+ 'gear' => null,
|
|
|
+ 'gift_id' => 305,
|
|
|
+ 'total_bonus' => $totalRewardPercent,
|
|
|
+ 'bonus' => $totalRewardPercent,
|
|
|
+ 'total_reward_percent' => $totalRewardPercent,
|
|
|
+ 'recommend' => 1,
|
|
|
+ ]];
|
|
|
+ }
|
|
|
+ $payload['amount'] = $amount;
|
|
|
+ $payload['total_reward_percent'] = $totalRewardPercent;
|
|
|
+ $payload['extra_reward'] = round($amount*$totalRewardPercent/100);
|
|
|
+ $payload['total_reward'] = round($amount*$totalRewardPercent/100)+$amount;
|
|
|
+ } else {
|
|
|
+ $payload['amount'] = $amount;
|
|
|
+ }
|
|
|
+
|
|
|
+ return apiReturnSuc($payload);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 连续未充值 VIP 礼包(gift_id=305)—— 获取 7 日礼包信息
|
|
|
+ */
|
|
|
+ public function vipInactiveGiftSevenDays(Request $request)
|
|
|
+ {
|
|
|
+ $user = $request->user();
|
|
|
+ $this->setUserLocale($request);
|
|
|
+ $userId = $user->UserID;
|
|
|
+
|
|
|
+ // 获取 7 日礼包记录
|
|
|
+ $record = DB::table('agent.dbo.inactive_vip_gift_records')
|
|
|
+ ->where('user_id', $userId)
|
|
|
+ ->where('gift_id', 305)
|
|
|
+ ->orderBy('id', 'desc')
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if (!$record) {
|
|
|
+ return apiReturnFail(['web.gift.vip_inactive_no_record', __('web.gift.vip_inactive_no_record')]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算从充值完成后的第几天(从第1天开始,即充值的次日)
|
|
|
+ // 如果created_at是2024-01-01,今天是2024-01-02,daysPassed=1,表示可以领取第1天的奖励
|
|
|
+ $createdDate = date('Y-m-d', strtotime($record->created_at));
|
|
|
+ $today = date('Y-m-d');
|
|
|
+ $daysPassed = floor((strtotime($today) - strtotime($createdDate)) / 86400);
|
|
|
+ // daysPassed = 0 表示充值当天(还不能领取),1 表示充值的次日(可以领取第1天),以此类推
|
|
|
+
|
|
|
+ // 检查是否已过期(超过7天)
|
|
|
+ $expiredAt = strtotime($record->expired_at);
|
|
|
+ $isExpired = time() > $expiredAt;
|
|
|
+
|
|
|
+ $perDayAmount = (float)$record->per_day_amount;
|
|
|
+ $claimedMask = (int)$record->claimed_days_mask;
|
|
|
+
|
|
|
+ // 构建每一天的状态
|
|
|
+ $days = [];
|
|
|
+ for ($day = 1; $day <= 7; $day++) {
|
|
|
+ $dayIndex = $day - 1; // 位索引:day1对应bit0
|
|
|
+ $isClaimed = ($claimedMask & (1 << $dayIndex)) > 0;
|
|
|
+
|
|
|
+ // 计算这一天对应的日期(充值后第day天)
|
|
|
+ $targetDate = date('Ymd', strtotime($record->created_at . ' +' . $day . ' days'));
|
|
|
+
|
|
|
+ // 判断状态
|
|
|
+ // 0=不可领取, 1=可领取, 2=已领取, 3=过期
|
|
|
+ $dayStatus = 0;
|
|
|
+ $betAmount = 0; // 初始化
|
|
|
+
|
|
|
+ // 第4-7天需要查询流水信息(无论状态如何,都要展示进度)
|
|
|
+ if ($day >= 4) {
|
|
|
+// var_dump($userId,$day,$targetDate);
|
|
|
+ $todayBet = DB::table('QPRecordDB.dbo.RecordUserDataStatisticsNew')
|
|
|
+ ->where('UserID', $userId)
|
|
|
+ ->where('DateID', $targetDate)
|
|
|
+ ->value('TotalBet') ?? 0;
|
|
|
+ $betAmount = $todayBet / NumConfig::NUM_VALUE; // 转换为元
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($isClaimed) {
|
|
|
+ $dayStatus = 2; // 已领取
|
|
|
+ } elseif ($daysPassed > $day) {
|
|
|
+ // 已过这一天但未领取:过期
|
|
|
+ // 例如:今天是第4天(daysPassed=4),但第3天的奖励还没领取,则第3天过期
|
|
|
+ $dayStatus = 3; // 过期
|
|
|
+ } elseif ($daysPassed < $day) {
|
|
|
+ // 还没到这一天:第day天的奖励需要在充值后的第day天才能领取
|
|
|
+ // 例如:第1天奖励需要daysPassed >= 1(充值的次日)才能领取
|
|
|
+ $dayStatus = 0; // 不可领取
|
|
|
+ } elseif ($isExpired || $daysPassed >= 7) {
|
|
|
+ // 整体过期(超过7天)时,未领取的奖励都过期
|
|
|
+ $dayStatus = 3; // 过期
|
|
|
+ } else {
|
|
|
+ // 到了这一天,判断是否可以领取
|
|
|
+ if ($day <= 3) {
|
|
|
+ // 前3天:直接领取
|
|
|
+ $dayStatus = 1; // 可领取
|
|
|
+ } else {
|
|
|
+ // 第4-7天:需要当天游戏流水 >= 100(流水信息已在上面查询)
|
|
|
+ if ($betAmount >= 100) {
|
|
|
+ $dayStatus = 1; // 可领取
|
|
|
+ } else {
|
|
|
+ $dayStatus = 0; // 不可领取(流水不足)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算进度条数据(仅第4-7天)
|
|
|
+ $betProgress = null;
|
|
|
+ if ($day >= 4) {
|
|
|
+ $requiredBet = 100;
|
|
|
+ $currentBetValue = round($betAmount, 2);
|
|
|
+ $progressPercent = $requiredBet > 0 ? min(100, round(($currentBetValue / $requiredBet) * 100, 2)) : 0;
|
|
|
+
|
|
|
+ $betProgress = [
|
|
|
+ 'current' => $currentBetValue, // 当前流水
|
|
|
+ 'required' => $requiredBet, // 需要流水
|
|
|
+ 'progress_percent' => $progressPercent, // 进度百分比(0-100)
|
|
|
+ 'is_completed' => $currentBetValue >= $requiredBet // 是否完成
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $days[] = [
|
|
|
+ 'day' => $day,
|
|
|
+ 'amount' => $perDayAmount,
|
|
|
+ 'status' => $dayStatus,
|
|
|
+ 'status_text' => [
|
|
|
+ __('web.gift.status_cannot_claim'),
|
|
|
+ __('web.gift.status_can_claim'),
|
|
|
+ __('web.gift.status_claimed'),
|
|
|
+ __('web.gift.status_expired')
|
|
|
+ ][$dayStatus] ?? __('web.gift.status_unknown'),
|
|
|
+ 'target_date' => $targetDate,
|
|
|
+ 'bet_progress' => $betProgress // 第4-7天的流水进度信息
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否有倒计时(未充值时的24小时倒计时)
|
|
|
+ $timerKey = "vip_inactive_gift_timer_{$userId}";
|
|
|
+ $timerData = Redis::get($timerKey);
|
|
|
+ $timeLeft = 0;
|
|
|
+ if ($timerData) {
|
|
|
+ $timerData = json_decode($timerData, true);
|
|
|
+ $expireTime = $timerData['expire_time'] ?? 0;
|
|
|
+ $timeLeft = max(0, $expireTime - time());
|
|
|
+ }
|
|
|
+
|
|
|
+ return apiReturnSuc([
|
|
|
+ 'record' => [
|
|
|
+ 'pay_amount' => (float)$record->pay_amount,
|
|
|
+ 'total_percent' => (float)$record->total_percent,
|
|
|
+ 'seven_days_percent' => (float)$record->seven_days_percent,
|
|
|
+ 'per_day_amount' => $perDayAmount,
|
|
|
+ 'inactive_days' => (int)$record->inactive_days,
|
|
|
+ 'created_at' => $record->created_at,
|
|
|
+ 'expired_at' => $record->expired_at
|
|
|
+ ],
|
|
|
+ 'days' => $days,
|
|
|
+ 'current_day' => min($daysPassed + 1, 7), // 当前是第几天
|
|
|
+ 'is_expired' => $isExpired,
|
|
|
+ 'time_left' => $timeLeft, // 未充值时的倒计时(秒)
|
|
|
+ 'expire_at' => $expiredAt
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 连续未充值 VIP 礼包(gift_id=305)—— 领取某日奖励
|
|
|
+ */
|
|
|
+ public function claimVipInactiveGiftDayReward(Request $request)
|
|
|
+ {
|
|
|
+ $user = $request->user();
|
|
|
+ $this->setUserLocale($request);
|
|
|
+ $userId = $user->UserID;
|
|
|
+ $day = (int)$request->input('day', 0);
|
|
|
+
|
|
|
+ if ($day < 1 || $day > 7) {
|
|
|
+ return apiReturnFail(['web.gift.invalid_reward_type', __('web.gift.invalid_reward_type')]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取 7 日礼包记录
|
|
|
+ $record = DB::table('agent.dbo.inactive_vip_gift_records')
|
|
|
+ ->where('user_id', $userId)
|
|
|
+ ->where('gift_id', 305)
|
|
|
+ ->orderBy('id', 'desc')
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if (!$record) {
|
|
|
+ return apiReturnFail(['web.gift.vip_inactive_no_record', __('web.gift.vip_inactive_no_record')]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否已过期
|
|
|
+ if (strtotime($record->expired_at) < time()) {
|
|
|
+ return apiReturnFail(['web.gift.vip_inactive_expired', __('web.gift.vip_inactive_expired')]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否已领取
|
|
|
+ $claimedMask = (int)$record->claimed_days_mask;
|
|
|
+ $dayIndex = $day - 1;
|
|
|
+ if ($claimedMask & (1 << $dayIndex)) {
|
|
|
+ return apiReturnFail(['web.gift.vip_inactive_day_claimed', str_replace(':day', $day, __('web.gift.vip_inactive_day_claimed'))]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算从充值完成后的第几天
|
|
|
+ $createdDate = date('Y-m-d', strtotime($record->created_at));
|
|
|
+ $today = date('Y-m-d');
|
|
|
+ $daysPassed = floor((strtotime($today) - strtotime($createdDate)) / 86400);
|
|
|
+
|
|
|
+ // 检查是否到了这一天:第day天的奖励只能在充值后的第day天领取(daysPassed == day)
|
|
|
+ if ($daysPassed < $day) {
|
|
|
+ return apiReturnFail(['web.gift.vip_inactive_day_not_time', str_replace(':day', $day, __('web.gift.vip_inactive_day_not_time'))]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否已过期:如果已经过了这一天(daysPassed > day),则不能领取
|
|
|
+ if ($daysPassed > $day) {
|
|
|
+ return apiReturnFail(['web.gift.vip_inactive_day_expired', str_replace(':day', $day, __('web.gift.vip_inactive_day_expired'))]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第4-7天需要检查当天游戏流水 >= 100
|
|
|
+ if ($day >= 4) {
|
|
|
+ $targetDate = date('Ymd', strtotime($record->created_at . ' +' . $day . ' days'));
|
|
|
+ $todayBet = DB::table('QPRecordDB.dbo.RecordUserDataStatisticsNew')
|
|
|
+ ->where('UserID', $userId)
|
|
|
+ ->where('DataID', $targetDate)
|
|
|
+ ->value('TotalBet') ?? 0;
|
|
|
+
|
|
|
+ $betAmount = $todayBet / NumConfig::NUM_VALUE; // 转换为元
|
|
|
+
|
|
|
+ if ($betAmount < 100) {
|
|
|
+ return apiReturnFail(['web.gift.vip_inactive_bet_insufficient', str_replace(':amount', 100, __('web.gift.vip_inactive_bet_insufficient'))]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $amount = (float)$record->per_day_amount;
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 发放奖励
|
|
|
+ OuroGameService::AddScore($userId, $amount * NumConfig::NUM_VALUE, 52, true); // 52=礼包奖励
|
|
|
+
|
|
|
+ // 更新位标记
|
|
|
+ $newMask = $claimedMask | (1 << $dayIndex);
|
|
|
+ DB::connection('write')->table('agent.dbo.inactive_vip_gift_records')
|
|
|
+ ->where('id', $record->id)
|
|
|
+ ->update([
|
|
|
+ 'claimed_days_mask' => $newMask,
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+
|
|
|
+ \Log::info('连续未充值VIP礼包奖励领取成功', [
|
|
|
+ 'user_id' => $userId,
|
|
|
+ 'day' => $day,
|
|
|
+ 'amount' => $amount
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return apiReturnSuc([
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'day' => $day,
|
|
|
+ 'message' => str_replace(':amount', $amount, __('web.gift.claim_success'))
|
|
|
+ ]);
|
|
|
+
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ \Log::error('连续未充值VIP礼包奖励领取失败', [
|
|
|
+ 'user_id' => $userId,
|
|
|
+ 'day' => $day,
|
|
|
+ 'error' => $e->getMessage()
|
|
|
+ ]);
|
|
|
+ return apiReturnFail(['web.gift.claim_failed', str_replace(':error', $e->getMessage(), __('web.gift.claim_failed'))]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|