66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace app\common\repositories\user;
|
|
|
|
use app\common\dao\user\ExchangeQuotaDao;
|
|
use app\common\repositories\BaseRepository;
|
|
|
|
class ExchangeQuotaRepository extends BaseRepository{
|
|
|
|
protected $dao;
|
|
|
|
public function __construct(ExchangeQuotaDao $dao){
|
|
$this->dao = $dao;
|
|
}
|
|
/**
|
|
* Common: 获取统计信息
|
|
* Author: wu-hui
|
|
* Time: 2024/01/11 9:51
|
|
* @return array
|
|
*/
|
|
public function getStat():array{
|
|
$model = $this->dao->getSearch([]);
|
|
return [
|
|
'sum_total_quota' => $model->sum('total_quota'),// 平台总额度
|
|
'sum_use_quota' => $model->sum('use_quota'),// 平台已使用额度
|
|
'sum_surplus_quota' => $model->sum('surplus_quota'),// 平台剩余额度
|
|
'sum_freeze_quota' => $model->sum('freeze_quota'),// 平台冻结额度
|
|
'sum_people_num' => $model->count(),// 参与人数
|
|
];
|
|
}
|
|
/**
|
|
* Common: 获取信息列表
|
|
* Author: wu-hui
|
|
* Time: 2024/01/11 9:59
|
|
* @param array $params
|
|
* @param int $page
|
|
* @param int $limit
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function getList(array $params,int $page,int $limit):array{
|
|
$query = $this->dao->getSearch([])
|
|
->when((int)$params['uid'] > 0,function($query) use ($params){
|
|
$query->where('uid', (int)$params['uid']);
|
|
})
|
|
->with([
|
|
'user' => function($query){
|
|
$query->field('uid,nickname,avatar')->bind(['nickname','avatar']);
|
|
}
|
|
])
|
|
->order('create_time DESC,id DESC');
|
|
$count = $query->count();
|
|
$list = $query->page($page,$limit)->select();
|
|
|
|
return compact('count','list');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|