<?php if( !defined( 'ONGPHP')) exit( 'Error ONGSOFT');
$D = db('');
$shezhi = $Mem1->g('shezhi');

$m = isset($_GET['m']) ? $_GET['m'] :'index';

$tong = tongjiz();//用户总充值  

//dump($tong);exit;
$tiaojian = array( 
      'id' => $_SESSION['houid']
    ) ;
$order = '  ';
$hou = $D -> setbiao('admin') -> where( $tiaojian ) ->order(  ) -> find();

$houtype = $hou['type'];
$chonddz = $hou['huobi']*$shezhi['daili'];

//dump($chonddz);exit;
//dump($_SESSION['houid']);exit;

?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>设置</title>
	<script type="text/javascript" src="/jquery-2.1.1.js"></script>
	<link rel="stylesheet" type="text/css" href="/layui/css/layui.css">
	<script type="text/javascript" src="/layui/layui.js" ></script>
	<link rel="stylesheet" type="text/css" href="/webuploader/webuploader.css">

<!--引入JS-->
<script type="text/javascript" src="/webuploader/webuploader.js"></script>

</head>
<body>

<style type="text/css">
	
.manman{
	padding: 2%;
}

</style>



<?php 
//dump($houtype);exit;


if ($houtype==1) {
    //    

    
$D = db('');
/*查询当前代理下的总用户*/
$order = '  ';
$tiaojian = array(
  'adminid' => $_SESSION['houid'],
  );




    $order = '  ';
    $tiaojian = array(
      'zhongjiangtype !='=>0
      );
    $rs = $D -> setbiao('jinelog') -> order(  )->where( $tiaojian )-> select();








?>
<div class="manman">
  






<form class="layui-form layui-form-pane" action=""   id="biaobiao">
   
<div class="layui-form-item">
    <label class="layui-form-label">推广地址</label>
    <div class="layui-input-block">
      <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input" 

      <?php 
        if ($shezhi['youxiyuming']!='') {
          ?>
          value="<?php echo $shezhi['youxiyuming'] ?>tg.php?fenxiao=<?php echo $_SESSION['houid'] ?>"
          <?php
        }else{
          ?>
             value="<?php echo WZHOST ?>tg.php?fenxiao=<?php echo $_SESSION['houid'] ?>"
          <?php
        }
      ?>
   


      >
    </div>
  </div>
<!-- quxiao-->

  <div class="layui-form-item">
    <label class="layui-form-label">二维码</label>
    <div class="layui-input-block">
    	
    <div class="chakan layui-btn">
    	查看图片

    </div>




    </div>
<div style="display: none;" id="tupian1" > <span style="position: absolute;background: #fff;padding: 5px 10px;margin-left: 371px; cursor: pointer;" id="guanbi">X</span>
	
  <img src="daili.php?fenxiao=<?php echo $_SESSION['houid']  ?>"  >

</div>

  
  </div>

<script type="text/javascript">
jQuery(function(){
	
	jQuery(".chakan").click(function(){
		jQuery("#tupian1").show();
	})

	jQuery("#guanbi").click(function(){
		jQuery("#tupian1").hide();
	})


});
</script>



  <?php 





$yingli =  $tong['chongzhiz']-$tong['yongjinz']-$tong['yonghude']-$tong['dailimoney']-$tong['hongbao'];

$yingli= sprintf("%0.2f",$yingli);
  



  ?>

  </form>

  <table class="layui-table">
  <colgroup>
    <col width="">
    <col width="">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>下线未中奖消费总额</th>
      <th>代理比例</th>
      <th>结算金额</th>
      <th>已经提现</th>
      <th>剩余金额</th>
      <th>操作</th>

    </tr> 
  </thead>
  <tbody>
    <tr>
      <td>

      <?php echo $chonddz ?>元


<br>
      <span> 



      <!-- <a href="?action=tongji&m=chongzhiz">  查看详情 </a> -->
        

      </span>



      </td>

<td>

<?php 
 

  if ($shezhi['daili']!='') {
    $dailiarr = explode(',',  $shezhi['daili'] );


    if ($houtype==1) {

      $dailibi = $dailiarr[0];
    }elseif ($houtype==2) {
          $dailibi = $dailiarr[1];
    }elseif ($houtype==3) {
            $dailibi = $dailiarr[2];
    }


    echo $dailibi;


  }

?>
%

</td>

<td>
  
<?php 

  $dailibi1 = $dailibi/100;

  // $dailibi1 =1;

  // $qianbili = $shezhi['bili']/100;


/*计算给网站带来的盈利*/

  $rr1 = $chonddz * $dailibi1  ;
  echo $rr1;


 ?>
元
</td>


<td>
  

  <?php 
    
  $order = '  ';
  $tiaojian = array(
    'adminid' => $_SESSION['houid'],
    );
  
  
  $daitixian = $D -> setbiao('dailitixian') -> order(  )->where( $tiaojian )-> select();

  if ($daitixian) {
    $daia = array();
    foreach($daitixian as  $k => $v){
      $daia[] = $v['jine'];

    }

    $daiak = array_sum($daia);


  }else{
    $daiak = 0;
  }

  echo $daiak;


  ?>
元


</td>


<td>
  

<?php 
  
  $rrwww = $rr1 - $daiak;
  echo $rrwww;
?>
元

</td>


<td>
  <span class="" ><a href="?action=dailitixian&mode=add">申请提现(需满300)</a></span>
</td>



    </tr>


  </tbody>
</table>

</div>

<?php 
  

  }else{
?>


<?php 
  
  if ($m=='index') {


?>
<div class="manman">
	

	<form class="layui-form layui-form-pane" action=""   id="biaobiao">
   




   <?php 





$yingli =  $tong['chongzhiz']-$tong['yongjinz']-$tong['yonghude']-$tong['dailimoney']-$tong['hongbao'];

$yingli= sprintf("%0.2f",$yingli);
  



  ?>







  </form>




  <table class="layui-table">
  <colgroup>
    <col width="">
    <col width="">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>消费总额</th>
      <th>代理商总获得</th>
      
      <th>分销佣金总获得</th>

      <th>中奖金币总获得</th>
      
      <th>抢红包总额</th>
      
      <th>盈利</th>
    </tr> 
  </thead>
  <tbody>
    <tr>
      <td>



      <?php echo $tong['chongzhiz'] ?>元
<br>
      <span> 



      <!-- <a href="?action=tongji&m=chongzhiz">  查看详情 </a> -->
        

      </span>



      </td>
      <td><?php echo $tong['dailimoney'] ?>元

        <br>
      <span> 



      <!-- <a href="?action=tongji&m=wz">  查看详情 </a> -->
        

      </span>

      </td>
      <td><?php echo $tong['yongjinz'] ?> 元
         <br>
      <span> 

      <!-- <a href="?action=tongji&m=yongz">  查看详情 </a> -->
        

      </span>

      </td>
      
      <td><?php echo $tong['yonghude'] ?> 元
         <br>
      <span> 

      <!-- <a href="?action=tongji&m=yongz">  查看详情 </a> -->
        

      </span>

      </td>
      
      <td><?php echo $tong['hongbao'] ?> 元
         <br>
      <span> 

      <!-- <a href="?action=tongji&m=yongz">  查看详情 </a> -->
        

      </span>

      </td>
      
      <td><?php echo $yingli ?> 元</td>
    </tr>


  </tbody>
</table>

</div>

<?php 
  }elseif ($m=='chongzhiz') {


  //分页开始
  //$WHERE['guanjian OLK'] = '%'.$ju.'%';
  $D = db('jinelog');
  $WHERE['type'] = 1;
  $order = 'id desc';
  $PAGE  = (int) isset( $_GET['page']) ? $_GET['page'] : 0;
  $limit = listmit( $CONN['hnum'] ,$PAGE);
  $ZSHU = $D  ->where( $WHERE ) ->  total();
  $rs = $D ->order( $order )->where( $WHERE )-> limit( $limit )-> select();



    ?>


    <div style="padding: 2%">
      <div>

<h1 style="padding-bottom: 20px;">
  << <a href="?action=tongji">返回</a>

</h1>

      
      <h2>
  
      充值金额统计:  <?php echo $tong['chongzhiz'] ?> 元


</h2>
    </div>


    <table class="layui-table">
  <colgroup>
    <col width="">
    <col width="">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>ID</th>
      <th>会员</th>
      <th>金额</th>
      <th>时间</th>
    </tr> 
  </thead>
  <tbody>


  <?php 
   
  //分页结束
  if ($rs) {
    foreach($rs as  $k => $v){
  ?>


    <tr>
      <td>
            <?php echo $v['id']  ?>

      </td>
      <td>
        
      <?php 

      $user = uid( $v['uid'] , 1 );
    
echo $user['name'];


       ?>

      </td>
      <td>
        
      <?php echo $v['jine'] ?>

      </td>
      <td>
        
      <?php echo date("Y-m-d H:i:s",$v['atime'])?>

      </td>
    </tr>


<?php 
    }
  }
?>

    
  </tbody>




</table>


    </div>
    






    <?php
  }elseif ($m=='wz') {





 



  //分页开始
  //$WHERE['guanjian OLK'] = '%'.$ju.'%';
$D = db('jinelog');
  $WHERE['type IN'] = '4,5,6,7';


  $order = 'id desc';
  $PAGE  = (int) isset( $_GET['page']) ? $_GET['page'] : 0;
  $limit = listmit( $CONN['hnum'] ,$PAGE);
  $ZSHU = $D  ->where( $WHERE ) ->  total();
  $rs = $D ->order( $order )->where( $WHERE )-> limit( $limit )-> select();







    ?>


    <div style="padding: 2%">
      <div>

<h1 style="padding-bottom: 20px;">
  << <a href="?action=tongji">返回</a>

</h1>

      
      <h2>
  
      用户挖金额统计:  <?php echo $tong['yonghude'] ?> 元




</h2>
    </div>


    <table class="layui-table">
  <colgroup>
    <col width="">
    <col width="">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>ID</th>
      <th>会员</th>
      <th>金额</th>
      <th>描述</th>
      <th>时间</th>
    </tr> 
  </thead>
  <tbody>


  <?php 
   
  //分页结束
  if ($rs) {
    foreach($rs as  $k => $v){
  ?>


    <tr>
      <td>
            <?php echo $v['id']  ?>

      </td>
      <td>
        
      <?php 

      $user = uid( $v['uid'] , 1 );
    
echo $user['name'];


       ?>

      </td>
      <td>
        
      <?php echo $v['jine'] ?>

      </td>

      <td><?php echo $v['data'] ?></td>
      <td>
        
      <?php echo date("Y-m-d H:i:s",$v['atime'])?>

      </td>
    </tr>


<?php 
    }
  }
?>

    
  </tbody>




</table>


    </div>
    






    <?php
  


  }elseif ($m=='yongz') {



  //分页开始
  //$WHERE['guanjian OLK'] = '%'.$ju.'%';
$D = db('jinelog');
  $WHERE['type IN'] = '8';


  $order = 'id desc';
  $PAGE  = (int) isset( $_GET['page']) ? $_GET['page'] : 0;
  $limit = listmit( $CONN['hnum'] ,$PAGE);
  $ZSHU = $D  ->where( $WHERE ) ->  total();
  $rs = $D ->order( $order )->where( $WHERE )-> limit( $limit )-> select();



    ?>


    <div style="padding: 2%">
      <div>

<h1 style="padding-bottom: 20px;">
  << <a href="?action=tongji">返回</a>

</h1>

      
      <h2>
  
      用户佣金  统计:  <?php echo $tong['yongjinz'] ?> 元




</h2>
    </div>


    <table class="layui-table">
  <colgroup>
    <col width="">
    <col width="">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>ID</th>
      <th>会员</th>
      <th>金额</th>
      <th>描述</th>
      <th>时间</th>
    </tr> 
  </thead>
  <tbody>


  <?php 
   
  //分页结束
  if ($rs) {
    foreach($rs as  $k => $v){
  ?>


    <tr>
      <td>
            <?php echo $v['id']  ?>

      </td>
      <td>
        
      <?php 

      $user = uid( $v['uid'] , 1 );
    
echo $user['name'];


       ?>

      </td>
      <td>
        
      <?php echo $v['jine'] ?>

      </td>

      <td><?php echo $v['data'] ?></td>
      <td>
        
      <?php echo date("Y-m-d H:i:s",$v['atime'])?>

      </td>
    </tr>


<?php 
    }
  }
?>

    
  </tbody>




</table>


    </div>
    

    <?php
  


  

  }
?>

<?php 
  }
