Explorar el Código

养客全局控制

ssvfdn hace 3 meses
padre
commit
6b8a1114b8

+ 90 - 0
app/controller/GameImproveRtpGlobal.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace app\controller;
+
+use app\BaseController;
+use app\model\GameImproveRtpGlobalModel;
+use think\facade\Request;
+
+class GameImproveRtpGlobal extends BaseController
+{
+    public function getImproveRtpGlobalList()
+    {
+        $userInfo = $this->getUserInfo();
+        $info = GameImproveRtpGlobalModel::find($userInfo['merchant_id'])->toArray();
+
+        $info['evaluation_period_text'] = [
+          '1' => '每日',
+          '2' => '每周',
+          '3' => '每月',
+          '4' => '终生',
+          '5' => '自定义时间'
+        ][$info['evaluation_period']] ?? "";
+
+        if(!empty($info['custom_time_start']) && !empty($info['custom_time_end'])) {
+            $info['custom_time_start'] = date('Y-m-d H:i:s', $info['custom_time_start']);
+            $info['custom_time_end'] = date('Y-m-d H:i:s', $info['custom_time_end']);
+        }
+
+        return json_success(['total' => 1, 'list' => [$info]]);
+    }
+
+    public function updateImproveRtpGlobalStatus()
+    {
+        $status = Request::param('status', '', 'trim');
+        if(!in_array($status, ['0', '1'])){
+            return json_error([], '参数错误');
+        }
+        $userInfo = $this->getUserInfo();
+        $info = GameImproveRtpGlobalModel::find($userInfo['merchant_id']);
+        $info->status = $status;
+        $info->save();
+        return json_success([],'操作成功');
+    }
+
+    public function updateImproveRtpGlobalInfo()
+    {
+        $userInfo = $this->getUserInfo();
+
+        try{
+            $data = Request::param([
+                'net_income' => 100, // 设定玩家在游戏内盈利值达到后关闭功能
+                'turnover_multiple' => 5, //达到设定流水倍数关闭提升状态
+                'evaluation_period' => 4, // 系统控制的触发周期选择
+                'effective_count' => 1, //周期内可被系统控制的次数
+                'trigger_interval_rounds' => 300, // 每次系统控制间隔局数
+            ], 'post', 'trim');
+            foreach ($data as $k => $v) {
+                if(empty($v)) {
+                    return json_error([], '参数错误');
+                }
+            }
+            $custom_time_start = Request::post('custom_time_start', '', 'trim');
+            $custom_time_end = Request::post('custom_time_end', '', 'trim');
+            if($data['evaluation_period'] == 5) {
+                if(empty($custom_time_start) || empty($custom_time_end)) {
+                    return json_error([], '参数错误');
+                }
+            }
+
+
+            $info = GameImproveRtpGlobalModel::find($userInfo['merchant_id']);
+            // 更新
+            $info->effective_count = $data['effective_count'];
+            $info->evaluation_period = $data['evaluation_period'];
+            $info->net_income = $data['net_income'];
+            $info->trigger_interval_rounds = $data['trigger_interval_rounds'];
+            $info->turnover_multiple = $data['turnover_multiple'];
+            $info->custom_time_start = !empty($custom_time_start) ?  strtotime($custom_time_start) : 0;
+            $info->custom_time_end = !empty($custom_time_end) ?  strtotime($custom_time_end) : 0;
+
+            $info->save();
+
+            return json_success([],'操作成功');
+        }catch (\Exception $e){
+            return json_error([], "更新全局养客功能错误:". $e->getMessage());
+        }
+
+    }
+
+}

+ 53 - 0
app/model/GameImproveRtpGlobalModel.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class GameImproveRtpGlobalModel extends Model
+{
+    // 设置表名
+    protected $name = 'improve_rtp_global_control';
+
+    // 设置主键
+    protected $pk = 'app_id';
+
+    protected $connection = 'fortue_tiger';
+
+
+    // 设置自动时间戳
+    protected $autoWriteTimestamp = 'int';
+
+    // 设置字段类型
+    protected $type = [
+        'app_id' => 'int', // 商户ID
+        'effective_count' => 'int', // 周期内可被系统控制的次数
+        'evaluation_period' => 'int', // 系统控制的触发周期选择
+        'net_income' => 'int', // 设定玩家在游戏内盈利值达到后关闭功能
+        'trigger_interval_rounds' => 'int', // 每次系统控制间隔局数
+        'turnover_multiple' => 'int', // 达到设定流水倍数关闭提升状态
+        'custom_time_start' => 'int', // 周期自定义时间
+        'custom_time_end' => 'int', // 周期自定义时间
+        'status' => 'int', // 状态 1 正常,0 取消
+        'create_time' => 'int',
+        'update_time' => 'int',
+    ];
+
+    public static function initCreateGlobal($app_id) {
+        self::create([
+            'app_id' => $app_id,
+            'status' => 1,
+            'effective_count' => 1,
+            'evaluation_period' => 4,
+            'net_income' => 100,
+            'trigger_interval_rounds' => 300,
+            'turnover_multiple' => 5,
+            'custom_time_start' => 0,
+            'custom_time_end' => 0,
+        ]);
+    }
+
+    public static function getInfo($app_id) {
+        return self::find($app_id);
+    }
+}

+ 48 - 0
app/model/GameImproveRtpUsersGlobalModel.php

@@ -0,0 +1,48 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class GameImproveRtpUsersGlobalModel extends Model
+{
+    // 设置表名
+    protected $name = 'improve_rtp_users_global_control';
+    // 设置主键
+    protected $pk = 'id';
+
+    protected $connection = 'fortue_tiger';
+
+
+    // 设置自动时间戳
+    protected $autoWriteTimestamp = 'int';
+
+    // 设置字段类型
+    protected $type = [
+        'id' => 'int',
+        'app_id' => 'int', // 商户ID
+        'user_id' => 'int', // 用户ID
+        'bet_amount' => 'int', // 点控期间 下注总分数
+        'bet_count' => 'int', // 点控期间 下单总数量
+        'total_win_amount' => 'int', // 点控期间总输赢
+        'winning_score' => 'int',
+        'status' => 'int', // 状态 1 正常,0 取消
+        'round_status' => 'int', // 轮开始 1 开始, 2 已满足
+        'round_count' => 'int',
+        'open_status_time' => 'int', // 每轮开始的时间
+        'create_time' => 'int',
+        'update_time' => 'int',
+        'end_time' => 'int',
+    ];
+
+    public static function getUserInfo($app_id, $user_id)
+    {
+        $where = ['app_id' => $app_id, 'user_id' => $user_id];
+        $info = self::where($where)->find();
+        if (empty($info)) {
+            self::create($where);
+            $info = self::where($where)->find();
+        }
+        return $info;
+    }
+}

+ 5 - 0
route/app.php

@@ -79,6 +79,11 @@ Route::group('improve_user_rtp', function () {
     Route::get('list', 'GameImproveUserRtp/getGameImproveUserList');
     Route::post('cancel', 'GameImproveUserRtp/cancelGameImproveUserRtp');
     Route::post('all_cancel', 'GameImproveUserRtp/cancelAllGameImproveUserRtp');
+
+    Route::get('global/list', 'GameImproveRtpGlobal/getImproveRtpGlobalList');
+    Route::post('global/update', 'GameImproveRtpGlobal/updateImproveRtpGlobalInfo');
+    Route::post('global/status', 'GameImproveRtpGlobal/updateImproveRtpGlobalStatus');
+
 })->middleware([\app\middleware\AuthMiddleware::class, \app\middleware\BehaviorLogMiddleware::class]);
 
 // 登录日志相关路由