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); } }