Ranking.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * 各种排行榜
  4. */
  5. namespace app\ais\controller\api\v1;
  6. use app\common\model\SystemUser;
  7. use app\ais\controller\api\Base;
  8. use app\ais\model\AisAdwords;
  9. use think\helper\Time;
  10. class Ranking extends Base{
  11. //省钱榜冠军
  12. public function topfirst(){
  13. $this->apiSign();
  14. list($start, $end) = Time::lastMonth();
  15. $condition[] = ['u.update_time','>=',$start];
  16. $condition[] = ['u.update_time','<=',$end];
  17. $list = SystemUser::alias('c')->where(['c.member_miniapp_id' => $this->miniapp_id])->join('AisCouponUser u', 'c.id = u.uid')->where(['u.member_miniapp_id' => $this->miniapp_id,'is_end' => 1])->where('money','<>',null)->where($condition)
  18. ->field('c.face,c.nickname,sum(money) as save')->group('u.uid')->order('money desc,c.create_time desc')->find();
  19. if (empty($list)) {
  20. return enjson(204,'没有数据');
  21. }
  22. $list->month = date('n',$start);
  23. return enjson(200,$list);
  24. }
  25. //省钱榜
  26. public function topMoney(){
  27. $param['page'] = $this->request->param('page/d',1);
  28. $this->apiSign($param);
  29. $list = SystemUser::alias('c')->where(['c.member_miniapp_id' => $this->miniapp_id])->join('AisCouponUser u', 'c.id = u.uid')->where(['u.member_miniapp_id' => $this->miniapp_id,'is_end' => 1])->where('money','<>',null)
  30. ->field('c.face,c.nickname,sum(money) as save')->group('u.uid')->order('money desc,c.create_time desc')->page($param['page'],10)->select();
  31. if ($list->isEmpty()) {
  32. return enjson(204,'没有数据');
  33. }
  34. return enjson(200,$list);
  35. }
  36. }