Browse Source

召回礼包

Tree 1 month ago
parent
commit
d3375e6551

+ 390 - 0
VIP_INACTIVE_GIFT_API.md

@@ -0,0 +1,390 @@
+# 连续未充值VIP礼包(gift_id=305)接口调用示例
+
+## 1. 礼包入口接口 - 检查条件和返回档位
+
+### 接口地址
+```
+POST /pay/vip_inactive_gift
+```
+
+### 请求示例
+```bash
+curl -X POST "https://your-domain.com/pay/vip_inactive_gift" \
+  -H "Authorization: Bearer {token}" \
+  -H "Content-Type: application/json"
+```
+
+### 响应示例
+
+#### 情况1:不满足条件(不是VIP用户)
+```json
+{
+  "code": 200,
+  "msg": "success",
+  "data": {
+    "status": 0,
+    "message": "您还不是VIP用户"
+  }
+}
+```
+
+#### 情况2:不满足条件(连续未充值天数不足)
+```json
+{
+  "code": 200,
+  "msg": "success",
+  "data": {
+    "status": 0,
+    "message": "连续未充值天数不足3天",
+    "inactive_days": 2
+  }
+}
+```
+
+#### 情况3:满足条件,未充值(含充值档位信息,参考 bankruptcyGift)
+```json
+{
+  "code": 200,
+  "msg": "success",
+  "data": {
+    "status": 1,
+    "amount": 19.99,
+    "inactive_days": 5,
+    "total_recharge": 120.50,
+    "avg_recharge": 15.06,
+    "time_left": 82800,
+    "expire_at": 1704067200,
+    "message": "可以充值礼包",
+    "total_reward_percent": 260.0,
+    "list": [
+      {
+        "money": 19.99,
+        "favorable_price": 23.99,
+        "give": 4.0,
+        "gear": "...",
+        "gift_id": 305,
+        "total_bonus": 260.0,
+        "bonus": 160.0,
+        "total_reward_percent": 260.0,
+        "recommend": 1
+      }
+    ]
+  }
+}
+```
+
+#### 情况4:已充值,奖励未全部领取
+```json
+{
+  "code": 200,
+  "msg": "success",
+  "data": {
+    "status": 2,
+    "amount": 19.99,
+    "inactive_days": 5,
+    "total_recharge": 120.50,
+    "avg_recharge": 15.06,
+    "time_left": 0,
+    "expire_at": null,
+    "message": "已充值,奖励未全部领取"
+  }
+}
+```
+
+#### 情况5:已充值,奖励全部领取
+```json
+{
+  "code": 200,
+  "msg": "success",
+  "data": {
+    "status": 3,
+    "amount": 19.99,
+    "inactive_days": 5,
+    "total_recharge": 120.50,
+    "avg_recharge": 15.06,
+    "time_left": 0,
+    "expire_at": null,
+    "message": "已充值,奖励全部领取"
+  }
+}
+```
+
+### 字段说明
+- `status`: 状态(0=不满足条件, 1=满足条件未充值, 2=已充值未全部领取, 3=已充值全部领取)
+- `amount`: 应显示的礼包金额(9.99/19.99/29.99/39.99)
+- `inactive_days`: 连续未充值天数
+- `total_recharge`: 总充值金额
+- `avg_recharge`: 平均单笔充值金额
+- `time_left`: 未充值时的倒计时(秒,0表示无倒计时)
+- `expire_at`: 倒计时过期时间戳
+- `total_reward_percent`: 总奖励百分比(仅 status=1 时),120% 立即 + 7日礼包%(140%~200%)
+- `list`: 充值档位列表(仅 status=1 时),结构参考 bankruptcyGift,gift_id 固定 305;每项含 money、favorable_price、give、gear、gift_id、total_bonus、bonus、total_reward_percent、recommend
+
+---
+
+## 2. 7日礼包信息接口 - 获取每日奖励详情
+
+### 接口地址
+```
+POST /pay/vip_inactive_gift_info
+```
+
+### 请求示例
+```bash
+curl -X POST "https://your-domain.com/pay/vip_inactive_gift_info" \
+  -H "Authorization: Bearer {token}" \
+  -H "Content-Type: application/json"
+```
+
+### 响应示例
+
+#### 成功响应
+```json
+{
+  "code": 200,
+  "msg": "success",
+  "data": {
+    "record": {
+      "pay_amount": 19.99,
+      "total_percent": 260.0,
+      "seven_days_percent": 140.0,
+      "per_day_amount": 3.99,
+      "inactive_days": 5,
+      "created_at": "2024-01-01 10:30:00",
+      "expired_at": "2024-01-08 10:30:00"
+    },
+    "days": [
+      {
+        "day": 1,
+        "amount": 3.99,
+        "status": 2,
+        "status_text": "已领取",
+        "target_date": "2024-01-02",
+        "bet_progress": null
+      },
+      {
+        "day": 2,
+        "amount": 3.99,
+        "status": 2,
+        "status_text": "已领取",
+        "target_date": "2024-01-03",
+        "bet_progress": null
+      },
+      {
+        "day": 3,
+        "amount": 3.99,
+        "status": 2,
+        "status_text": "已领取",
+        "target_date": "2024-01-04",
+        "bet_progress": null
+      },
+      {
+        "day": 4,
+        "amount": 3.99,
+        "status": 1,
+        "status_text": "可领取",
+        "target_date": "2024-01-05",
+        "bet_progress": {
+          "current": 125.50,
+          "required": 100,
+          "progress_percent": 100.0,
+          "is_completed": true
+        }
+      },
+      {
+        "day": 5,
+        "amount": 3.99,
+        "status": 0,
+        "status_text": "不可领取",
+        "target_date": "2024-01-06",
+        "bet_progress": {
+          "current": 65.30,
+          "required": 100,
+          "progress_percent": 65.3,
+          "is_completed": false
+        }
+      },
+      {
+        "day": 6,
+        "amount": 3.99,
+        "status": 0,
+        "status_text": "不可领取",
+        "target_date": "2024-01-07",
+        "bet_progress": {
+          "current": 0,
+          "required": 100,
+          "progress_percent": 0,
+          "is_completed": false
+        }
+      },
+      {
+        "day": 7,
+        "amount": 3.99,
+        "status": 0,
+        "status_text": "不可领取",
+        "target_date": "2024-01-08",
+        "bet_progress": {
+          "current": 0,
+          "required": 100,
+          "progress_percent": 0,
+          "is_completed": false
+        }
+      }
+    ],
+    "current_day": 5,
+    "is_expired": false,
+    "time_left": 0,
+    "expire_at": 1704675000
+  }
+}
+```
+
+#### 失败响应(未找到记录)
+```json
+{
+  "code": 400,
+  "msg": "error",
+  "data": {
+    "message": "未找到7日礼包记录"
+  }
+}
+```
+
+### 字段说明
+
+#### record 对象
+- `pay_amount`: 充值金额
+- `total_percent`: 总奖励百分比(120% + 7日礼包百分比)
+- `seven_days_percent`: 7日礼包总奖励百分比
+- `per_day_amount`: 每日奖励金额
+- `inactive_days`: 触发前连续未充值天数
+- `created_at`: 创建时间
+- `expired_at`: 过期时间
+
+#### days 数组
+- `day`: 第几天(1-7)
+- `amount`: 该天的奖励金额
+- `status`: 状态(0=不可领取, 1=可领取, 2=已领取, 3=过期)
+- `status_text`: 状态文本
+- `target_date`: 目标日期(该天对应的日期)
+- `bet_progress`: 流水进度(仅第4-7天,第1-3天为null)
+  - `current`: 当前流水金额
+  - `required`: 需要流水金额(100)
+  - `progress_percent`: 进度百分比(0-100)
+  - `is_completed`: 是否完成
+
+---
+
+## 3. 领取某日奖励接口
+
+### 接口地址
+```
+POST /pay/claim_vip_inactive_gift_day
+```
+
+### 请求参数
+```json
+{
+  "day": 4
+}
+```
+
+### 请求示例
+```bash
+curl -X POST "https://your-domain.com/pay/claim_vip_inactive_gift_day" \
+  -H "Authorization: Bearer {token}" \
+  -H "Content-Type: application/json" \
+  -d '{"day": 4}'
+```
+
+### 响应示例
+
+#### 成功响应
+```json
+{
+  "code": 200,
+  "msg": "success",
+  "data": {
+    "amount": 3.99,
+    "day": 4,
+    "message": "成功领取3.99奖励"
+  }
+}
+```
+
+#### 失败响应 - 无效的天数
+```json
+{
+  "code": 400,
+  "msg": "error",
+  "data": {
+    "message": "无效的奖励类型"
+  }
+}
+```
+
+#### 失败响应 - 未找到记录
+```json
+{
+  "code": 400,
+  "msg": "error",
+  "data": {
+    "message": "未找到7日礼包记录"
+  }
+}
+```
+
+#### 失败响应 - 已过期
+```json
+{
+  "code": 400,
+  "msg": "error",
+  "data": {
+    "message": "7日礼包已过期"
+  }
+}
+```
+
+#### 失败响应 - 已领取
+```json
+{
+  "code": 400,
+  "msg": "error",
+  "data": {
+    "message": "第4天的奖励已领取"
+  }
+}
+```
+
+#### 失败响应 - 还未到时间
+```json
+{
+  "code": 400,
+  "msg": "error",
+  "data": {
+    "message": "还未到第5天的领取时间"
+  }
+}
+```
+
+#### 失败响应 - 流水不足(第4-7天)
+```json
+{
+  "code": 400,
+  "msg": "error",
+  "data": {
+    "message": "当天游戏流水不足,需要流水100"
+  }
+}
+```
+
+---
+
+## 注意事项
+
+1. **认证**:所有接口都需要用户登录(middleware: `checkGameLogin`, `mustGameLogin`)
+2. **多语言**:响应消息会根据用户的语言设置自动切换
+3. **时间计算**:第1天的奖励在充值后的次日才能领取;某一天未领取则过期后无法补领
+4. **流水要求**:第4-7天需要当天游戏流水 >= 100 才能领取
+5. **倒计时**:满足条件但未充值时,有24小时倒计时,每天重置
+6. **奖励计算**:7日礼包奖励比例 = 140% + (未充值天数-3) × 10%,最高200%

