Tree 5 giorni fa
parent
commit
6a7ef4a497

+ 6 - 0
app/Game/Services/GameEncrypt.php

@@ -25,7 +25,13 @@ class GameEncrypt
     {
         $hasLz=$request->has('lz');
         $debug=RouteService::isTestSite()||$request->has('_db')&&($request->input('_db')=='g');
+        //判定一下,如果路由是/game/registerNew 就输出日志
         if($hasLz) {
+            if ($request->path() === 'game/registerNew') {
+                // 输出日志逻辑
+                Util::WriteLog('register_params', 'Register new user: ' . json_encode($request->all()));
+            }
+
             try{
                 $newarr = \GuzzleHttp\json_decode(self::decrypt($request->input('lz')),true);
                 $_REQUEST=array_merge($_REQUEST,$newarr);

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

@@ -1211,6 +1211,8 @@ class RechargeController extends Controller
                 $item->day_rewards = $item->day_rewards ? json_decode($item->day_rewards, true) : null;
                 $item->betting_bonus = $item->betting_bonus ? json_decode($item->betting_bonus, true) : null;
                 $item->betting_task = $item->betting_task ? json_decode($item->betting_task, true) : null;
+                // task_bonus 是数字字段,保留两位小数
+                $item->task_bonus = $item->task_bonus !== null ? round((float)$item->task_bonus, 2) : null;
             }
 
             return view('admin.recharge.gift_list', compact('list'));
@@ -1279,6 +1281,13 @@ class RechargeController extends Controller
                 $data['betting_task'] = '';
             }
 
+            // 处理每日任务奖励(数字字段,保留两位小数)
+            if ($request->has('task_bonus')) {
+                $data['task_bonus'] = round((float)$request->task_bonus ?: 0, 2);
+            } else {
+                $data['task_bonus'] = null;
+            }
+
                 DB::connection('write')->table('agent.dbo.recharge_gift')->insert($data);
                 return apiReturnSuc();
             } catch (\Exception $e) {
@@ -1350,6 +1359,13 @@ class RechargeController extends Controller
                 $data['betting_task'] = '';
             }
 
+            // 处理每日任务奖励(数字字段,保留两位小数)
+            if ($request->has('task_bonus')) {
+                $data['task_bonus'] = round((float)$request->task_bonus ?: 0, 2);
+            } else {
+                $data['task_bonus'] = null;
+            }
+
             DB::connection('write')->table('agent.dbo.recharge_gift')->where('id', $id)->update($data);
             return apiReturnSuc();
         }
@@ -1358,6 +1374,8 @@ class RechargeController extends Controller
         $info->day_rewards = $info->day_rewards ? json_decode($info->day_rewards, true) : null;
         $info->betting_bonus = $info->betting_bonus ? json_decode($info->betting_bonus, true) : null;
         $info->betting_task = $info->betting_task ? json_decode($info->betting_task, true) : null;
+        // task_bonus 是数字字段,保留两位小数
+        $info->task_bonus = $info->task_bonus !== null ? round((float)$info->task_bonus, 2) : null;
 
         return view('admin.recharge.gift_update', compact('info'));
     }

+ 1 - 25
app/Http/Controllers/Game/LoginController.php

@@ -1151,36 +1151,12 @@ class LoginController extends Controller
             return $this->guestLogin($guestUser);
         }
 
-//        $guser = GlobalUserInfo::toWebData($guestUser,true);
-
-
-//        return response()->json(apiReturnSuc($guser, ['reg.success', 'Registro realizado com sucesso!']));//->withCookie($this->setLoginCookie($guser['sign']));
-
-
         $login_ip = IpLocation::getRealIp();
         $RegisterLocation = $request->country ?? env('COUNTRY_CODE',1);
         $ServerRegion = env('REGION_24680','sa-east');
         $Language = $request->lang ?? $request->getLocale();
-//        $Phone = $request->phone ?? "";
-//
-//        $Phone = $this->checkPhone($Phone, $RegisterLocation,$request);
-//        //有错误返回
-//        if (is_array($Phone)) {
-//            return $Phone;
-//        }else if(is_object($Phone)&&isset($Phone->GlobalUID)){
-//            //原来就存在,直接返回
-//            $guser = GlobalUserInfo::toWebData($Phone,true);
-//            $guser['reg'] = 1;
-//            return response()->json(apiReturnSuc($guser, ['reg.success', 'Registro realizado com sucesso!']));
-//        }
 
-//        if (isset($request->email) && strstr($request->email, '@')) {
-//            $isExist = GlobalUserInfo::query()->where("Email", $request->email)->exists();
-//            //账户查重
-//            if ($isExist) {
-//                return apiReturnFail(['web.reg.fail_email_exist', 'O e-mail já existe, altere-o e tente se cadastrar novamente!']);
-//            }
-//        }
+
 
 
         $redisKey = 'register_' . $FPID;

+ 298 - 20
app/Http/Controllers/Game/PayRechargeController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Game;
 
 
 use App\Facade\TableName;
