webman_duanju/app/admin/model/SysUserMoneyDetails.php

85 lines
3.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\admin\model;
use app\common\library\DatabaseRoute;
use think\facade\Cache;
use think\facade\Db;
use think\Model;
use think\model\relation\BelongsTo;
class SysUserMoneyDetails extends Model
{
public static function queryUserMoneyDetails($page, $limit, $sysUserId, $userId, $classify, $type, $moneyType, $viewType)
{
if ($sysUserId !== null) {
$sysUserId = intval($sysUserId);
$db = DatabaseRoute::getDb('sys_user_money_details', $sysUserId);
$total = $db->name('sys_user_money_details')->where('user_id', $sysUserId)->count();
// 系统用户模式:查询系统用户资金明细
$list = $db->name('sys_user_money_details')->where('user_id', $sysUserId)
->order('create_time', 'desc')
->limit(page($page, $limit), $limit)
->select()
->toArray();
return [
'list' => $list,
'totalCount' => $total,
'totalPage' => (int)ceil($total / $limit),
'currPage' => $page,
'pageSize' => $limit,
];
}
if($userId !== null) {
$db = DatabaseRoute::getDb('user_money_details', $userId)->name('user_money_details');
$query = $db->where('user_id', $userId);
if ($classify !== null) {
$query = $query->where('classify', $classify);
}
if ($type !== null) {
$query = $query->where('type', $type);
}
if ($moneyType !== null) {
$query = $query->where('money_type', $moneyType);
}
if ($viewType == 1) {
// 视图类型1特殊分类1和6
$query = $query->whereIn('classify', [1, 6]);
}
$total = $query->count();
$query = $query->limit(page($page, $limit), $limit)
->order('create_time', 'desc')
->select()
->toArray();
return [
'list' => $query,
'totalCount' => $total,
'totalPage' => (int)ceil($total / $limit),
'currPage' => $page,
'pageSize' => $limit,
];
}else {
return DatabaseRoute::paginateAllDb('user_money_details', function ($query)use($page, $limit, $sysUserId, $userId, $classify, $type, $moneyType, $viewType) {
if ($classify !== null) {
$query->where('classify', $classify);
}
if ($type !== null) {
$query->where('type', $type);
}
if ($moneyType !== null) {
$query->where('money_type', $moneyType);
}
if ($viewType == 1) {
// 视图类型1特殊分类1和6
$query->whereIn('classify', [1, 6]);
}
return $query;
}, $page, $limit);
}
}
}