+ 1 - 0
app/Http/Controllers/Admin/RechargeController.php

@@ -262,6 +262,7 @@ class RechargeController extends Controller
                 '302' => '破产礼包',
                 '303' => '每日首充礼包',
                 '304' => '每日礼包',
+                '305' => '召回礼包',
                 '401' => '转盘活动充值',
                 '402' => '圣诞活动',
             ];

+ 483 - 3
app/Http/Controllers/Game/PayRechargeController.php

@@ -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'))]);
+        }
+    }
+
 
 
 

+ 3 - 0
app/Models/Order.php

@@ -272,6 +272,9 @@ class Order extends Model
             case 304:
                 $GiftsName = '每日礼包';
                 break;
+            case 305:
+                $GiftsName = '召回礼包';
+                break;
             case 401:
                 $GiftsName = '大转盘';
                 break;

+ 106 - 0
app/Services/OrderServices.php

@@ -187,6 +187,31 @@ class  OrderServices
                     }
                 }
 
+            }else if ($GiftsID == 305) { // 连续未充值 VIP 新礼包
+                // 检查用户是否已经充值过 305 礼包
+                $hasPurchased305 = DB::connection('write')->table('agent.dbo.order')
+                    ->where('user_id', $user_id)
+                    ->where('GiftsID', 305)
+                    ->where('pay_status', 1)
+                    ->exists();
+                
+                if ($hasPurchased305) {
+                    // 已经充值过 305 礼包,只发放本金(不发放奖励)
+                    $Recharge = $payAmt;
+                    $give = 0;
+                    $favorable_price = $Recharge + $give;
+                    $czReason = 1;
+                    $cjReason = 45;
+                } else {
+                    // 首次充值 305 礼包,发放 120% 奖励(固定120%,不从配置读取)
+                    $favorable_price = round($payAmt * 120 / 100, 2);
+                    $give = $favorable_price - $payAmt;
+                    $Recharge = $payAmt;
+                    $czReason = 50;
+                    $cjReason = 51;
+                    $this->createInactiveVipGiftRecord($user_id, $payAmt);
+                }
+
             }else if ($GiftsID > 400) {
                 $Status = 1;
                 $recharge_gear = DB::connection('write')->table('agent.dbo.recharge_gear')->where('status', $Status)->where('money', $payAmt)->select('favorable_price', 'give')->first();
@@ -384,6 +409,30 @@ class  OrderServices
         (new RechargeWithDraw())->recharge($user_id, $payAmt);
 //        (new RechargeWithDraw())->recharge($user_id, $Recharge);
 
+        // 连续未充值 VIP 新礼包(gift_id=305)—— 充值成功后写入 7 日礼包记录(仅在首次充值时)
+//        if (!empty($GiftsID) && (int)$GiftsID === 305 && $payAmt > 0) {
+//            // 检查是否已经充值过305礼包,只有在首次充值时才创建7日礼包记录
+//            $hasPurchased305 = DB::connection('write')->table('agent.dbo.order')
+//                ->where('user_id', $user_id)
+//                ->where('GiftsID', 305)
+//                ->where('pay_status', 1)
+////                ->where('order_sn', '!=', $order_sn) // 排除当前订单
+//                ->exists();
+//
+//            if (!$hasPurchased305) {
+//                // 首次充值,创建7日礼包记录
+//                try {
+//                    $this->createInactiveVipGiftRecord($user_id, $payAmt);
+//                } catch (\Exception $e) {
+//                    \Log::error('inactive vip gift record create failed', [
+//                        'user_id' => $user_id,
+//                        'payAmt'  => $payAmt,
+//                        'error'   => $e->getMessage(),
+//                    ]);
+//                }
+//            }
+//        }
+
         if ($AdId && $payAmt) AfEvent::dispatch([$user_id, $payAmt, $AdId, $eventType]);
         try {
             //新邀请
@@ -531,6 +580,63 @@ class  OrderServices
         }
     }
 
