<extend name="Public/base"/>

<block name="body">
  <link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
  <script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
  <script type="text/javascript" src="__JS__/select2.min.js"></script>
  <style>
    .select2-container--default .select2-selection--single {
      color: #000;
      resize: none;
      border-width: 1px;
      border-style: solid;
      border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
      box-shadow: 0px 3px 3px #F7F8F9 inset;height:35px;
      height:28px;border-radius:3px;font-size:12px;
    }
    .select2-container--default .select2-selection--single .select2-selection__rendered {
      line-height:35px;
      line-height:28px;
    }
    .select2-container--default .select2-selection--single .select2-selection__arrow {
      height:26px;
    }
    .select2-container--default .select2-search--dropdown .select2-search__field {
      height:26px;line-height:26px;font-size:12px;
    }
    .select2-results__option[aria-selected] {font-size:12px;}

    .tooltip {
      position: relative;
      display: inline-block;
      color: #056dae;
    }

    .tooltip .tooltiptext {
      visibility: hidden;
      width: 250%;
      background-color: #fff;
      color: #fff;
      text-align: center;
      border-radius: 6px;
      padding: 5px 0;
      position: absolute;
      z-index: 1;
      bottom: 80%;
      left: 0;
      margin-left: -70%;
      border: #000 solid 1px;
    }

    .tooltip .tooltiptext::after {
      content: "";
      position: absolute;
      top: 100%;
      left: 50%;
      margin-left: -5px;
      border-width: 5px;
      border-style: solid;
      border-color: black transparent transparent transparent;
    }

    .tooltip:hover .tooltiptext {

      color: #000;
      visibility: visible;
      line-height: 20px;
    }

  </style>

  <div class="cf main-place top_nav_list navtab_list">

    <h3 class="page_title">支付渠道统计</h3>
    <p class="description_text">说明:平台币直充金额2019.12.18以前sdk新包数据及sdk旧包数据,无法对应相关游戏无法计入以上平台币列表中,<span style="color:red">充值方式统计</span>一栏统计<span style="color:red">平台币直充总金额</span></p>
    <div class="fr">
      <a class="tabchose" href="">游戏充值统计</a>
      <a class="" href="{:U('Finance/payTypeStatistics')}">充值方式统计</a>
    </div>
  </div>

  <div class="cf top_nav_list">

    <!-- 高级搜索 -->
    <div class="jssearch fl cf search_list">
      <!--游戏类型搜索END-->

