From 279f47205efd31a4d6e15b6f12f966b9ccdc2e4b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 28 Aug 2023 17:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/adminapi/lists/finance/AccountLogLists.php | 14 ++++++-------- app/common/model/user/UserAccountLog.php | 7 ++++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/adminapi/lists/finance/AccountLogLists.php b/app/adminapi/lists/finance/AccountLogLists.php index dd4f44459..38b66008f 100755 --- a/app/adminapi/lists/finance/AccountLogLists.php +++ b/app/adminapi/lists/finance/AccountLogLists.php @@ -18,6 +18,7 @@ use app\adminapi\lists\BaseAdminDataLists; use app\common\enum\user\AccountLogEnum; use app\common\lists\ListsSearchInterface; use app\common\model\user\UserAccountLog; +use app\common\model\user\UserRole; use app\common\service\FileService; @@ -80,19 +81,16 @@ class AccountLogLists extends BaseAdminDataLists implements ListsSearchInterface */ public function lists(): array { - $field = 'u.nickname,u.sn,u.avatar,u.mobile,al.action,al.change_amount,al.left_amount,al.change_type,al.source_sn,al.create_time'; - $lists = UserAccountLog::alias('al') - ->join('user u', 'u.id = al.user_id') - ->field($field) - ->where($this->searchWhere) + $lists = UserAccountLog::where($this->searchWhere) + ->with(['company_info','user_info']) ->where($this->queryWhere()) - ->order('al.id', 'desc') + ->order('id', 'desc') ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); - foreach ($lists as &$item) { - $item['avatar'] = FileService::getFileUrl($item['avatar']); + $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']; diff --git a/app/common/model/user/UserAccountLog.php b/app/common/model/user/UserAccountLog.php index 169867a1e..f6b490c24 100755 --- a/app/common/model/user/UserAccountLog.php +++ b/app/common/model/user/UserAccountLog.php @@ -15,6 +15,7 @@ namespace app\common\model\user; use app\common\model\BaseModel; +use app\common\model\Company; use think\model\concern\SoftDelete; /** @@ -30,6 +31,10 @@ class UserAccountLog extends BaseModel public function userInfo() { - return $this->hasOne(User::class, 'id', 'user_id')->field('id,nickname'); + return $this->hasOne(User::class, 'id', 'user_id')->field('id,nickname,avatar,group_id'); + } + + public function companyInfo(){ + return $this->hasOne(Company::class, 'id', 'company_id')->field('id,company_name'); } } \ No newline at end of file