150 lines
4.7 KiB
PHP
150 lines
4.7 KiB
PHP
|
<?php
|
|||
|
// +----------------------------------------------------------------------
|
|||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
|||
|
// +----------------------------------------------------------------------
|
|||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
|||
|
// | 开源版本可自由商用,可去除界面版权logo
|
|||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
|||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
|||
|
// | 访问官网:https://www.likeadmin.cn
|
|||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
|||
|
// +----------------------------------------------------------------------
|
|||
|
// | author: likeadminTeam
|
|||
|
// +----------------------------------------------------------------------
|
|||
|
|
|||
|
namespace app\adminapi\lists\finance;
|
|||
|
|
|||
|
use app\adminapi\lists\BaseAdminDataLists;
|
|||
|
use app\common\enum\user\AccountLogEnum;
|
|||
|
use app\common\lists\ListsExcelInterface;
|
|||
|
use app\common\lists\ListsSearchInterface;
|
|||
|
use app\common\model\user\UserAccountLog;
|
|||
|
use app\common\model\user\UserRole;
|
|||
|
use app\common\service\FileService;
|
|||
|
|
|||
|
|
|||
|
/**
|
|||
|
* 账记流水列表
|
|||
|
* Class AccountLogLists
|
|||
|
* @package app\adminapi\lists\finance
|
|||
|
*/
|
|||
|
class AccountLogLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
|||
|
{
|
|||
|
|
|||
|
/**
|
|||
|
* @notes 导出字段
|
|||
|
* @return string[]
|
|||
|
* @author 段誉
|
|||
|
* @date 2023/2/24 16:07
|
|||
|
*/
|
|||
|
public function setExcelFields(): array
|
|||
|
{
|
|||
|
return [
|
|||
|
'user_info_sn' => '用户编号',
|
|||
|
'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();
|
|||
|
}
|
|||
|
}
|