+use App\Game\GlobalUserInfo;
 use App\Game\Services\OuroGameService;
 use App\Http\Controllers\Controller;
 use App\Http\helper\NumConfig;
@@ -13,11 +14,24 @@ use App\Services\OrderServices;
 use App\Utility\SetNXLock;
 use App\Util;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\App;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Redis;
 
 class PayRechargeController extends Controller
 {
+    /**
+     * 设置用户语言环境
+     */
+    private function setUserLocale($request)
+    {
+        $user = $request->user();
+        if ($user) {
+            $locale = GlobalUserInfo::getLocaleByUserID($user->UserID, 'en');
+            App::setLocale($locale);
+        }
+    }
+
     // 充值记录
     public function orderList(Request $request)
     {
@@ -108,13 +122,15 @@ class PayRechargeController extends Controller
     {
         $user = $request->user();
         
+        $this->setUserLocale($request);
+        
         // 获取礼包配置
         $giftConfig = DB::table('agent.dbo.recharge_gift')
             ->where('gift_id', 301)
             ->first();
         
         if (!$giftConfig) {
-            return apiReturnFail('礼包配置不存在');
+            return apiReturnFail(['web.gift.config_not_exists', __('web.gift.config_not_exists')]);
         }
         
         // 检查用户是否购买了首充礼包
@@ -442,6 +458,7 @@ class PayRechargeController extends Controller
         $user = $request->user();
         $userId = $user->UserID;
         $rewardType = $request->input('reward_type');  // 'day_reward', 'betting_bonus', 'betting_task'
+        $this->setUserLocale($request);
         
         // 获取礼包记录
         $giftRecord = DB::table('agent.dbo.first_pay_gift_records')
@@ -449,7 +466,7 @@ class PayRechargeController extends Controller
             ->first();
         
         if (!$giftRecord) {
-            return apiReturnFail('未购买首充礼包');
+            return apiReturnFail(['web.gift.not_purchased', __('web.gift.not_purchased')]);
         }
         
         $rewardAmount = 0;
@@ -459,7 +476,7 @@ class PayRechargeController extends Controller
             if ($rewardType === 'day_reward') {
                 $dayRewardsData = json_decode($giftRecord->day_rewards_data, true);
                 if (!$dayRewardsData) {
-                    return apiReturnFail('没有每日奖励配置');
+                    return apiReturnFail(['web.gift.no_day_rewards_config', __('web.gift.no_day_rewards_config')]);
                 }
                 
                 $bonusDay = $dayRewardsData['bonus_day'] ?? 0;
@@ -469,7 +486,7 @@ class PayRechargeController extends Controller
                 
                 // 检查是否还有可领取的天数
                 if ($claimedDays >= $bonusDay) {
-                    return apiReturnFail('每日奖励已全部领取');
+                    return apiReturnFail(['web.gift.day_rewards_all_claimed', __('web.gift.day_rewards_all_claimed')]);
                 }
                 
                 // 计算当前是购买后的第几天
@@ -479,7 +496,7 @@ class PayRechargeController extends Controller
                 
                 // 检查是否到了可以领取的天数(从第start_day天开始)
                 if ($daysPassed < $startDay-1) {
-                    return apiReturnFail('还未到可领取时间,需要从第' . $startDay . '天开始');
+                    return apiReturnFail(['web.gift.day_rewards_not_time', str_replace(':day', $startDay, __('web.gift.day_rewards_not_time'))]);
                 }
                 
                 // 计算今天应该领取第几天的奖励
@@ -488,13 +505,13 @@ class PayRechargeController extends Controller
                 
                 // 检查是否超过奖励天数
                 if ($todayRewardIndex >= $bonusDay) {
-                    return apiReturnFail('每日奖励已过期');
+                    return apiReturnFail(['web.gift.day_rewards_expired', __('web.gift.day_rewards_expired')]);
                 }
                 
                 // 检查今天是否已领取
                 $lastClaimDate = $giftRecord->day_last_claim_date;
                 if ($lastClaimDate && $lastClaimDate === $currentDate) {
-                    return apiReturnFail('今天已经领取过了');
+                    return apiReturnFail(['web.gift.day_rewards_claimed_today', __('web.gift.day_rewards_claimed_today')]);
                 }
                 
                 // 检查是否跳过了某些天(过期不补领)
@@ -521,7 +538,7 @@ class PayRechargeController extends Controller
             elseif ($rewardType === 'betting_bonus') {
                 $bettingBonusData = json_decode($giftRecord->betting_bonus_data, true);
                 if (!$bettingBonusData) {
-                    return apiReturnFail('没有下注奖励配置');
+                    return apiReturnFail(['web.gift.no_betting_bonus_config', __('web.gift.no_betting_bonus_config')]);
                 }
                 
                 // 检查是否过期(购买后7天)
@@ -529,7 +546,7 @@ class PayRechargeController extends Controller
                 $currentDate = date('Y-m-d');
                 $daysPassed = floor((strtotime($currentDate) - strtotime($purchaseDate)) / 86400);
                 if ($daysPassed >= 7) {
-                    return apiReturnFail('下注奖励已过期');
+                    return apiReturnFail(['web.gift.betting_bonus_expired', __('web.gift.betting_bonus_expired')]);
                 }
                 
                 // 获取最新的下注次数
@@ -545,7 +562,7 @@ class PayRechargeController extends Controller
                 
                 // 检查是否还有剩余奖励
                 if ($remainingBonus <= 0) {
-                    return apiReturnFail('下注奖励已全部领取');
+                    return apiReturnFail(['web.gift.betting_bonus_all_claimed', __('web.gift.betting_bonus_all_claimed')]);
                 }
                 
                 // 每次可领取的金额(直接使用配置的值,不是百分比计算)
@@ -562,7 +579,8 @@ class PayRechargeController extends Controller
                 
                 // 检查是否可以领取
                 if ($canClaimTimes <= 0) {
-                    return apiReturnFail('下注次数不足,还需下注 ' . (($claimedTimes + 1) * $perBet - $currentBetCount) . ' 次才能领取');
+                    $neededBets = (($claimedTimes + 1) * $perBet - $currentBetCount);
+                    return apiReturnFail(['web.gift.betting_bonus_insufficient', str_replace(':times', $neededBets, __('web.gift.betting_bonus_insufficient'))]);
                 }
                 
                 // ✅ 一次性领取所有已达成的奖励(但不能超过剩余总额)
@@ -589,12 +607,12 @@ class PayRechargeController extends Controller
             // 下注任务领取(使用下注金额)
             elseif ($rewardType === 'betting_task') {
                 if ($giftRecord->betting_task_claimed == 1) {
-                    return apiReturnFail('下注任务奖励已领取');
+                    return apiReturnFail(['web.gift.betting_task_claimed', __('web.gift.betting_task_claimed')]);
                 }
                 
                 $bettingTaskData = json_decode($giftRecord->betting_task_data, true);
                 if (!$bettingTaskData) {
-                    return apiReturnFail('没有下注任务配置');
+                    return apiReturnFail(['web.gift.no_betting_task_config', __('web.gift.no_betting_task_config')]);
                 }
                 
                 // 检查是否过期(购买后7天)
@@ -602,7 +620,7 @@ class PayRechargeController extends Controller
                 $currentDate = date('Y-m-d');
                 $daysPassed = floor((strtotime($currentDate) - strtotime($purchaseDate)) / 86400);
                 if ($daysPassed >= 7) {
-                    return apiReturnFail('下注任务奖励已过期');
+                    return apiReturnFail(['web.gift.betting_task_expired', __('web.gift.betting_task_expired')]);
                 }
                 
                 // 获取最新的下注金额
@@ -616,7 +634,7 @@ class PayRechargeController extends Controller
                 $requiredBet = $giftRecord->pay_amount * $betPayTimes;
                 
                 if ($currentBetAmount < $requiredBet) {
-                    return apiReturnFail('下注金额不足,需要下注 ' . $requiredBet);
+                    return apiReturnFail(['web.gift.betting_task_insufficient', str_replace(':amount', $requiredBet, __('web.gift.betting_task_insufficient'))]);
                 }
                 
                 $rewardAmount = $giftRecord->betting_task_total;
@@ -630,7 +648,7 @@ class PayRechargeController extends Controller
                     ]);
             }
             else {
-                return apiReturnFail('无效的奖励类型');
+                return apiReturnFail(['web.gift.invalid_reward_type', __('web.gift.invalid_reward_type')]);
             }
             
             // 添加奖励到用户账户
@@ -646,7 +664,7 @@ class PayRechargeController extends Controller
             
             return apiReturnSuc([
                 'amount' => $rewardAmount,
-                'message' => '成功领取 ' . $rewardAmount . ' 奖励'
+                'message' => str_replace(':amount', $rewardAmount, __('web.gift.claim_success'))
             ]);
             
         } catch (\Exception $e) {
@@ -654,7 +672,7 @@ class PayRechargeController extends Controller
                 'user_id' => $userId,
                 'error' => $e->getMessage()
             ]);
-            return apiReturnFail('领取失败:' . $e->getMessage());
+            return apiReturnFail(['web.gift.claim_failed', str_replace(':error', $e->getMessage(), __('web.gift.claim_failed'))]);
         }
     }
 