+    /**
+     * 连续未充值 VIP 礼包(gift_id=305)—— 创建 7 日礼包记录
+     * @param int   $user_id
+     * @param float $payAmt  本次充值金额(元)
+     */
+    private function createInactiveVipGiftRecord($user_id, $payAmt)
+    {
+        // 获取上一次充值订单(不包括刚刚充值的这一条),用于计算连续未充值天数
+        // 计算从最后一次充值的日期到今天的未充值天数
+        $prevOrder = DB::connection('write')->table('agent.dbo.order')
+            ->where('user_id', $user_id)
+            ->where('pay_status', 1)
+            ->where('GiftsID', '!=', 305) // 排除305礼包本身,避免重复计算
+            ->orderBy('pay_at', 'desc')
+            ->first();
+
+        // 默认连续未充值天数至少为 3(以便至少满足条件)
+        $inactiveDays = 3;
+        
+        if ($prevOrder) {
+            // 计算从最后一次充值到今天的未充值天数
+            $prevDate = date('Y-m-d', strtotime($prevOrder->pay_at));
+            $today = date('Y-m-d');
+            $diffDays = (strtotime($today) - strtotime($prevDate)) / 86400;
+            // 连续未充值天数:如果最后一次充值是昨天,则未充值天数为0;如果是前天,则为1;以此类推
+            $inactiveDays = max(3, (int)$diffDays - 1); // 至少为3,确保满足条件
+        }
+
+        // 七日礼包总奖励百分比:140% + (inactiveDays - 3) * 10%,上限 200%
+        $sevenPercent = 140 + max(0, $inactiveDays - 3) * 10;
+        $sevenPercent = min($sevenPercent, 200);
+
+        // 总奖励百分比 = 120%(立即奖励) + 七日礼包百分比
+        $totalPercent = 120 + $sevenPercent;
+
+        // 七日礼包总金额 & 每日金额
+        $sevenTotalAmount = round($payAmt * $sevenPercent / 100, 2);
+        $perDayAmount     = round($sevenTotalAmount / 7, 2);
+
+        $now   = date('Y-m-d H:i:s');
+        $expAt = date('Y-m-d H:i:s', strtotime('+7 days'));
+
+        DB::connection('write')->table('agent.dbo.inactive_vip_gift_records')->insert([
+            'user_id'            => $user_id,
+            'gift_id'            => 305,
+            'pay_amount'         => $payAmt,
+            'total_percent'      => $totalPercent,
+            'seven_days_percent' => $sevenPercent,
+            'per_day_amount'     => $perDayAmount,
+            'inactive_days'      => $inactiveDays,
+            'claimed_days_mask'  => 0,
+            'created_at'         => $now,
+            'updated_at'         => $now,
+            'expired_at'         => $expAt,
+        ]);
+    }
+
     /**
      * 创建首充礼包记录
      */

