// +---------------------------------------------------------------------- namespace app\common\dao\user; use app\common\dao\BaseDao; use app\common\model\user\UserExtract; use app\common\model\user\UserExtract as model; class UserExtractDao extends BaseDao { protected function getModel(): string { return model::class; } public function search(array $where) { $query = model::alias('UserExtract'); $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['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'])); })->order('UserExtract.create_time DESC'); return $query; } public function getPromoterInfo(array $uids) { return UserExtract::getDB()->field('sum(extract_price) as total_price,count(extract_id) as total_num, uid')->whereIn('uid', $uids)->group('uid')->where('status', 1)->select()->toArray(); } }