['change_type','company_id'], ]; } /** * @notes 搜索条件 * @author 段誉 * @date 2023/2/24 15:26 */ public function queryWhere() { $where = []; // 用户余额 if (isset($this->params['type']) && $this->params['type'] == 'um') { $where[] = ['change_type', 'in', AccountLogEnum::getUserMoneyChangeType()]; } if (!empty($this->params['start_time'])) { $where[] = ['create_time', '>=', strtotime($this->params['start_time'])]; } if (!empty($this->params['end_time'])) { $where[] = ['create_time', '<=', strtotime($this->params['end_time'])]; } return $where; } /** * @notes 获取列表 * @return array * @author 段誉 * @date 2023/2/24 15:31 */ public function lists(): array { $lists = UserAccountLog::where($this->searchWhere) ->with(['company_info','user_info']) ->where($this->queryWhere()) ->order('id', 'desc') ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); foreach ($lists as &$item) { $item['user_info']['avatar'] = FileService::getFileUrl($item['user_info']['avatar']); $item['user_info']['group_name']=UserRole::where('id',$item['user_info']['group_id'])->value('name'); $item['change_type_desc'] = AccountLogEnum::getChangeTypeDesc($item['change_type']); $symbol = $item['action'] == AccountLogEnum::INC ? '+' : '-'; $item['change_amount'] = $symbol . $item['change_amount']; } return $lists; } /** * @notes 获取数量 * @return int * @author 段誉 * @date 2023/2/24 15:36 */ public function count(): int { return UserAccountLog::where($this->queryWhere()) ->where($this->searchWhere) ->count(); } }