diff --git a/app/common/dao/user/UserExtractDao.php b/app/common/dao/user/UserExtractDao.php index ea107fd..56bbcc1 100644 --- a/app/common/dao/user/UserExtractDao.php +++ b/app/common/dao/user/UserExtractDao.php @@ -17,30 +17,42 @@ class UserExtractDao extends BaseDao public function search(array $where) { - if(isset($where['wechat']) && $where['wechat'] != '') { - $query = model::hasWhere('user',function ($query)use($where){ + if(isset($where['wechat']) && $where['wechat'] != ''){ + $query = model::hasWhere('user',function($query) use ($where){ $query->where('nickname',"%{$where['wechat']}%"); }); - }else{ + } + else{ $query = model::alias('UserExtract'); } - $query->when(isset($where['uid']) && $where['uid'] != '',function($query)use($where){ + $query->when(isset($where['uid']) && $where['uid'] != '',function($query) use ($where){ $query->where('uid',$where['uid']); - })->when(isset($where['extract_type']) && $where['extract_type'] != '',function($query)use($where){ - $query->where('extract_type',$where['extract_type']); - })->when(isset($where['keyword']) && $where['keyword'] != '',function($query)use($where){ - $query->whereLike('UserExtract.real_name|UserExtract.uid|bank_code|alipay_code|wechat',"%{$where['keyword']}%"); - })->when(isset($where['status']) && $where['status'] != '',function($query)use($where){ - $query->where('UserExtract.status',$where['status']); - })->when(isset($where['real_name']) && $where['real_name'] != '',function($query)use($where){ - $query->where('UserExtract.real_name','%'.$where['real_name'].'%'); - })->when(isset($where['date']) && $where['date'] != '',function($query)use($where){ - getModelTime($query, $where['date']); - })->when(isset($where['brokerage_level']) && $where['brokerage_level'], function ($query) use ($where) { - $query->join('User user', 'UserExtract.uid = user.uid', 'left')->where('user.brokerage_level', intval($where['brokerage_level'])); - })->when(isset($where['user_keyword']) && $where['user_keyword'], function ($query) use ($where) { - $query->join('User user', 'UserExtract.uid = user.uid', 'left')->where('user.uid|user.real_name|user.nickname|user.phone', 'like', '%' . $where['keyword'] . '%'); - })->order('UserExtract.create_time DESC'); + }) + ->when(isset($where['extract_type']) && $where['extract_type'] != '',function($query) use ($where){ + $query->where('extract_type',$where['extract_type']); + }) + ->when(isset($where['keyword']) && $where['keyword'] != '',function($query) use ($where){ + $query->whereLike('UserExtract.real_name|UserExtract.uid|bank_code|alipay_code|wechat',"%{$where['keyword']}%"); + }) + ->when(isset($where['status']) && $where['status'] != '',function($query) use ($where){ + if(is_array($where['status'])) $query->whereIn('UserExtract.status',$where['status']); + else $query->where('UserExtract.status',$where['status']); + }) + ->when(isset($where['real_name']) && $where['real_name'] != '',function($query) use ($where){ + $query->where('UserExtract.real_name','%'.$where['real_name'].'%'); + }) + ->when(isset($where['date']) && $where['date'] != '',function($query) use ($where){ + getModelTime($query,$where['date']); + }) + ->when(isset($where['brokerage_level']) && $where['brokerage_level'],function($query) use ($where){ + $query->join('User user','UserExtract.uid = user.uid','left') + ->where('user.brokerage_level',intval($where['brokerage_level'])); + }) + ->when(isset($where['user_keyword']) && $where['user_keyword'],function($query) use ($where){ + $query->join('User user','UserExtract.uid = user.uid','left') + ->where('user.uid|user.real_name|user.nickname|user.phone','like','%'.$where['keyword'].'%'); + }) + ->order('UserExtract.create_time DESC'); return $query; } diff --git a/app/common/repositories/user/UserExtractRepository.php b/app/common/repositories/user/UserExtractRepository.php index 0c22960..2e91b8f 100644 --- a/app/common/repositories/user/UserExtractRepository.php +++ b/app/common/repositories/user/UserExtractRepository.php @@ -80,7 +80,7 @@ class UserExtractRepository extends BaseRepository */ public function userTotalExtract($uid) { - return $this->dao->search(['status' => 1, 'uid' => $uid])->sum('extract_price'); + return $this->dao->search(['status' => [0,1], 'uid' => $uid])->sum('extract_price'); } /**