@@ -745,6 +763,7 @@ class PayRechargeController extends Controller
     public function bankruptcyGift(Request $request)
     {
         $user = $request->user();
+        $this->setUserLocale($request);
         
         // 判断用户是否充值
         $user_recharge = DB::table(TableName::QPAccountsDB() . 'YN_VIPAccount')
@@ -752,7 +771,7 @@ class PayRechargeController extends Controller
             ->value('Recharge') ?: 0;
         
         if ($user_recharge <= 0) {
-            return apiReturnFail('用户未充值');
+            return apiReturnFail(['web.gift.user_not_recharged', __('web.gift.user_not_recharged')]);
         }
         
         // 获取所有破产礼包配置 (gift_id=302)
@@ -761,7 +780,7 @@ class PayRechargeController extends Controller
             ->get();
         
         if ($bankruptcyGifts->isEmpty()) {
-            return apiReturnFail('破产礼包配置不存在');
+            return apiReturnFail(['web.gift.bankruptcy_gift_not_exists', __('web.gift.bankruptcy_gift_not_exists')]);
         }
 
         $result = [];
@@ -793,6 +812,265 @@ class PayRechargeController extends Controller
         return apiReturnSuc($result);
     }
 
+    // 每日首充礼包
+    public function dailyFirstRechargeGift(Request $request)
+    {
+        $user = $request->user();
+        $this->setUserLocale($request);
+        
+        // 检查用户今日是否已充值(完成任意档位充值后入口消失)
+        $todayStart = date('Y-m-d') . ' 00:00:00';
+        $todayEnd = date('Y-m-d') . ' 23:59:59';
+        
+        $todayRecharge = DB::table('agent.dbo.order')
+            ->where('user_id', $user->UserID)
+            ->where('pay_status', 1)
+            ->where('pay_at', '>=', $todayStart)
+            ->where('pay_at', '<=', $todayEnd)
+            ->first();
+        
+        // 如果今日已充值,返回入口消失标记
+        if ($todayRecharge) {
+            return apiReturnSuc([
+                'has_recharged_today' => true,
+                'message' => __('web.gift.recharged_today')
+            ]);
+        }
+        
+        // 获取每日首充礼包配置 (gift_id=303)
+        $dailyGifts = DB::table('agent.dbo.recharge_gift')
+            ->where('gift_id', 303)
+            ->get();
+        
+        if ($dailyGifts->isEmpty()) {
+            return apiReturnFail(['web.gift.daily_first_recharge_not_exists', __('web.gift.daily_first_recharge_not_exists')]);
+        }
+
+        $result = [];
+        
+        // 遍历每条礼包配置,根据 recommend 关联 recharge_gear
+        foreach ($dailyGifts as $gift) {
+            $gear = DB::table('agent.dbo.recharge_gear')
+                ->select('money', 'favorable_price', 'gear', 'give')
+                ->where('money', $gift->recommend)
+                ->where('status', 1)
+                ->first();
+            
+            if ($gear) {
+                $gear->gift_id = $gift->gift_id;
+                $gear->total_bonus = $gift->total_bonus;
+                $gear->bonus = $gift->total_bonus - 100;
+                if (!empty($gear->gear)) {
+                    $gear->gear = Util::filterGearByDevice($gear->gear);
+                }
+                $result[] = $gear;
+            }
+        }
+
+        // 按 money 排序
+        usort($result, function($a, $b) {
+            return $a->money <=> $b->money;
+        });
+
+        return apiReturnSuc([
+            'has_recharged_today' => false,
+            'list' => $result
+        ]);
+    }
+
+    // 每日礼包(三档充值)
+    public function dailyGift(Request $request)
+    {
+        $user = $request->user();
+        $this->setUserLocale($request);
+        
+        // 获取每日礼包配置 (gift_id=304),应该有3档
+        $dailyGifts = DB::table('agent.dbo.recharge_gift')
+            ->where('gift_id', 304)
+            ->orderBy('recommend', 'asc')
+            ->get();
+        
+        if ($dailyGifts->isEmpty()) {
+            return apiReturnFail(['web.gift.daily_gift_not_exists', __('web.gift.daily_gift_not_exists')]);
+        }
+        
+        if ($dailyGifts->count() > 3) {
+            // 如果配置超过3档,只取前3档
+            $dailyGifts = $dailyGifts->take(3);
+        }
+        
+        // 检查用户今日每档的充值状态
+        $todayStart = date('Y-m-d') . ' 00:00:00';
+        $todayEnd = date('Y-m-d') . ' 23:59:59';
+        
+        $todayRecharges = DB::table('agent.dbo.order')
+            ->where('user_id', $user->UserID)
+            ->where('GiftsID', 304)
+            ->where('pay_status', 1)
+            ->where('pay_at', '>=', $todayStart)
+            ->where('pay_at', '<=', $todayEnd)
+            ->pluck('amount')
+            ->toArray();
+        
+        $result = [];
+        $completedCount = 0;
+        
+        // 遍历每档配置
+        foreach ($dailyGifts as $index => $gift) {
+            $gear = DB::table('agent.dbo.recharge_gear')
+                ->select('money', 'favorable_price', 'gear', 'give')
+                ->where('money', $gift->recommend)
+                ->where('status', 1)
+                ->first();
+            
+            if ($gear) {
+                // 检查该档位今日是否已充值(使用浮点数比较,允许小数点精度差异)
+                $isCompleted = false;
+                foreach ($todayRecharges as $rechargeAmount) {
+                    if (abs($rechargeAmount - $gift->recommend) < 0.01) {
+                        $isCompleted = true;
+                        break;
+                    }
+                }
+                if ($isCompleted) {
+                    $completedCount++;
+                }
+                
+                $gear->gift_id = $gift->gift_id;
+                $gear->total_bonus = $gift->total_bonus;
+                $gear->bonus = $gift->total_bonus - 100;
+                $gear->is_completed = $isCompleted; // 是否已完成
+                $gear->gear_index = $index + 1; // 档位序号(1,2,3)
+                
+                if (!empty($gear->gear)) {
+                    $gear->gear = Util::filterGearByDevice($gear->gear);
+                }
+                $result[] = $gear;
+            }
+        }
+        
+        // 获取额外奖励金额(从任意一档的 task_bonus 字段获取,task_bonus 是数字字段)
+        $taskBonus = null;
+        $firstGift = $dailyGifts->first();
+        if ($firstGift && $firstGift->task_bonus !== null) {
+            $taskBonus = round((float)$firstGift->task_bonus, 2);
+        }
+        
+        // 检查是否可以领取额外奖励(三档都完成)
+        $canClaimBonus = ($completedCount >= 3 && $taskBonus > 0);
+        
+        // 检查是否已领取过额外奖励
+        $hasClaimedBonus = false;
+        if ($canClaimBonus) {
+            $redisKey = "daily_gift_bonus_claimed_{$user->UserID}_" . date('Y-m-d');
+            $hasClaimedBonus = Redis::exists($redisKey);
+        }
+        
+        return apiReturnSuc([
+            'list' => $result,
+            'completed_count' => $completedCount,
+            'total_count' => count($result),
+            'can_claim_bonus' => $canClaimBonus && !$hasClaimedBonus,
+            'has_claimed_bonus' => $hasClaimedBonus,
+            'task_bonus' => $taskBonus
+        ]);
+    }
+
+    // 领取每日礼包三档完成后的额外奖励
+    public function claimDailyGiftBonus(Request $request)
+    {
+        $user = $request->user();
+        $userId = $user->UserID;
+        $this->setUserLocale($request);
+        
+        // 检查三档是否都已完成
+        $todayStart = date('Y-m-d') . ' 00:00:00';
+        $todayEnd = date('Y-m-d') . ' 23:59:59';
+        
+        // 获取每日礼包配置
+        $dailyGifts = DB::table('agent.dbo.recharge_gift')
+            ->where('gift_id', 304)
+            ->orderBy('recommend', 'asc')
+            ->get()
+            ->take(3);
+        
+        if ($dailyGifts->isEmpty()) {
+            return apiReturnFail(['web.gift.daily_gift_not_exists', __('web.gift.daily_gift_not_exists')]);
+        }
+        
+        // 检查每档今日是否都已充值
+        $todayRecharges = DB::table('agent.dbo.order')
+            ->where('user_id', $userId)
+            ->where('GiftsID', 304)
+            ->where('pay_status', 1)
+            ->where('pay_at', '>=', $todayStart)
+            ->where('pay_at', '<=', $todayEnd)
+            ->pluck('amount')
+            ->toArray();
+        
+        $completedCount = 0;
+        foreach ($dailyGifts as $gift) {
+            // 检查该档位是否已充值(使用浮点数比较)
+            $isCompleted = false;
+            foreach ($todayRecharges as $rechargeAmount) {
+                if (abs($rechargeAmount - $gift->recommend) < 0.01) {
+                    $isCompleted = true;
+                    break;
+                }
+            }
+            if ($isCompleted) {
+                $completedCount++;
+            }
+        }
+        
+        if ($completedCount < 3) {
+            return apiReturnFail(['web.gift.three_tiers_not_completed', __('web.gift.three_tiers_not_completed')]);
+        }
+        
+        // 检查是否已领取过
+        $redisKey = "daily_gift_bonus_claimed_{$userId}_" . date('Y-m-d');
+        if (Redis::exists($redisKey)) {
+            return apiReturnFail(['web.gift.bonus_already_claimed_today', __('web.gift.bonus_already_claimed_today')]);
+        }
+        
+        // 获取奖励金额(从任意一档的 task_bonus 获取,task_bonus 是数字字段)
+        $firstGift = $dailyGifts->first();
+        $rewardAmount = 0;
+        
+        if ($firstGift && $firstGift->task_bonus !== null) {
+            $rewardAmount = round((float)$firstGift->task_bonus, 2);
+        }
+        
+        if ($rewardAmount <= 0) {
+            return apiReturnFail(['web.gift.bonus_config_not_exists', __('web.gift.bonus_config_not_exists')]);
+        }
+        
+        try {
+            // 发放奖励
+            OuroGameService::AddScore($userId, $rewardAmount * NumConfig::NUM_VALUE, 52, true); // 52=礼包奖励
+            
+            // 标记已领取
+            Redis::setex($redisKey, 86400, 1); // 24小时过期
+            
+            \Log::info('每日礼包额外奖励领取成功', [
+                'user_id' => $userId,
+                'reward_amount' => $rewardAmount
+            ]);
+            
+            return apiReturnSuc([
+                'amount' => $rewardAmount,
+                'message' => str_replace(':amount', $rewardAmount, __('web.gift.claim_success'))
+            ]);
+            
+        } catch (\Exception $e) {
+            \Log::error('每日礼包额外奖励领取失败', [
+                'user_id' => $userId,
+                'error' => $e->getMessage()
+            ]);
+            return apiReturnFail(['web.gift.claim_failed', str_replace(':error', $e->getMessage(), __('web.gift.claim_failed'))]);
+        }
+    }
+
     public function getSecondGive(Request $request)
     {
         $user = $request->user();

+ 7 - 2
app/Http/Controllers/Game/WebRouteController.php

@@ -108,7 +108,7 @@ class WebRouteController extends Controller
             }
         }
 
