user2.inc.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. global $_GPC, $_W;
  3. $GLOBALS['frames'] = $this->getMainMenu();
  4. $where= " where uniacid=:uniacid";
  5. $data[':uniacid']=$_W['uniacid'];
  6. if($_GPC['keywords']){
  7. $where.=" and name LIKE concat('%', :name,'%')";
  8. $data[':name']=$_GPC['keywords'];
  9. }
  10. $pageindex = max(1, intval($_GPC['page']));
  11. $pagesize=10;
  12. $sql="select * from " . tablename("zhtc_user") .$where." order by id desc";
  13. $select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
  14. $list = pdo_fetchall($select_sql,$data);
  15. $total=pdo_fetchcolumn("select count(*) from " . tablename("zhtc_user") .$where,$data);
  16. $pager = pagination($total, $pageindex, $pagesize);
  17. for($i=0;$i<count($list);$i++){
  18. $userid=$list[$i]['id'];
  19. $yxtime=time()-60*60*24*7;
  20. $yxnum=count(pdo_fetchall("select * from ".tablename("zhtc_userformid")." where user_id={$userid} and UNIX_TIMESTAMP(time)>={$yxtime}"));
  21. $list[$i]['yxnum']=$yxnum;
  22. }
  23. if($_GPC['op']=='delete'){
  24. $res4=pdo_delete("zhtc_user",array('id'=>$_GPC['id']));
  25. if($res4){
  26. message('删除成功!', $this->createWebUrl('user2'), 'success');
  27. }else{
  28. message('删除失败!','','error');
  29. }
  30. }
  31. if($_GPC['op']=='defriend'){
  32. $res4=pdo_update("zhtc_user",array('state'=>2),array('id'=>$_GPC['id']));
  33. if($res4){
  34. message('拉黑成功!', $this->createWebUrl('user2',array('page'=>$_GPC['page'])), 'success');
  35. }else{
  36. message('拉黑失败!','','error');
  37. }
  38. }
  39. if($_GPC['op']=='relieve'){
  40. $res4=pdo_update("zhtc_user",array('state'=>1),array('id'=>$_GPC['id']));
  41. if($res4){
  42. message('取消成功!', $this->createWebUrl('user2',array('page'=>$_GPC['page'])), 'success');
  43. }else{
  44. message('取消失败!','','error');
  45. }
  46. }
  47. if(checksubmit('submit2')){
  48. $res=pdo_update('zhtc_user',array('money +='=>$_GPC['reply']),array('id'=>$_GPC['id2']));
  49. if($res){
  50. if($_GPC['reply']!=0){
  51. if($_GPC['reply']<0){
  52. $data2['type']=2;
  53. $data2['note']='后台扣款';
  54. }else{
  55. $data2['type']=1;
  56. $data2['note']='后台充值';
  57. }
  58. $data2['money']=$_GPC['reply'];
  59. $data2['user_id']=$_GPC['id2'];
  60. $data2['time']=date('Y-m-d H:i:s');
  61. $res2=pdo_insert('zhtc_qbmx',$data2);
  62. if($res2){
  63. message('充值成功!', $this->createWebUrl('user2'), 'success');
  64. }else{
  65. message('充值失败!','','error');
  66. }
  67. }
  68. }
  69. }
  70. if(checksubmit('submit3')){
  71. $res=pdo_update('zhtc_user',array('total_score +='=>$_GPC['score']),array('id'=>$_GPC['id3']));
  72. if($res){
  73. $data2['score']=$_GPC['score'];
  74. $data2['user_id']=$_GPC['id3'];
  75. $data2['note']='后台充值';
  76. $data2['type']=1;
  77. $data2['cerated_time']=date('Y-m-d H:i:s');
  78. $data2['uniacid']=$_W['uniacid'];//小程序id
  79. $res2=pdo_insert('zhtc_integral',$data2);//添加积分明细
  80. if($res2){
  81. message('充值成功!', $this->createWebUrl('user2'), 'success');
  82. }else{
  83. message('充值失败!','','error');
  84. }
  85. }
  86. }
  87. if(checksubmit('export_submit', true)) {
  88. $time=date("Y-m-d");
  89. $time="'%$time%'";
  90. $start=$_GPC['time']['start'];
  91. $end=$_GPC['time']['end'];
  92. $count = pdo_fetchcolumn("SELECT COUNT(*) FROM". tablename("zhtc_user")." WHERE uniacid={$_W['uniacid']}");
  93. $pagesize = ceil($count/5000);
  94. //array_unshift( $names, '活动名称');
  95. $header = array(
  96. 'id'=>'用户id',
  97. 'img' => '用户头像',
  98. 'name' => '用户昵称',
  99. 'openid' => '用户openid',
  100. 'time' => '注册时间',
  101. 'commission' => '余额',
  102. 'total_score' => '积分',
  103. 'number' => '发帖数'
  104. );
  105. $keys = array_keys($header);
  106. $html = "\xEF\xBB\xBF";
  107. foreach ($header as $li) {
  108. $html .= $li . "\t ,";
  109. }
  110. $html .= "\n";
  111. for ($j = 1; $j <= $pagesize; $j++) {
  112. $sql = "select * from " . tablename("zhtc_user")." WHERE uniacid={$_W['uniacid']} limit " . ($j - 1) * 5000 . ",5000 ";
  113. $list = pdo_fetchall($sql);
  114. if (!empty($list)) {
  115. $size = ceil(count($list) / 500);
  116. for ($i = 0; $i < $size; $i++) {
  117. $buffer = array_slice($list, $i * 500, 500);
  118. $user = array();
  119. foreach ($buffer as $k =>$row) {
  120. $row['time']=date("Y-m-d H:i:s",$row['time']);
  121. $num=pdo_get('zhtc_information',array('user_id'=>$row['id']),array('count(*) as count'));
  122. $row['number']=$num['count'];
  123. foreach ($keys as $key) {
  124. $data5[] = $row[$key];
  125. }
  126. $user[] = implode("\t ,", $data5) . "\t ,";
  127. unset($data5);
  128. }
  129. $html .= implode("\n", $user) . "\n";
  130. }
  131. }
  132. }
  133. header("Content-type:text/csv");
  134. header("Content-Disposition:attachment; filename=商家数据.csv");
  135. echo $html;
  136. exit();
  137. }
  138. include $this->template('web/user2');