| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace App\Module\Fund\Services;
- use App\Module\Fund\Dto\FundLogDto;
- use App\Module\Fund\Logic\Log;
- use Illuminate\Pagination\LengthAwarePaginator;
- /**
- * 日志服务
- *
- */
- class LogService
- {
- /**
- * 日志记录
- *
- * @param array $where 查询条件
- * @param int $page 页码
- * @param int $rows 每页行数
- * @return LengthAwarePaginator 分页结果,包含FundLogDto对象
- */
- public function log_list(array $where, int $page, int $rows = 5)
- {
- $log = new Log();
- $paginator = $log->lists($where, $page, $rows);
- // 获取资金类型名称映射
- $fundNames = AccountService::getFundsDesc();
- // 获取操作类型名称映射
- $operateTypeNames = [
- 1 => '充值',
- 2 => '提现',
- 3 => '转账',
- 4 => '系统操作',
- 5 => '管理员操作',
- 6 => '交易',
- 7 => '流转',
- ];
- // 将模型转换为DTO
- $items = $paginator->getCollection()->map(function ($model) use ($fundNames, $operateTypeNames) {
- return FundLogDto::fromModel($model, $fundNames, $operateTypeNames);
- });
- // 创建新的分页器,使用DTO集合
- return new LengthAwarePaginator(
- $items,
- $paginator->total(),
- $paginator->perPage(),
- $paginator->currentPage(),
- ['path' => request()->url(), 'query' => request()->query()]
- );
- }
- /**
- * 统计资金日志
- *
- * @param array $where 查询条件
- * @return array 统计结果
- */
- public function statistical(array $where)
- {
- $log = new Log();
- $result = $log->statistical($where);
- return $result;
- }
- }
|