DetailController.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. // +—————————————————————————————————————————————————————————————————————
  3. // | Created by Yunbao
  4. // +—————————————————————————————————————————————————————————————————————
  5. // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
  6. // +—————————————————————————————————————————————————————————————————————
  7. // | Author: https://gitee.com/yunbaokeji
  8. // +—————————————————————————————————————————————————————————————————————
  9. // | Date: 2022-02-17
  10. // +—————————————————————————————————————————————————————————————————————
  11. /**
  12. * 我的明细
  13. */
  14. namespace app\appapi\controller;
  15. use cmf\controller\HomeBaseController;
  16. use think\Db;
  17. class DetailController extends HomebaseController {
  18. public function index(){
  19. $data = $this->request->param();
  20. $uid=isset($data['uid']) ? $data['uid']: '';
  21. $token=isset($data['token']) ? $data['token']: '';
  22. $uid=(int)checkNull($uid);
  23. $token=checkNull($token);
  24. $checkToken=checkToken($uid,$token);
  25. if($checkToken==700){
  26. $reason='您的登陆状态失效,请重新登陆!';
  27. $this->assign('reason', $reason);
  28. return $this->fetch(':error');
  29. }
  30. $this->assign("uid",$uid);
  31. $this->assign("token",$token);
  32. $list=Db::name('user_voterecord')->field("fromid,actionid,sum(nums) as num,sum(total) as totalall")->where(["action"=>'1',"uid"=>$uid])->group("fromid,actionid,showid")->order("addtime desc")->limit(0,50)->select()->toArray();
  33. foreach($list as $k=>$v){
  34. $giftinfo=Db::name('gift')->field("giftname")->where("id={$v['actionid']}")->find();
  35. if(!$giftinfo){
  36. $giftinfo=array(
  37. "giftname"=>'礼物已删除'
  38. );
  39. }
  40. $list[$k]['giftinfo']=$giftinfo;
  41. $list[$k]['totalall']=number_format($v['totalall']);
  42. $userinfo=getUserInfo($v['fromid']);
  43. if(!$userinfo){
  44. $userinfo=array(
  45. "user_nicename"=>'用户已删除'
  46. );
  47. }
  48. $list[$k]['userinfo']=$userinfo;
  49. }
  50. $this->assign("list",$list);
  51. $list_live=Db::name('live_record')->field("starttime,endtime")->where(["uid"=>$uid])->order("starttime desc")->limit(0,50)->select()->toArray();
  52. foreach($list_live as $k=>$v){
  53. $cha=$v['endtime']-$v['starttime'];
  54. $list_live[$k]['length']=getSeconds($cha,1);
  55. $list_live[$k]['starttime']=date("Y-m-d H:i",$v['starttime']);
  56. $list_live[$k]['endtime']=date("Y-m-d H:i",$v['endtime']);
  57. }
  58. $this->assign("list_live",$list_live);
  59. return $this->fetch();
  60. }
  61. public function receive_more()
  62. {
  63. $data = $this->request->param();
  64. $uid=isset($data['uid']) ? $data['uid']: '';
  65. $token=isset($data['token']) ? $data['token']: '';
  66. $p=isset($data['page']) ? $data['page']: '1';
  67. $uid=(int)checkNull($uid);
  68. $token=checkNull($token);
  69. $p=checkNull($p);
  70. $result=array(
  71. 'data'=>array(),
  72. 'nums'=>0,
  73. 'isscroll'=>0,
  74. );
  75. if(checkToken($uid,$token)==700){
  76. echo json_encode($result);
  77. exit;
  78. }
  79. $pnums=50;
  80. $start=($p-1)*$pnums;
  81. $list=Db::name('user_voterecord')->field("fromid,actionid,sum(nums) as num,sum(total) as totalall")->where(["action"=>'1',"uid"=>$uid])->group("fromid,actionid,showid")->order("addtime desc")->limit($start,$pnums)->select()->toArray();
  82. foreach($list as $k=>$v){
  83. $giftinfo=Db::name('gift')->field("giftname")->where("id={$v['actionid']}")->find();
  84. if(!$giftinfo){
  85. $giftinfo=array(
  86. "giftname"=>'礼物已删除'
  87. );
  88. }
  89. $list[$k]['giftinfo']=$giftinfo;
  90. $list[$k]['totalall']=number_format($v['totalall']);
  91. $userinfo=getUserInfo($v['fromid']);
  92. if(!$userinfo){
  93. $userinfo=array(
  94. "user_nicename"=>'用户已删除'
  95. );
  96. }
  97. $list[$k]['userinfo']=$userinfo;
  98. }
  99. $nums=count($list);
  100. if($nums<$pnums){
  101. $isscroll=0;
  102. }else{
  103. $isscroll=1;
  104. }
  105. $result=array(
  106. 'data'=>$list,
  107. 'nums'=>$nums,
  108. 'isscroll'=>$isscroll,
  109. );
  110. echo json_encode($result);
  111. exit;
  112. }
  113. public function liverecord_more()
  114. {
  115. $data = $this->request->param();
  116. $uid=isset($data['uid']) ? $data['uid']: '';
  117. $token=isset($data['token']) ? $data['token']: '';
  118. $p=isset($data['page']) ? $data['page']: '1';
  119. $uid=(int)checkNull($uid);
  120. $token=checkNull($token);
  121. $p=checkNull($p);
  122. $result=array(
  123. 'data'=>array(),
  124. 'nums'=>0,
  125. 'isscroll'=>0,
  126. );
  127. if(checkToken($uid,$token)==700){
  128. echo json_encode($result);
  129. exit;
  130. }
  131. $pnums=50;
  132. $start=($p-1)*$pnums;
  133. $list=Db::name('live_record')->field("starttime,endtime")->where(["uid"=>$uid])->order("starttime desc")->limit($start,$pnums)->select()->toArray();
  134. foreach($list as $k=>$v){
  135. $list[$k]['starttime']=date("Y-m-d H:i",$v['starttime']);
  136. $list[$k]['endtime']=date("Y-m-d H:i",$v['endtime']);
  137. $cha=$v['endtime']-$v['starttime'];
  138. $list[$k]['length']=getSeconds($cha,1);
  139. }
  140. $nums=count($list);
  141. if($nums<$pnums){
  142. $isscroll=0;
  143. }else{
  144. $isscroll=1;
  145. }
  146. $result=array(
  147. 'data'=>$list,
  148. 'nums'=>$nums,
  149. 'isscroll'=>$isscroll,
  150. );
  151. echo json_encode($result);
  152. exit;
  153. }
  154. }