new-admin-api/app/controller/admin/user/ExchangeQuota.php

123 lines
3.8 KiB
PHP

<?php
namespace app\controller\admin\user;
use app\common\repositories\user\ExchangeIntegralRecordRepository;
use app\common\repositories\user\ExchangeQuotaRecordRepository;
use app\common\repositories\user\ExchangeQuotaRepository;
use crmeb\basic\BaseController;
use app\common\model\user\User;
class ExchangeQuota extends BaseController
{
protected $repository;
/**
* Common: 额度信息 - 统计
* Author: wu-hui
* Time: 2024/01/11 9:54
* @return mixed
*/
public function quotaTitle(){
$statInfo = app()->make(ExchangeQuotaRepository::class)->getStat();
$data = [
['className' => 'el-icon-coin','count' => $statInfo['sum_total_quota'],'field' => '分','name' => '平台总额度'],
['className' => 'el-icon-coin','count' => $statInfo['sum_use_quota'],'field' => '分','name' => '平台已使用额度'],
['className' => 'el-icon-coin','count' => $statInfo['sum_surplus_quota'],'field' => '分','name' => '平台剩余额度'],
['className' => 'el-icon-coin','count' => $statInfo['sum_freeze_quota'],'field' => '分','name' => '平台冻结额度'],
['className' => 'el-icon-coin','count' => $statInfo['sum_people_num'],'field' => '分','name' => '参与人数'],
];
return app('json')->success($data);
}
/**
* Common: 额度信息 - 额度持有信息
* Author: wu-hui
* Time: 2024/01/11 9:59
* @return mixed
*/
public function quotaList(){
[$page, $limit] = $this->getPage();
$params = $this->request->params(['uid']);
$data = app()->make(ExchangeQuotaRepository::class)->getList((array)$params,(int)$page,(int)$limit);
return app('json')->success($data);
}
/**
* Common: 额度信息 - 变更记录
* Author: wu-hui
* Time: 2024/01/11 10:02
* @return mixed
*/
public function quotaRecordList(){
[$page, $limit] = $this->getPage();
$params = $this->request->params(['uid']);
$data = app()->make(ExchangeQuotaRecordRepository::class)->getList((array)$params,(int)$page,(int)$limit);
return app('json')->success($data);
}
/**
* Common: 兑换积分 - 统计
* Author: wu-hui
* Time: 2024/01/12 17:38
* @return mixed
*/
public function integralTitle(){
$model = new User();
$data = [
['className' => 'el-icon-coin','count' => $model->sum('exchange_integral'),'field' => '分','name' => '总兑换积分'],
];
return app('json')->success($data);
}
/**
* Common: 兑换积分 - 额度持有信息
* Author: wu-hui
* Time: 2024/01/12 17:39
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function integralList(){
[$page, $limit] = $this->getPage();
$params = $this->request->params(['uid']);
$query = (new User())
->when((int)$params['uid'] > 0,function($query) use ($params){
$query->where('uid', (int)$params['uid']);
})
->where('exchange_integral','>',0)
->order('create_time DESC,uid DESC');
$count = $query->count();
$list = $query->page($page,$limit)->select();
return app('json')->success(compact('count','list'));
}
/**
* Common: 兑换积分 - 变更记录
* Author: wu-hui
* Time: 2024/01/12 17:40
* @return mixed
*/
public function integralRecordList(){
[$page, $limit] = $this->getPage();
$params = $this->request->params(['uid']);
$data = app()->make(ExchangeIntegralRecordRepository::class)->getList((array)$params,(int)$page,(int)$limit);
return app('json')->success($data);
}
}