-        if(!$user && $guestOpen){
+        if(!$user){
             //游客模式打开,随时可以登录
             $user=GlobalUserInfo::getGameUserInfo('FPID',$FPID);
         }
@@ -121,7 +121,12 @@ class WebRouteController extends Controller
             $user=GlobalUserInfo::GetRecentLogin($request);
         }
         //转换成web数据
-        if ($user) $user = GlobalUserInfo::toWebData($user);
+        if ($user){
+            $user = GlobalUserInfo::toWebData($user);
+        } else{
+            Util::WriteLog('routes_params',[$request]);
+        }
+
 
 
 

+ 86 - 0
app/Services/OrderServices.php

@@ -100,6 +100,92 @@ class  OrderServices
                     $cjReason = 45;
                 }
 
+            }else if ($GiftsID == 303) { // 每日首充礼包
+                // 检查用户今日是否已充值过每日首充礼包
+                $todayStart = date('Y-m-d') . ' 00:00:00';
+                $todayEnd = date('Y-m-d') . ' 23:59:59';
+                
+                $todayRecharge = DB::connection('write')->table('agent.dbo.order')
+                    ->where('user_id', $user_id)
+                    ->where('GiftsID', 303)
+                    ->where('pay_status', 1)
+                    ->where('pay_at', '>=', $todayStart)
+                    ->where('pay_at', '<=', $todayEnd)
+                    ->first();
+                
+                if ($todayRecharge) {
+                    // 今日已充值过,只发放本金(不发放奖励)
+                    $Recharge = $payAmt;
+                    $give = 0;
+                    $favorable_price = $Recharge + $give;
+                    $czReason = 1;
+                    $cjReason = 45;
+                } else {
+                    // 今日未充值过,按照礼包配置的比例发放
+                    $Gifts = DB::connection('write')->table('agent.dbo.recharge_gift')
+                        ->where('gift_id', $GiftsID)
+                        ->where('recommend', $payAmt)
+                        ->first();
+                    
+                    if($Gifts){
+                        $favorable_price = round($Gifts->bonus_instantly*$payAmt/100,2);
+                        $give = $favorable_price-$payAmt;
+                        $Recharge = $payAmt;
+                        $czReason = 50;
+                        $cjReason = 51;
+                    }else{
+                        // 如果没有找到对应的礼包配置,按照普通充值处理
+                        $Recharge = $payAmt;
+                        $give = 0;
+                        $favorable_price = $Recharge + $give;
+                        $czReason = 1;
+                        $cjReason = 45;
+                    }
+                }
+
+            }else if ($GiftsID == 304) { // 每日礼包(三档充值)
+                // 检查用户今日是否已充值过该档位的每日礼包
+                $todayStart = date('Y-m-d') . ' 00:00:00';
+                $todayEnd = date('Y-m-d') . ' 23:59:59';
+                
+                $todayRecharge = DB::connection('write')->table('agent.dbo.order')
+                    ->where('user_id', $user_id)
+                    ->where('GiftsID', 304)
+                    ->where('amount', $payAmt) // 检查该档位金额
+                    ->where('pay_status', 1)
+                    ->where('pay_at', '>=', $todayStart)
+                    ->where('pay_at', '<=', $todayEnd)
+                    ->first();
+                
+                if ($todayRecharge) {
+                    // 今日已充值过该档位,只发放本金(不发放奖励)
+                    $Recharge = $payAmt;
+                    $give = 0;
+                    $favorable_price = $Recharge + $give;
+                    $czReason = 1;
+                    $cjReason = 45;
+                } else {
+                    // 今日未充值过该档位,按照礼包配置的比例发放
+                    $Gifts = DB::connection('write')->table('agent.dbo.recharge_gift')
+                        ->where('gift_id', $GiftsID)
+                        ->where('recommend', $payAmt)
+                        ->first();
+                    
+                    if($Gifts){
+                        $favorable_price = round($Gifts->bonus_instantly*$payAmt/100,2);
+                        $give = $favorable_price-$payAmt;
+                        $Recharge = $payAmt;
+                        $czReason = 50;
+                        $cjReason = 51;
+                    }else{
+                        // 如果没有找到对应的礼包配置,按照普通充值处理
+                        $Recharge = $payAmt;
+                        $give = 0;
+                        $favorable_price = $Recharge + $give;
+                        $czReason = 1;
+                        $cjReason = 45;
+                    }
+                }
 
             }else if ($GiftsID > 400) {
                 $Status = 1;

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

@@ -76,4 +76,37 @@ return [
         'redpack_not_available' => 'There is no RedPack',
         'redpack_no_recharge' => 'You need deposit first!',
     ],
+    'gift' => [
+        'config_not_exists' => 'Gift configuration does not exist',
+        'recharged_today' => 'Recharged today, entry closed',
+        'daily_first_recharge_not_exists' => 'Daily first recharge gift configuration does not exist',
+        'not_purchased' => 'First recharge gift not purchased',
+        'no_day_rewards_config' => 'No daily rewards configuration',
+        'day_rewards_all_claimed' => 'All daily rewards have been claimed',
+        'day_rewards_not_time' => 'Not yet time to claim, need to start from day :day',
+        'day_rewards_expired' => 'Daily rewards have expired',
+        'day_rewards_claimed_today' => 'Already claimed today',
+        'no_betting_bonus_config' => 'No betting bonus configuration',
+        'betting_bonus_expired' => 'Betting bonus has expired',
+        'betting_bonus_all_claimed' => 'All betting bonuses have been claimed',
+        'betting_bonus_insufficient' => 'Insufficient bets, need :times more bets to claim',
+        'betting_task_claimed' => 'Betting task reward has been claimed',
+        'no_betting_task_config' => 'No betting task configuration',
+        'betting_task_expired' => 'Betting task reward has expired',
+        'betting_task_insufficient' => 'Insufficient bet amount, need to bet :amount',
+        'invalid_reward_type' => 'Invalid reward type',
+        'claim_failed' => 'Claim failed: :error',
+        'claim_success' => 'Successfully claimed :amount reward',
+        'user_not_recharged' => 'User has not recharged',
+        'bankruptcy_gift_not_exists' => 'Bankruptcy gift configuration does not exist',
+        'daily_gift_not_exists' => 'Daily gift configuration does not exist',
+        'three_tiers_not_completed' => 'Three tiers recharge not completed, cannot claim reward',
+        'bonus_already_claimed_today' => 'Bonus already claimed today',
+        'bonus_config_not_exists' => 'Reward configuration does not exist',
+        'status_cannot_claim' => 'Cannot claim',
+        'status_can_claim' => 'Can claim',
+        'status_claimed' => 'Claimed',
+        'status_expired' => 'Expired',
+        'status_unknown' => 'Unknown',
+    ],
 ]; 

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

