This commit is contained in:
mkm 2023-08-28 17:21:30 +08:00
parent b1ffaa7bd7
commit 279f47205e
2 changed files with 12 additions and 9 deletions

View File

@ -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'];

View File

@ -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');
}
}