laowu 3 дней назад
Родитель
Сommit
f4eefe9d54

+ 62 - 37
app/Http/Controllers/Admin/ProtectLevelController.php

@@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use App\Http\helper\NumConfig;
-use stdClass;
 
 class ProtectLevelController extends Controller
 {
@@ -19,7 +18,15 @@ class ProtectLevelController extends Controller
             ->orderBy('VIP')
             ->get();
 
-        return view('admin.protect_level.index', compact('list'));
+        // 获取配置值(合并查询)
+        $statusInfo = DB::connection('read')->table('QPAccountsDB.dbo.SystemStatusInfo')
+            ->whereIn('StatusName', ['ProtectLevelDownDays', 'ProtectLevelExpireDays'])
+            ->pluck('StatusValue', 'StatusName');
+
+        $downDays = $statusInfo['ProtectLevelDownDays'] ?? null;
+        $expireDays = $statusInfo['ProtectLevelExpireDays'] ?? null;
+
+        return view('admin.protect_level.index', compact('list', 'downDays', 'expireDays'));
     }
 
     // 增加
@@ -30,31 +37,26 @@ class ProtectLevelController extends Controller
         }
 
         $data = $request->only([
-            'ID','Recharge','GrantNum','VIP','LevelUpBonus',
-            'MinRecharge','WithdrawLimit','DailyWithdraws',
-            'WithdrawFeeRate','SignAlpha','CustomServiceType',
-            'RechargeExtraSendRate','SuperballNum','BirthdayValue',
+            'ID', 'Recharge', 'VIP', 'LevelUpBonus',
+            'MinRecharge', 'WithdrawLimit', 'DailyWithdraws',
+            'WithdrawFeeRate', 'Alpha', 'CustomServiceType',
+            'RechargeExtraSendRate', 'SuperballNum', 'BirthdayValue',
         ]);
-        // 将 GrantNum 存储为原值 * NumConfig::NUM_VALUE
-        if (isset($data['GrantNum'])) {
-            $data['GrantNum'] = intval($data['GrantNum'] * NumConfig::NUM_VALUE);
-        }
 
         // 简单验证(ID唯一性后面手动检查)
         $this->validate($request, [
-            'ID'            => 'required|integer',
-            'Recharge'      => 'required|numeric|min:0',
-            'GrantNum'      => 'required|integer|min:0',
-            'VIP'           => 'required|integer|min:0',
-            'LevelUpBonus'  => 'required|integer|min:0',
-            'MinRecharge'   => 'required|integer|min:0',
+            'ID' => 'required|integer',
+            'Recharge' => 'required|numeric|min:0',
+            'VIP' => 'required|integer|min:0',
+            'LevelUpBonus' => 'required|integer|min:0',
+            'MinRecharge' => 'required|integer|min:0',
             'WithdrawLimit' => 'required|integer|min:0',
-            'DailyWithdraws'=> 'required|integer|min:0|max:255',
-            'WithdrawFeeRate'=> 'required|numeric|min:0',
-            'SignAlpha'     => 'required|integer|min:0',
+            'DailyWithdraws' => 'required|integer|min:0|max:255',
+            'WithdrawFeeRate' => 'required|numeric|min:0',
+            'Alpha' => 'required|numeric|min:0',
             'CustomServiceType' => 'required|integer|in:1,2',
             'RechargeExtraSendRate' => 'required|numeric|min:0',
-            'SuperballNum'  => 'required|integer|min:0',
+            'SuperballNum' => 'required|integer|min:0',
             'BirthdayValue' => 'required|integer|min:0',
         ]);
         // 唯一性检查
@@ -77,30 +79,25 @@ class ProtectLevelController extends Controller
         }
 
         $post = $request->only([
-            'Recharge','GrantNum','VIP','LevelUpBonus',
-            'MinRecharge','WithdrawLimit','DailyWithdraws',
-            'WithdrawFeeRate','SignAlpha','CustomServiceType',
-            'RechargeExtraSendRate','SuperballNum','BirthdayValue',
+            'Recharge', 'VIP', 'LevelUpBonus',
+            'MinRecharge', 'WithdrawLimit', 'DailyWithdraws',
+            'WithdrawFeeRate', 'Alpha', 'CustomServiceType',
+            'RechargeExtraSendRate', 'SuperballNum', 'BirthdayValue',
         ]);
