Răsfoiți Sursa

提现任务修改

laowu 1 zi în urmă
părinte
comite
3db9754f78
1 a modificat fișierele cu 98 adăugiri și 5 ștergeri
  1. 98 5
      app/Http/Controllers/Game/ActivityController.php

+ 98 - 5
app/Http/Controllers/Game/ActivityController.php

@@ -267,6 +267,7 @@ class ActivityController extends Controller
         // 获取返回值
         // 获取返回值
 //        $returnValue = $result[1]->ReturnValue;
 //        $returnValue = $result[1]->ReturnValue;
         if ($returnValue == 0) {
         if ($returnValue == 0) {
+            $this->triggerRelief($UserID);
             return apiReturnSuc($result);
             return apiReturnSuc($result);
         } else if ($returnValue == 1) {
         } else if ($returnValue == 1) {
             return apiReturnFail(['web.protect.score_limit','Score limit reached']);
             return apiReturnFail(['web.protect.score_limit','Score limit reached']);
@@ -1190,10 +1191,10 @@ class ActivityController extends Controller
                     ],
                     ],
                     [
                     [
                         'id' => 'stage2_task3',
                         'id' => 'stage2_task3',
-                        'title' => 'Start inviting once',
-                        'type' => 'invite',
+                        'title' => 'Claim Relief Fund',
+                        'type' => 'relief',
                         'target' => 1,
                         'target' => 1,
-                        'progress_key' => 'invite_count'
+                        'progress_key' => 'relief_count'
                     ]
                     ]
                 ]
                 ]
             ],
             ],
@@ -1259,7 +1260,8 @@ class ActivityController extends Controller
             'recharge_count' => 0,
             'recharge_count' => 0,
             'played_games_count' => 0,
             'played_games_count' => 0,
             'invite_count' => 0,
             'invite_count' => 0,
-            'sign_in_count' => 0
+            'sign_in_count' => 0,
+            'relief_count' => 0
         ];
         ];
     }
     }
 
 
@@ -1297,6 +1299,11 @@ class ActivityController extends Controller
         if (!isset($taskData['sign_in_count'])) {
         if (!isset($taskData['sign_in_count'])) {
             $taskData['sign_in_count'] = 0;
             $taskData['sign_in_count'] = 0;
         }
         }
+
+        // 救济金领取次数从Redis读取(通过 triggerRelief 方法触发)
+        if (!isset($taskData['relief_count'])) {
+            $taskData['relief_count'] = 0;
+        }
         
         
         // 如存在未充值前的签到标记,且在同一天内完成充值,则补记签到
         // 如存在未充值前的签到标记,且在同一天内完成充值,则补记签到
         $pendingKey = "vip_withdraw_sign_pending_{$userId}";
         $pendingKey = "vip_withdraw_sign_pending_{$userId}";
@@ -1409,7 +1416,7 @@ class ActivityController extends Controller
         if ($taskData['stage1_completed']) {
         if ($taskData['stage1_completed']) {
             $taskData['stage2_task1'] = $taskData['played_games_count'] >= 100;
             $taskData['stage2_task1'] = $taskData['played_games_count'] >= 100;
             $taskData['stage2_task2'] = $taskData['total_bet'] >= 200;
             $taskData['stage2_task2'] = $taskData['total_bet'] >= 200;
-            $taskData['stage2_task3'] = $taskData['invite_count'] >= 1;
+            $taskData['stage2_task3'] = $taskData['relief_count'] >= 1;
             $taskData['stage2_completed'] = $taskData['stage2_task1'] && 
             $taskData['stage2_completed'] = $taskData['stage2_task1'] && 
                                              $taskData['stage2_task2'] && 
                                              $taskData['stage2_task2'] && 
                                              $taskData['stage2_task3'];
                                              $taskData['stage2_task3'];
@@ -1677,4 +1684,90 @@ class ActivityController extends Controller
         }
         }
     }
     }
 
 
+    /**
+     * 手动触发救济金领取(供其他地方调用)
+     * 注意:只有充值用户且阶段1完成后才会计数
+     */
+    public function triggerRelief($userId)
+    {
+        // 检查用户是否已充值
+        $user_recharge = DB::table(TableName::QPAccountsDB() . 'YN_VIPAccount')
+            ->where('UserID', $userId)
+            ->value('Recharge') ?: 0;
+        
+        if ($user_recharge <= 0) {
+            \Log::info('VIP提现任务-救济金触发失败', [
+                'user_id' => $userId,
+                'reason' => '用户未充值'
+            ]);
+            return false;
+        }
+        
+        $redisKey = "vip_withdraw_task_{$userId}";
+        $data = Redis::get($redisKey);
+        
+        if ($data) {
+            $taskData = json_decode($data, true);
+            
+            // 检查阶段1是否完成
+            if (!isset($taskData['stage1_completed']) || !$taskData['stage1_completed']) {
+                \Log::info('VIP提现任务-救济金触发失败', [
+                    'user_id' => $userId,
+                    'reason' => '阶段1未完成',
+                    'stage1_completed' => $taskData['stage1_completed'] ?? false
+                ]);
+                return false;
+            }
+            
+            // 阶段1已完成,增加救济金计数
+            $taskData['relief_count'] = ($taskData['relief_count'] ?? 0) + 1;
+            
+            $this->saveUserTaskData($userId, $taskData);
+            Redis::setex($redisKey, 86400, json_encode($taskData));
+            
+            \Log::info('VIP提现任务-救济金触发成功', [
+                'user_id' => $userId,
+                'relief_count' => $taskData['relief_count']
+            ]);
+            
+            return true;
+        } else {
+            // 如果Redis没有数据,从数据库加载
+            $dbData = DB::table('agent.dbo.vip_withdraw_tasks')
+                ->where('user_id', $userId)
+                ->first();
+            
+            if ($dbData) {
+                $taskData = json_decode($dbData->task_data, true);
+                
+                // 检查阶段1是否完成
+                if (!isset($taskData['stage1_completed']) || !$taskData['stage1_completed']) {
+                    \Log::info('VIP提现任务-救济金触发失败', [
+                        'user_id' => $userId,
+                        'reason' => '阶段1未完成'
+                    ]);
+                    return false;
+                }
+                
+                $taskData['relief_count'] = ($taskData['relief_count'] ?? 0) + 1;
+                
+                $this->saveUserTaskData($userId, $taskData);
+                Redis::setex($redisKey, 86400, json_encode($taskData));
+                
+                \Log::info('VIP提现任务-救济金触发成功(从数据库加载)', [
+                    'user_id' => $userId,
+                    'relief_count' => $taskData['relief_count']
+                ]);
+                
+                return true;
+            } else {
+                \Log::info('VIP提现任务-救济金触发失败', [
+                    'user_id' => $userId,
+                    'reason' => '用户数据不存在或阶段1未完成'
+                ]);
+                return false;
+            }
+        }
+    }
+
 }
 }