Przeglądaj źródła

自动调控配置

ssvfdn 3 miesięcy temu
rodzic
commit
a2399659a3

+ 3 - 0
app/common.php

@@ -10,6 +10,9 @@ $GLOBALS['token_key_secret'] = "z.1i8L?Ld+ovuA4r%4YZrz?w1Y%-NYvlrJ=TqV$[W[5=B#C[
 /// COOKIE 有效期
 $GLOBALS['cookieExpire'] = 60 * 60 * 24 * 3;
 
+// 全局默认RTP值
+$GLOBALS['defaultRTPValue'] = 97;
+
 /**
  * 响应成功json
  */

+ 96 - 0
app/controller/GameControlAutoRTPConfig.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace app\controller;
+
+use app\BaseController;
+use app\model\GameControlAutoRTPConfigModel;
+use think\facade\Request;
+
+class GameControlAutoRTPConfig extends BaseController
+{
+    /**
+     * 更新自动RTP配置
+     */
+    public function updateAutoRTPConfig()
+    {
+
+        $float_rate = Request::post('float_rate',0, 'intval');
+        $new_user_number = Request::post('new_user_number',0, 'intval');
+        $rtp_kill_data = Request::post('rtp_kill_data',[]);
+
+        if( empty($float_rate) || empty($new_user_number) || empty($rtp_kill_data)){
+            return json_error([],'参数错误');
+        }
+
+        if(count($rtp_kill_data) >= 20) {
+            return  json_error([],'玩家RTP区间不能超过20个');
+        }
+
+
+        $userInfo = $this->getUserInfo();
+
+
+        $info = GameControlAutoRTPConfigModel::where(['app_id' => $userInfo['merchant_id']])->find();
+        if(empty($info)){
+            return json_error([],'参数错误');
+        }
+        $info->float_rate = bcmul( $float_rate , 100) * 1;
+        $info->new_user_number = $new_user_number;
+
+
+        foreach ($rtp_kill_data as $idx => $item) {
+            $item['new'] = ($item['new'] ?? 0) * 100;
+            $item['old'] = ($item['old'] ?? 0) * 100;
+            $rtp_kill_data[$idx] = $item;
+        }
+        $info->rtp_kill_data = json_encode( $rtp_kill_data);
+        $info->save();
+
+        return json_success([]);
+    }
+
+    /**
+     * 获取自动RTP配置
+     * @return \think\response\Json
+     */
+    public function getAutoRTPConfigInfo()
+    {
+        $userInfo = $this->getUserInfo();
+        $autoRtpConfig = GameControlAutoRTPConfigModel::getAutoRTPConfigInfo($userInfo['merchant_id']);
+        if(empty($autoRtpConfig)){
+            return json_success([
+                'total' => 0,
+                'list' => []
+            ]);
+        }
+        return json_success([
+            'total' => 1,
+            'list' => [$autoRtpConfig]
+        ]);
+    }
+
+    /**
+     * 更新自动RTP配置状态
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function updateAutoRTPStatus()
+    {
+        $status = Request::post("status", 0, "trim");
+        $id = Request::post("id", 0, "trim");
+        if(empty($id)){
+            return json_error([],'参数错误');
+        }
+        $info = GameControlAutoRTPConfigModel::find($id);
+        if(empty($info)){
+            return json_error([],'参数错误');
+        }
+        $info->status = $status;
+        $info->save();
+        return json_success();
+    }
+
+
+}

+ 88 - 0
app/model/GameControlAutoRTPConfigModel.php

@@ -0,0 +1,88 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class GameControlAutoRTPConfigModel extends Model
+{
+    // 设置表名
+    protected $name = 'control_auto_rtp_config';
+
+    protected $connection = 'fortue_tiger';
+
+    // 设置主键
+    protected $pk = 'id';
+    // 设置自动时间戳
+    protected $autoWriteTimestamp = 'int';
+
+    // 设置字段类型
+    protected $type = [
+        'id' => 'int',
+        'app_id' => 'int', // 商户ID
+        'new_user_number' => 'int', // 定义新手玩家的游戏局数
+        'float_rate' => 'int', // 玩家RTP高于游戏设定RTP进入系统判断
+        'rtp_check' => 'int', // 游戏内统计数据周期
+        'rtp_float' => 'int', // 玩家RTP上下限的误差范围
+        'status' => 'int', // 状态 1 正常,0 取消
+        'rtp_kill_data' => 'string', // 配置列表
+        'create_time' => 'int',
+        'update_time' => 'int',
+    ];
+
+    /**
+     * 初始化 生成默认配置
+     * @param $appId
+     * @return array
+     */
+    public static function initCreateData($appId) {
+        $form = [
+            'app_id' => $appId,
+            'new_user_number' => 150,
+            'float_rate' => 15 * 100,
+            'rtp_check' => 10,
+            'rtp_float' => 2.5 * 100,
+            'status' => 1,
+            'rtp_kill_data' => [
+                ['new' => 0, 'old' => 5000,], // defaultRtpValue * 100 + float_rate ~ defaultRtpValue * 100 + float_rate + (rtp_float * 2)
+                ['new' => 500, 'old' => 5000],
+                ['new' => 1000, 'old' => 5000],
+                ['new' => 1500, 'old' => 5000],
+                ['new' => 2000, 'old' => 5000],
+                ['new' => 2000, 'old' => 5000],
+                ['new' => 2000, 'old' => 6000],
+                ['new' => 2000, 'old' => 7000],
+                ['new' => 2000, 'old' => 8000],
+                ['new' => 2000, 'old' => 9000],
+            ]
+        ];
+        $form['rtp_kill_data'] = json_encode($form['rtp_kill_data']);
+        self::create($form);
+        return $form;
+    }
+
+    public static function getAutoRtpConfigInfo($app_id, $defaultRtp = null)
+    {
+        $info = self::where(['app_id' => $app_id])->find();
+        if(empty($info)) {
+            return null;
+        }
+        $info = $info->toArray();
+        $info['rtp_kill_data'] = json_decode($info['rtp_kill_data'], true);
+        $diff_rtp = $info['rtp_float'] * 2;
+
+        $rtp = ($defaultRtp ?? $GLOBALS['defaultRTPValue']) * 100;
+        foreach ($info['rtp_kill_data'] as $idx => $item) {
+            // $start = $rtp + ($diff_rtp * $idx) + $info['float_rate'];
+            // $end = $start + $diff_rtp;
+            $item['new'] = bcdiv($item['new'], 100, 2) * 1;
+            $item['old'] = bcdiv($item['old'], 100, 2) * 1;
+            $info['rtp_kill_data'][$idx] = $item;
+        }
+
+        $info['float_rate'] = bcdiv($info['float_rate'], 100, 2) * 1;
+        $info['rtp_float'] = bcdiv($info['rtp_float'], 100, 2) * 1;
+        $info['default_rtp'] = bcdiv($rtp, 100, 2) * 1;
+        return $info;
+    }
+}