@@ -76,4 +76,37 @@ return [
         'redpack_not_available' => 'Não há envelope vermelho disponível',
         'redpack_no_recharge' => 'Você precisa depositar primeiro!',
     ],
+    'gift' => [
+        'config_not_exists' => 'Configuração de presente não existe',
+        'recharged_today' => 'Recarregado hoje, entrada fechada',
+        'daily_first_recharge_not_exists' => 'Configuração de presente de primeira recarga diária não existe',
+        'not_purchased' => 'Presente de primeira recarga não comprado',
+        'no_day_rewards_config' => 'Não há configuração de recompensas diárias',
+        'day_rewards_all_claimed' => 'Todas as recompensas diárias foram reivindicadas',
+        'day_rewards_not_time' => 'Ainda não é hora de reivindicar, precisa começar do dia :day',
+        'day_rewards_expired' => 'Recompensas diárias expiraram',
+        'day_rewards_claimed_today' => 'Já reivindicado hoje',
+        'no_betting_bonus_config' => 'Não há configuração de bônus de apostas',
+        'betting_bonus_expired' => 'Bônus de apostas expirou',
+        'betting_bonus_all_claimed' => 'Todos os bônus de apostas foram reivindicados',
+        'betting_bonus_insufficient' => 'Apostas insuficientes, precisa de :times apostas a mais para reivindicar',
+        'betting_task_claimed' => 'Recompensa da tarefa de apostas já foi reivindicada',
+        'no_betting_task_config' => 'Não há configuração de tarefa de apostas',
+        'betting_task_expired' => 'Recompensa da tarefa de apostas expirou',
+        'betting_task_insufficient' => 'Valor de aposta insuficiente, precisa apostar :amount',
+        'invalid_reward_type' => 'Tipo de recompensa inválido',
+        'claim_failed' => 'Falha ao reivindicar: :error',
+        'claim_success' => 'Recompensa de :amount reivindicada com sucesso',
+        'user_not_recharged' => 'Usuário não recarregou',
+        'bankruptcy_gift_not_exists' => 'Configuração de presente de falência não existe',
+        'daily_gift_not_exists' => 'Configuração de presente diário não existe',
+        'three_tiers_not_completed' => 'Recarga de três níveis não concluída, não é possível reivindicar recompensa',
+        'bonus_already_claimed_today' => 'Bônus já reivindicado hoje',
+        'bonus_config_not_exists' => 'Configuração de recompensa não existe',
+        'status_cannot_claim' => 'Não pode reivindicar',
+        'status_can_claim' => 'Pode reivindicar',
+        'status_claimed' => 'Reivindicado',
+        'status_expired' => 'Expirado',
+        'status_unknown' => 'Desconhecido',
+    ],
 ]; 

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

