12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- /**
- * 各种排行榜
- */
- namespace app\ais\controller\api\v1;
- use app\common\model\SystemUser;
- use app\ais\controller\api\Base;
- use app\ais\model\AisAdwords;
- use think\helper\Time;
- class Ranking extends Base{
- //省钱榜冠军
- public function topfirst(){
- $this->apiSign();
- list($start, $end) = Time::lastMonth();
- $condition[] = ['u.update_time','>=',$start];
- $condition[] = ['u.update_time','<=',$end];
- $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)
- ->field('c.face,c.nickname,sum(money) as save')->group('u.uid')->order('money desc,c.create_time desc')->find();
- if (empty($list)) {
- return enjson(204,'没有数据');
- }
- $list->month = date('n',$start);
- return enjson(200,$list);
- }
-
- //省钱榜
- public function topMoney(){
- $param['page'] = $this->request->param('page/d',1);
- $this->apiSign($param);
- $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)
- ->field('c.face,c.nickname,sum(money) as save')->group('u.uid')->order('money desc,c.create_time desc')->page($param['page'],10)->select();
- if ($list->isEmpty()) {
- return enjson(204,'没有数据');
- }
- return enjson(200,$list);
- }
- }
|