| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?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) > 10) {
- return json_error([],'玩家RTP区间不能超过10个');
- }
- $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();
- }
- }
|