@@ -76,4 +76,37 @@ return [
         'redpack_not_available' => '没有红包可用',
         'redpack_no_recharge' => '您需要先充值!',
     ],
+    'gift' => [
+        'config_not_exists' => '礼包配置不存在',
+        'recharged_today' => '今日已充值,入口已关闭',
+        'daily_first_recharge_not_exists' => '每日首充礼包配置不存在',
+        'not_purchased' => '未购买首充礼包',
+        'no_day_rewards_config' => '没有每日奖励配置',
+        'day_rewards_all_claimed' => '每日奖励已全部领取',
+        'day_rewards_not_time' => '还未到可领取时间,需要从第:day天开始',
+        'day_rewards_expired' => '每日奖励已过期',
+        'day_rewards_claimed_today' => '今天已经领取过了',
+        'no_betting_bonus_config' => '没有下注奖励配置',
+        'betting_bonus_expired' => '下注奖励已过期',
+        'betting_bonus_all_claimed' => '下注奖励已全部领取',
+        'betting_bonus_insufficient' => '下注次数不足,还需下注:times次才能领取',
+        'betting_task_claimed' => '下注任务奖励已领取',
+        'no_betting_task_config' => '没有下注任务配置',
+        'betting_task_expired' => '下注任务奖励已过期',
+        'betting_task_insufficient' => '下注金额不足,需要下注:amount',
+        'invalid_reward_type' => '无效的奖励类型',
+        'claim_failed' => '领取失败::error',
+        'claim_success' => '成功领取:amount奖励',
+        'user_not_recharged' => '用户未充值',
+        'bankruptcy_gift_not_exists' => '破产礼包配置不存在',
+        'daily_gift_not_exists' => '每日礼包配置不存在',
+        'three_tiers_not_completed' => '三档充值未完成,无法领取奖励',
+        'bonus_already_claimed_today' => '今日已领取过额外奖励',
+        'bonus_config_not_exists' => '奖励配置不存在',
+        'status_cannot_claim' => '不可领取',
+        'status_can_claim' => '可领取',
+        'status_claimed' => '已领取',
+        'status_expired' => '过期',
+        'status_unknown' => '未知',
+    ],
 ]; 

