laowu 1 روز پیش
والد
کامیت
e55c2d97ba

+ 2 - 0
.gitignore

@@ -1,3 +1,5 @@
 .idea
 .env
 vendor
+storage/logs/*
+storage/framework/*

+ 123 - 0
app/Http/Controllers/Admin/ProtectLevelController.php

@@ -0,0 +1,123 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+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
+{
+    protected $table = 'QPAccountsDB.dbo.ProtectLevel';
+
+    // 列表
+    public function index()
+    {
+        $list = DB::connection('read')->table($this->table)
+            ->orderBy('VIP')
+            ->get();
+
+        return view('admin.protect_level.index', compact('list'));
+    }
+
+    // 增加
+    public function add(Request $request)
+    {
+        if ($request->isMethod('get')) {
+            return view('admin.protect_level.add');
+        }
+
+        $data = $request->only([
+            'ID','Recharge','GrantNum','VIP','LevelUpBonus',
+            'MinRecharge','WithdrawLimit','DailyWithdraws',
+            'WithdrawFeeRate','SignAlpha','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',
+            'WithdrawLimit' => 'required|integer|min:0',
+            'DailyWithdraws'=> 'required|integer|min:0|max:255',
+            'WithdrawFeeRate'=> 'required|numeric|min:0',
+            'SignAlpha'     => 'required|integer|min:0',
+            'CustomServiceType' => 'required|integer|in:1,2',
+            'RechargeExtraSendRate' => 'required|numeric|min:0',
+            'SuperballNum'  => 'required|integer|min:0',
+            'BirthdayValue' => 'required|integer|min:0',
+        ]);
+        // 唯一性检查
+        if (DB::connection('read')->table($this->table)->where('ID', $data['ID'])->exists()) {
+            return apiReturnFail('ID already exists');
+        }
+
+        DB::connection('write')->table($this->table)->insert($data);
+        return apiReturnSuc();
+    }
+
+    // 修改
+    public function edit(Request $request, $id)
+    {
+        if ($request->isMethod('get')) {
+            $info = DB::connection('read')->table($this->table)
+                ->where('ID', $id)
+                ->first();
+            return view('admin.protect_level.edit', compact('info'));
+        }
+
+        $post = $request->only([
+            'Recharge','GrantNum','VIP','LevelUpBonus',
+            'MinRecharge','WithdrawLimit','DailyWithdraws',
+            'WithdrawFeeRate','SignAlpha','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',
+            'WithdrawLimit' => 'required|integer|min:0',
+            'DailyWithdraws'=> 'required|integer|min:0|max:255',
+            'WithdrawFeeRate'=> 'required|numeric|min:0',
+            'SignAlpha'     => 'required|integer|min:0',
+            'CustomServiceType' => 'required|integer|in:1,2',
+            'RechargeExtraSendRate' => 'required|numeric|min:0',
+            'SuperballNum'  => 'required|integer|min:0',
+            'BirthdayValue' => 'required|integer|min:0',
+        ]);
+
+        DB::connection('write')->table($this->table)
+            ->where('ID', $id)
+            ->update($post);
+
+        return apiReturnSuc();
+    }
+
+    // 删除
+    public function delete($id)
+    {
+        DB::connection('write')->table($this->table)
+            ->where('ID', $id)
+            ->delete();
+
+        return apiReturnSuc();
+    }
+}

+ 1 - 1
app/Http/Controllers/Game/WithDrawInfoController.php

@@ -126,7 +126,7 @@ class WithDrawInfoController
 
         $sql="DECLARE  @return_value int
         set nocount on use QPAccountsDB
-        EXEC  @return_value = GSP_GR_GetWithDraw '$UserID','$score'
+        EXEC  @return_value = GSP_GR_GetWithDraw20260312 '$UserID','$score'
         SELECT 'ReturnValue' = @return_value";
 
 //        echo $sql;die;

+ 3 - 1
app/Models/RecordScoreInfo.php

@@ -17,7 +17,9 @@ class RecordScoreInfo extends Model
     protected $guarded = [];
 
     // 彩金----21:绑定手机赠送--33:注册赠送--44:签到--45:充值--49:月卡--42:邮件附件(彩金) 51:首充彩金 36:推广充值彩金
-    protected static $Reason = [21, 33, 36, 37, 42, 44, 45, 49, 51, 52, 72];
+    protected static $Reason = [21, 33, 36, 37, 42, 44, 45, 49, 51, 52, 72, 73];
+    /** @var int vip商城充值额外赠送 */
+    const REASON_VIP_SEND_CHIPS = 73;
 
     public static function addScore($user_id, $ChangeScore, $Reason,$currentScore = 0)
     {

+ 11 - 1
app/Services/OrderServices.php

@@ -341,8 +341,18 @@ class  OrderServices
             if ($AfterScore) {
                 RecordScoreInfo::addScore($user_id, ($give * NumConfig::NUM_VALUE), $cjReason, $AfterScore); #赠送彩金
             }
+            // vip额外赠送
+            $userRecharge = $query ?: 0;
+            $VIP = VipService::calculateVipLevel($user_id,$userRecharge);
+            $level = VipService::getVipByField('VIP', $VIP);
+            if ($level && $level->RechargeExtraSendRate > 0) {
+                $vipSendChips = floor($Recharge * NumConfig::NUM_VALUE * ($level->RechargeExtraSendRate/100));
+                if ($vipSendChips > 0) {
+                    RecordScoreInfo::addScore($user_id, $vipSendChips, RecordScoreInfo::REASON_VIP_SEND_CHIPS, $AfterScore);
+                }
+            }
         }