-        // GrantNum 乘以系数保存
-        if (isset($post['GrantNum'])) {
-            $post['GrantNum'] = intval($post['GrantNum'] * NumConfig::NUM_VALUE);
-        }
 
         // 字段校验
         $this->validate($request, [
-            'Recharge'      => 'required|numeric|min:0',
-            'GrantNum'      => 'required|integer|min:0',
-            'VIP'           => 'required|integer|min:0',
-            'LevelUpBonus'  => 'required|integer|min:0',
-            'MinRecharge'   => 'required|integer|min:0',
+            'Recharge' => 'required|numeric|min:0',
+            'VIP' => 'required|integer|min:0',
+            'LevelUpBonus' => 'required|integer|min:0',
+            'MinRecharge' => 'required|integer|min:0',
             'WithdrawLimit' => 'required|integer|min:0',
-            'DailyWithdraws'=> 'required|integer|min:0|max:255',
-            'WithdrawFeeRate'=> 'required|numeric|min:0',
-            'SignAlpha'     => 'required|integer|min:0',
+            'DailyWithdraws' => 'required|integer|min:0|max:255',
+            'WithdrawFeeRate' => 'required|numeric|min:0',
+            'Alpha' => 'required|numeric|min:0',
             'CustomServiceType' => 'required|integer|in:1,2',
             'RechargeExtraSendRate' => 'required|numeric|min:0',
-            'SuperballNum'  => 'required|integer|min:0',
+            'SuperballNum' => 'required|integer|min:0',
             'BirthdayValue' => 'required|integer|min:0',
         ]);
         $post['BirthdayValue'] = $post['BirthdayValue'] * NumConfig::NUM_VALUE;
@@ -120,4 +117,32 @@ class ProtectLevelController extends Controller
 
         return apiReturnSuc();
     }
+
+    // 保存配置
+    public function saveConfig(Request $request)
+    {
+        $this->validate($request, [
+            'down_days' => 'required|integer|min:1',
+            'expire_days' => 'required|integer|min:1',
+        ]);
+
+        $downDays = $request->input('down_days');
+        $expireDays = $request->input('expire_days');
+
+        // 更新或创建 ProtectLevelDownDays 配置
+        DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
+            ->updateOrInsert(
+                ['StatusName' => 'ProtectLevelDownDays'],
+                ['StatusValue' => $downDays]
+            );
+
+        // 更新或创建 ProtectLevelExpireDays 配置
+        DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
+            ->updateOrInsert(
+                ['StatusName' => 'ProtectLevelExpireDays'],
+                ['StatusValue' => $expireDays]
+            );
+
+        return apiReturnSuc();
+    }
 }

+ 77 - 34
app/Http/Controllers/Game/ActivityController.php

@@ -32,6 +32,7 @@ use App\Services\ChristmasWheelService;
 use App\Services\PayConfig;
 use App\Services\SmartFastPay;
 use App\Services\StoredProcedure;
+use App\Services\VipService;
 use App\Util;
 use App\Utility\SetNXLock;
 use Illuminate\Http\Request;
@@ -143,28 +144,53 @@ class ActivityController extends Controller
         $UserID=$user->UserID;
         $res=DB::connection('sqlsrv')->select("exec QPAccountsDB.dbo.GSP_GP_QueryProtect $UserID");
         $cooldownSeconds = 2 * 60 * 60;
-        $lastRecvTime = DB::connection('sqlsrv')
+        $recordProtectList = DB::connection('sqlsrv')
             ->table('QPAccountsDB.dbo.RecordProtectList')
             ->where('UserID', $UserID)
-            ->value('UpdateDate');
+            ->first();
+        $userVipState = DB::table('QPAccountsDB.dbo.UserVipState')
+            ->where('UserID', $user->UserID)
+            ->first();
+        $lastRechargeDays = $userVipState ? intval($userVipState->ActiveDays) : -1; // 上次充值后签到天数
+        $totalAddNum = $recordProtectList ? $recordProtectList->AddNum : 0;
+        $vipExpireDays = DB::table('QPAccountsDB.dbo.SystemStatusInfo')
+            ->where('StatusName', 'ProtectLevelExpireDays')->value('StatusValue') ?: 7;
+        $vipLevelDownDays = DB::table('QPAccountsDB.dbo.SystemStatusInfo')
+            ->where('StatusName', 'ProtectLevelDownDays')->value('StatusValue') ?: 3;
 
         $cooldownLeftSeconds = 0;
         $cooldownEndTime = null;
