'用户编号', 'company_info_company_name' => '归属公司', 'user_info_nickname' => '用户昵称', 'user_info_group_name' => '角色名称', 'user_info_mobile' => '手机号码', 'change_amount' => '变动金额', 'left_amount' => '剩余金额', 'change_type_desc' => '变动类型', 'source_sn' => '来源单号', 'create_time' => '记录时间', ]; } /** * @notes 导出表名 * @return string * @author 段誉 * @date 2023/2/24 16:07 */ public function setFileName(): string { return '余额明细'; } /** * @notes 搜索条件 * @return array * @author 段誉 * @date 2023/2/24 15:26 */ public function setSearch(): array { return [ '=' => ['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']; // 用于导出 $item['user_info_sn'] = $item['user_info']['sn']; $item['company_info_company_name'] = $item['company_info']['company_name']; $item['user_info_nickname'] = $item['user_info']['nickname']; $item['user_info_group_name'] = $item['user_info']['group_name']; $item['user_info_mobile'] = $item['user_info']['mobile']; } 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(); } }