-        $favorable_price =  (int) round($favorable_price * NumConfig::NUM_VALUE);
+        $favorable_price =  (int) round($favorable_price * NumConfig::NUM_VALUE) + ($vipSendChips ?? 0);
         $firstScore = DB::connection('write')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $user_id)->value('Score');
         $Score = $favorable_price + $firstScore;
 

+ 6 - 3
app/Services/SuperballActivityService.php

@@ -38,7 +38,8 @@ class SuperballActivityService
 
         // VIP 等级与每日免费球数(赠送球数 = VIP 等级)
         $vipLevel = $this->getUserVipLevel($userId);
-        $vipFreeBalls = $vipLevel > 0 ? $vipLevel : 0;
+        $level = VipService::getVipByField('VIP', $vipLevel);
+        $vipFreeBalls = $level ? ($level->SuperballNum ?? 0) : 0;
 
         $rechargeToday = $this->getUserRechargeForDate($userId, $today);
         $turnoverToday = $this->getUserTotalBetForDate($userId, $today);
@@ -281,7 +282,8 @@ class SuperballActivityService
         // 基础任务球数 + 每日 VIP 免费球数(赠送球 = VIP 等级)
         $baseBallCount = (int) $tierConfig->ball_count;
         $vipLevel = $this->getUserVipLevel($userId);