+ 8 - 0
route/app.php

@@ -58,6 +58,7 @@ Route::group('game', function () {
     Route::get('export', 'Game/export');
 })->middleware([\app\middleware\AuthMiddleware::class, \app\middleware\BehaviorLogMiddleware::class]);
 
+// 玩家点控
 Route::group('player_control', function () {
     Route::post('update', 'PlayerControl/updatePlayerControl');
     Route::get('list', 'PlayerControl/getPlayerControlList');
@@ -65,6 +66,13 @@ Route::group('player_control', function () {
     Route::post('all_cancel', 'PlayerControl/cancelAllPlayerControlInfo');
 })->middleware([\app\middleware\AuthMiddleware::class, \app\middleware\BehaviorLogMiddleware::class]);
 
+// 自动调控配置
+Route::group('auto_rtp', function () {
+    Route::post('update', 'GameControlAutoRTPConfig/updateAutoRTPConfig');
+    Route::post('status', 'GameControlAutoRTPConfig/updateAutoRTPStatus');
+    Route::get('info', 'GameControlAutoRTPConfig/getAutoRTPConfigInfo');
+})->middleware([\app\middleware\AuthMiddleware::class, \app\middleware\BehaviorLogMiddleware::class]);
+
 
 // 登录日志相关路由
 Route::group('login_log', function () {