-        if (!empty($lastRecvTime)) {
-            $end = Carbon::parse($lastRecvTime)->addSeconds($cooldownSeconds);
-            $now = now();
-            if ($now->lt($end)) {
-                $cooldownLeftSeconds = $now->diffInSeconds($end);
-                $cooldownEndTime = $end->toDateTimeString();
-            }
-        }
 
         // 查询接口返回倒计时信息
         if (!empty($res) && isset($res[0])) {
-            $res[0]->cooldown_seconds = $cooldownSeconds;
-            $res[0]->cooldown_left_seconds = $cooldownLeftSeconds;
-            $res[0]->cooldown_end_time = $cooldownEndTime;
-            $res[0]->can_receive = $cooldownLeftSeconds <= 0 ? 1 : 0;
+            // 非vip用户30日后需要充值才能领取
+            $webUser = GlobalUserInfo::toWebData($user);
+            $regDays = intval((time() - strtotime($user->RegisterDate))/86400);
+            $totalRecharge = DB::table('QPRecordDB.dbo.RecordUserTotalStatistics')
+                ->where('UserID', $user->UserID)
+                ->value('Recharge') * NumConfig::NUM_VALUE;
+            $res[0]->cooldown_seconds = $cooldownSeconds; //deprecated
+            $res[0]->cooldown_left_seconds = $cooldownLeftSeconds; //deprecated
+            $res[0]->cooldown_end_time = $cooldownEndTime; //deprecated
+            $res[0]->can_receive = 1;
+            $res[0]->new_user_thirty_days_without_recharge = $regDays >= 30 && $webUser['vip'] == 0;
+            $res[0]->can_receive_num = max(0, $totalRecharge-$totalAddNum);
+            $res[0]->total_recharge = $totalRecharge;
+            $res[0]->last_recharge_days = $lastRechargeDays;
+            $res[0]->vip = $webUser['vip'];
+            if ($res[0]->new_user_thirty_days_without_recharge) {
+                $res[0]->can_receive = 0;
+            }
+            $res[0]->vip_level_down = $lastRechargeDays >= $vipLevelDownDays && $lastRechargeDays < $vipExpireDays;
+            $res[0]->vip_expire = false;
+            if ($res[0]->vip > 0 && $res[0]->last_recharge_days >= $vipExpireDays) {
+                $res[0]->can_receive = 0;
+                $res[0]->vip_expire = true;
+            }
+            $res[0]->level_down_warning_day = config('vip.level_down_warning_days');
+            $res[0]->vip_expire_warning_day = config('vip.expire_warning_days');
+            $res[0]->vip_level_down_days = $vipLevelDownDays;
+            $res[0]->vip_expire_days = $vipExpireDays;
         }
 
         return apiReturnSuc($res);
@@ -179,26 +205,12 @@ class ActivityController extends Controller
             //欧洲暂时封闭
             return apiReturnSuc();
         }