+ 11 - 0
resources/views/admin/recharge/gift_add.blade.php

@@ -148,6 +148,17 @@
                                     </div>
                                 </div>
 
+                                <hr>
+                                <div class="row">
+                                    <div class="col-md-6">
+                                        <div class="form-group">
+                                            <label>每日任务奖励</label>
+                                            <input type="number" step="0.01" class="form-control" name="task_bonus" placeholder="请输入每日任务奖励金额(支持两位小数)" value="0">
+                                            <small class="form-text text-muted">每日任务奖励金额,支持两位小数</small>
+                                        </div>
+                                    </div>
+                                </div>
+
                                 <button type="button" onclick="commit()" class="btn btn-gradient-primary">
                                     <i class="mdi mdi-file-check btn-icon-prepend"></i>
                                     提交

+ 8 - 0
resources/views/admin/recharge/gift_list.blade.php

@@ -37,6 +37,7 @@
                                         <th>每日奖励</th>
                                         <th>下注奖励</th>
                                         <th>下注任务</th>
+                                        <th>每日任务奖励</th>
                                         <th>操作</th>
                                     </tr>
                                 </thead>
@@ -74,6 +75,13 @@
                                                 -
                                             @endif
                                         </td>
+                                        <td>
+                                            @if($item->task_bonus !== null)
+                                                {{ number_format($item->task_bonus, 2) }}
+                                            @else
+                                                -
+                                            @endif
+                                        </td>
                                         <td>
                                             <button class="btn btn-sm btn-gradient-info" onclick="update({{ $item->id }})">修改</button>
                                             <button class="btn btn-sm btn-gradient-danger" onclick="del({{ $item->id }})">删除</button>