?>

</body>
<script>
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form()
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
  
  //创建一个编辑器
  var editIndex = layedit.build('LAY_demo_editor');
 
  //自定义验证规则
  form.verify({
    title: function(value){
      if(value.length < 5){
        return '标题至少得5个字符啊';
      }
    }
    ,pass: [/(.+){6,12}$/, '密码必须6到12位']
    ,content: function(value){
      layedit.sync(editIndex);
    }
  });
  
  //监听指定开关
  form.on('switch(switchTest)', function(data){
    // layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
    //   offset: '6px'
    // });
    // layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
  });
  
  //监听提交
  form.on('submit(demo1)', function(data){
    layer.alert(JSON.stringify(data.field), {
      title: '最终的提交信息'
    })
    return false;
  });
  
  
});
</script>









<script type="text/javascript">
jQuery(function(){

  /*删除*/
  jQuery(".shanchu").click(function(){
    var p = jQuery(this).parent('.ss');
    p.remove();

  })

  /*增加提现规则*/

  jQuery(".adtixcian").click(function(){
      
      jQuery("#tixian").append('<input type="text" name="data[tixian][]" autocomplete="off" placeholder="" class="layui-input"  >');

  })

  /*增加邀请规则*/
  jQuery(".adyaoqing").click(function(){

    jQuery("#yaoqing").append('<input type="text" name="data[yaoqing][]" autocomplete="off" placeholder="" class="layui-input"  >');

  })




  /*增加作弊*/
  jQuery(".adzuobi").click(function(){
    
    jQuery("#zuobi").append('<input type="text" name="data[zuobi][]" autocomplete="off" placeholder="" class="layui-input"  >');

  })

  /*增加规则*/

  jQuery(".adguize").click(function(){
    jQuery("#guieze").append('<input type="text" name="data[guize][]" autocomplete="off" placeholder="" class="layui-input"  >');

  })


  	jQuery(".tijiaoshezhi").click(function(){

        var biaobiao = jQuery("#biaobiao").serialize();
        var data = biaobiao+'&action=shezhi';

        $.ajax({
          async: true,
          type:"POST",
          url:"?action=ajax",
          data:data,
          dataType:'json',
          success:function(data){
            if (data.o=='yes') {
              alert('更新成功');
              location.reload(true);
            }


            
          }



        })



	})
});
</script>


<script type="text/javascript">
  

   // 初始化Web Uploader
    var uploader = WebUploader.create({
        // 选完文件后，是否自动上传。
        auto: true,
            fileVal: 'all',
        // swf文件路径
        swf:   'http://cdn.staticfile.org/webuploader/0.1.0/Uploader.swf',
        // 文件接收服务端。
        server: '<?php  echo '?action=ajax&upload=yes&uplx=all'?>',

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#filePicker',

        // 只允许选择图片文件。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/jpg,image/jpeg,image/png'
        }
    });



    // 文件上传成功，给item添加成功class, 用样式标记上传成功。
    uploader.on( 'uploadSuccess', function( file,respond ) {
        var tupian = respond.url;
        jQuery(".tpul").html('');

        jQuery(".tpul").append('<li><img style="width:100px;" src="'+tupian+'" alt=""><input type="hidden" name="data[beijing]" value="'+tupian+'" /> </li>');
    });

</script>

</html>