field('a.*,b.nickname,c.name,c.number') ->order('a.id DESC') ->leftJoin('user b', 'b.uid = a.uid') ->leftJoin('out c', 'c.id = a.out_id'); if ($where['name']) $model->where('b.nickname|a.uid', 'like', '%'.$where['name'].'%'); if ($where['status'] == 1){ $model->where('a.status', 0); } if ($where['status'] == 2){ $model->where('a.status', 1); } if ($where['status'] == 3){ $model->where('a.status', 2); } if ($where['status'] == 4){ $model->where('a.status', -1); } $data['count'] = $model->count(); if ($where['page'] && $where['limit']){ $model->page($where['page'], $where['limit']); }else{ $model->page(20, 1); } $list = $model->select(); $list = count($list) ? $list->toArray() : []; foreach ($list as &$item) { $uids = User::where('spread_uid', $item['uid'])->column('uid'); if ($item['money'] == 0){ $item['money'] = StoreOrder::where('uid', 'in', $uids) ->where('paid', 1) ->where('is_participate', 0) ->sum('pay_price'); } } $data['data'] = $list; return $data; } }