+ 11 - 0
resources/views/admin/recharge/gift_update.blade.php

@@ -148,6 +148,17 @@
                                     </div>
                                 </div>
 
+                                <hr>
+                                <div class="row">
+                                    <div class="col-md-6">
+                                        <div class="form-group">
+                                            <label>每日任务奖励</label>
+                                            <input type="number" step="0.01" class="form-control" name="task_bonus" placeholder="请输入每日任务奖励金额(支持两位小数)" value="{{ $info->task_bonus !== null ? number_format($info->task_bonus, 2, '.', '') : '0' }}">
+                                            <small class="form-text text-muted">每日任务奖励金额,支持两位小数</small>
+                                        </div>
+                                    </div>
+                                </div>
+
                                 <button type="button" onclick="commit({{ $info->id }})" class="btn btn-gradient-primary">
                                     <i class="mdi mdi-file-check btn-icon-prepend"></i>
                                     提交

+ 3 - 0
routes/game.php

@@ -243,6 +243,9 @@ Route::group([
     $route->any('/pay/first_pay_gift', 'Game\PayRechargeController@firstPayGift'); // 首充礼包(带倒计时)
     $route->any('/pay/claim_first_pay_gift', 'Game\PayRechargeController@claimFirstPayGiftReward'); // 领取首充礼包奖励
     $route->any('/pay/bankruptcy_gift', 'Game\PayRechargeController@bankruptcyGift'); // 破产礼包
+    $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('/reward-code/redeem', 'Game\RewardCodeController@redeem');