<!doctype html>
@extends('base.base')
@section('base')
<!-- 内容区域 -->
<style type="text/css">
    /*.table th {*/
    /*    padding: 0.5375rem;*/
    /*    vertical-align: top;*/
    /*    border-top: 1px solid #ebedf2;*/
    /*}*/

</style>
<div class="main-panel">
    <div class="content-wrapper">
        <div class="page-header">
            <h3 class="page-title">
                     <span class="page-title-icon bg-gradient-primary text-white mr-2">
                        <i class="mdi mdi-settings"></i>
                    </span>
                {{ __('auto.群控配置') }}
            </h3>
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="#">{{ __('auto.用户控制') }}</a></li>
                    <li class="breadcrumb-item active" aria-current="page">{{ __('auto.群控配置') }}</li>
                </ol>
            </nav>
        </div>
        <div class="row">
            <div class="col-lg-12 grid-margin stretch-card">
                <div class="card">
                    <div class="card-body">
                        <h4 class="card-title">{{ __('auto.群控配置') }}</h4>
                        <form class="well form-inline margin-top-20" method="get"
                              action='/admin/group_control/control'>
                            <span style="padding-left: 5px">{{ __('auto.游戏：') }}</span>
                            <select class="form-control" name="kind_id" value="{{$kind_id}}" id="select"
                                    onchange="gradeChange(this.options[this.options.selectedIndex].value)">
                                <option value="">{{ __('auto.选择游戏') }}</option>
                                @foreach($game_name as $k=>$v)
                                    <option value="{{$k}}" @if($k==$kind_id) selected @endif >{{$v}}</option>
                                @endforeach
                            </select>
                            <span style="padding-left: 5px">{{ __('auto.房间：') }}</span>
                            <select class="form-control" name="game_level" value="" id="game_level">
                                <option value="">{{ __('auto.选择房间') }}</option>
                                @foreach($room_list as $k=>$v)
                                    <option value="{{$v->GameID}}-{{$v->SortID}}"
                                            @if(($v->GameID.'-'.$v->SortID)==$game_level) selected @endif>{{$v->RoomName}}</option>
                                @endforeach
                            </select> &nbsp;&nbsp;
                            <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                            <a href="/admin/group_control/control"
                               class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}&{{ __('auto.刷新') }}</a>
                        </form>
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th width="6%">{{ __('auto.游戏') }}ID</th>
                                <th width="6%">{{ __('auto.房间场次') }}</th>
                                <th width="6%">{{ __('auto.游戏名称') }}</th>
                                <th width="6%">{{ __('auto.房间累计税收') }}</th>
                                <th width="6%">{{ __('auto.房间累计暗税') }}</th>
                                <th width="6%">{{ __('auto.游戏房间') }}</th>
                                <th width="6%">{{ __('auto.游戏库存') }}</th>

                                <th width="6%">{{ __('auto.当日房间流水') }}</th>
                                <th width="6%">{{ __('auto.当日房间输赢') }}</th>
                                <th width="6%">{{ __('auto.当前杀率') }}</th>
                                <th width="6%">{{ __('auto.当前触发系统输概率') }}</th>
                                <th width="6%">{{ __('auto.当前触发系统赢概率') }}</th>
                                <th width="15%">{{ __('auto.操作') }}</th>
                            </tr>
                            </thead>
                            <tbody>

                            {{ gamesButton('/admin/group_control/control') }}

                            @foreach($list as $k=>$v)
                                <tr>
                                    <td>{{ $v->GameID }}</td>
                                    <td>{{$v->SortIDTxt}}</td>
                                    <td>{{ $v->KindName }}</td>
                                    <td>{{ $v->Revenue}}</td>
                                    <td>{{ $v->RevenueD}}</td>
                                    <td>{{ $v->RoomName }}</td>
                                    <td id="stock">{{ $v->Stock }}</td>
                                    <td>{{$v->TurnOver}}</td>
                                    <td>{{$v->Winlost}}</td>
                                    <td>{{$v->ShaLv}} %</td>
                                    <td>
                                        @if (!empty($v->LostRate))
                                            {{ __('auto.系统') }} <span style="color: green">{{ __('auto.输') }}</span> {{ __('auto.玩家') }}{{$v->LostRate}}
                                        @endif
                                    </td>
                                    <td>
                                        @if (!empty($v->WinRate))
                                            {{ __('auto.系统') }} <span style="color: red">{{ __('auto.赢') }}</span> {{ __('auto.玩家') }}{{$v->WinRate}}
                                        @endif
                                    </td>

                                    <td>

                                        <button type="button" class="btn btn-sm btn-gradient-dark"
                                                onclick="sync_res(this,{{$v->GameID}},{{$v->SortID}})">
                                            {{ __('auto.刷新') }}
                                        </button>

                                        <button type="button" class="btn btn-sm btn-facebook btn-icon-text"
                                                onclick="show({{$v->GameID}},{{$v->SortID}})">
                                            {{ __('auto.查配置') }}

                                        </button>
                                        <button type="button"
                                                class="btn btn-sm btn-gradient-danger btn-icon-text"
                                                {{--                                                onclick="update_stock({{$v->ServerID}})">--}}
                                                onclick="update_stock({{$v->GameID}},{{$v->SortID}})">
                                            {{ __('auto.修改库存') }}
                                        </button>


                                        @if ($v->GameID == 3000)
                                            <button type="button" class="btn btn-sm btn-facebook btn-icon-text"
                                                    onclick="award_allocation()">
                                                {{ __('auto.奖项配置') }}
                                            </button>
                                        @endif
                                        @if ($v->GameID == 3050)
                                            <button type="button" class="btn btn-sm btn-facebook btn-icon-text"
                                                    onclick="gemstone()">
                                                {{ __('auto.奖项配置') }}
                                            </button>
                                            <button type="button" class="btn btn-sm btn-facebook btn-icon-text"
                                                    onclick="LuckyGemstoneMul()">
                                                {{ __('auto.钻石倍数') }}
                                            </button>

                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <div class="box-footer clearfix">
                            {{ __('auto.总共') }} <b>{{ $list->appends([
    'kind_id'=>$kind_id,
    'gameType' => $gameType,
    'game_level' => $game_level
    ])->total() }}</b>
                            {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                            {!! $list->links() !!}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    function award_allocation() {
        var page = layer.open({
            type: 2,
            title: '{{ __('auto.奖项配置') }}',
            shadeClose: true,
            shade: 0.8,
            area: ['70%', '70%'],
            content: '/admin/group_control/award_allocation'
        });
    }
    function gemstone() {
        var page = layer.open({
            type: 2,
            title: '{{ __('auto.奖项配置') }}',
            shadeClose: true,
            shade: 0.8,
            area: ['70%', '70%'],
            content: '/admin/group_control/gemstone'
        });
    }
    function LuckyGemstoneMul() {
        var page = layer.open({
            type: 2,
            title: '{{ __('auto.奖项配置') }}',
            shadeClose: true,
            shade: 0.8,
            area: ['70%', '70%'],
            content: '/admin/group_control/LuckyGemstoneMul'
        });
    }


    function edit(id) {
        var page = layer.open({
            type: 2,
            title: '{{ __('auto.配置修改') }}',
            shadeClose: true,
            shade: 0.8,
            area: ['70%', '70%'],
            content: '/admin/gold/gameconfig/update/' + id
        });
    }

    function show(GameID, SortID) {
        layer.ready(function () {
            // 弹框代码
            var page = layer.open({

                type: 2,
                title: '{{ __('auto.查看配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '70%'],

                content: '/admin/group_control/show_control_config/' + GameID + '?SortID=' + SortID,

            });
        })
    }

    // 修改库存
    function update_stock(GameID, SortID) {

        var page = layer.open({
            type: 2,
            title: '{{ __('auto.修改库存') }}',
            shadeClose: true,
            shade: 0.8,
            area: ['70%', '70%'],
            content: '/admin/gold/update_stock/' + GameID + '?SortID=' + SortID
        });

    }

    // 更新库存
    function sync_res(obj, GameID, SortID) {

        // 库存
        var Revenue = $(obj).parents('tr').find('td').eq(3);
        var RevenueD = $(obj).parents('tr').find('td').eq(4);
        var Stock = $(obj).parents('tr').find('td').eq(6);
        var TurnOver = $(obj).parents('tr').find('td').eq(7);
        var Winlost = $(obj).parents('tr').find('td').eq(8);
        var ShaLv = $(obj).parents('tr').find('td').eq(9);
        var LostRate = $(obj).parents('tr').find('td').eq(10);
        var WinRate = $(obj).parents('tr').find('td').eq(11);

        // 税收
        // var revenue = $(obj).parents('tr').find('td').eq(3);

        myRequest("/admin/group_control/sync_res/" + GameID, "post", {SortID}, function (res) {

            layer.msg(res.msg)
            if (res.code == 200) {

                LostRateText = WinRateText = ''

                if (res.data.LostRate != '') {
                    LostRateText = `{{ __('auto.系统') }} {{ __('auto.输') }} {{ __('auto.玩家') }}` + res.data.LostRate
                }

                if (res.data.WinRate != '') {
                    WinRateText = `{{ __('auto.系统') }} {{ __('auto.赢') }} {{ __('auto.玩家') }}` + res.data.WinRate
                }


                Revenue.text(res.data.Revenue);
                RevenueD.text(res.data.RevenueD);
                Stock.text(res.data.Stock);
                TurnOver.text(res.data.TurnOver);
                Winlost.text(res.data.Winlost);
                ShaLv.text(res.data.ShaLv + '%');
                LostRate.text(LostRateText);
                WinRate.text(WinRateText);

            }

        });

    }

    function gradeChange(value) {

        myRequest("/admin/group_control/roomList", "post", {'GameID': value}, function (res) {
            var data = res.data
            var html = ''
            for (var i of data) {
                html += '<option value=' + i['GameID'] + '-' + i['SortID'] + '>' + i['RoomName'] + '</option>'
            }
            console.log(html)
            $("#game_level").html(html)
        });
    }

</script>
@endsection
