89 lines
2.6 KiB
PHP
89 lines
2.6 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\api\lists\finance;
|
||
|
||
use app\api\lists\BaseApiDataLists;
|
||
use app\common\model\finance\UserFinance;
|
||
use app\common\model\setting\Language;
|
||
|
||
/**
|
||
* 充值记录列表
|
||
* Class UserFinanceLists
|
||
* @package app\api\lists\finance
|
||
*/
|
||
class UserFinanceLists extends BaseApiDataLists
|
||
{
|
||
|
||
/**
|
||
* @notes 获取充值记录列表
|
||
* @return array
|
||
*@author bd
|
||
* @date 2024/01/31 14:07
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
|
||
$where = '1 = 1';
|
||
|
||
if( $this->params['action'] == 1){
|
||
$where = ' action = 1 ';
|
||
}else if( $this->params['action'] == 2){
|
||
$where = ' action = 2 ';
|
||
}
|
||
|
||
if( $this->params['frozen'] == 1){
|
||
$where .= ' AND frozen = 1 ';
|
||
}
|
||
|
||
$field = 'id,sn,change_type as type,change_amount as amount,remark,action,create_time';
|
||
$lists = UserFinance::field($field)
|
||
->where($where)
|
||
->where([
|
||
'user_id' => $this->userId,
|
||
])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['create_time' => 'desc','id' => 'desc'])
|
||
->select()
|
||
->toArray();
|
||
|
||
//查询语言
|
||
$timeFormat = 'Y-m-d H:i:s';
|
||
$language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty();
|
||
if (!$language->isEmpty()) {
|
||
$timeFormat = $language['time_format'];
|
||
}
|
||
|
||
foreach ($lists as &$item) {
|
||
$item['create_time'] = date($timeFormat, strtotime($item['create_time']));
|
||
}
|
||
|
||
return $lists;
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取充值记录数量
|
||
* @return int
|
||
* @author bd
|
||
* @date 2024/01/31 14:07
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return UserFinance::where([
|
||
'user_id' => $this->userId,
|
||
])
|
||
->count();
|
||
}
|
||
} |