| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace app\controller;
- use app\BaseController;
- use app\model\GameModel;
- use app\model\MerchantsUserModel;
- use app\model\PlayerControlModel;
- use think\facade\Request;
- class PlayerControl extends BaseController
- {
- /**
- * 添加或更新 点控设置
- * {"account_ids":["115"],"game_ids":[1],"rtp":9900,"max_win_multi":500,"auto_cancel_rtp":100,"agent_id":6027,"win_pro":-1}
- */
- public function updatePlayerControl()
- {
- $userInfo = $this->request->userInfo;
- $data = Request::param([
- 'account_ids' => "",
- 'game_ids' => "",
- 'rtp' => 0,
- 'max_win_multi' => -1,
- 'auto_cancel_rtp' => -1
- ]);
- // 判断RTP
- if(empty($data['rtp'])) {
- return json_error([], 'RTP错误');
- }
- $account_ids = $data['account_ids'] ?? "";
- $game_ids = $data['game_ids'] ?? "";
- // 游戏平台ID和游戏ID不能为空
- if(empty($account_ids) || empty($game_ids)) {
- return json_error([], '平台ID和游戏ID不能为空');
- }
- $account_ids = explode(",", $account_ids);
- $game_ids = explode(",", $game_ids);
- $unameList = [];
- foreach ($account_ids as $account_id) {
- $account_id = trim($account_id);
- if(!empty($account_id)) {
- $unameList[] = $account_id;
- }
- }
- $gameList = [];
- foreach ($game_ids as $game_id) {
- $game_id = trim($game_id);
- if(!empty($game_id)) {
- $gameList[] = $game_id;
- }
- }
- // 过滤掉 游戏平台ID和游戏ID不能为空
- if(empty($unameList) || empty($gameList)) {
- return json_error([], '平台ID和游戏ID不能为空');
- }
- $allGameList = GameModel::getGames($userInfo['merchant_id']);
- $gameIds = array_column($allGameList, 'game_id');
- $emptyIds = [];
- foreach ($gameList as $gameId) {
- if(!in_array($gameId, $gameIds)) {
- $emptyIds[] = $gameId;
- }
- }
- if(!empty($emptyIds)) {
- return json_error([], "不存在游戏:" . implode(", ", $emptyIds));
- }
- $merchantsUserList = MerchantsUserModel::getPlayerListByIds($userInfo['merchant_id'], $unameList);
- $merchantsUserList = array_column($merchantsUserList, null, 'uname');
- foreach ($account_ids as $accountId) {
- $merchantsUserInfo = $merchantsUserList[$accountId] ?? [];
- if(empty($merchantsUserInfo)) {
- continue;
- }
- foreach ($game_ids as $gameId) {
- $info = PlayerControlModel::getPlayerControlInfo($userInfo['merchant_id'], $merchantsUserInfo['user_id'], $gameId);
- if(!empty($info)) {
- // 需要更新
- $item = [
- 'control_rpt' => $data['rtp'],
- 'auto_cancel_rtp' => $data['auto_cancel_rtp'], // 达到RTP值取消
- 'max_win_multi' => $data['max_win_multi'], // 最高倍数
- ];
- }else {
- $item = [
- 'app_id' => $userInfo['merchant_id'],
- 'user_id' => $userInfo['user_id'],
- 'player_id' => $merchantsUserInfo['user_id'],// 玩家id
- 'game_id' => $gameId,
- 'control_rpt' => $data['rtp'],
- 'auto_cancel_rtp' => $data['auto_cancel_rtp'], // 达到RTP值取消
- 'max_win_multi' => $data['max_win_multi'], // 最高倍数
- 'control_balance' => $merchantsUserInfo['balance'], // 设置时点控那刻当前余额
- ];
- }
- print_r($item);
- }
- }
- return json_success([],'操作成功');
- }
- }
|