-        // 领取低保增加 2 小时 CD
-        $cooldownSeconds = 2 * 60 * 60;
-        $lastRecvTime = DB::connection('sqlsrv')
-            ->table('QPAccountsDB.dbo.RecordProtectList')
-            ->where('UserID', $UserID)
-            ->value('UpdateDate');
-        if (!empty($lastRecvTime)) {
-            $end = Carbon::parse($lastRecvTime)->addSeconds($cooldownSeconds);
-            $now = now();
-            if ($now->lt($end)) {
-                $left = $now->diffInSeconds($end);
-                return apiReturnFail(
-                    ['web.protect.cooldown', 'Please claim again after cooldown'],
-                    [
-                        'cooldown_seconds' => $cooldownSeconds,
-                        'cooldown_left_seconds' => $left,
-                        'cooldown_end_time' => $end->toDateTimeString(),
-                    ]
-                );
-            }
+        
+        // 非vip用户30日后需要充值才能领取
+        $webUser = GlobalUserInfo::toWebData($user);
+        $regDays = intval((time() - strtotime($user->RegisterDate))/86400);
+        if ($webUser['vip'] == 0 && $regDays >= 30) {
+            return apiReturnFail(['web.protect.must_recharge', 'Please recharge before claim']);
         }
         $dbh = DB::connection()->getPdo();
 
@@ -226,8 +238,12 @@ class ActivityController extends Controller
             return apiReturnSuc($result);
         } else if ($returnValue == 1) {
             return apiReturnFail(['web.protect.score_limit','Score limit reached']);
+        } else if ($returnValue == 2) {
+            return apiReturnFail(['web.protect.must_recharge', 'Please recharge before claim']);
         } else if ($returnValue == 3) {
             return apiReturnFail(['web.protect.times_limit','Protect times limit reached']);
+        } else if ($returnValue == 4) {
+            return apiReturnFail(['web.protect.amount_limit','Protect amount limit reached']);
         } else {
             return apiReturnFail(['web.withdraw.try_again_later','Unknown error']);
         }
@@ -266,6 +282,26 @@ class ActivityController extends Controller
                 }
             }
             $res2['config']=$res;
+            $userVipState = DB::table('QPAccountsDB.dbo.UserVipState')
+                ->where('UserID', $UserID)
+                ->first();
+            $res2['LastRechargeDays'] = $userVipState ? intval($userVipState->ActiveDays) : -1; // 上次充值后签到天数
+            $webUser = GlobalUserInfo::toWebData($user);
+            $regDays = intval((time() - strtotime($user->RegisterDate))/86400);
+            $res2['new_user_thirty_days_without_recharge'] = $regDays >= 30 && $webUser['vip'] == 0;
+            $res2['vip'] = $webUser['vip'];
+            $vipExpireDays = DB::table('QPAccountsDB.dbo.SystemStatusInfo')
+                ->where('StatusName', 'ProtectLevelExpireDays')->value('StatusValue') ?: 7;
+            $vipLevelDownDays = DB::table('QPAccountsDB.dbo.SystemStatusInfo')
+                ->where('StatusName', 'ProtectLevelDownDays')->value('StatusValue') ?: 3;
+            $res2['vip_level_down'] = $res2['LastRechargeDays'] >= $vipLevelDownDays && $res2['LastRechargeDays'] < $vipExpireDays;
+            $res2['vip_expire'] = $res2['LastRechargeDays'] >= $vipExpireDays;
+            $res2['vip_level_down_days'] = $vipLevelDownDays;
+            $res2['vip_expire_days'] = $vipExpireDays;
+            $res2['level_down_warning_day'] = config('vip.level_down_warning_days');
+            $res2['vip_expire_warning_day'] = config('vip.expire_warning_days');
+            $res2['Alpha'] = DB::table('QPAccountsDB.dbo.ProtectLevel')
+                ->where('VIP', $res2['vip'])->value('Alpha') * ($res2['vip_level_down'] ? 0.5 : 1);
             return apiReturnSuc($res2);
         } finally {
             // 确保释放锁
@@ -277,6 +313,13 @@ class ActivityController extends Controller
     {
         $user=$request->user();
         $UserID=$user->UserID;
+
+        $webUser = GlobalUserInfo::toWebData($user);
+        $regDays = intval((time() - strtotime($user->RegisterDate))/86400);
+        if ($regDays >= 30 && $webUser['vip'] == 0) {
+            return apiReturnFail(['web.checkin.recharge_required', 'Recharge is required to sign in'],[],777);
+        }
+
         try {
             // 定义输出参数
             $errorDescribe = '';

+ 9 - 1
app/Http/Controllers/Game/PayRechargeController.php

@@ -804,8 +804,15 @@ class PayRechargeController extends Controller
         if ($bankruptcyGifts->isEmpty()) {
             return apiReturnFail(['web.gift.bankruptcy_gift_not_exists', __('web.gift.bankruptcy_gift_not_exists')]);
         }
+        $moneys = $bankruptcyGifts->pluck('recommend')->toArray();
+        foreach ($moneys as $k => $v) {
+            $moneys[$k]=round($v, 2);
+        }
 
-
+        $paidAmounts = DB::table('agent.dbo.order')
+            ->where(['user_id' => $user->UserID, 'pay_status' => 1, 'GiftsID' => 302])
+            ->whereDate('created_at', date('Y-m-d'))
+            ->get()->pluck('amount')->toArray();
         $result = [];
         
         // 遍历每条礼包配置,根据 recommend 关联 recharge_gear
@@ -820,6 +827,7 @@ class PayRechargeController extends Controller
                 $gear->gift_id = $gift->gift_id;
                 $gear->total_bonus = $gift->total_bonus;
                 $gear->bonus = $gift->total_bonus - 100;
+                $gear->paidToday = in_array(round($gear->money*NumConfig::NUM_VALUE, 2), $paidAmounts);
                 if (!empty($gear->gear)) {
                     $gear->gear = Util::filterGearByDevice($gear->gear,GlobalUserInfo::toWebData($user));
                 }

+ 12 - 0
app/Jobs/Order.php

@@ -4,11 +4,13 @@ namespace App\Jobs;
 
 use App\Facade\TableName;
 use App\Game\Services\OuroGameService;
+use App\Http\helper\NumConfig;
 use App\Models\AccountsInfo;
 use App\Models\PrivateMail;
 use App\Services\Custom;
 use App\Services\FirstPayStatService;
 use App\Services\OrderServices;
+use App\Services\VipService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
@@ -70,6 +72,16 @@ class Order implements ShouldQueue
             $service = new FirstPayStatService();
             $isfirst = $service->stat($order_sn);
 
+            // VIP签到救济金天数重置
+            $minRechargeValue = VipService::getKeepLevelMinRecharge();
+            if ($minRechargeValue < $payAmt * NumConfig::NUM_VALUE) {
+                DB::table('QPAccountsDB.dbo.UserVipState')->where('UserID', $user_id)
+                    ->update(['ActiveDays' => 0, 'UpdateDate' => date('Y-m-d H:i:s')]);
+
+            }
+
+            Log::info("订单处理成功: {$order_sn}, 用户: {$user_id}, 金额: {$payAmt}, 到账: {$Score}");
+
         }catch (\Exception $e) {
             Log::error('订单处理失败:' . $e->getMessage());
         }

+ 10 - 3
app/Services/OrderServices.php

@@ -83,10 +83,17 @@ class  OrderServices
                         ]);
                     }
                 }