<!--      <div class="input-list input-list-promote search_label_rehab">-->
<!--        <select id="count_date" name="count_date" class="select_gallery" style="width:150px;">-->
<!--          <option value="">请选择月份</option>-->
<!--          <volist name=":getMonth()" id="vo">-->
<!--            <option value="{$vo}" <if condition="$vo eq $_GET['count_date']">selected=selected</if>>{$vo}</option>-->
<!--          </volist>-->
<!--        </select>-->
<!--      </div>-->
<!--      <div class="input-list input-list-server search_label_rehab">-->
<!--        <select id="partner_id" name="partner_id" class="select_gallery"  style="width:120px;">-->
<!--          <option value="">请选择合作方</option>-->
<!--          <volist name=":getPartner()" id="vo">-->
<!--            <option partner-id="{$vo.id}" value="{$vo.id}" <if condition="$vo.id eq $_GET['partner_id']">selected=selected</if>>{$vo.partner}</option>-->
<!--          </volist>-->
<!--        </select>-->
<!--      </div>-->
      <div class="input-list input-list-game search_label_rehab">
        <select id="game_name" name="game_id" class="select_gallery" >
          <option value="">游戏名称</option>
        </select>
      </div>

      <div class="input-list">
        <input type="text" id="timestart" name="timestart" class="" value="{:I('timestart')}" placeholder="下单开始时间" autocomplete="off"/>
        -
        <div class="input-append date" id="datetimepicker"  style="display:inline-block">
          <input type="text" id="timeend" name="timeend" class="" value="{:I('timeend')}" placeholder="下单结束时间" autocomplete="off"/>
          <span class="add-on"><i class="icon-th"></i></span>
        </div>
      </div>

      <input type="hidden" name="" value="" class="sortBy">
      <div class="input-list">
        <a class="sch-btn" href="javascript:;" id="search" url="{:U('PayChannel/index','model='.$model['name'].'&row='.I('row'),false)}"
           style="width: 100px;border: #3C95C8 solid 1px;">搜索</a>
        <a class="sch-btn" href="{:U('/PayChannel/index/export/1',
                array_merge(array('export'=>1),I('get.'))
                ,false)}" style="width: 100px;border: #3C95C8 solid 1px;">导出</a>
      </div>
    </div>
  </div>


  <!-- 数据列表 -->
  <div class="data_list">
    <empty name="show_status">
    <div class="">
      <table>
        <!-- 表头 -->
        <thead>
        <tr>

          <th ><div class="tooltip">产品名称<span class="tooltiptext"><span style="margin-left: -10px">平台官网,超级签,游戏等等产品</span></span></div></th>

          <th ><div class="tooltip">游戏现金金额<span class="tooltiptext"><span style="margin-left: -10px">第三方支付充值到游戏的金额</span></span></div></th>

          <th ><div class="tooltip">平台币直充金额<span class="tooltiptext"><span style="margin-left: -10px">玩家在游戏内充值到SDK(余额-平台币)内平台币的金额</span></span></div></th>

          <th ><div class="tooltip">测试金额<span class="tooltiptext"><span style="margin-left: -10px">测试环境白名单下测试账号所产生的测试金额。只展示充值成功通知成功的订单</span></span></div></th>

          <th ><div class="tooltip">支付渠道内合计<span class="tooltiptext"><span style="margin-left: -10px">超级签金额+游戏现金金额+平台币直充+测试金额</span></span></div></th>

          <th >操作</th>
        </tr>
        </thead>
        <!-- 列表 -->
        <tbody>
        <style>
          .data-table thead th, .data-table tbody td{text-align:center}
          .data-table tbody td{border-right:1px solid #DDDDDD;}
          .d_list .drop-down ul {z-index:999;}
        </style>
<!--        <if condition = "empty($data)">-->
<!--          <tr>-->
<!--            <td colspan="14" class="text-center">aOh! 暂时还没有内容!</td>-->
<!--          </tr>-->
<!--        </if>-->
        <notemtpy name = "listdata">
          <volist name="listdata" id="data">
            <tr>
              <td >{$data.game_name}</td>
              <td>
<!--                onclick="showWindow({$data.game_id})"-->
              {$data['pay_amount']}</td>
              <td >{$data['platform_coin']}</td>
              <td ><a href="{:U('PayChannel/testDetail',array_merge(array('game_id'=>$data['game_id'],'game_name'=>$data['game_name']),I('get.'),['p'=>1]))}" style="display:block;">{$data['test_coin']}</a></td>
              <td >{$data['sum']}</td>
              <td >
                <a href="{:U('PayChannel/gameDetail',array_merge(array('game_id'=>$data['game_id'],'game_name'=>$data['game_name'].'游戏'),I('get.'),['p'=>1]))}" >订单查看</a>
              </td>
            </tr>
          </volist>
          <if condition="$_GET['game_id'] eq ''">
            <tr>
              <td><span>超级签</span></td>
              <td ><span><if condition="$superSignData.pay_amount neq ''">{$superSignData['pay_amount']}<else/>0.00</if></span></td>
              <td>0.00</td>
              <td><span><a href="{:U('PayChannel/testDetail',array_merge(array('model'=>'game_supersign','game_name'=>'超级签'),I('get.'),['p'=>1]))}" style="display:block;"><if condition="$superSignData.test_coin neq ''">{$superSignData.test_coin}<else/>0.00</if></a></span></td>
              <td><if condition="$superSignData.pay_amount neq ''">{$superSignData['sum']}<else/>0.00</if></td>
              <td>
                <a href="{:U('SuperStatistical/index',array_merge(array('model'=>'game_supersign','game_name'=>'超级签'),I('get.'),['p'=>1]))}" >订单查看</a>
              </td>
            </tr>
            <tr>
              <td><span>官网</span></td>
              <td >0.00</td>
              <td>{$offcialData['pay_amount']}</td>
              <td><a href="{:U('PayChannel/testDetail',array_merge(array('model'=>'deposit','game_name'=>'官网'),I('get.'),['p'=>1]))}" style="display:block;"><if condition="$offcialData.test_coin neq ''">{$offcialData.test_coin}<else/>0.00</if></a></td>
              <td><if condition="$offcialData.pay_amount neq ''">{$offcialData['sum']}<else/>0.00</if></td>
              <td>
                <a href="{:U('PayChannel/gameDetail',array_merge(array('id'=>21,'model'=>'deposit','game_name'=>'官网'),I('get.'),['p'=>1]))}" >订单查看</a>
              </td>
            </tr>
            <tr>
              <td><span>推广后台</span></td>
              <td ><span>0.00</span></td>
              <td>{$spreadData['pay_amount']}</td>
              <td>0.00</td>
              <td><if condition="$spreadData['pay_amount'] neq ''">{$spreadData['sum']}<else/>0.00</if></td>
              <td>
                <a href="{:U('PayChannel/gameDetail',array_merge(array('id'=>21,'model'=>'coin_pay_order','game_name'=>'推广后台'),I('get.'),['p'=>1]))}" >订单查看</a>
              </td>
            </tr>
          </if>
          <tr>
            <td><span>汇总</span></td>
            <td ><span><if condition="$sumData.pay_amount neq ''">{$sumData['pay_amount']}<else/>0.00</if></span></td>
            <td><span><if condition="$sumData.platform_coin neq ''">{$sumData['platform_coin']}<else/>0.00</if></span></td>
            <td>{$sumData['test_coin']}</td>
            <td><if condition="$sumData['sum'] neq ''">{$sumData['sum']}<else/>0.00</if></td>
            <td>
              <a href="#" >------</a>
            </td>
          </tr>
          <tr>
            <td><span>测试环境内外网平台</span></td>
            <td ><span><if condition="$sum_pay_amount.sum_order_amount neq ''">{$sum_pay_amount['sum_order_amount']}<else/>0.00</if></span></td>
            <td><span>0.00</span></td>
            <td>0.00</td>
            <td><if condition="$sum_pay_amount['sum_order_amount'] neq ''">{$sum_pay_amount['sum_order_amount']}<else/>0.00</if></td>
            <td>
              <a href="{:U('TestOrder/lists')}" >订单查看</a>
            </td>
          </tr>
        </notemtpy>
        <tr>
          <td><span>充值方式统计</span></td>
          <td colspan="5">
            <volist name="payTypeData" id="payTypeData" key="index">
              <if condition="$key neq '其他支付金额' and $payTypeData neq 0">
                {$key}:{$payTypeData} &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
              </if>
            </volist>
            平台币直充总金额<span style="color: red">(2019.12.18号以前的无法对应游戏记录不显示在列表中,此项也不计入充值方式统计)</span>:<if condition="$coinSum neq ''">{$coinSum}<else/>0.00</if>
          </td>
        </tr>
        <tr>
          <td><span>支付渠道</span></td>
          <td colspan="5">
            <volist name="channelData" id="channelData">
              {$channelData.pay_way}:{$channelData.pay_amount} &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
            </volist>
          </td>
        </tr>
        <tr>
          <td><span>支付渠道占比</span></td>
          <td colspan="5">
            <volist name="channelData2" id="channel">
              {$channel.pay_way}:
              <php>
                echo round($channel['pay_amount']*100/ $moneyAllCount,2) ."%&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
              </php>
            </volist>
          </td>
        </tr>
        </tbody>
      </table>
    </div>
    </empty>
  </div>
  <div class="page">
    {$_page|default=''}
  </div>

</block>

<block name="script">
  <script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
  <script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js" ></script>
  <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
  <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
  <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
  <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
  <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
  <script>
    <volist name=":I('get.')" id="vo">
      Think.setValue('{$key}',"{$vo}");
    </volist>
  </script>
  <script type="text/javascript">



    //导航高亮
    highlight_subnav('{:U('PayChannel/index')}');

    function showWindow() {
      layer.open({
        type: 2,
        title: "游戏登录记录",
        shadeClose: true,
        shade: 0.8,
        area: ['70%', '80%'],
        content: ['admin.php?s=/Member/denglu/id/', 'no']
      });
    }

    function get_game_list()
    {
      var game_name = "{:I('game_id')}";
      $.ajax({
        url:"{:U('PayChannel/getGameList')}",
        type:"post",
        data:{partner_id:$("#partner_id option:selected").val(), sdk_type:$("#sdk_version1 option:selected").val()},
        dataType:'json',
        success:function(data){
          var str = "<option value=''>请选择游戏</option>";
          for (var i in data){
            str += "<option value='"+data[i].id+"'"+(game_name && data[i].id == game_name?'selected':'')+">"+data[i].game_name+"</option>"
          }
          // console.log(str);
          $("#game_name").empty();
          $("#game_name").append(str);
          $("#game_name").select2();

        }
      })
    }
      get_game_list();
    $(function(){

      $('#timestart').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
        minView:2,
        autoclose:true
      });

      $('#datetimepicker').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
        minView:2,
        autoclose:true,
        pickerPosition:'bottom-left'
      })

      //搜索功能
      $("#search").click(function(){
        var starttime = $.trim($('#time-start').val());
        var endtime = $.trim($('#time-end').val());

        if (starttime && endtime && starttime > endtime) {layer.msg('开始时间必须小于等于结束时间');return false;}


        var url = $(this).attr('url');
        var query  = $('.jssearch').find('input').serialize();
        query  += "&" + $('.jssearch').find('select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
          url += '&' + query;
        }else{
          url += '?' + query;
        }
        window.location.href = url;
      });

      //回车自动提交
      $('.jssearch').find('input').keyup(function(event){
        if(event.keyCode===13){
          $("#search").click();
        }
      });
      $(".ljcz").click(function(){
        var id = $(this).attr('data-value');
        var game_name = "{:I('game_name')}";
        var server_name = "{:I('server_id')}";
        layer.open({
          type: 2,
          title: '游戏消费记录',
          shadeClose: true,
          shade: 0.8,
          area: ['70%', '80%'],
          content: 'admin.php?s=/Platform/chongzhi_detail/promote_id/'+id+'/game_name/'+game_name+'/server_name/'+server_name+''//iframe的url
        });
      });

      $("#partner_id").change(function(){
        $.ajax({
          url:"{:U('Finance/getGameList')}",
          type:"post",
          data:{partner_id:$("#partner_id option:selected").attr('partner-id')},
          dataType:'json',
          success:function(data){
            var str = "<option value=''>请选择游戏</option>";
            for (var i in data){
              str += "<option value='"+data[i].id+"'>"+data[i].game_name+"</option>"
            }
            console.log(str);
            $("#game_id").empty();
            $("#game_id").append(str);
            // $("#server_id").select2();

          }
        })
      });
      var game_id = "{:I('game_name')}";
      var game_server = "{:I('server_id')}";
      if(game_id){
        $.ajax({
          url:"{:U('Ajax/getSpendServer')}",
          type:"post",
          data:{game_id:game_id,type:2},
          dataType:'json',
          success:function(data){
            str = "<option value=''>请选择区服</option>";
            for (var i in data){
              str += "<option value='"+data[i].server_name+"' "+(game_server && data[i].server_name == game_server?'selected':'')+">"+data[i].server_name+"</option>"
            }
            $("#server_id").empty();
            $("#server_id").append(str);
            $("#server_id").select2();

          }
        })
      }
    })
  </script>
</block>