+ 2 - 2
config/pay.php

@@ -52,10 +52,10 @@ return [
         'return' => env('APP_URL', '').'/api/wdpay/return',
     ],
     'WDPayOut' => [
-        'key' => '5380a6be330744a1adc146803708536c',
+        'key' => '06845be73c704f579ce64d797019dbb0',
         'customer' => 'usslot777',
         'customerNo' => '1027017801',
-        'apiUrl' => 'https://pay.wonderspay.com/charging/create-pay-out',
+        'apiUrl' => 'https://transfer.wonderspay.com/charging/create-pay-out',
         'currency' => 'USD',
         'wayCode' => 'cashapp',
         'signType' => 'MD5',

+ 12 - 0
resources/lang/en/web.php

@@ -108,5 +108,17 @@ return [
         'status_claimed' => 'Claimed',
         'status_expired' => 'Expired',
         'status_unknown' => 'Unknown',
+        'vip_inactive_not_vip' => 'You are not a VIP user yet',
+        'vip_inactive_days_insufficient' => 'Insufficient consecutive inactive days (need at least 3 days)',
+        'vip_inactive_can_recharge' => 'Can recharge gift',
+        'vip_inactive_claimed_partial' => 'Recharged, rewards not all claimed',
+        'vip_inactive_claimed_all' => 'Recharged, all rewards claimed',
+        'vip_inactive_seven_days_expired' => 'Recharged, 7-day gift has expired',
+        'vip_inactive_no_record' => '7-day gift record not found',
+        'vip_inactive_expired' => '7-day gift has expired',
+        'vip_inactive_day_claimed' => 'Day :day reward already claimed',
+        'vip_inactive_day_not_time' => 'Not yet time to claim day :day reward',
+        'vip_inactive_day_expired' => 'Day :day reward has expired and cannot be claimed',
+        'vip_inactive_bet_insufficient' => 'Insufficient daily game flow, need :amount',
     ],
 ]; 