-            }if ($GiftsID == 302) { // 破产礼包
-                // 首次购买首充礼包,走赠送逻辑(立即获得bonus_instantly%)
+            } else if ($GiftsID == 302) { // 破产礼包
+                // 检查用户今日是否已充值过破产礼包
+                $todayRecharge = DB::connection('write')->table('agent.dbo.order')
+                    ->where('user_id', $user_id)
+                    ->where('GiftsID', 302)
+                    ->where('pay_status', 1)
+                    ->whereDate('created_at', date('Y-m-d'))
+                    ->first();
+                // 今日首次购买破产礼包,走赠送逻辑
                 $Gifts = DB::connection('write')->table('agent.dbo.recharge_gift')->where('gift_id', $GiftsID)->where('recommend', $payAmt)->first();
-                if($Gifts){
+                if($Gifts && !$todayRecharge){
                     $favorable_price = round($Gifts->bonus_instantly*$payAmt/100,2);
                     $give = $favorable_price-$payAmt;
                     $Recharge = $payAmt;

+ 8 - 1
app/Services/VipService.php

@@ -71,7 +71,7 @@ class VipService
         $levels = DB::table('QPAccountsDB.dbo.ProtectLevel')
             ->orderBy('MinRecharge', 'asc')
             ->select('ID', 'VIP', 'MinRecharge', 'Recharge', 'WithdrawLimit', 'DailyWithdraws', 'GrantNum', 'LevelUpBonus',
-             'WithdrawFeeRate', 'SignAlpha', 'CustomServiceType', 'RechargeExtraSendRate', 'SuperballNum', 'BirthdayValue')
+             'WithdrawFeeRate', 'SignAlpha', 'Alpha', 'CustomServiceType', 'RechargeExtraSendRate', 'SuperballNum', 'BirthdayValue')
             ->get();
 
         // 缓存10分钟
@@ -96,4 +96,11 @@ class VipService
         }
         return null;
     }