-        $vipFreeBalls = $vipLevel > 0 ? $vipLevel : 0;
+        $level = VipService::getVipByField('VIP', $vipLevel);
+        $vipFreeBalls = $level ? ($level->SuperballNum ?? 0) : 0;
         $ballCount = $baseBallCount + $vipFreeBalls;
 
         DB::connection('write')->transaction(function () use ($userId, $today, $task, $ballCount) {
@@ -334,7 +336,8 @@ class SuperballActivityService
         // 与领取时保持一致:基础任务球数 + 每日 VIP 免费球数
         $baseBallCount = (int) $tierConfig->ball_count;
         $vipLevel = $this->getUserVipLevel($userId);
-        $vipFreeBalls = $vipLevel > 0 ? $vipLevel : 0;
+        $level = VipService::getVipByField('VIP', $vipLevel);
+        $vipFreeBalls = $level ? ($level->SuperballNum ?? 0) : 0;
         $ballCount = $baseBallCount + $vipFreeBalls;
         if (count($numbers) !== $ballCount) {
             return ['success' => false, 'message' => ['web.superball.number_count_mismatch', 'Number count mismatch']];

+ 19 - 1
app/Services/VipService.php

@@ -70,7 +70,8 @@ class VipService
         // 从数据库查询(按MinRecharge升序排列)
         $levels = DB::table('QPAccountsDB.dbo.ProtectLevel')
             ->orderBy('MinRecharge', 'asc')
-            ->select('ID', 'VIP', 'MinRecharge', 'Recharge', 'WithdrawLimit', 'DailyWithdraws', 'GrantNum', 'LevelUpBonus')
+            ->select('ID', 'VIP', 'MinRecharge', 'Recharge', 'WithdrawLimit', 'DailyWithdraws', 'GrantNum', 'LevelUpBonus',
+             'WithdrawFeeRate', 'SignAlpha', 'CustomServiceType', 'RechargeExtraSendRate', 'SuperballNum', 'BirthdayValue')
             ->get();
 
         // 缓存10分钟
@@ -78,4 +79,21 @@ class VipService
 
         return $levels;
     }
+
+    /**
+     * 通过某个字段获取vip信息
+     * @param $field
+     * @param $value
+     * @return mixed|null
+     */
+    public static function getVipByField($field, $value)
+    {
+        $vipLevels = self::getVipLevelConfig();
+        foreach ($vipLevels as $level) {
+            if ($level->{$field} == $value) {
+                return $level;
+            }
+        }
+        return null;
+    }
 }

+ 76 - 0
resources/views/admin/protect_level/add.blade.php

@@ -0,0 +1,76 @@
+@extends('base.base')
+@section('base')
+<div class="main-panel">
+    <div class="content-wrapper">
+        <form method="post" class="form-ajax" action="{{ url()->current() }}">
+            @csrf
+            <div class="form-group">
+                <label>ID</label>
+                <input name="ID" class="form-control" value="{{ $info->ID ?? '' }}" {{ isset($info) ? 'readonly' : '' }}>
+            </div>
+            <div class="form-group">
+                <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 ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>升级奖励 LevelUpBonus</label>
+                <input name="LevelUpBonus" class="form-control" value="{{ $info->LevelUpBonus ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>最小充值 MinRecharge</label>
+                <input name="MinRecharge" class="form-control" value="{{ $info->MinRecharge ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>提现限额 WithdrawLimit</label>
+                <input name="WithdrawLimit" class="form-control" value="{{ $info->WithdrawLimit ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>茶叶次数 DailyWithdraws</label>
+                <input name="DailyWithdraws" class="form-control" value="{{ $info->DailyWithdraws ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>提现费率 WithdrawFeeRate</label>
+                <div class="input-group">
+                    <input name="WithdrawFeeRate" class="form-control" value="{{ $info->WithdrawFeeRate ?? '' }}">
+                    <div class="input-group-append"><span class="input-group-text">%</span></div>
+                </div>
+            </div>
+            <div class="form-group">
+                <label>签到系数 SignAlpha</label>
+                <input name="SignAlpha" class="form-control" value="{{ $info->SignAlpha ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>客服类型 CustomServiceType</label>
+                <select name="CustomServiceType" class="form-control">
+                    <option value="1" {{ (isset($info) && $info->CustomServiceType==1) ? 'selected' : '' }}>普通客服</option>
+                    <option value="2" {{ (isset($info) && $info->CustomServiceType==2) ? 'selected' : '' }}>一对一客服</option>
+                </select>
+            </div>
+            <div class="form-group">
+                <label>充值额外赠送 RechargeExtraSendRate</label>
+                <div class="input-group">
+                    <input name="RechargeExtraSendRate" class="form-control" value="{{ $info->RechargeExtraSendRate ?? '' }}">
+                    <div class="input-group-append"><span class="input-group-text">%</span></div>
+                </div>
+            </div>
+            <div class="form-group">
+                <label>SuperballNum</label>
+                <input name="SuperballNum" class="form-control" value="{{ $info->SuperballNum ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>生日礼价值 BirthdayValue</label>
+                <input name="BirthdayValue" class="form-control" value="{{ $info->BirthdayValue ?? '' }}">
+            </div>
+            <button type="submit" class="btn btn-primary">{{ isset($info) ? '保存' : '添加' }}</button>
+        </form>
+    </div>
+</div>
+@endsection

+ 76 - 0
resources/views/admin/protect_level/edit.blade.php

@@ -0,0 +1,76 @@
+@extends('base.base')
+@section('base')
+<div class="main-panel">
+    <div class="content-wrapper">
+        <form method="post" class="form-ajax" action="{{ url()->current() }}">
+            @csrf
+            <div class="form-group">
+                <label>ID</label>
+                <input name="ID" class="form-control" value="{{ $info->ID ?? '' }}" readonly>
+            </div>
+            <div class="form-group">
+                <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 ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>升级奖励 LevelUpBonus</label>
+                <input name="LevelUpBonus" class="form-control" value="{{ $info->LevelUpBonus ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>最小充值 MinRecharge</label>
+                <input name="MinRecharge" class="form-control" value="{{ $info->MinRecharge ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>提现限额 WithdrawLimit</label>
+                <input name="WithdrawLimit" class="form-control" value="{{ $info->WithdrawLimit ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>茶叶次数 DailyWithdraws</label>
+                <input name="DailyWithdraws" class="form-control" value="{{ $info->DailyWithdraws ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>提现费率 WithdrawFeeRate</label>
+                <div class="input-group">
+                    <input name="WithdrawFeeRate" class="form-control" value="{{ $info->WithdrawFeeRate ?? '' }}">
+                    <div class="input-group-append"><span class="input-group-text">%</span></div>
+                </div>
+            </div>
+            <div class="form-group">
+                <label>签到系数 SignAlpha</label>
+                <input name="SignAlpha" class="form-control" value="{{ $info->SignAlpha ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>客服类型 CustomServiceType</label>
+                <select name="CustomServiceType" class="form-control">
+                    <option value="1" {{ ($info->CustomServiceType==1) ? 'selected' : '' }}>普通客服</option>
+                    <option value="2" {{ ($info->CustomServiceType==2) ? 'selected' : '' }}>一对一客服</option>
+                </select>
+            </div>
+            <div class="form-group">
+                <label>充值额外赠送 RechargeExtraSendRate</label>
+                <div class="input-group">
+                    <input name="RechargeExtraSendRate" class="form-control" value="{{ $info->RechargeExtraSendRate ?? '' }}">
+                    <div class="input-group-append"><span class="input-group-text">%</span></div>
+                </div>
+            </div>
+            <div class="form-group">
+                <label>SuperballNum</label>
+                <input name="SuperballNum" class="form-control" value="{{ $info->SuperballNum ?? '' }}">
+            </div>
+            <div class="form-group">
+                <label>生日礼价值 BirthdayValue</label>
+                <input name="BirthdayValue" class="form-control" value="{{ $info->BirthdayValue ?? '' }}">
+            </div>
+            <button type="submit" class="btn btn-primary">保存</button>
+        </form>
+    </div>
+</div>
+@endsection

+ 81 - 0
resources/views/admin/protect_level/index.blade.php

@@ -0,0 +1,81 @@
+@extends('base.base')
+@section('base')
+<div class="main-panel">
+    <div class="content-wrapper">
+        <div class="page-header">
+            <h3 class="page-title">{{ __('VIP 等级配置') }}</h3>
+        </div>
+
+        <div class="card">
+            <div class="card-body">
+                <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>客服类型 1 普通 2 一对一</th>
+                        <th>商城充值额外赠送百分比</th>
+                        <th>Superball每日赠送球数</th>
+                        <th>生日礼价值</th>
+                        <th>操作</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach($list as $row)
+                        <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->CustomServiceType }}</td>
+                            <td>{{ $row->RechargeExtraSendRate }} %</td>
+                            <td>{{ $row->SuperballNum }}</td>
+                            <td>{{ $row->BirthdayValue }}</td>
+                            <td>
+                                <button class="btn btn-sm btn-primary" onclick="edit({{ $row->ID }})">{{ __('修改') }}</button>
+                                <button class="btn btn-sm btn-danger" onclick="del({{ $row->ID }})">{{ __('删除') }}</button>
+                            </td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script>
+    function add(){
+        layer.open({
+            type:2,shade:0.8,area:['50%','70%'],
+            content:'/admin/protect-level/add'
+        });
+    }
+    function edit(id){
+        layer.open({
+            type:2,shade:0.8,area:['50%','70%'],
+            content:'/admin/protect-level/edit/'+id
+        });
+    }
+    function del(id){
+        myConfirm('确认删除?', function(){
+            myRequest('/admin/protect-level/delete/'+id,'post',{},function(){
+                layer.msg('已删除'); location.reload();
+            });
+        });
+    }
+</script>
+@endsection

+ 5 - 1
routes/web.php

@@ -832,7 +832,11 @@ Route::group([
 
         $route->any('/game_data/user_detail', 'Admin\GameDataController@userDetail');
         $route->any('/user_total/list', 'Admin\GameDataController@userTotalList');
-
+        // vip 等级配置管理
+        $route->get('/protect-level', 'Admin\ProtectLevelController@index');
+        $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');
     });
 
 });