+ 12 - 0
resources/lang/pt/web.php

@@ -108,5 +108,17 @@ return [
         'status_claimed' => 'Reivindicado',
         'status_expired' => 'Expirado',
         'status_unknown' => 'Desconhecido',
+        'vip_inactive_not_vip' => 'Você ainda não é um usuário VIP',
+        'vip_inactive_days_insufficient' => 'Dias consecutivos inativos insuficientes (precisa de pelo menos 3 dias)',
+        'vip_inactive_can_recharge' => 'Pode recarregar presente',
+        'vip_inactive_claimed_partial' => 'Recarregado, recompensas não totalmente reivindicadas',
+        'vip_inactive_claimed_all' => 'Recarregado, todas as recompensas reivindicadas',
+        'vip_inactive_seven_days_expired' => 'Recarregado, presente de 7 dias expirou',
+        'vip_inactive_no_record' => 'Registro de presente de 7 dias não encontrado',
+        'vip_inactive_expired' => 'Presente de 7 dias expirou',
+        'vip_inactive_day_claimed' => 'Recompensa do dia :day já foi reivindicada',
+        'vip_inactive_day_not_time' => 'Ainda não é hora de reivindicar a recompensa do dia :day',
+        'vip_inactive_day_expired' => 'Recompensa do dia :day expirou e não pode ser reivindicada',
+        'vip_inactive_bet_insufficient' => 'Fluxo diário de jogos insuficiente, precisa de :amount',
     ],
 ]; 

+ 12 - 0
resources/lang/zh/web.php

@@ -108,5 +108,17 @@ return [
         'status_claimed' => '已领取',
         'status_expired' => '过期',
         'status_unknown' => '未知',
+        'vip_inactive_not_vip' => '您还不是VIP用户',
+        'vip_inactive_days_insufficient' => '连续未充值天数不足3天',
+        'vip_inactive_can_recharge' => '可以充值礼包',
+        'vip_inactive_claimed_partial' => '已充值,奖励未全部领取',
+        'vip_inactive_claimed_all' => '已充值,奖励全部领取',
+        'vip_inactive_seven_days_expired' => '已充值,7天礼包已过期',
+        'vip_inactive_no_record' => '未找到7日礼包记录',
+        'vip_inactive_expired' => '7日礼包已过期',
+        'vip_inactive_day_claimed' => '第:day天的奖励已领取',
+        'vip_inactive_day_not_time' => '还未到第:day天的领取时间',
+        'vip_inactive_day_expired' => '第:day天的奖励已过期,无法领取',
+        'vip_inactive_bet_insufficient' => '当天游戏流水不足,需要流水:amount',
     ],
 ]; 

+ 3 - 0
routes/game.php

@@ -248,6 +248,9 @@ Route::group([
     $route->any('/pay/daily_first_recharge_gift', 'Game\PayRechargeController@dailyFirstRechargeGift'); // 每日首充礼包
     $route->any('/pay/daily_gift', 'Game\PayRechargeController@dailyGift'); // 每日礼包(三档充值)
     $route->any('/pay/claim_daily_gift_bonus', 'Game\PayRechargeController@claimDailyGiftBonus'); // 领取每日礼包三档完成后的额外奖励
+    $route->any('/pay/vip_inactive_gift', 'Game\PayRechargeController@vipInactiveGift'); // 连续未充值VIP礼包入口
+    $route->any('/pay/vip_inactive_gift_info', 'Game\PayRechargeController@vipInactiveGiftSevenDays'); // 连续未充值VIP礼包7日礼包信息
+    $route->any('/pay/claim_vip_inactive_gift_day', 'Game\PayRechargeController@claimVipInactiveGiftDayReward'); // 领取连续未充值VIP礼包某日奖励
 
     $route->any('/reward-code/redeem', 'Game\RewardCodeController@redeem');