+
+    public static function getKeepLevelMinRecharge()
+    {
+        return DB::table('QPAccountsDB.dbo.SystemStatusInfo')
+            ->where('StatusName', 'ProtectLevelKeepMinRecharge')
+            ->value('StatusValue');
+    }
 }

+ 7 - 0
config/vip.php

@@ -0,0 +1,7 @@
+<?php
+
+
+return [
+    'level_down_warning_days' => 5, // 多少天后没充值 vip权益下降提示
+    'expire_warning_days' => 10, // 多少天后没充值 vip权益过期提示
+];

+ 4 - 8
resources/views/admin/protect_level/add.blade.php

@@ -12,10 +12,6 @@
                 <label>充值金额 Recharge</label>
                 <input name="Recharge" class="form-control" value="{{ $info->Recharge ?? '' }}">
             </div>
-            <div class="form-group">
-                <label>救济金 GrantNum</label>
-                <input name="GrantNum" class="form-control" value="{{ isset($info) ? round($info->GrantNum / \App\Http\helper\NumConfig::NUM_VALUE, 2) : '' }}">
-            </div>
             <div class="form-group">
                 <label>VIP 等级 VIP</label>
                 <input name="VIP" class="form-control" value="{{ $info->VIP ?? '' }}">
@@ -44,8 +40,8 @@
                 </div>
             </div>
             <div class="form-group">
-                <label>签到系数 SignAlpha</label>
-                <input name="SignAlpha" class="form-control" value="{{ $info->SignAlpha ?? '' }}">
+                <label>Alpha (签到、救济金系数)</label>
+                <input name="Alpha" class="form-control" value="{{ $info->Alpha ?? '' }}" step="0.01">
             </div>
             <div class="form-group">
                 <label>客服类型 CustomServiceType</label>
@@ -63,11 +59,11 @@
             </div>
             <div class="form-group">
                 <label>SuperballNum</label>
-                <input name="SuperballNum" class="form-control" value="{{ $info->SuperballNum ?? '' }}">
+                <input name="SuperballNum" class="form-control" value="{{ $info->SuperballNum ?? 0 }}">
             </div>
             <div class="form-group">
                 <label>生日礼价值 BirthdayValue</label>
-                <input name="BirthdayValue" class="form-control" value="{{ ($info->BirthdayValue ?? '')/100 }}">
+                <input name="BirthdayValue" class="form-control" value="{{ ($info->BirthdayValue ?? 0)/100 }}">
             </div>
             <button type="submit" class="btn btn-primary">{{ isset($info) ? '保存' : '添加' }}</button>
         </form>

+ 2 - 6
resources/views/admin/protect_level/edit.blade.php

@@ -12,10 +12,6 @@
                 <label>充值金额 Recharge</label>
                 <input name="Recharge" class="form-control" value="{{ $info->Recharge ?? '' }}">
             </div>
-            <div class="form-group">
-                <label>救济金 GrantNum</label>
-                <input name="GrantNum" class="form-control" value="{{ round($info->GrantNum / \App\Http\helper\NumConfig::NUM_VALUE, 2) }}">
-            </div>
             <div class="form-group">
                 <label>VIP 等级 VIP</label>
                 <input name="VIP" class="form-control" value="{{ $info->VIP ?? '' }}">
@@ -44,8 +40,8 @@
                 </div>
             </div>
             <div class="form-group">
-                <label>签到系数 SignAlpha</label>
-                <input name="SignAlpha" class="form-control" value="{{ $info->SignAlpha ?? '' }}">
+                <label>Alpha (签到、救济金系数)</label>
+                <input name="Alpha" class="form-control" value="{{ $info->Alpha ?? '' }}" step="0.01">
             </div>
             <div class="form-group">
                 <label>客服类型 CustomServiceType</label>

+ 46 - 5
resources/views/admin/protect_level/index.blade.php

@@ -3,24 +3,43 @@
 <div class="main-panel">
     <div class="content-wrapper">
         <div class="page-header">
-            <h3 class="page-title">{{ __('VIP 等级配置') }}</h3>
+            <h3 class="page-title">{{ __('VIP 配置') }}</h3>
         </div>
 
         <div class="card">
             <div class="card-body">
+                <!-- VIP配置表单 -->
+                <form id="configForm">
+                    <div class="form-row">
+                        <div class="form-group col-md-2">
+                            <label for="downDays">{{ __('VIP降级天数') }}</label>
+                            <input type="number" class="form-control" id="downDays" name="down_days"
+                                   value="{{ $downDays ?? 0 }}" min="1" required>
+                            <small class="form-text text-muted">{{ __('必须为正整数') }}</small>
+                        </div>
+                        <div class="form-group col-md-2">
+                            <label for="expireDays">{{ __('VIP过期天数') }}</label>
+                            <input type="number" class="form-control" id="expireDays" name="expire_days"
+                                   value="{{ $expireDays ?? 0 }}" min="1" required>
+                            <small class="form-text text-muted">{{ __('必须为正整数') }}</small>
+                        </div>
+                        <div class="form-group col-md-2 d-flex align-items-center">
+                            <button type="button" class="btn btn-sm btn-primary" onclick="saveConfig()">{{ __('保存') }}</button>
+                        </div>
+                    </div>
+                </form>
                 <button class="btn btn-sm btn-success mb-2" onclick="add()">新增等级</button>
                 <table class="table table-bordered">
                     <thead>
                     <tr>
                         <th>ID</th>
                         <th>充值金额</th>
-                        <th>救济金金额</th>
                         <th>VIP等级</th>
                         <th>最小充值</th>
                         <th>提现限额</th>
                         <th>茶叶次数</th>
                         <th>提现费率百分比</th>
-                        <th>签到系数</th>
+                        <th>Alpha (签到、救济金系数)</th>
                         <th>客服类型 1 普通 2 一对一</th>
                         <th>商城充值额外赠送百分比</th>
                         <th>Superball每日赠送球数</th>
@@ -33,13 +52,12 @@
                         <tr>
                             <td>{{ $row->ID }}</td>
                             <td>{{ $row->Recharge }}</td>
-                            <td>{{ round($row->GrantNum/\App\Http\helper\NumConfig::NUM_VALUE, 2) }}</td>
                             <td>{{ $row->VIP }}</td>
                             <td>{{ $row->MinRecharge }}</td>
                             <td>{{ $row->WithdrawLimit }}</td>
                             <td>{{ $row->DailyWithdraws }}</td>
                             <td>{{ $row->WithdrawFeeRate }} %</td>
-                            <td>{{ $row->SignAlpha }}</td>
+                            <td>{{ $row->Alpha }}</td>
                             <td>{{ $row->CustomServiceType }}</td>
                             <td>{{ $row->RechargeExtraSendRate }} %</td>
                             <td>{{ $row->SuperballNum }}</td>
@@ -54,6 +72,8 @@
                 </table>
             </div>
         </div>
+
+
     </div>
 </div>
 
@@ -77,5 +97,26 @@
             });
         });
     }
+    function saveConfig(){
+        var downDays = document.getElementById('downDays').value;
+        var expireDays = document.getElementById('expireDays').value;
+        
+        // 验证输入
+        if (!downDays || downDays <= 0 || isNaN(downDays)) {
+            layer.msg('VIP降级时间必须为正整数');
+            return;
+        }
+        if (!expireDays || expireDays <= 0 || isNaN(expireDays)) {
+            layer.msg('VIP过期时间必须为正整数');
+            return;
+        }
+        
+        myRequest('/admin/protect-level/save-config','post',{
+            down_days: downDays,
+            expire_days: expireDays
+        },function(){
+            layer.msg('配置已保存');
+        });
+    }
 </script>
 @endsection

+ 1 - 0
routes/web.php

@@ -854,6 +854,7 @@ Route::group([
         $route->any('/protect-level/add', 'Admin\ProtectLevelController@add');
         $route->any('/protect-level/edit/{id}', 'Admin\ProtectLevelController@edit');
         $route->post('/protect-level/delete/{id}', 'Admin\ProtectLevelController@delete');
+        $route->post('/protect-level/save-config', 'Admin\ProtectLevelController@saveConfig');
     
         $route->any('/win_lose_rank', 'Admin\WinLoseRankController@index');
     });